Skip to content

Commit fe8821d

Browse files
committed
change "goes4" to "psm4"
1 parent 0118317 commit fe8821d

6 files changed

Lines changed: 86 additions & 86 deletions

File tree

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Get NSRDB GOES V4.0.0
2+
Get NSRDB PSM4
33
see
44
https://developer.nrel.gov/docs/solar/nsrdb/nsrdb-GOES-conus-v4-0-0-download/
55
"""
@@ -23,7 +23,7 @@
2323
'surface_pressure', 'wind_direction', 'wind_speed')
2424
PVLIB_PYTHON = 'pvlib python'
2525

26-
# Dictionary mapping GOES4 response names to pvlib names
26+
# Dictionary mapping PSM4 response names to pvlib names
2727
VARIABLE_MAP = {
2828
'GHI': 'ghi',
2929
'DHI': 'dhi',
@@ -45,8 +45,8 @@
4545
'Asymmetry': 'asymmetry',
4646
}
4747

48-
# Dictionary mapping pvlib names to GOES4 request names
49-
# Note, GOES4 uses different names for the same variables in the
48+
# Dictionary mapping pvlib names to PSM4 request names
49+
# Note, PSM4 uses different names for the same variables in the
5050
# response and the request
5151
REQUEST_VARIABLE_MAP = {
5252
'ghi': 'ghi',
@@ -70,12 +70,12 @@
7070
}
7171

7272

73-
def get_goes4(latitude, longitude, api_key, email, names='tmy', interval=60,
74-
attributes=ATTRIBUTES, leap_day=True, full_name=PVLIB_PYTHON,
75-
affiliation=PVLIB_PYTHON, map_variables=True, url=None,
76-
timeout=30):
73+
def get_psm4(latitude, longitude, api_key, email, names='tmy', interval=60,
74+
attributes=ATTRIBUTES, leap_day=True, full_name=PVLIB_PYTHON,
75+
affiliation=PVLIB_PYTHON, map_variables=True, url=None,
76+
timeout=30):
7777
"""
78-
Retrieve NSRDB GOES4 timeseries weather data from the GOES4 API. The NSRDB
78+
Retrieve NSRDB PSM4 timeseries weather data from the GOES4 API. The NSRDB
7979
is described in [1]_ and the GOES4 API is described in [2]_, [3]_, and
8080
[4]_.
8181
@@ -100,7 +100,7 @@ def get_goes4(latitude, longitude, api_key, email, names='tmy', interval=60,
100100
typical year requests (i.e., tmy/tgy/tdy).
101101
attributes : list of str, optional
102102
meteorological fields to fetch. If not specified, defaults to
103-
``pvlib.iotools.goes4.ATTRIBUTES``. See references [2]_, [3]_, and [4]_
103+
``pvlib.iotools.psm4.ATTRIBUTES``. See references [2]_, [3]_, and [4]_
104104
for lists of available fields. Alternatively, pvlib names may also be
105105
used (e.g. 'ghi' rather than 'GHI'); see :const:`REQUEST_VARIABLE_MAP`.
106106
To retrieve all available fields, set ``attributes=[]``.
@@ -123,10 +123,10 @@ def get_goes4(latitude, longitude, api_key, email, names='tmy', interval=60,
123123
Returns
124124
-------
125125
data : pandas.DataFrame
126-
timeseries data from NREL GOES4
126+
timeseries data from NREL PSM4
127127
metadata : dict
128-
metadata from NREL GOES4 about the record, see
129-
:func:`pvlib.iotools.parse_goes4` for fields
128+
metadata from NREL PSM4 about the record, see
129+
:func:`pvlib.iotools.parse_psm4` for fields
130130
131131
Raises
132132
------
@@ -144,14 +144,14 @@ def get_goes4(latitude, longitude, api_key, email, names='tmy', interval=60,
144144
.. warning:: The "DEMO_KEY" `api_key` is severely rate limited and may
145145
result in rejected requests.
146146
147-
.. warning:: GOES4 is limited to data found in the NSRDB, please consult
147+
.. warning:: PSM4 is limited to data found in the NSRDB, please consult
148148
the references below for locations with available data. Additionally,
149149
querying data with < 30-minute resolution uses a different API endpoint
150150
with fewer available fields (see [4]_).
151151
152152
See Also
153153
--------
154-
pvlib.iotools.read_goes4, pvlib.iotools.parse_goes4
154+
pvlib.iotools.read_psm4, pvlib.iotools.parse_psm4
155155
156156
References
157157
----------
@@ -175,7 +175,7 @@ def get_goes4(latitude, longitude, api_key, email, names='tmy', interval=60,
175175
# convert to string to accomodate integer years being passed in
176176
names = str(names)
177177

178-
# convert pvlib names in attributes to psm3/goes4 convention
178+
# convert pvlib names in attributes to PSM4 convention
179179
attributes = [REQUEST_VARIABLE_MAP.get(a, a) for a in attributes]
180180

181181
# required query-string parameters for request to GOES4 API
@@ -193,7 +193,7 @@ def get_goes4(latitude, longitude, api_key, email, names='tmy', interval=60,
193193
'utc': 'false',
194194
'interval': interval
195195
}
196-
# request CSV download from NREL GOES4
196+
# request CSV download from NREL PSM4
197197
if url is None:
198198
# determine the endpoint that suits the user inputs
199199
if any(prefix in names for prefix in ('tmy', 'tgy', 'tdy')):
@@ -220,7 +220,7 @@ def get_goes4(latitude, longitude, api_key, email, names='tmy', interval=60,
220220

221221
def parse_goes4(fbuf, map_variables=True):
222222
"""
223-
Parse an NSRDB GOES4 weather file (formatted as SAM CSV). The NSRDB
223+
Parse an NSRDB PSM4 weather file (formatted as SAM CSV). The NSRDB
224224
is described in [1]_ and the SAM CSV format is described in [2]_.
225225
226226
Parameters
@@ -234,16 +234,16 @@ def parse_goes4(fbuf, map_variables=True):
234234
Returns
235235
-------
236236
data : pandas.DataFrame
237-
timeseries data from NREL GOES4
237+
timeseries data from NREL PSM4
238238
metadata : dict
239-
metadata from NREL GOES4 about the record, see notes for fields
239+
metadata from NREL PSM4 about the record, see notes for fields
240240
241241
Notes
242242
-----
243243
The return is a tuple with two items. The first item is a dataframe with
244-
the GOES4 timeseries data.
244+
the PSM4 timeseries data.
245245
246-
The second item is a dictionary with metadata from NREL GOES4 about the
246+
The second item is a dictionary with metadata from NREL PSM4 about the
247247
record containing the following fields:
248248
249249
* Source
@@ -295,13 +295,13 @@ def parse_goes4(fbuf, map_variables=True):
295295
296296
Examples
297297
--------
298-
>>> # Read a local GOES4 file:
298+
>>> # Read a local PSM4 file:
299299
>>> with open(filename, 'r') as f: # doctest: +SKIP
300-
... df, metadata = iotools.parse_goes4(f) # doctest: +SKIP
300+
... df, metadata = iotools.parse_psm4(f) # doctest: +SKIP
301301
302302
See Also
303303
--------
304-
pvlib.iotools.read_goes4, pvlib.iotools.get_goes4
304+
pvlib.iotools.read_psm4, pvlib.iotools.get_psm4
305305
306306
References
307307
----------
@@ -351,9 +351,9 @@ def parse_goes4(fbuf, map_variables=True):
351351
return data, metadata
352352

353353

354-
def read_goes4(filename, map_variables=True):
354+
def read_psm4(filename, map_variables=True):
355355
"""
356-
Read an NSRDB GOES4 weather file (formatted as SAM CSV). The NSRDB
356+
Read an NSRDB PSM4 weather file (formatted as SAM CSV). The NSRDB
357357
is described in [1]_ and the SAM CSV format is described in [2]_.
358358
359359
.. versionchanged:: 0.9.0
@@ -372,14 +372,14 @@ def read_goes4(filename, map_variables=True):
372372
Returns
373373
-------
374374
data : pandas.DataFrame
375-
timeseries data from NREL GOES4
375+
timeseries data from NREL PSM4
376376
metadata : dict
377-
metadata from NREL GOES4 about the record, see
378-
:func:`pvlib.iotools.parse_goes4` for fields
377+
metadata from NREL PSM4 about the record, see
378+
:func:`pvlib.iotools.parse_psm4` for fields
379379
380380
See Also
381381
--------
382-
pvlib.iotools.parse_goes4, pvlib.iotools.get_goes4
382+
pvlib.iotools.parse_psm4, pvlib.iotools.get_psm4
383383
384384
References
385385
----------
@@ -389,5 +389,5 @@ def read_goes4(filename, map_variables=True):
389389
<https://web.archive.org/web/20170207203107/https://sam.nrel.gov/sites/default/files/content/documents/pdf/wfcsv.pdf>`_
390390
"""
391391
with open(str(filename), 'r') as fbuf:
392-
content = parse_goes4(fbuf, map_variables)
392+
content = parse_psm4(fbuf, map_variables)
393393
return content
Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""
2-
test iotools for GOES4
2+
test iotools for PSM4
33
"""
44

55
import os
6-
from pvlib.iotools import goes4
6+
from pvlib.iotools import psm4
77
from ..conftest import DATA_DIR, RERUNS, RERUNS_DELAY, assert_index_equal
88
import numpy as np
99
import pandas as pd
@@ -12,10 +12,10 @@
1212
from io import StringIO
1313
import warnings
1414

15-
TMY_TEST_DATA = DATA_DIR / 'test_goes4_tmy-2023.csv'
16-
YEAR_TEST_DATA = DATA_DIR / 'test_goes4_2023.csv'
17-
YEAR_TEST_DATA_5MIN = DATA_DIR / 'test_goes4_2023_5min.csv'
18-
MANUAL_TEST_DATA = DATA_DIR / 'test_read_goes4.csv'
15+
TMY_TEST_DATA = DATA_DIR / 'test_psm4_tmy-2023.csv'
16+
YEAR_TEST_DATA = DATA_DIR / 'test_psm4_2023.csv'
17+
YEAR_TEST_DATA_5MIN = DATA_DIR / 'test_psm4_2023_5min.csv'
18+
MANUAL_TEST_DATA = DATA_DIR / 'test_read_psm4.csv'
1919
LATITUDE, LONGITUDE = 40.5137, -108.5449
2020
METADATA_FIELDS = [
2121
'Source', 'Location ID', 'City', 'State', 'Country', 'Latitude',
@@ -46,8 +46,8 @@ def nrel_api_key():
4646
return demo_key
4747

4848

49-
def assert_goes4_equal(data, metadata, expected):
50-
"""check consistency of GOES4 data"""
49+
def assert_psm4_equal(data, metadata, expected):
50+
"""check consistency of PSM4 data"""
5151
# check datevec columns
5252
assert np.allclose(data.Year, expected.Year)
5353
assert np.allclose(data.Month, expected.Month)
@@ -73,46 +73,46 @@ def assert_goes4_equal(data, metadata, expected):
7373

7474
@pytest.mark.remote_data
7575
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
76-
def test_get_goes4_tmy(nrel_api_key):
77-
"""test get_goes4 with a TMY"""
78-
data, metadata = goes4.get_goes4(LATITUDE, LONGITUDE, nrel_api_key,
79-
PVLIB_EMAIL, names='tmy-2023',
80-
leap_day=False, map_variables=False)
76+
def test_get_psm4_tmy(nrel_api_key):
77+
"""test get_psm4 with a TMY"""
78+
data, metadata = psm4.get_psm4(LATITUDE, LONGITUDE, nrel_api_key,
79+
PVLIB_EMAIL, names='tmy-2023',
80+
leap_day=False, map_variables=False)
8181
expected = pd.read_csv(TMY_TEST_DATA)
82-
assert_goes4_equal(data, metadata, expected)
82+
assert_psm4_equal(data, metadata, expected)
8383

8484

8585
@pytest.mark.remote_data
8686
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
87-
def test_get_goes4_singleyear(nrel_api_key):
88-
"""test get_goes4 with a single year"""
89-
data, metadata = goes4.get_goes4(LATITUDE, LONGITUDE, nrel_api_key,
90-
PVLIB_EMAIL, names='2023',
91-
leap_day=False, map_variables=False,
92-
interval=30)
87+
def test_get_psm4_singleyear(nrel_api_key):
88+
"""test get_psm4 with a single year"""
89+
data, metadata = psm4.get_psm4(LATITUDE, LONGITUDE, nrel_api_key,
90+
PVLIB_EMAIL, names='2023',
91+
leap_day=False, map_variables=False,
92+
interval=30)
9393
expected = pd.read_csv(YEAR_TEST_DATA)
94-
assert_goes4_equal(data, metadata, expected)
94+
assert_psm4_equal(data, metadata, expected)
9595

9696

9797
@pytest.mark.remote_data
9898
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
99-
def test_get_goes4_5min(nrel_api_key):
100-
"""test get_goes4 for 5-minute data"""
101-
data, metadata = goes4.get_goes4(LATITUDE, LONGITUDE, nrel_api_key,
102-
PVLIB_EMAIL, names='2023', interval=5,
103-
leap_day=False, map_variables=False)
99+
def test_get_psm4_5min(nrel_api_key):
100+
"""test get_psm4 for 5-minute data"""
101+
data, metadata = psm4.get_psm4(LATITUDE, LONGITUDE, nrel_api_key,
102+
PVLIB_EMAIL, names='2023', interval=5,
103+
leap_day=False, map_variables=False)
104104
assert len(data) == 525600/5
105105
first_day = data.loc['2023-01-01']
106106
expected = pd.read_csv(YEAR_TEST_DATA_5MIN)
107-
assert_goes4_equal(first_day, metadata, expected)
107+
assert_psm4_equal(first_day, metadata, expected)
108108

109109

110110
@pytest.mark.remote_data
111111
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
112-
def test_get_goes4_check_leap_day(nrel_api_key):
113-
data_2012, _ = goes4.get_goes4(LATITUDE, LONGITUDE, nrel_api_key,
114-
PVLIB_EMAIL, names="2012", interval=60,
115-
leap_day=True, map_variables=False)
112+
def test_get_psm4_check_leap_day(nrel_api_key):
113+
data_2012, _ = psm4.get_psm4(LATITUDE, LONGITUDE, nrel_api_key,
114+
PVLIB_EMAIL, names="2012", interval=60,
115+
leap_day=True, map_variables=False)
116116
assert len(data_2012) == (8760 + 24)
117117

118118

@@ -124,10 +124,10 @@ def test_get_goes4_check_leap_day(nrel_api_key):
124124
])
125125
@pytest.mark.remote_data
126126
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
127-
def test_get_goes4_tmy_errors(
127+
def test_get_psm4_tmy_errors(
128128
latitude, longitude, api_key, names, interval
129129
):
130-
"""Test get_goes4() for multiple erroneous input scenarios.
130+
"""Test get_psm4() for multiple erroneous input scenarios.
131131
132132
These scenarios include:
133133
* Bad API key -> HTTP 403 forbidden because api_key is rejected
@@ -136,39 +136,39 @@ def test_get_goes4_tmy_errors(
136136
* Bad interval, single year -> Intervals can only be 30 or 60 minutes.
137137
"""
138138
with pytest.raises(HTTPError) as excinfo:
139-
goes4.get_goes4(latitude, longitude, api_key, PVLIB_EMAIL,
140-
names=names, interval=interval, leap_day=False,
141-
map_variables=False)
139+
psm4.get_psm4(latitude, longitude, api_key, PVLIB_EMAIL,
140+
names=names, interval=interval, leap_day=False,
141+
map_variables=False)
142142
# ensure the HTTPError caught isn't due to overuse of the API key
143143
assert "OVER_RATE_LIMIT" not in str(excinfo.value)
144144

145145

146146
@pytest.fixture
147147
def io_input(request):
148-
"""file-like object for parse_goes4"""
148+
"""file-like object for parse_psm4"""
149149
with MANUAL_TEST_DATA.open() as f:
150150
data = f.read()
151151
obj = StringIO(data)
152152
return obj
153153

154154

155-
def test_parse_goes4(io_input):
156-
"""test parse_goes4"""
157-
data, metadata = goes4.parse_goes4(io_input, map_variables=False)
155+
def test_parse_psm4(io_input):
156+
"""test parse_psm4"""
157+
data, metadata = psm4.parse_psm4(io_input, map_variables=False)
158158
expected = pd.read_csv(YEAR_TEST_DATA)
159-
assert_goes4_equal(data, metadata, expected)
159+
assert_psm4_equal(data, metadata, expected)
160160

161161

162-
def test_read_goes4():
163-
"""test read_goes4"""
164-
data, metadata = goes4.read_goes4(MANUAL_TEST_DATA, map_variables=False)
162+
def test_read_psm4():
163+
"""test read_psm4"""
164+
data, metadata = psm4.read_psm4(MANUAL_TEST_DATA, map_variables=False)
165165
expected = pd.read_csv(YEAR_TEST_DATA)
166-
assert_goes4_equal(data, metadata, expected)
166+
assert_psm4_equal(data, metadata, expected)
167167

168168

169-
def test_read_goes4_map_variables():
170-
"""test read_goes4 map_variables=True"""
171-
data, metadata = goes4.read_goes4(MANUAL_TEST_DATA, map_variables=True)
169+
def test_read_psm4_map_variables():
170+
"""test read_psm4 map_variables=True"""
171+
data, metadata = psm4.read_psm4(MANUAL_TEST_DATA, map_variables=True)
172172
columns_mapped = ['Year', 'Month', 'Day', 'Hour', 'Minute', 'temp_air',
173173
'alpha', 'aod', 'asymmetry', 'dhi_clear', 'dni_clear',
174174
'ghi_clear', 'Cloud Fill Flag', 'Cloud Type',
@@ -181,13 +181,13 @@ def test_read_goes4_map_variables():
181181

182182
@pytest.mark.remote_data
183183
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
184-
def test_get_goes4_attribute_mapping(nrel_api_key):
184+
def test_get_psm4_attribute_mapping(nrel_api_key):
185185
"""Test that pvlib names can be passed in as attributes and get correctly
186-
reverse mapped to GOES4 names"""
187-
data, meta = goes4.get_goes4(LATITUDE, LONGITUDE, nrel_api_key,
188-
PVLIB_EMAIL, names=2019, interval=60,
189-
attributes=['ghi', 'wind_speed'],
190-
leap_day=False, map_variables=True)
186+
reverse mapped to psm4 names"""
187+
data, meta = psm4.get_psm4(LATITUDE, LONGITUDE, nrel_api_key,
188+
PVLIB_EMAIL, names=2019, interval=60,
189+
attributes=['ghi', 'wind_speed'],
190+
leap_day=False, map_variables=True)
191191
# Check that columns are in the correct order (GH1647)
192192
expected_columns = [
193193
'Year', 'Month', 'Day', 'Hour', 'Minute', 'ghi', 'wind_speed']

0 commit comments

Comments
 (0)