Skip to content

Commit 5a48da7

Browse files
committed
Update test_era5.py
1 parent 5481954 commit 5a48da7

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

tests/iotools/test_era5.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ def params():
1717
return {
1818
'latitude': 40.01, 'longitude': -80.01,
1919
'start': '2020-06-01', 'end': '2020-06-01',
20-
'variables': ['ghi', 'temp_air'],
20+
# Test a mix of pvlib and ERA5 variable names
21+
'variables': [
22+
'ghi', 'temp_air', 'total_sky_direct_solar_radiation_at_surface'],
2123
'api_key': api_key,
2224
}
2325

@@ -33,7 +35,10 @@ def expected():
3335
ghi = [153., 18.4, 0., 0., 0., 0., 0., 0., 0., 0., 0., 60., 229.5,
3436
427.8, 620.1, 785.5, 910.1, 984.2, 1005.9, 962.4, 844.1, 685.2,
3537
526.9, 331.4]
36-
df = pd.DataFrame({'temp_air': temp_air, 'ghi': ghi}, index=index)
38+
bhi = [102.6, 8.3, 0., 0., 0., 0., 0., 0., 0., 0., 0., 34.9, 167.8, 345.6,
39+
524.3, 679.5, 796.1, 866.1, 893.4, 841.7, 724. , 539.6, 415.1,
40+
239.6]
41+
df = pd.DataFrame({'temp_air': temp_air, 'ghi': ghi, 'bhi': bhi}, index=index)
3742
return df
3843

3944

@@ -66,9 +71,11 @@ def test_get_era5_timezone(params, expected):
6671
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
6772
def test_get_era5_map_variables(params, expected):
6873
df, meta = pvlib.iotools.get_era5(**params, map_variables=False)
69-
expected = expected.rename(columns={'temp_air': 't2m', 'ghi': 'ssrd'})
74+
expected = expected.rename(columns={
75+
'temp_air': 't2m', 'ghi': 'ssrd', "bhi": "fdir"})
7076
df['t2m'] -= 273.15 # apply unit conversions manually
7177
df['ssrd'] /= 3600
78+
df['fdir'] /= 3600
7279
pd.testing.assert_frame_equal(df, expected, check_freq=False, atol=0.1)
7380
assert meta['longitude'] == -80.0
7481
assert meta['latitude'] == 40.0

0 commit comments

Comments
 (0)