Skip to content

Commit

Permalink
add test for redtoreg
Browse files Browse the repository at this point in the history
  • Loading branch information
jswhit committed Jan 16, 2024
1 parent 5363c50 commit 2ef5dd8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/test_latlons.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# 3rd Party
import pytest
import numpy as np
from pygrib import redtoreg


# filename is passed as an argument to samplegribfile fixture
Expand Down Expand Up @@ -100,3 +101,16 @@ def test_latlons_randpoint(samplegribfile, pt_ji, expected):
lats, lons = samplegribfile.message(1).latlons()
j, i = pt_ji
assert np.allclose([lons[j, i], lats[j, i]], expected)

@pytest.mark.parametrize(
"filename, field",
[
("ecmwf_tigge.grb","Soil moisture"),
])
def test_redtoreg(samplegribfile,field):
"""Test the redtoreg function"""
grb = samplegribfile.select(parameterName=field)[0]
fld = grb.values
grb.expand_grid(False)
fld_tst = redtoreg(grb.values, grb.pl, missval=grb.missingValue)
assert np.allclose(fld,fld_tst)

0 comments on commit 2ef5dd8

Please sign in to comment.