pvlib 0.13.1a1__py3-none-any.whl → 0.14.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pvlib/bifacial/infinite_sheds.py +3 -2
- pvlib/inverter.py +2 -2
- pvlib/iotools/__init__.py +2 -3
- pvlib/iotools/acis.py +2 -2
- pvlib/iotools/era5.py +207 -0
- pvlib/iotools/merra2.py +196 -0
- pvlib/iotools/psm4.py +0 -1
- pvlib/irradiance.py +26 -25
- pvlib/ivtools/sdm/__init__.py +2 -1
- pvlib/ivtools/sdm/desoto.py +72 -0
- pvlib/pvarray.py +130 -1
- pvlib/pvsystem.py +135 -46
- pvlib/singlediode.py +249 -52
- pvlib/solarposition.py +1 -1
- pvlib/spa.py +1 -1
- pvlib/spectrum/__init__.py +3 -2
- pvlib/spectrum/mismatch.py +101 -0
- pvlib/temperature.py +11 -12
- {pvlib-0.13.1a1.dist-info → pvlib-0.14.0.dist-info}/METADATA +3 -3
- {pvlib-0.13.1a1.dist-info → pvlib-0.14.0.dist-info}/RECORD +24 -23
- pvlib/iotools/psm3.py +0 -365
- {pvlib-0.13.1a1.dist-info → pvlib-0.14.0.dist-info}/WHEEL +0 -0
- {pvlib-0.13.1a1.dist-info → pvlib-0.14.0.dist-info}/licenses/AUTHORS.md +0 -0
- {pvlib-0.13.1a1.dist-info → pvlib-0.14.0.dist-info}/licenses/LICENSE +0 -0
- {pvlib-0.13.1a1.dist-info → pvlib-0.14.0.dist-info}/top_level.txt +0 -0
|
@@ -4,26 +4,26 @@ pvlib/albedo.py,sha256=MqrkDztnF6VWaM7W28AGGEgCyAK6X13bDvPk9YEaimU,6205
|
|
|
4
4
|
pvlib/atmosphere.py,sha256=zG6dXIrAdCvruXXHi7OthbcVqbXfSd6laib7JPkCztA,26854
|
|
5
5
|
pvlib/clearsky.py,sha256=8_R4CNXkm4SoTY1ug1Vv03z6RPC3s3d5jYEXcc6KOFE,38612
|
|
6
6
|
pvlib/iam.py,sha256=zL0YzOaMA2Twbl0JJ0y5nxoxjmaOb9OQGH_Z1MVGcIw,44224
|
|
7
|
-
pvlib/inverter.py,sha256=
|
|
8
|
-
pvlib/irradiance.py,sha256=
|
|
7
|
+
pvlib/inverter.py,sha256=cQw1IB965RYeb9orpBiJGaRsidAspuv1Vks3ZSwOamg,19440
|
|
8
|
+
pvlib/irradiance.py,sha256=M_PqXxQ2UqIxct_81OhzF66hreh0WZuq5Ae3wS5tK2Y,147891
|
|
9
9
|
pvlib/location.py,sha256=G31Iabv1KcYzMFr5sd0JhcJr9IpZx2rLv25h1K2XaAE,17509
|
|
10
10
|
pvlib/modelchain.py,sha256=pwOLSlPhtxUm0d17tc2FdcD-XSItIcPkeLlUeZBw7M0,72995
|
|
11
|
-
pvlib/pvarray.py,sha256=
|
|
12
|
-
pvlib/pvsystem.py,sha256=
|
|
11
|
+
pvlib/pvarray.py,sha256=rQ2lOKhC0Ons97iy0NV5iqfMoL-S0RY5yJ2byDH7WKI,19006
|
|
12
|
+
pvlib/pvsystem.py,sha256=FFo1E3dpiVvHCZzOSBQXUL9mW2llyaYMtgCI0M9o3AM,116049
|
|
13
13
|
pvlib/scaling.py,sha256=SsQEmM4f4O1wC7e0amEV4SgaRTBX8nG5IiSV9Xs0i5o,10983
|
|
14
14
|
pvlib/shading.py,sha256=S1Av-oskqxQTyLKkmaVr854bve3StfbP_yF5isHF5zI,26172
|
|
15
|
-
pvlib/singlediode.py,sha256=
|
|
15
|
+
pvlib/singlediode.py,sha256=7KQ0rrRg_kDYsrAgudNX40PTEbUYqTdOD-X5UHJIw2E,42569
|
|
16
16
|
pvlib/snow.py,sha256=1jbfCvyi8ClE15U_stwdnxdaMnXOw8igN3BIYEjFrko,14755
|
|
17
17
|
pvlib/soiling.py,sha256=zDJ3N0uyeS1CoO0mxSdG16q2FCBLZSHbujJHgish54U,8799
|
|
18
|
-
pvlib/solarposition.py,sha256=
|
|
19
|
-
pvlib/spa.py,sha256=
|
|
20
|
-
pvlib/temperature.py,sha256=
|
|
18
|
+
pvlib/solarposition.py,sha256=vcJCk8tywMJghIRrhFnkr70GzMeyaKcpPKZb3WWy7qE,51325
|
|
19
|
+
pvlib/spa.py,sha256=t4WIWNnc6sTJrZigoPVs77qeK_lyxj5cHCQ-dIiOPfw,44848
|
|
20
|
+
pvlib/temperature.py,sha256=KWa2Y5IV87OCbwgyti6K7GMIju9aoD0QONjW8TgmiP4,60758
|
|
21
21
|
pvlib/tools.py,sha256=WX_qEGR38q3urjZdhFLqnEH2Zo7NM3RwjeWqgHbBr4I,14752
|
|
22
22
|
pvlib/tracking.py,sha256=7YCuKqXdFfJl3AQVWAiAGtvWu_sV-juWwqy5N63JUSA,16303
|
|
23
23
|
pvlib/transformer.py,sha256=FXyYaPPooFXAvAP3Ib5vENDVJocbo6kUuBAPzQdimHo,3437
|
|
24
24
|
pvlib/version.py,sha256=0CONzyOSN34Jgbaj9JzemFuaEnbRON_yxp-ah6_KxxQ,165
|
|
25
25
|
pvlib/bifacial/__init__.py,sha256=64cyMvdne1gJJ-tSEetheorxEeMm-TOIad1u-0DSucA,460
|
|
26
|
-
pvlib/bifacial/infinite_sheds.py,sha256=
|
|
26
|
+
pvlib/bifacial/infinite_sheds.py,sha256=B83Tv1QOiSp64N3L5XMFFN6V8y1NmN7-9IJQzzO6K6Q,22992
|
|
27
27
|
pvlib/bifacial/loss_models.py,sha256=RDl9TcKqFoYXnE3P88DjLVFODh2mHdKEFUUH-BnvH7E,5944
|
|
28
28
|
pvlib/bifacial/pvfactors.py,sha256=6o1xh5Lihl5AO8qrMWCYUxVJCJe4-WrFzYZwzq_8n0I,5438
|
|
29
29
|
pvlib/bifacial/utils.py,sha256=98D7buxlcE8oilC3BqHqqDT7pCjrM-dAGhYvpYjqalU,14558
|
|
@@ -38,17 +38,18 @@ pvlib/data/sam-library-cec-inverters-2019-03-05.csv,sha256=wZIlLw1hIE31j7DflVFKK
|
|
|
38
38
|
pvlib/data/sam-library-cec-modules-2019-03-05.csv,sha256=p8OxrT2rtUJTaGFcFjIvLjUYX8QWOAtHHE5I3VRbGSA,5446588
|
|
39
39
|
pvlib/data/sam-library-sandia-modules-2015-6-30.csv,sha256=fhC-Oi0IaYVViKEjyDyDWDCIFfD52rU2gL7w2FBAhPM,195253
|
|
40
40
|
pvlib/data/soiling_hsu_example_inputs.csv,sha256=Dkr0Sc5GA2s6I2hBSeAGIEI5J4KKBNgf-LTtzKS0qEE,319716
|
|
41
|
-
pvlib/iotools/__init__.py,sha256=
|
|
42
|
-
pvlib/iotools/acis.py,sha256=
|
|
41
|
+
pvlib/iotools/__init__.py,sha256=AQ3w7rO6qOq__BEtAZ8O7x8JcwXmuMlXTH9U2a7KDNY,2982
|
|
42
|
+
pvlib/iotools/acis.py,sha256=PvD7pjA3n5fX6WIwgVO4o0nseVS5rPFdzbhnEukqFU4,18455
|
|
43
43
|
pvlib/iotools/bsrn.py,sha256=N1bkRukFfHzV95jjEZIKRDdxizddV7cXQUKo--bElw8,22013
|
|
44
44
|
pvlib/iotools/crn.py,sha256=PLugc4RF_0LzesWHnyCOtx9KmqeECZH9kxcXgzgjGrQ,5336
|
|
45
45
|
pvlib/iotools/epw.py,sha256=Y9R9Od3AQqyHMxCRAUuOzFpZkzaAUXeERAZ44RyQjXU,17470
|
|
46
|
+
pvlib/iotools/era5.py,sha256=3Eq-fsxONklT_nXGVMuiCzfCZxRNLJqdiZFFYqT9m9I,6490
|
|
47
|
+
pvlib/iotools/merra2.py,sha256=-P_eCYFfeOae3oSC4s6LdxK35QPyVhfnhZ5lusP-anU,7587
|
|
46
48
|
pvlib/iotools/meteonorm.py,sha256=wFwURSSnde9SxgBzdV_SluL6YsXb2l6hrnf0e9dl1sY,22534
|
|
47
49
|
pvlib/iotools/midc.py,sha256=T2kskGsBzeHY-9HHc8096mbOaifKvFturCTcZq1pIzY,9568
|
|
48
50
|
pvlib/iotools/nasa_power.py,sha256=HhRYycK2q6hD1BSU0-P06loqhkuBoqaQdqNhYQQkYBM,5188
|
|
49
51
|
pvlib/iotools/panond.py,sha256=okK6zNh5r-H1gDPbZRmWEcYYaBmifPhp1ESR-P2YM9s,5262
|
|
50
|
-
pvlib/iotools/
|
|
51
|
-
pvlib/iotools/psm4.py,sha256=TVU_uZmShnJdsCL7DABnluvYENshpIcYJbJCg864rRw,30112
|
|
52
|
+
pvlib/iotools/psm4.py,sha256=W_tOdgbLR1Tchd_lxOfPazqRauBWJ2ywHaaJl2xKeF4,30084
|
|
52
53
|
pvlib/iotools/pvgis.py,sha256=dd5mfODwYEVaNv-UvNjbvBbQgKUi5C89rna_h8KWphM,32279
|
|
53
54
|
pvlib/iotools/sodapro.py,sha256=3oBnN3GhDrB1tHmjgpSiYehitv7POFhs1yBzGDNOxOQ,15234
|
|
54
55
|
pvlib/iotools/solaranywhere.py,sha256=_kDetQ0R8rQgcfTZjeQArq9nmCtVa4upF_KGrcipovQ,12535
|
|
@@ -61,22 +62,22 @@ pvlib/iotools/tmy.py,sha256=k96b43OXuiezq3UwCVBMnWlmPsbUf8ry5HvZ9LpaX6Q,26694
|
|
|
61
62
|
pvlib/ivtools/__init__.py,sha256=bnUDPqkzCP96CaFFK3Gw4HNczJoHtO-cI9GBGAtZVGI,159
|
|
62
63
|
pvlib/ivtools/sde.py,sha256=HL2oE70Ls7xccikyaUSi6SQKx3cWES5XoaMAGuMjPIw,17008
|
|
63
64
|
pvlib/ivtools/utils.py,sha256=xL88J-RuYLXFZyy1za8tvoWei0hcwWb_2ktXara2m_M,19423
|
|
64
|
-
pvlib/ivtools/sdm/__init__.py,sha256=
|
|
65
|
+
pvlib/ivtools/sdm/__init__.py,sha256=_Nn-Wwc0h10yHHb8UdSykWIZwBYsj3aA8-S6nuRmm1Y,500
|
|
65
66
|
pvlib/ivtools/sdm/_fit_desoto_pvsyst_sandia.py,sha256=E3A-Q3qSdrbMGkibx_9YHevNG9ivWkSI4mp3dElB7vU,22522
|
|
66
67
|
pvlib/ivtools/sdm/cec.py,sha256=_YZjurrd-HZfm3Ild9PewXJ54fRFD1O4lZ0nt67IMtA,3437
|
|
67
|
-
pvlib/ivtools/sdm/desoto.py,sha256=
|
|
68
|
+
pvlib/ivtools/sdm/desoto.py,sha256=bmwrVEAM0PQpAuWJCHeasI8aRQGGYMcUvHoCuRZSKaU,17313
|
|
68
69
|
pvlib/ivtools/sdm/pvsyst.py,sha256=vn87iYgMcHX9Lx5SfXvRpaF0F5VUzCbWijN7f74STxA,23260
|
|
69
70
|
pvlib/spa_c_files/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
70
71
|
pvlib/spa_c_files/setup.py,sha256=RcMEf0R2wKHJjvpUH5y6h22m86y6UrdXwkPkHKNme48,1102
|
|
71
72
|
pvlib/spa_c_files/spa_py_example.py,sha256=p3ms0mhLycAuZJyaE3Wageqnd_56zh2EKxXK-jlTJfg,1179
|
|
72
|
-
pvlib/spectrum/__init__.py,sha256=
|
|
73
|
+
pvlib/spectrum/__init__.py,sha256=vIceJAPkSAXRmpT53VRBwd5-rqaVa1Tws3I1JOaWMOY,542
|
|
73
74
|
pvlib/spectrum/irradiance.py,sha256=VY0-FTUv2WWHTZRyy4lo8lQGrAjIREf4nQMVYrv0mXM,7827
|
|
74
|
-
pvlib/spectrum/mismatch.py,sha256=
|
|
75
|
+
pvlib/spectrum/mismatch.py,sha256=Ucb7hTUB8gD1fY0AC9K2XSifsK7jhze-hghNAJ7DJVA,34291
|
|
75
76
|
pvlib/spectrum/response.py,sha256=k3FCoPPR_2yGrfXPGsZljJcgrQ7sckQn0CwiqERNntY,9413
|
|
76
77
|
pvlib/spectrum/spectrl2.py,sha256=sPOZe5lXgkwMem3JbEi19uW7OQq4FzxcZyCnxzXFjWs,19022
|
|
77
|
-
pvlib-0.
|
|
78
|
-
pvlib-0.
|
|
79
|
-
pvlib-0.
|
|
80
|
-
pvlib-0.
|
|
81
|
-
pvlib-0.
|
|
82
|
-
pvlib-0.
|
|
78
|
+
pvlib-0.14.0.dist-info/licenses/AUTHORS.md,sha256=Fxk4p_lXlMeQ6g2A1-7oPrgpULDxuJuC9Ebc-3yyj_o,1474
|
|
79
|
+
pvlib-0.14.0.dist-info/licenses/LICENSE,sha256=oC4S3araPPDV292K_91XfC7sZAdYqVhCowT3UTuMC-Q,1622
|
|
80
|
+
pvlib-0.14.0.dist-info/METADATA,sha256=PV0R-xC119QvE935W-OcQFGw_7j15fptn50Gesfhlz0,2912
|
|
81
|
+
pvlib-0.14.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
82
|
+
pvlib-0.14.0.dist-info/top_level.txt,sha256=eq9CH6YXUc3Fh3dyQ5hQXoGYfSm1SYEAlMygyR22MgE,6
|
|
83
|
+
pvlib-0.14.0.dist-info/RECORD,,
|
pvlib/iotools/psm3.py
DELETED
|
@@ -1,365 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Get PSM3 TMY
|
|
3
|
-
see https://developer.nrel.gov/docs/solar/nsrdb/psm3_data_download/
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
import io
|
|
7
|
-
import requests
|
|
8
|
-
import pandas as pd
|
|
9
|
-
from json import JSONDecodeError
|
|
10
|
-
from pvlib._deprecation import deprecated
|
|
11
|
-
from pvlib import tools
|
|
12
|
-
|
|
13
|
-
NSRDB_API_BASE = "https://developer.nrel.gov"
|
|
14
|
-
PSM_URL = NSRDB_API_BASE + "/api/nsrdb/v2/solar/psm3-2-2-download.csv"
|
|
15
|
-
TMY_URL = NSRDB_API_BASE + "/api/nsrdb/v2/solar/psm3-tmy-download.csv"
|
|
16
|
-
PSM5MIN_URL = NSRDB_API_BASE + "/api/nsrdb/v2/solar/psm3-5min-download.csv"
|
|
17
|
-
|
|
18
|
-
ATTRIBUTES = (
|
|
19
|
-
'air_temperature', 'dew_point', 'dhi', 'dni', 'ghi', 'surface_albedo',
|
|
20
|
-
'surface_pressure', 'wind_direction', 'wind_speed')
|
|
21
|
-
PVLIB_PYTHON = 'pvlib python'
|
|
22
|
-
|
|
23
|
-
# Dictionary mapping PSM3 response names to pvlib names
|
|
24
|
-
VARIABLE_MAP = {
|
|
25
|
-
'GHI': 'ghi',
|
|
26
|
-
'DHI': 'dhi',
|
|
27
|
-
'DNI': 'dni',
|
|
28
|
-
'Clearsky GHI': 'ghi_clear',
|
|
29
|
-
'Clearsky DHI': 'dhi_clear',
|
|
30
|
-
'Clearsky DNI': 'dni_clear',
|
|
31
|
-
'Solar Zenith Angle': 'solar_zenith',
|
|
32
|
-
'Temperature': 'temp_air',
|
|
33
|
-
'Dew Point': 'temp_dew',
|
|
34
|
-
'Relative Humidity': 'relative_humidity',
|
|
35
|
-
'Pressure': 'pressure',
|
|
36
|
-
'Wind Speed': 'wind_speed',
|
|
37
|
-
'Wind Direction': 'wind_direction',
|
|
38
|
-
'Surface Albedo': 'albedo',
|
|
39
|
-
'Precipitable Water': 'precipitable_water',
|
|
40
|
-
}
|
|
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_ghi',
|
|
50
|
-
'dhi_clear': 'clearsky_dhi',
|
|
51
|
-
'dni_clear': 'clearsky_dni',
|
|
52
|
-
'solar_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
|
-
|
|
63
|
-
|
|
64
|
-
def get_psm3(latitude, longitude, api_key, email, names='tmy', interval=60,
|
|
65
|
-
attributes=ATTRIBUTES, leap_day=True, full_name=PVLIB_PYTHON,
|
|
66
|
-
affiliation=PVLIB_PYTHON, map_variables=True, url=None,
|
|
67
|
-
timeout=30):
|
|
68
|
-
"""
|
|
69
|
-
Retrieve NSRDB PSM3 timeseries weather data from the PSM3 API. The NSRDB
|
|
70
|
-
is described in [1]_ and the PSM3 API is described in [2]_, [3]_, and [4]_.
|
|
71
|
-
|
|
72
|
-
.. versionchanged:: 0.9.0
|
|
73
|
-
The function now returns a tuple where the first element is a dataframe
|
|
74
|
-
and the second element is a dictionary containing metadata. Previous
|
|
75
|
-
versions of this function had the return values switched.
|
|
76
|
-
|
|
77
|
-
.. versionchanged:: 0.10.0
|
|
78
|
-
The default endpoint for hourly single-year datasets is now v3.2.2.
|
|
79
|
-
The previous datasets can still be accessed (for now) by setting
|
|
80
|
-
the ``url`` parameter to the original API endpoint
|
|
81
|
-
(``"https://developer.nrel.gov/api/nsrdb/v2/solar/psm3-download.csv"``).
|
|
82
|
-
|
|
83
|
-
Parameters
|
|
84
|
-
----------
|
|
85
|
-
latitude : float or int
|
|
86
|
-
in decimal degrees, between -90 and 90, north is positive
|
|
87
|
-
longitude : float or int
|
|
88
|
-
in decimal degrees, between -180 and 180, east is positive
|
|
89
|
-
api_key : str
|
|
90
|
-
NREL Developer Network API key
|
|
91
|
-
email : str
|
|
92
|
-
NREL API uses this to automatically communicate messages back
|
|
93
|
-
to the user only if necessary
|
|
94
|
-
names : str, default 'tmy'
|
|
95
|
-
PSM3 API parameter specifing year (e.g. ``2020``) or TMY variant
|
|
96
|
-
to download (e.g. ``'tmy'`` or ``'tgy-2019'``). The allowed values
|
|
97
|
-
update periodically, so consult the NSRDB references below for the
|
|
98
|
-
current set of options.
|
|
99
|
-
interval : int, {60, 5, 15, 30}
|
|
100
|
-
interval size in minutes, must be 5, 15, 30 or 60. Must be 60 for
|
|
101
|
-
typical year requests (i.e., tmy/tgy/tdy).
|
|
102
|
-
attributes : list of str, optional
|
|
103
|
-
meteorological fields to fetch. If not specified, defaults to
|
|
104
|
-
``pvlib.iotools.psm3.ATTRIBUTES``. See references [2]_, [3]_, and [4]_
|
|
105
|
-
for lists of available fields. Alternatively, pvlib names may also be
|
|
106
|
-
used (e.g. 'ghi' rather than 'GHI'); see :const:`REQUEST_VARIABLE_MAP`.
|
|
107
|
-
To retrieve all available fields, set ``attributes=[]``.
|
|
108
|
-
leap_day : bool, default : True
|
|
109
|
-
include leap day in the results. Only used for single-year requests
|
|
110
|
-
(i.e., it is ignored for tmy/tgy/tdy requests).
|
|
111
|
-
full_name : str, default 'pvlib python'
|
|
112
|
-
optional
|
|
113
|
-
affiliation : str, default 'pvlib python'
|
|
114
|
-
optional
|
|
115
|
-
map_variables : bool, default True
|
|
116
|
-
When true, renames columns of the Dataframe to pvlib variable names
|
|
117
|
-
where applicable. See variable :const:`VARIABLE_MAP`.
|
|
118
|
-
url : str, optional
|
|
119
|
-
API endpoint URL. If not specified, the endpoint is determined from
|
|
120
|
-
the ``names`` and ``interval`` parameters.
|
|
121
|
-
timeout : int, default 30
|
|
122
|
-
time in seconds to wait for server response before timeout
|
|
123
|
-
|
|
124
|
-
Returns
|
|
125
|
-
-------
|
|
126
|
-
data : pandas.DataFrame
|
|
127
|
-
timeseries data from NREL PSM3
|
|
128
|
-
metadata : dict
|
|
129
|
-
metadata from NREL PSM3 about the record, see
|
|
130
|
-
:func:`pvlib.iotools.read_psm3` for fields
|
|
131
|
-
|
|
132
|
-
Raises
|
|
133
|
-
------
|
|
134
|
-
requests.HTTPError
|
|
135
|
-
if the request response status is not ok, then the ``'errors'`` field
|
|
136
|
-
from the JSON response or any error message in the content will be
|
|
137
|
-
raised as an exception, for example if the `api_key` was rejected or if
|
|
138
|
-
the coordinates were not found in the NSRDB
|
|
139
|
-
|
|
140
|
-
Notes
|
|
141
|
-
-----
|
|
142
|
-
The required NREL developer key, `api_key`, is available for free by
|
|
143
|
-
registering at the `NREL Developer Network <https://developer.nrel.gov/>`_.
|
|
144
|
-
|
|
145
|
-
.. warning:: The "DEMO_KEY" `api_key` is severely rate limited and may
|
|
146
|
-
result in rejected requests.
|
|
147
|
-
|
|
148
|
-
.. warning:: PSM3 is limited to data found in the NSRDB, please consult the
|
|
149
|
-
references below for locations with available data. Additionally,
|
|
150
|
-
querying data with < 30-minute resolution uses a different API endpoint
|
|
151
|
-
with fewer available fields (see [4]_).
|
|
152
|
-
|
|
153
|
-
See Also
|
|
154
|
-
--------
|
|
155
|
-
pvlib.iotools.read_psm3
|
|
156
|
-
|
|
157
|
-
References
|
|
158
|
-
----------
|
|
159
|
-
|
|
160
|
-
.. [1] `NREL National Solar Radiation Database (NSRDB)
|
|
161
|
-
<https://nsrdb.nrel.gov/>`_
|
|
162
|
-
.. [2] `Physical Solar Model (PSM) v3.2.2
|
|
163
|
-
<https://developer.nrel.gov/docs/solar/nsrdb/psm3-2-2-download/>`_
|
|
164
|
-
.. [3] `Physical Solar Model (PSM) v3 TMY
|
|
165
|
-
<https://developer.nrel.gov/docs/solar/nsrdb/psm3-tmy-download/>`_
|
|
166
|
-
.. [4] `Physical Solar Model (PSM) v3 - Five Minute Temporal Resolution
|
|
167
|
-
<https://developer.nrel.gov/docs/solar/nsrdb/psm3-5min-download/>`_
|
|
168
|
-
"""
|
|
169
|
-
# The well know text (WKT) representation of geometry notation is strict.
|
|
170
|
-
# A POINT object is a string with longitude first, then the latitude, with
|
|
171
|
-
# four decimals each, and exactly one space between them.
|
|
172
|
-
longitude = ('%9.4f' % longitude).strip()
|
|
173
|
-
latitude = ('%8.4f' % latitude).strip()
|
|
174
|
-
# TODO: make format_WKT(object_type, *args) in tools.py
|
|
175
|
-
|
|
176
|
-
# convert to string to accomodate integer years being passed in
|
|
177
|
-
names = str(names)
|
|
178
|
-
|
|
179
|
-
# convert pvlib names in attributes to psm3 convention
|
|
180
|
-
attributes = [REQUEST_VARIABLE_MAP.get(a, a) for a in attributes]
|
|
181
|
-
|
|
182
|
-
# required query-string parameters for request to PSM3 API
|
|
183
|
-
params = {
|
|
184
|
-
'api_key': api_key,
|
|
185
|
-
'full_name': full_name,
|
|
186
|
-
'email': email,
|
|
187
|
-
'affiliation': affiliation,
|
|
188
|
-
'reason': PVLIB_PYTHON,
|
|
189
|
-
'mailing_list': 'false',
|
|
190
|
-
'wkt': 'POINT(%s %s)' % (longitude, latitude),
|
|
191
|
-
'names': names,
|
|
192
|
-
'attributes': ','.join(attributes),
|
|
193
|
-
'leap_day': str(leap_day).lower(),
|
|
194
|
-
'utc': 'false',
|
|
195
|
-
'interval': interval
|
|
196
|
-
}
|
|
197
|
-
# request CSV download from NREL PSM3
|
|
198
|
-
if url is None:
|
|
199
|
-
# determine the endpoint that suits the user inputs
|
|
200
|
-
if any(prefix in names for prefix in ('tmy', 'tgy', 'tdy')):
|
|
201
|
-
url = TMY_URL
|
|
202
|
-
elif interval in (5, 15):
|
|
203
|
-
url = PSM5MIN_URL
|
|
204
|
-
else:
|
|
205
|
-
url = PSM_URL
|
|
206
|
-
|
|
207
|
-
response = requests.get(url, params=params, timeout=timeout)
|
|
208
|
-
if not response.ok:
|
|
209
|
-
# if the API key is rejected, then the response status will be 403
|
|
210
|
-
# Forbidden, and then the error is in the content and there is no JSON
|
|
211
|
-
try:
|
|
212
|
-
errors = response.json()['errors']
|
|
213
|
-
except JSONDecodeError:
|
|
214
|
-
errors = response.content.decode('utf-8')
|
|
215
|
-
raise requests.HTTPError(errors, response=response)
|
|
216
|
-
# the CSV is in the response content as a UTF-8 bytestring
|
|
217
|
-
# to use pandas we need to create a file buffer from the response
|
|
218
|
-
fbuf = io.StringIO(response.content.decode('utf-8'))
|
|
219
|
-
return read_psm3(fbuf, map_variables)
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
def read_psm3(filename, map_variables=True):
|
|
223
|
-
"""
|
|
224
|
-
Read an NSRDB PSM3 weather file (formatted as SAM CSV). The NSRDB
|
|
225
|
-
is described in [1]_ and the SAM CSV format is described in [2]_.
|
|
226
|
-
|
|
227
|
-
.. versionchanged:: 0.9.0
|
|
228
|
-
The function now returns a tuple where the first element is a dataframe
|
|
229
|
-
and the second element is a dictionary containing metadata. Previous
|
|
230
|
-
versions of this function had the return values switched.
|
|
231
|
-
|
|
232
|
-
Parameters
|
|
233
|
-
----------
|
|
234
|
-
filename: str, path-like, or buffer
|
|
235
|
-
Filename or in-memory buffer of a file containing data to read.
|
|
236
|
-
map_variables: bool, default True
|
|
237
|
-
When true, renames columns of the Dataframe to pvlib variable names
|
|
238
|
-
where applicable. See variable :const:`VARIABLE_MAP`.
|
|
239
|
-
|
|
240
|
-
Returns
|
|
241
|
-
-------
|
|
242
|
-
data : pandas.DataFrame
|
|
243
|
-
timeseries data from NREL PSM3
|
|
244
|
-
metadata : dict
|
|
245
|
-
metadata from NREL PSM3 about the record, see notes for fields
|
|
246
|
-
|
|
247
|
-
Notes
|
|
248
|
-
-----
|
|
249
|
-
The return is a tuple with two items. The first item is a dataframe with
|
|
250
|
-
the PSM3 timeseries data.
|
|
251
|
-
|
|
252
|
-
The second item is a dictionary with metadata from NREL PSM3 about the
|
|
253
|
-
record containing the following fields:
|
|
254
|
-
|
|
255
|
-
* Source
|
|
256
|
-
* Location ID
|
|
257
|
-
* City
|
|
258
|
-
* State
|
|
259
|
-
* Country
|
|
260
|
-
* Latitude
|
|
261
|
-
* Longitude
|
|
262
|
-
* Time Zone
|
|
263
|
-
* Elevation
|
|
264
|
-
* Local Time Zone
|
|
265
|
-
* Clearsky DHI Units
|
|
266
|
-
* Clearsky DNI Units
|
|
267
|
-
* Clearsky GHI Units
|
|
268
|
-
* Dew Point Units
|
|
269
|
-
* DHI Units
|
|
270
|
-
* DNI Units
|
|
271
|
-
* GHI Units
|
|
272
|
-
* Solar Zenith Angle Units
|
|
273
|
-
* Temperature Units
|
|
274
|
-
* Pressure Units
|
|
275
|
-
* Relative Humidity Units
|
|
276
|
-
* Precipitable Water Units
|
|
277
|
-
* Wind Direction Units
|
|
278
|
-
* Wind Speed Units
|
|
279
|
-
* Cloud Type -15
|
|
280
|
-
* Cloud Type 0
|
|
281
|
-
* Cloud Type 1
|
|
282
|
-
* Cloud Type 2
|
|
283
|
-
* Cloud Type 3
|
|
284
|
-
* Cloud Type 4
|
|
285
|
-
* Cloud Type 5
|
|
286
|
-
* Cloud Type 6
|
|
287
|
-
* Cloud Type 7
|
|
288
|
-
* Cloud Type 8
|
|
289
|
-
* Cloud Type 9
|
|
290
|
-
* Cloud Type 10
|
|
291
|
-
* Cloud Type 11
|
|
292
|
-
* Cloud Type 12
|
|
293
|
-
* Fill Flag 0
|
|
294
|
-
* Fill Flag 1
|
|
295
|
-
* Fill Flag 2
|
|
296
|
-
* Fill Flag 3
|
|
297
|
-
* Fill Flag 4
|
|
298
|
-
* Fill Flag 5
|
|
299
|
-
* Surface Albedo Units
|
|
300
|
-
* Version
|
|
301
|
-
|
|
302
|
-
Examples
|
|
303
|
-
--------
|
|
304
|
-
>>> # Read a local PSM3 file:
|
|
305
|
-
>>> df, metadata = iotools.read_psm3("data.csv") # doctest: +SKIP
|
|
306
|
-
|
|
307
|
-
>>> # Read a file object or an in-memory buffer:
|
|
308
|
-
>>> with open(filename, 'r') as f: # doctest: +SKIP
|
|
309
|
-
... df, metadata = iotools.read_psm3(f) # doctest: +SKIP
|
|
310
|
-
|
|
311
|
-
See Also
|
|
312
|
-
--------
|
|
313
|
-
pvlib.iotools.get_psm3
|
|
314
|
-
|
|
315
|
-
References
|
|
316
|
-
----------
|
|
317
|
-
.. [1] `NREL National Solar Radiation Database (NSRDB)
|
|
318
|
-
<https://nsrdb.nrel.gov/>`_
|
|
319
|
-
.. [2] `Standard Time Series Data File Format
|
|
320
|
-
<https://web.archive.org/web/20170207203107/https://sam.nrel.gov/sites/default/files/content/documents/pdf/wfcsv.pdf>`_
|
|
321
|
-
"""
|
|
322
|
-
with tools._file_context_manager(filename) as fbuf:
|
|
323
|
-
# The first 2 lines of the response are headers with metadata
|
|
324
|
-
metadata_fields = fbuf.readline().split(',')
|
|
325
|
-
metadata_values = fbuf.readline().split(',')
|
|
326
|
-
# get the column names so we can set the dtypes
|
|
327
|
-
columns = fbuf.readline().split(',')
|
|
328
|
-
columns[-1] = columns[-1].strip() # strip trailing newline
|
|
329
|
-
# Since the header has so many columns, excel saves blank cols in the
|
|
330
|
-
# data below the header lines.
|
|
331
|
-
columns = [col for col in columns if col != '']
|
|
332
|
-
dtypes = dict.fromkeys(columns, float) # all floats except datevec
|
|
333
|
-
dtypes.update({'Year': int, 'Month': int, 'Day': int, 'Hour': int,
|
|
334
|
-
'Minute': int, 'Cloud Type': int, 'Fill Flag': int})
|
|
335
|
-
data = pd.read_csv(
|
|
336
|
-
fbuf, header=None, names=columns, usecols=columns, dtype=dtypes,
|
|
337
|
-
delimiter=',', lineterminator='\n') # skip carriage returns \r
|
|
338
|
-
|
|
339
|
-
metadata_fields[-1] = metadata_fields[-1].strip() # trailing newline
|
|
340
|
-
metadata_values[-1] = metadata_values[-1].strip() # trailing newline
|
|
341
|
-
metadata = dict(zip(metadata_fields, metadata_values))
|
|
342
|
-
# the response is all strings, so set some metadata types to numbers
|
|
343
|
-
metadata['Local Time Zone'] = int(metadata['Local Time Zone'])
|
|
344
|
-
metadata['Time Zone'] = int(metadata['Time Zone'])
|
|
345
|
-
metadata['Latitude'] = float(metadata['Latitude'])
|
|
346
|
-
metadata['Longitude'] = float(metadata['Longitude'])
|
|
347
|
-
metadata['Elevation'] = int(metadata['Elevation'])
|
|
348
|
-
|
|
349
|
-
# the response 1st 5 columns are a date vector, convert to datetime
|
|
350
|
-
dtidx = pd.to_datetime(data[['Year', 'Month', 'Day', 'Hour', 'Minute']])
|
|
351
|
-
# in USA all timezones are integers
|
|
352
|
-
tz = 'Etc/GMT%+d' % -metadata['Time Zone']
|
|
353
|
-
data.index = pd.DatetimeIndex(dtidx).tz_localize(tz)
|
|
354
|
-
|
|
355
|
-
if map_variables:
|
|
356
|
-
data = data.rename(columns=VARIABLE_MAP)
|
|
357
|
-
metadata['latitude'] = metadata.pop('Latitude')
|
|
358
|
-
metadata['longitude'] = metadata.pop('Longitude')
|
|
359
|
-
metadata['altitude'] = metadata.pop('Elevation')
|
|
360
|
-
|
|
361
|
-
return data, metadata
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
parse_psm3 = deprecated(since="0.13.0", name="parse_psm3",
|
|
365
|
-
alternative="read_psm3")(read_psm3)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|