Skip to content

Commit

Permalink
Fix s111/s104 inverted grid properties and update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
erin-nagel committed Dec 15, 2023
1 parent 6892148 commit 0608e5b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
4 changes: 2 additions & 2 deletions s100py/s104/README.md
Expand Up @@ -120,8 +120,8 @@ grid_properties = {
'maxy': -18.944464,
'cellsize_x': 0.01384226425,
'cellsize_y': 0.0130463781538463,
'nx': 16,
'ny': 13
'nx': 13,
'ny': 16
}

datetime_forecast_issuance = datetime.datetime(2021, 9, 1, 0, 0, 0)
Expand Down
4 changes: 2 additions & 2 deletions s100py/s111/README.md
Expand Up @@ -48,8 +48,8 @@ grid_properties = {
'maxy': 37.497223,
'cellsize_x': 0.005695343,
'cellsize_y': 0.0056991577,
'nx': 6,
'ny': 5
'nx': 5,
'ny': 6
}

datetime_forecast_issuance = datetime.datetime(2021, 1, 7, 12, 0, 0)
Expand Down
13 changes: 9 additions & 4 deletions tests/s104/s104_test.py
Expand Up @@ -1349,8 +1349,8 @@ def input_data(s104):
'maxy': -18.208768,
'cellsize_x': 0.0138324559534882,
'cellsize_y': 0.0139546193943669,
'nx': 71,
'ny': 43
'ny': 71,
'nx': 43
}

height_dcf3_dcf7_001 = numpy.array([1.15, 0.74, 1.02, 0.32, 0.51, 0.7, 0.89, 0.1, 0.28, 0.48])
Expand Down Expand Up @@ -1570,8 +1570,8 @@ def test_create_s104_dcf2(s104, input_data):
assert h5_file['WaterLevel/WaterLevel.01/Group_002/values']['waterLevelHeight'] == pytest.approx(input_data.height_dcf2_002)
assert h5_file['WaterLevel/WaterLevel.01/Group_001/values']['waterLevelTrend'] == pytest.approx(input_data.trend_dcf2_001)
assert h5_file['WaterLevel/WaterLevel.01/Group_002/values']['waterLevelTrend'] == pytest.approx(trend_002)
assert h5_file['WaterLevel/WaterLevel.01/'].attrs['numPointsLongitudinal'] == input_data.height_dcf2_001.shape[0]
assert h5_file['WaterLevel/WaterLevel.01/'].attrs['numPointsLatitudinal'] == input_data.height_dcf2_001.shape[1]
assert h5_file['WaterLevel/WaterLevel.01/'].attrs['numPointsLongitudinal'] == input_data.height_dcf2_001.shape[1]
assert h5_file['WaterLevel/WaterLevel.01/'].attrs['numPointsLatitudinal'] == input_data.height_dcf2_001.shape[0]
assert h5_file.attrs['eastBoundLongitude'] == pytest.approx(input_data.grid_properties_dcf2['maxx'])
assert h5_file.attrs['westBoundLongitude'] == pytest.approx(input_data.grid_properties_dcf2['minx'])
assert h5_file.attrs['northBoundLatitude'] == pytest.approx(input_data.grid_properties_dcf2['maxy'])
Expand All @@ -1584,6 +1584,11 @@ def test_create_s104_dcf2(s104, input_data):
assert all([h5py_string_comp(actual, expected) for actual, expected in zip(h5_file['Group_F/WaterLevel'][()][2],
input_data.expected_groupf[2])])

assert pytest.approx((h5_file.attrs['westBoundLongitude'] + h5_file['WaterLevel/WaterLevel.01/'].attrs['numPointsLongitudinal']
* h5_file['WaterLevel/WaterLevel.01/'].attrs['gridSpacingLongitudinal']), rel=0.005) == h5_file.attrs['eastBoundLongitude']
assert pytest.approx((h5_file.attrs['southBoundLatitude'] + h5_file['WaterLevel/WaterLevel.01/'].attrs['numPointsLatitudinal']
* h5_file['WaterLevel/WaterLevel.01/'].attrs['gridSpacingLatitudinal']), rel=0.005) == h5_file.attrs['northBoundLatitude']


def test_create_s104_dcf3(s104, input_data):
if s104.EDITION == 1.1:
Expand Down
8 changes: 6 additions & 2 deletions tests/s111/s111_test.py
Expand Up @@ -3844,8 +3844,12 @@ def test_create_s111_dcf2(s111, input_data):
input_data.speed_dcf2_002)
assert numpy.allclose(h5_file['SurfaceCurrent/SurfaceCurrent.01/Group_002/values']['surfaceCurrentDirection'],
input_data.direction_dcf2_002)
assert h5_file['SurfaceCurrent/SurfaceCurrent.01/'].attrs['numPointsLongitudinal'] == input_data.speed_dcf2_001.shape[0]
assert h5_file['SurfaceCurrent/SurfaceCurrent.01/'].attrs['numPointsLatitudinal'] == input_data.speed_dcf2_001.shape[1]
assert h5_file['SurfaceCurrent/SurfaceCurrent.01/'].attrs['numPointsLongitudinal'] == input_data.speed_dcf2_001.shape[1]
assert h5_file['SurfaceCurrent/SurfaceCurrent.01/'].attrs['numPointsLatitudinal'] == input_data.speed_dcf2_001.shape[0]
assert pytest.approx((h5_file.attrs['westBoundLongitude'] + h5_file['SurfaceCurrent/SurfaceCurrent.01/'].attrs['numPointsLongitudinal']
* h5_file['SurfaceCurrent/SurfaceCurrent.01/'].attrs['gridSpacingLongitudinal']), rel=0.005) == h5_file.attrs['eastBoundLongitude']
assert pytest.approx((h5_file.attrs['southBoundLatitude'] + h5_file['SurfaceCurrent/SurfaceCurrent.01/'].attrs['numPointsLatitudinal']
* h5_file['SurfaceCurrent/SurfaceCurrent.01/'].attrs['gridSpacingLatitudinal']), rel=0.005) == h5_file.attrs['northBoundLatitude']

assert all([h5py_string_comp(actual, expected) for actual, expected in
zip(h5_file['Group_F/SurfaceCurrent'][()][0], input_data.expected_groupf[0])])
Expand Down

0 comments on commit 0608e5b

Please sign in to comment.