From 1ebc5d744f6f485dffa94dc5d2fb8f3e7cb0ac89 Mon Sep 17 00:00:00 2001 From: Paolo Veglio <paolo.veglio@ssec.wisc.edu> Date: Thu, 25 Apr 2024 19:32:53 +0000 Subject: [PATCH] fixed test_conf and test_read_data --- tests/test_conf.py | 18 ++++++++++++------ tests/test_read_data.py | 30 +++++++++++++++--------------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/tests/test_conf.py b/tests/test_conf.py index 552af02..ad6df62 100644 --- a/tests/test_conf.py +++ b/tests/test_conf.py @@ -70,13 +70,19 @@ def test_c_single_threshold(rad, single_threshold, reference_data): ref_confidence = np.load(reference_data)["ref_sgl"] ref_confidence_flipped = np.load(reference_data)["ref_sgl_flipped"] - c = anc.py_conf_test( - rad, single_threshold[0], single_threshold[2], single_threshold[3], single_threshold[1] - ) + locut = np.array(single_threshold[0], dtype=float) + 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) single_threshold[0:-1] = single_threshold[-2::-1] - c = anc.py.conf_test( - rad, single_threshold[0], single_threshold[2], single_threshold[3], single_threshold[1] - ) + locut = np.array(single_threshold[0], dtype=float) + 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) diff --git a/tests/test_read_data.py b/tests/test_read_data.py index e91e7d2..4135de0 100644 --- a/tests/test_read_data.py +++ b/tests/test_read_data.py @@ -103,31 +103,29 @@ def test_l1b(l1b_file, geo_file): 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.""" - viirs = rd.ReadData(satellite="snpp", sensor="viirs") + viirs = rd.ReadData(satellite="snpp", sensor="viirs", file_name_geo=geo_file) geo = viirs.read_viirs_geo() ancillary = rd.ReadAncillary( latitude=geo.latitude.values, longitude=geo.longitude.values, resolution=1, - ancillary_dir=fixturepath, - sst_file=sst_file, + sst_file=os.path.join(fixturepath, sst_file), ) sst = ancillary.get_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.""" - viirs = rd.ReadData(satellite="snpp", sensor="viirs") + viirs = rd.ReadData(satellite="snpp", sensor="viirs", file_name_geo=geo_file) geo = viirs.read_viirs_geo() ancillary = rd.ReadAncillary( latitude=geo.latitude.values, longitude=geo.longitude.values, resolution=1, - ancillary_dir=fixturepath, - ndvi_file=ndvi_file, + ndvi_file=os.path.join(fixturepath, ndvi_file), ) ndvi = ancillary.get_ndvi() check_differences(ref_file, ndvi, "ndvi") @@ -135,6 +133,8 @@ def test_ndvi(fixturepath, ndvi_file, ref_file): def test_geos( fixturepath, + l1b_file, + geo_file, geos_file_1, geos_file_2, geos_land, @@ -143,18 +143,18 @@ def test_geos( ref_file, ): """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() ancillary = rd.ReadAncillary( + file_name_l1b=l1b_file, latitude=geo.latitude.values, longitude=geo.longitude.values, resolution=1, - ancillary_dir=fixturepath, - geos_file_1=geos_file_1, - geos_file_2=geos_file_2, - geos_land=geos_land, - geos_ocean=geos_ocean, - geos_constants=geos_constants, + geos_file_1=os.path.join(fixturepath, geos_file_1), + geos_file_2=os.path.join(fixturepath, geos_file_2), + geos_land=os.path.join(fixturepath, geos_land), + geos_ocean=os.path.join(fixturepath, geos_ocean), + geos_constants=os.path.join(fixturepath, geos_constants), ) geos_data = ancillary.get_geos() -- GitLab