Skip to content
Snippets Groups Projects
Commit 1ebc5d74 authored by Paolo Veglio's avatar Paolo Veglio
Browse files

fixed test_conf and test_read_data

parent 3d2ff753
No related branches found
No related tags found
No related merge requests found
Pipeline #51253 failed
...@@ -70,13 +70,19 @@ def test_c_single_threshold(rad, single_threshold, reference_data): ...@@ -70,13 +70,19 @@ def test_c_single_threshold(rad, single_threshold, reference_data):
ref_confidence = np.load(reference_data)["ref_sgl"] ref_confidence = np.load(reference_data)["ref_sgl"]
ref_confidence_flipped = np.load(reference_data)["ref_sgl_flipped"] ref_confidence_flipped = np.load(reference_data)["ref_sgl_flipped"]
c = anc.py_conf_test( locut = np.array(single_threshold[0], dtype=float)
rad, single_threshold[0], single_threshold[2], single_threshold[3], single_threshold[1] midpt = np.array(single_threshold[1], dtype=float)
) hicut = np.array(single_threshold[2], dtype=float)
power = np.array(single_threshold[3], dtype=float)
c = anc.py_conf_test(np.array(rad, dtype=np.float32), locut, hicut, power, midpt)
assert np.all(c == ref_confidence) assert np.all(c == ref_confidence)
single_threshold[0:-1] = single_threshold[-2::-1] single_threshold[0:-1] = single_threshold[-2::-1]
c = anc.py.conf_test( locut = np.array(single_threshold[0], dtype=float)
rad, single_threshold[0], single_threshold[2], single_threshold[3], single_threshold[1] midpt = np.array(single_threshold[1], dtype=float)
) hicut = np.array(single_threshold[2], dtype=float)
power = np.array(single_threshold[3], dtype=float)
c = anc.py_conf_test(np.array(rad, dtype=np.float32), locut, hicut, power, midpt)
assert np.all(c == ref_confidence_flipped) assert np.all(c == ref_confidence_flipped)
...@@ -103,31 +103,29 @@ def test_l1b(l1b_file, geo_file): ...@@ -103,31 +103,29 @@ def test_l1b(l1b_file, geo_file):
assert "M11" in l1b.data_vars assert "M11" in l1b.data_vars
def test_sst(fixturepath, sst_file, ref_file): def test_sst(fixturepath, geo_file, sst_file, ref_file):
"""Test SST reading.""" """Test SST reading."""
viirs = rd.ReadData(satellite="snpp", sensor="viirs") viirs = rd.ReadData(satellite="snpp", sensor="viirs", file_name_geo=geo_file)
geo = viirs.read_viirs_geo() geo = viirs.read_viirs_geo()
ancillary = rd.ReadAncillary( ancillary = rd.ReadAncillary(
latitude=geo.latitude.values, latitude=geo.latitude.values,
longitude=geo.longitude.values, longitude=geo.longitude.values,
resolution=1, resolution=1,
ancillary_dir=fixturepath, sst_file=os.path.join(fixturepath, sst_file),
sst_file=sst_file,
) )
sst = ancillary.get_sst() sst = ancillary.get_sst()
check_differences(ref_file, sst, "sst") check_differences(ref_file, sst, "sst")
def test_ndvi(fixturepath, ndvi_file, ref_file): def test_ndvi(fixturepath, geo_file, ndvi_file, ref_file):
"""Test NDVI reading.""" """Test NDVI reading."""
viirs = rd.ReadData(satellite="snpp", sensor="viirs") viirs = rd.ReadData(satellite="snpp", sensor="viirs", file_name_geo=geo_file)
geo = viirs.read_viirs_geo() geo = viirs.read_viirs_geo()
ancillary = rd.ReadAncillary( ancillary = rd.ReadAncillary(
latitude=geo.latitude.values, latitude=geo.latitude.values,
longitude=geo.longitude.values, longitude=geo.longitude.values,
resolution=1, resolution=1,
ancillary_dir=fixturepath, ndvi_file=os.path.join(fixturepath, ndvi_file),
ndvi_file=ndvi_file,
) )
ndvi = ancillary.get_ndvi() ndvi = ancillary.get_ndvi()
check_differences(ref_file, ndvi, "ndvi") check_differences(ref_file, ndvi, "ndvi")
...@@ -135,6 +133,8 @@ def test_ndvi(fixturepath, ndvi_file, ref_file): ...@@ -135,6 +133,8 @@ def test_ndvi(fixturepath, ndvi_file, ref_file):
def test_geos( def test_geos(
fixturepath, fixturepath,
l1b_file,
geo_file,
geos_file_1, geos_file_1,
geos_file_2, geos_file_2,
geos_land, geos_land,
...@@ -143,18 +143,18 @@ def test_geos( ...@@ -143,18 +143,18 @@ def test_geos(
ref_file, ref_file,
): ):
"""Test GEOS reading.""" """Test GEOS reading."""
viirs = rd.ReadData(satellite="snpp", sensor="viirs") viirs = rd.ReadData(satellite="snpp", sensor="viirs", file_name_geo=geo_file)
geo = viirs.read_viirs_geo() geo = viirs.read_viirs_geo()
ancillary = rd.ReadAncillary( ancillary = rd.ReadAncillary(
file_name_l1b=l1b_file,
latitude=geo.latitude.values, latitude=geo.latitude.values,
longitude=geo.longitude.values, longitude=geo.longitude.values,
resolution=1, resolution=1,
ancillary_dir=fixturepath, geos_file_1=os.path.join(fixturepath, geos_file_1),
geos_file_1=geos_file_1, geos_file_2=os.path.join(fixturepath, geos_file_2),
geos_file_2=geos_file_2, geos_land=os.path.join(fixturepath, geos_land),
geos_land=geos_land, geos_ocean=os.path.join(fixturepath, geos_ocean),
geos_ocean=geos_ocean, geos_constants=os.path.join(fixturepath, geos_constants),
geos_constants=geos_constants,
) )
geos_data = ancillary.get_geos() geos_data = ancillary.get_geos()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment