|
15 | 15 | TMY_URL = NSRDB_API_BASE + "/api/nsrdb/v2/solar/psm3-tmy-download.csv"
|
16 | 16 | PSM5MIN_URL = NSRDB_API_BASE + "/api/nsrdb/v2/solar/psm3-5min-download.csv"
|
17 | 17 |
|
18 |
| -# 'relative_humidity', 'total_precipitable_water' are not available |
19 | 18 | ATTRIBUTES = (
|
20 | 19 | 'air_temperature', 'dew_point', 'dhi', 'dni', 'ghi', 'surface_albedo',
|
21 | 20 | 'surface_pressure', 'wind_direction', 'wind_speed')
|
22 | 21 | PVLIB_PYTHON = 'pvlib python'
|
23 | 22 |
|
24 |
| -# Dictionary mapping PSM3 names to pvlib names |
| 23 | +# Dictionary mapping PSM3 response names to pvlib names |
25 | 24 | VARIABLE_MAP = {
|
26 | 25 | 'GHI': 'ghi',
|
27 | 26 | 'DHI': 'dhi',
|
|
31 | 30 | 'Clearsky DNI': 'dni_clear',
|
32 | 31 | 'Solar Zenith Angle': 'solar_zenith',
|
33 | 32 | 'Temperature': 'temp_air',
|
34 |
| - 'Relative Humidity': 'relative_humidity', |
35 | 33 | 'Dew point': 'temp_dew',
|
| 34 | + 'Relative Humidity': 'relative_humidity', |
36 | 35 | 'Pressure': 'pressure',
|
37 |
| - 'Wind Direction': 'wind_direction', |
38 | 36 | 'Wind Speed': 'wind_speed',
|
| 37 | + 'Wind Direction': 'wind_direction', |
39 | 38 | 'Surface Albedo': 'albedo',
|
40 | 39 | 'Precipitable Water': 'precipitable_water',
|
41 | 40 | }
|
42 | 41 |
|
| 42 | +# Dictionary mapping pvlib names to PSM3 request names |
| 43 | +# Note, PSM3 uses different names for the same variables in the |
| 44 | +# response and the request |
| 45 | +REQUEST_VARIABLE_MAP = { |
| 46 | + 'ghi': 'ghi', |
| 47 | + 'dhi': 'dhi', |
| 48 | + 'dni': 'dni', |
| 49 | + 'ghi_clear': 'clearsky_dhi', |
| 50 | + 'dhi_clear': 'clearsky_dhi', |
| 51 | + 'dni_clear': 'clearsky_dni', |
| 52 | + 'zenith': 'solar_zenith_angle', |
| 53 | + 'temp_air': 'air_temperature', |
| 54 | + 'temp_dew': 'dew_point', |
| 55 | + 'relative_humidity': 'relative_humidity', |
| 56 | + 'pressure': 'surface_pressure', |
| 57 | + 'wind_speed': 'wind_speed', |
| 58 | + 'wind_direction': 'wind_direction', |
| 59 | + 'albedo': 'surface_albedo', |
| 60 | + 'precipitable_water': 'total_precipitable_water', |
| 61 | +} |
| 62 | + |
43 | 63 |
|
44 | 64 | def get_psm3(latitude, longitude, api_key, email, names='tmy', interval=60,
|
45 | 65 | attributes=ATTRIBUTES, leap_day=None, full_name=PVLIB_PYTHON,
|
@@ -74,7 +94,7 @@ def get_psm3(latitude, longitude, api_key, email, names='tmy', interval=60,
|
74 | 94 | meteorological fields to fetch. If not specified, defaults to
|
75 | 95 | ``pvlib.iotools.psm3.ATTRIBUTES``. See references [2]_, [3]_, and [4]_
|
76 | 96 | for lists of available fields. Alternatively, pvlib names may also be
|
77 |
| - used (e.g. 'ghi' rather than 'GHI'); see :const:`VARIABLE_MAP`. |
| 97 | + used (e.g. 'ghi' rather than 'GHI'); see :const:`REQUEST_VARIABLE_MAP`. |
78 | 98 | leap_day : boolean, default False
|
79 | 99 | include leap day in the results. Only used for single-year requests
|
80 | 100 | (i.e., it is ignored for tmy/tgy/tdy requests).
|
@@ -158,12 +178,8 @@ def get_psm3(latitude, longitude, api_key, email, names='tmy', interval=60,
|
158 | 178 | # convert to string to accomodate integer years being passed in
|
159 | 179 | names = str(names)
|
160 | 180 |
|
161 |
| - # convert pvlib names in attributes to psm3 convention (reverse mapping) |
162 |
| - # unlike psm3 columns, attributes are lower case and with underscores |
163 |
| - amap = {value: key.lower().replace(' ', '_') for (key, value) in |
164 |
| - VARIABLE_MAP.items()} |
165 |
| - attributes = [amap.get(a, a) for a in attributes] |
166 |
| - attributes = list(set(attributes)) # remove duplicate values |
| 181 | + # convert pvlib names in attributes to psm3 convention |
| 182 | + attributes = [REQUEST_VARIABLE_MAP.get(a, a) for a in attributes] |
167 | 183 |
|
168 | 184 | if (leap_day is None) and (not names.startswith('t')):
|
169 | 185 | warnings.warn(
|
|
0 commit comments