Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance support for FY-3F/MERSI-3 #2861

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion satpy/etc/readers/mersi3_l1b.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ datasets:
standard_name: counts
'19':
name: '19'
wavelength: [1.23, 1.24, 1.25] # or 1.03um?
wavelength: [1.02, 1.03, 1.04]
resolution: 1000
file_type: mersi3_l1b_1000
file_key: Data/EV_1KM_RefSB
Expand Down
10 changes: 5 additions & 5 deletions satpy/readers/mersi_l1b.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
The files for this reader are HDF5 and come in four varieties; band data
and geolocation data, both at 250m and 1000m resolution.

This reader was tested on FY-3A/B/C MERSI-1, FY-3D MERSI-2, FY-3E MERSI-LL and FY-3G MERSI-RM data,
This reader was tested on FY-3A/B/C MERSI-1, FY-3D MERSI-2, FY-3E MERSI-LL, FY-3F MERSI-3 and FY-3G MERSI-RM data,
but should work on future platforms as well assuming no file format changes.

"""
Expand Down Expand Up @@ -238,12 +238,12 @@
After applying slope and intercept, we just get it. And Same way for IR bands, no matter which sensor it is.

"""
mersi_2_vis = [str(i) for i in range(1, 20)]
mersi_2_3_vis = [str(i) for i in range(1, 20)]
mersi_rm_vis = [str(i) for i in range(1, 6)]

if self.sensor_name == "mersi-2" and datset_id["name"] in mersi_2_vis:
if (self.sensor_name == "mersi-2" or self.sensor_name == "mersi-3") and datset_id["name"] in mersi_2_3_vis:

Check warning on line 244 in satpy/readers/mersi_l1b.py

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Complex Conditional

MERSIL1B._get_rad_dataset has 1 complex conditionals with 2 branches, threshold = 2. A complex conditional is an expression inside a branch (e.g. if, for, while) which consists of multiple, logical operators such as AND/OR. The more logical operators in an expression, the more severe the code smell.
E0 = self["/attr/Solar_Irradiance"]
rad = self._get_ref_dataset(data, ds_info) / 100 * E0[mersi_2_vis.index(datset_id["name"])] / np.pi
rad = self._get_ref_dataset(data, ds_info) / 100 * E0[mersi_2_3_vis.index(datset_id["name"])] / np.pi

Check warning on line 246 in satpy/readers/mersi_l1b.py

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Complex Method

MERSIL1B._get_rad_dataset has a cyclomatic complexity of 9, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
elif self.sensor_name == "mersi-rm" and datset_id["name"] in mersi_rm_vis:
E0 = self._get_coefficients("Calibration/Solar_Irradiance", mersi_rm_vis.index(datset_id["name"]))
rad = self._get_ref_dataset(data, ds_info) / 100 * E0 / np.pi
Expand Down Expand Up @@ -285,7 +285,7 @@
elif self.sensor_name == "mersi-2":
corr_coeff_a = float(self["/attr/TBB_Trans_Coefficient_A"][calibration_index])
corr_coeff_b = float(self["/attr/TBB_Trans_Coefficient_B"][calibration_index])
elif self.sensor_name == "mersi-ll":
elif self.sensor_name == "mersi-ll" or self.sensor_name == "mersi-3":
# MERSI-LL stores these coefficients differently
try:
coeffs = self["/attr/TBB_Trans_Coefficient"]
Expand Down
27 changes: 23 additions & 4 deletions satpy/tests/reader_tests/test_mersi_l1b.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ def _set_sensor_attrs(self, global_attrs):
global_attrs["/attr/Satellite Name"] = "FY-3E"
global_attrs["/attr/Sensor Identification Code"] = "MERSI LL"
ftype = "LL"
elif "mersi3_l1b" in self.filetype_info["file_type"]:
global_attrs["/attr/Satellite Name"] = "FY-3F"
global_attrs["/attr/Sensor Identification Code"] = "MERSI"
ftype = "VIS"
elif "mersi_rm" in self.filetype_info["file_type"]:
global_attrs["/attr/Satellite Name"] = "FY-3G"
global_attrs["/attr/Sensor Identification Code"] = "MERSI RM"
Expand Down Expand Up @@ -555,14 +559,14 @@ def test_rad_calib(self):
reader = _test_find_files_and_readers(self.reader_configs, filenames)

ds_ids = []
test_bands = self.bands_1000 + self.bands_250 if self.yaml_file in ["mersi2_l1b.yaml", "mersi_ll_l1b.yaml"] \
test_bands = self.bands_1000 + self.bands_250 if self.yaml_file in ["mersi2_l1b.yaml", "mersi3_l1b.yaml", "mersi_ll_l1b.yaml"] \
else self.ir_250_bands + self.ir_1000_bands

for band_name in test_bands:
ds_ids.append(make_dataid(name=band_name, calibration="radiance"))
res = reader.load(ds_ids)
assert len(res) == len(test_bands)
if self.yaml_file in ["mersi2_l1b.yaml", "mersi_ll_l1b.yaml"]:
if self.yaml_file in ["mersi2_l1b.yaml", "mersi3_l1b.yaml", "mersi_ll_l1b.yaml"]:
_assert_bands_mda_as_exp(res, self.bands_250, ("radiance", "mW/ (m2 cm-1 sr)", (2 * 40, 2048 * 2)))
_assert_bands_mda_as_exp(res, self.bands_1000, ("radiance", "mW/ (m2 cm-1 sr)", (2 * 10, 2048)))
else:
Expand Down Expand Up @@ -631,7 +635,7 @@ class TestFY3DMERSI2L1B(MERSI12llL1BTester):


class TestFY3EMERSIllL1B(MERSI12llL1BTester):
"""Test the FY3D MERSI2 L1B reader."""
"""Test the FY3E MERSI2 L1B reader."""

yaml_file = "mersi_ll_l1b.yaml"
filenames_1000m = ["FY3E_MERSI_GRAN_L1_20230410_1910_1000M_V0.HDF", "FY3E_MERSI_GRAN_L1_20230410_1910_GEO1K_V0.HDF"]
Expand All @@ -645,8 +649,23 @@ class TestFY3EMERSIllL1B(MERSI12llL1BTester):
bands_250 = vis_250_bands + ir_250_bands


class TestFY3FMERSIllL1B(MERSI12llL1BTester):
"""Test the FY3F MERSI2 L1B reader."""

yaml_file = "mersi3_l1b.yaml"
filenames_1000m = ["FY3F_MERSI_GRAN_L1_20230410_1910_1000M_V0.HDF", "FY3F_MERSI_GRAN_L1_20230410_1910_GEO1K_V0.HDF"]
filenames_250m = ["FY3F_MERSI_GRAN_L1_20230410_1910_0250M_V0.HDF", "FY3F_MERSI_GRAN_L1_20230410_1910_GEOQK_V0.HDF"]
filenames_all = filenames_1000m + filenames_250m
vis_250_bands = ["1", "2", "3", "4"]
ir_250_bands = ["24", "25"]
vis_1000_bands = ["5", "8", "9", "11", "15", "17", "19"]
ir_1000_bands = ["20", "21", "23"]
bands_1000 = vis_1000_bands + ir_1000_bands
bands_250 = vis_250_bands + ir_250_bands


class TestMERSIRML1B(MERSIL1BTester):
"""Test the FY3E MERSI-RM L1B reader."""
"""Test the FY3G MERSI-RM L1B reader."""

yaml_file = "mersi_rm_l1b.yaml"
filenames_500m = ["FY3G_MERSI_GRAN_L1_20230410_1910_0500M_V1.HDF",
Expand Down
Loading