77URL = 'https://power.larc.nasa.gov/api/temporal/hourly/point'
88
99DEFAULT_PARAMETERS = [
10- 'ALLSKY_SFC_SW_DNI' , 'ALLSKY_SFC_SW_DIFF' , 'ALLSKY_SFC_SW_DWN' ,
11- 'T2M' , 'WS10M'
10+ 'dni' , 'dhi' , 'ghi' , 'temp_air' , 'wind_speed'
1211]
1312
1413VARIABLE_MAP = {
@@ -48,11 +47,11 @@ def get_nasa_power(latitude, longitude, start, end,
4847 full list see [3]_. Note that the pvlib naming conventions can also be
4948 used.
5049
51- * ``ALLSKY_SFC_SW_DWN``: Global Horizontal Irradiance (GHI) [Wm⁻²]
52- * ``ALLSKY_SFC_SW_DIFF``: Diffuse Horizontal Irradiance (DHI) [Wm⁻²]
53- * ``ALLSKY_SFC_SW_DNI``: Direct Normal Irradiance (DNI) [Wm⁻²]
54- * ``T2M``: Air temperature at 2 m [C]
55- * ``WS10M``: Wind speed at 10 m [m/s]
50+ * Global Horizontal Irradiance (GHI) [Wm⁻²]
51+ * Diffuse Horizontal Irradiance (DHI) [Wm⁻²]
52+ * Direct Normal Irradiance (DNI) [Wm⁻²]
53+ * Air temperature at 2 m [C]
54+ * Wind speed at 10 m [m/s]
5655
5756 community: str, default 're'
5857 Can be one of the following depending on which parameters are of
@@ -134,7 +133,6 @@ def get_nasa_power(latitude, longitude, start, end,
134133 hourly_data = data ['properties' ]['parameter' ]
135134 df = pd .DataFrame (hourly_data )
136135 df .index = pd .to_datetime (df .index , format = '%Y%m%d%H' ).tz_localize ('UTC' )
137- df = df .replace (- 999 , np .nan )
138136
139137 # Create metadata dictionary
140138 meta = data ['header' ]
@@ -145,6 +143,9 @@ def get_nasa_power(latitude, longitude, start, end,
145143 meta ['latitude' ] = data ['geometry' ]['coordinates' ][1 ]
146144 meta ['altitude' ] = data ['geometry' ]['coordinates' ][2 ]
147145
146+ # Replace NaN values
147+ df = df .replace (meta ['fill_value' ], np .nan )
148+
148149 # Rename according to pvlib convention
149150 if map_variables :
150151 df = df .rename (columns = VARIABLE_MAP )
0 commit comments