Skip to content

Commit a997b6b

Browse files
committed
Add dataset option to get_era5
1 parent 7929b38 commit a997b6b

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

pvlib/iotools/era5.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def _m_to_cm(m):
5858

5959

6060
def get_era5(latitude, longitude, start, end, variables, api_key,
61+
dataset="reanalysis-era5-single-levels-timeseries",
6162
map_variables=True, timeout=60,
6263
url='https://cds.climate.copernicus.eu/api/retrieve/v1/'):
6364
"""
@@ -84,6 +85,10 @@ def get_era5(latitude, longitude, start, end, variables, api_key,
8485
See [1]_ for additional options.
8586
api_key : str
8687
ECMWF CDS API key.
88+
dataset : str, default "reanalysis-era5-single-levels-timeseries"
89+
The dataset to query. May be either
90+
"reanalysis-era5-single-levels-timeseries" or
91+
"reanalysis-era5-land-timeseries".
8792
map_variables : bool, default True
8893
When true, renames columns of the DataFrame to pvlib variable names
8994
where applicable. Also converts units of some variables. See variable
@@ -137,7 +142,7 @@ def _to_utc_dt_notz(dt):
137142
"data_format": "csv"
138143
}
139144
}
140-
slug = "processes/reanalysis-era5-single-levels-timeseries/execution"
145+
slug = f"processes/{dataset}/execution"
141146
response = requests.post(url + slug, json=params, headers=headers,
142147
timeout=timeout)
143148
submission_response = response.json()

tests/iotools/test_era5.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ def test_get_era5(params, expected):
4848
assert isinstance(meta['jobID'], str)
4949

5050

51+
@requires_ecmwf_credentials
52+
@pytest.mark.remote_data
53+
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
54+
def test_get_era5_land(params, expected):
55+
params['dataset'] = "reanalysis-era5-land-timeseries"
56+
df, meta = pvlib.iotools.get_era5(**params)
57+
assert meta['longitude'] == -80.0
58+
assert meta['latitude'] == 40.0
59+
assert pd.testing.assert_index_equal(df.index, expected.index)
60+
61+
5162
@requires_ecmwf_credentials
5263
@pytest.mark.remote_data
5364
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)

0 commit comments

Comments
 (0)