Skip to content

Commit 5d64654

Browse files
authored
Merge branch 'main' into get_meteonorm
2 parents 5c3c9bf + 2d9dc51 commit 5d64654

File tree

13 files changed

+341
-60
lines changed

13 files changed

+341
-60
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Installation
7474
============
7575

7676
pvlib-python releases may be installed using the ``pip`` and ``conda`` tools.
77-
Please see the [Installation page](https://pvlib-python.readthedocs.io/en/stable/user_guide/installation.html) of the documentation for complete instructions.
77+
Please see the [Installation page](https://pvlib-python.readthedocs.io/en/stable/user_guide/getting_started/installation.html) of the documentation for complete instructions.
7878

7979

8080
Contributing

docs/sphinx/source/reference/iotools.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ clear-sky irradiance globally.
5757
iotools.parse_cams
5858

5959

60+
NASA POWER
61+
**********
62+
63+
Satellite-derived irradiance and weather data with global coverage.
64+
65+
.. autosummary::
66+
:toctree: generated/
67+
68+
iotools.get_nasa_power
69+
70+
6071
NSRDB
6172
*****
6273

docs/sphinx/source/user_guide/extras/nomenclature.rst

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,24 @@ There is a convention on consistent variable names throughout the library:
2222

2323
aoi
2424
Angle of incidence. Angle between the surface normal vector and the
25-
vector pointing towards the suns center
25+
vector pointing towards the sun's center. [°]
2626

2727
aoi_projection
28-
cos(aoi)
28+
cos(aoi). When the sun is behind the surface, the value is negative.
29+
For many uses, negative values must be set to zero.
2930

3031
ape
3132
Average photon energy
3233

3334
apparent_zenith
34-
Refraction-corrected solar zenith angle in degrees
35+
Refraction-corrected solar zenith angle. The solar
36+
zenith angle describes the position of the sun relative to the vertical and is
37+
defined as the angle between a vector pointed straight up and a vector pointed
38+
at the sun, from the observer. [°]
39+
40+
apparent_elevation
41+
Refraction-corrected solar elevation angle. This is the complement of
42+
:term:`apparent_zenith` (90 - apparent_zenith). [°]
3543

3644
bhi
3745
Beam/direct horizontal irradiance
@@ -87,10 +95,10 @@ There is a convention on consistent variable names throughout the library:
8795
Sandia Array Performance Model IV curve parameters
8896

8997
latitude
90-
Latitude
98+
Latitude in decimal degrees. Positive north of equator, negative to south.
9199

92100
longitude
93-
Longitude
101+
Longitude in decimal degrees. Positive east of prime meridian, negative to west.
94102

95103
pac, ac
96104
AC power
@@ -141,10 +149,15 @@ There is a convention on consistent variable names throughout the library:
141149
Diode saturation current
142150

143151
solar_azimuth
144-
Azimuth angle of the sun in degrees East of North
152+
Azimuth angle of the sun in degrees East of North. The solar azimuth angle
153+
describes the sun’s position along the horizon relative to the observer.
154+
The pvlib-python convention is defined as degrees East of North, so
155+
North = 0°, East = 90°, South = 180°, West = 270°.
145156

146157
solar_zenith
147-
Zenith angle of the sun in degrees
158+
Zenith angle of the sun in degrees. This is the angle between is between a
159+
vector pointed straight up and a vector pointed at the sun, from the observer.
160+
This is the complement of solar elevation (90 - elevation). [°]
148161

149162
spectra
150163
spectra_components
@@ -154,11 +167,16 @@ There is a convention on consistent variable names throughout the library:
154167
is composed of direct and diffuse components.
155168

156169
surface_azimuth
157-
Azimuth angle of the surface
170+
Azimuth angle of the surface in degrees East of North. This angle describes the
171+
horizontal projection of the normal vector from the surface. The pvlib-python
172+
convention is defined as degrees East (clockwise) of North, so North = 0°,
173+
East = 90°, South = 180°, West = 270°.
158174

159175
surface_tilt
160-
Panel tilt from horizontal [°]. For example, a surface facing up = 0°,
161-
surface facing horizon = 90°.
176+
Tilt from horizontal [°]. The surface tilt angle
177+
is defined as degrees from the horizontal
178+
such that a surface facing up would have a surface tilt of 0°, and one facing
179+
the horizon would be 90°. [°]
162180

163181
temp_air
164182
Temperature of the air

docs/sphinx/source/whatsnew/v0.13.1.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Breaking Changes
1010

1111
Deprecations
1212
~~~~~~~~~~~~
13+
* Deprecate :py:func:`~pvlib.modelchain.get_orientation`. (:pull:`2495`)
1314
* Rename parameter name ``aparent_azimuth`` to ``solar_azimuth`` in :py:func:`~pvlib.tracking.singleaxis`.
1415
(:issue:`2479`, :pull:`2480`)
1516

@@ -22,9 +23,15 @@ Enhancements
2223
* Add iotools functions to retrieve irradiance and weather data from Meteonorm:
2324
:py:func:`~pvlib.iotools.get_meteonorm` and :py:func:`~pvlib.iotools.get_meteonorm_tmy`.
2425
(:pull:`2499`)
26+
* Add :py:func:`pvlib.iotools.get_nasa_power` to retrieve data from NASA POWER free API.
27+
(:pull:`2500`)
28+
* :py:func:`pvlib.spectrum.spectral_factor_firstsolar` no longer emits warnings
29+
when airmass and precipitable water values fall out of range. (:pull:`2512`)
2530

2631
Documentation
2732
~~~~~~~~~~~~~
33+
* Substantiate definitions of solar/surface azimuth/zenith and aoi on the
34+
:ref:`nomenclature` page. (:issue:`2448`, :pull:`2503`)
2835

2936

3037
Testing
@@ -47,3 +54,7 @@ Maintenance
4754
Contributors
4855
~~~~~~~~~~~~
4956
* Elijah Passmore (:ghuser:`eljpsm`)
57+
* Ioannis Sifnaios (:ghuser:`IoannisSifnaios`)
58+
* Rajiv Daxini (:ghuser:`RDaxini`)
59+
* Omar Bahamida (:ghuser:`OmarBahamida`)
60+
* Kevin Anderson (:ghuser:`kandersolar`)

pvlib/iotools/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@
4141
from pvlib.iotools.solargis import get_solargis # noqa: F401
4242
from pvlib.iotools.meteonorm import get_meteonorm # noqa: F401
4343
from pvlib.iotools.meteonorm import get_meteonorm_tmy # noqa: F401
44+
from pvlib.iotools.nasa_power import get_nasa_power # noqa: F401

pvlib/iotools/nasa_power.py

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
"""Functions for reading and retrieving data from NASA POWER."""
2+
3+
import pandas as pd
4+
import requests
5+
import numpy as np
6+
7+
URL = 'https://power.larc.nasa.gov/api/temporal/hourly/point'
8+
9+
DEFAULT_PARAMETERS = [
10+
'dni', 'dhi', 'ghi', 'temp_air', 'wind_speed'
11+
]
12+
13+
VARIABLE_MAP = {
14+
'ALLSKY_SFC_SW_DWN': 'ghi',
15+
'ALLSKY_SFC_SW_DIFF': 'dhi',
16+
'ALLSKY_SFC_SW_DNI': 'dni',
17+
'CLRSKY_SFC_SW_DWN': 'ghi_clear',
18+
'T2M': 'temp_air',
19+
'WS2M': 'wind_speed_2m',
20+
'WS10M': 'wind_speed',
21+
}
22+
23+
24+
def get_nasa_power(latitude, longitude, start, end,
25+
parameters=DEFAULT_PARAMETERS, *, community='re',
26+
elevation=None, wind_height=None, wind_surface=None,
27+
map_variables=True, url=URL):
28+
"""
29+
Retrieve irradiance and weather data from NASA POWER.
30+
31+
A general description of NASA POWER is given in [1]_ and the API is
32+
described in [2]_. A detailed list of the available parameters can be
33+
found in [3]_.
34+
35+
Parameters
36+
----------
37+
latitude: float
38+
In decimal degrees, north is positive (ISO 19115).
39+
longitude: float
40+
In decimal degrees, east is positive (ISO 19115).
41+
start: datetime like
42+
First timestamp of the requested period.
43+
end: datetime like
44+
Last timestamp of the requested period.
45+
parameters: str, list
46+
List of parameters. The default parameters are mentioned below; for the
47+
full list see [3]_. Note that the pvlib naming conventions can also be
48+
used.
49+
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]
55+
56+
community: str, default 're'
57+
Can be one of the following depending on which parameters are of
58+
interest. Note that in many cases this choice
59+
might affect the units of the parameter.
60+
61+
* ``'re'``: renewable energy
62+
* ``'sb'``: sustainable buildings
63+
* ``'ag'``: agroclimatology
64+
65+
elevation: float, optional
66+
The custom site elevation in meters to produce the corrected
67+
atmospheric pressure adjusted for elevation.
68+
wind_height: float, optional
69+
The custom wind height in meters to produce the wind speed adjusted
70+
for height. Has to be between 10 and 300 m; see [4]_.
71+
wind_surface: str, optional
72+
The definable surface type to adjust the wind speed. For a list of the
73+
surface types see [4]_. If you provide a wind surface alias please
74+
include a site elevation with the request.
75+
map_variables: bool, default True
76+
When true, renames columns of the Dataframe to pvlib variable names
77+
where applicable. See variable :const:`VARIABLE_MAP`.
78+
79+
Raises
80+
------
81+
requests.HTTPError
82+
Raises an error when an incorrect request is made.
83+
84+
Returns
85+
-------
86+
data : pd.DataFrame
87+
Time series data. The index corresponds to the start (left) of the
88+
interval.
89+
meta : dict
90+
Metadata.
91+
92+
References
93+
----------
94+
.. [1] `NASA Prediction Of Worldwide Energy Resources (POWER)
95+
<https://power.larc.nasa.gov/>`_
96+
.. [2] `NASA POWER API
97+
<https://power.larc.nasa.gov/api/pages/>`_
98+
.. [3] `NASA POWER API parameters
99+
<https://power.larc.nasa.gov/parameters/>`_
100+
.. [4] `NASA POWER corrected wind speed parameters
101+
<https://power.larc.nasa.gov/docs/methodology/meteorology/wind/>`_
102+
"""
103+
start = pd.Timestamp(start)
104+
end = pd.Timestamp(end)
105+
106+
# allow the use of pvlib parameter names
107+
parameter_dict = {v: k for k, v in VARIABLE_MAP.items()}
108+
parameters = [parameter_dict.get(p, p) for p in parameters]
109+
110+
params = {
111+
'latitude': latitude,
112+
'longitude': longitude,
113+
'start': start.strftime('%Y%m%d'),
114+
'end': end.strftime('%Y%m%d'),
115+
'community': community,
116+
'parameters': ','.join(parameters), # make parameters in a string
117+
'format': 'json',
118+
'user': None,
119+
'header': True,
120+
'time-standard': 'utc',
121+
'site-elevation': elevation,
122+
'wind-elevation': wind_height,
123+
'wind-surface': wind_surface,
124+
}
125+
126+
response = requests.get(url, params=params)
127+
if not response.ok:
128+
# response.raise_for_status() does not give a useful error message
129+
raise requests.HTTPError(response.json())
130+
131+
# Parse the data to dataframe
132+
data = response.json()
133+
hourly_data = data['properties']['parameter']
134+
df = pd.DataFrame(hourly_data)
135+
df.index = pd.to_datetime(df.index, format='%Y%m%d%H').tz_localize('UTC')
136+
137+
# Create metadata dictionary
138+
meta = data['header']
139+
meta['times'] = data['times']
140+
meta['parameters'] = data['parameters']
141+
142+
meta['longitude'] = data['geometry']['coordinates'][0]
143+
meta['latitude'] = data['geometry']['coordinates'][1]
144+
meta['altitude'] = data['geometry']['coordinates'][2]
145+
146+
# Replace NaN values
147+
df = df.replace(meta['fill_value'], np.nan)
148+
149+
# Rename according to pvlib convention
150+
if map_variables:
151+
df = df.rename(columns=VARIABLE_MAP)
152+
153+
return df, meta

pvlib/iotools/pvgis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def get_pvgis_hourly(latitude, longitude, start=None, end=None,
202202
.. [2] `PVGIS Hourly Radiation
203203
<https://ec.europa.eu/jrc/en/PVGIS/tools/hourly-radiation>`_
204204
.. [3] `PVGIS Non-interactive service
205-
<https://ec.europa.eu/jrc/en/PVGIS/docs/noninteractive>`_
205+
<https://joint-research-centre.ec.europa.eu/photovoltaic-geographical-information-system-pvgis/getting-started-pvgis/api-non-interactive-service_en>`_
206206
.. [4] `PVGIS horizon profile tool
207207
<https://ec.europa.eu/jrc/en/PVGIS/tools/horizon>`_
208208
""" # noqa: E501

pvlib/modelchain.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
from pvlib.pvsystem import _DC_MODEL_PARAMS
1919
from pvlib.tools import _build_kwargs
2020

21+
from pvlib._deprecation import deprecated
22+
2123
# keys that are used to detect input data and assign data to appropriate
2224
# ModelChain attribute
2325
# for ModelChain.weather
@@ -59,6 +61,13 @@
5961
)
6062

6163

64+
@deprecated(
65+
since="0.13.1",
66+
removal="",
67+
name="pvlib.modelchain.get_orientation",
68+
alternative=None,
69+
addendum=None,
70+
)
6271
def get_orientation(strategy, **kwargs):
6372
"""
6473
Determine a PV system's surface tilt and surface azimuth

pvlib/solarposition.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def spa_python(time, latitude, longitude,
285285
Calculate the solar position using a python implementation of the
286286
NREL SPA algorithm.
287287
288-
The details of the NREL SPA algorithm are described in [1]_.
288+
The details of the NREL SPA algorithm are described in [1]_, [2]_.
289289
290290
If numba is installed, the functions can be compiled to
291291
machine code and the function can be multithreaded.
@@ -328,25 +328,26 @@ def spa_python(time, latitude, longitude,
328328
-------
329329
DataFrame
330330
The DataFrame will have the following columns:
331-
apparent_zenith (degrees),
332-
zenith (degrees),
333-
apparent_elevation (degrees),
334-
elevation (degrees),
335-
azimuth (degrees),
336-
equation_of_time (minutes).
337331
332+
- apparent_zenith (degrees),
333+
- zenith (degrees),
334+
- apparent_elevation (degrees),
335+
- elevation (degrees),
336+
- azimuth (degrees),
337+
- equation_of_time (minutes).
338338
339339
References
340340
----------
341341
.. [1] I. Reda and A. Andreas, Solar position algorithm for solar
342342
radiation applications. Solar Energy, vol. 76, no. 5, pp. 577-589, 2004.
343+
:doi:`10.1016/j.solener.2003.12.003`.
343344
344345
.. [2] I. Reda and A. Andreas, Corrigendum to Solar position algorithm for
345346
solar radiation applications. Solar Energy, vol. 81, no. 6, p. 838,
346-
2007.
347+
2007. :doi:`10.1016/j.solener.2007.01.003`.
347348
348-
.. [3] USNO delta T:
349-
https://maia.usno.navy.mil/products/deltaT
349+
.. [3] `U.S. Naval Observatory, delta T
350+
<https://maia.usno.navy.mil/products/deltaT>`_
350351
351352
See also
352353
--------

0 commit comments

Comments
 (0)