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

feat: Enable to read for the Q4 coverage and the IQTI files for the fci l1c data #2843

Merged
merged 22 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
da769ce
feat: Enable to read for the Q4 coverage and the IQTI files for the f…
ClementLaplace Jun 28, 2024
5a75c9b
test : Add the IQTI tests
ClementLaplace Jul 5, 2024
440925d
test : Erased the FakeFCIFileHandlerWithBadIDPFData class and the tes…
ClementLaplace Jul 8, 2024
5a30d79
test: Add test related to the rc_period_min_cycle and count_in_repeat…
ClementLaplace Jul 9, 2024
75fa7e3
feat : Make sur that the reader works for reflectance calibration for…
ClementLaplace Jul 9, 2024
cc1bd30
test: Create IQTI mock data for the earth_sun_distance
ClementLaplace Jul 9, 2024
588a648
test : Refactore the test and add test to check that sun_earth_distan…
ClementLaplace Jul 10, 2024
9d3a000
test : Refactore the test related to the earth_sun_distance and rc_pe…
ClementLaplace Jul 10, 2024
7427e70
test : change set of parameters to a tuple for test_count_in_repeat_c…
ClementLaplace Jul 11, 2024
5560b85
test: add cache_property for compute_sun_earth and add test related t…
ClementLaplace Jul 15, 2024
5de79ca
test: Compartimentalize the _get_assert_load method into the test_fci…
ClementLaplace Jul 18, 2024
7cabd61
test: Reduce number of parameters into the _get_assert_load method fo…
ClementLaplace Jul 18, 2024
d8a9dfe
typo: Do the typo as suggested into this PR https://github.com/pytrol…
ClementLaplace Jul 18, 2024
b57c970
test: Put all the internal method into the ModuleTestFCIL1cNcReader c…
ClementLaplace Jul 18, 2024
070f8f6
test: Add 4 decimals for numpy.testing.assert_array_almost_equal to a…
ClementLaplace Jul 18, 2024
58ee692
typo: Add in the documentation that the reader now supports RSS scan…
ClementLaplace Jul 18, 2024
247b988
Fix typo in IDPF
ameraner Jul 19, 2024
9d2a979
Add "Q4" indication
ameraner Jul 19, 2024
a9b2fdb
Fix "useful" typo
ameraner Jul 19, 2024
c1c00b2
fix "datas" in docstring
ameraner Jul 26, 2024
44263f7
fix alignment of tuple
ameraner Jul 26, 2024
a5c5022
refactor: Refactor orbital_param method into the fci_l1_nc.py
ClementLaplace Jul 26, 2024
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
65 changes: 35 additions & 30 deletions satpy/readers/fci_l1c_nc.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,18 +216,27 @@
logger.debug("Start: {}".format(self.start_time))
logger.debug("End: {}".format(self.end_time))

if self.filename_info["coverage"] == "Q4":
# change number of chunk so that padding gets activated correctly on missing chunks
self.filename_info["count_in_repeat_cycle"] += 28

if self.filename_info["facility_or_tool"] == "IQTI":
self.is_iqt = True
else :
self.is_iqt = False

self._cache = {}

@property
def rc_period_min(self):
"""Get nominal repeat cycle duration.

As RSS is not yet implemented an error will be raised if RSS are tried to be read.
"""
if self.filename_info["coverage"] not in ["FD","AF"]:
raise NotImplementedError(f"coverage for {self.filename_info['coverage']} not supported by this reader")
"""Get nominal repeat cycle duration."""
if "Q4" in self.filename_info["coverage"]:
return 2.5
return 10
elif self.filename_info["coverage"] in ["FD","AF"]:
return 10
else:
raise NotImplementedError(f"coverage for {self.filename_info['coverage']}"

Check warning on line 238 in satpy/readers/fci_l1c_nc.py

View check run for this annotation

Codecov / codecov/patch

satpy/readers/fci_l1c_nc.py#L238

Added line #L238 was not covered by tests
" not supported by this reader")

@property
def nominal_start_time(self):
Expand Down Expand Up @@ -378,11 +387,12 @@
self["attr/platform"], self["attr/platform"])

# remove unpacking parameters for calibrated data
if key["calibration"] in ["brightness_temperature", "reflectance"]:
if key["calibration"] in ["brightness_temperature", "reflectance","radiance"]:
res.attrs.pop("add_offset")
res.attrs.pop("warm_add_offset")
res.attrs.pop("scale_factor")
res.attrs.pop("warm_scale_factor")
res.attrs.pop("valid_range")

# remove attributes from original file which don't apply anymore
res.attrs.pop("long_name")
Expand All @@ -400,9 +410,21 @@
@cached_property
def orbital_param(self):
"""Compute the orbital parameters for the current segment."""
actual_subsat_lon = float(np.nanmean(self._get_aux_data_lut_vector("subsatellite_longitude")))
actual_subsat_lat = float(np.nanmean(self._get_aux_data_lut_vector("subsatellite_latitude")))
actual_sat_alt = float(np.nanmean(self._get_aux_data_lut_vector("platform_altitude")))
if self.is_iqt:
actual_subsat_lon = float(self.get_and_cache_npxr("data/mtg_geos_projection/attr/"
"longitude_of_projection_origin"))
#actual_subsat_lon = -3.4
actual_subsat_lat = 0.0
actual_sat_alt = float(self.get_and_cache_npxr("data/mtg_geos_projection/attr/perspective_point_height"))
#actual_sat_alt = 0.0
logger.info("IQT data the following parameters are hardcoded "
f"satellite_actual_longitude = {actual_subsat_lon} ,"
f" satellite_actual_latitude = {actual_subsat_lat} ,"
f"satellite_sat_alt = {actual_sat_alt}")
else:
actual_subsat_lon = float(np.nanmean(self._get_aux_data_lut_vector("subsatellite_longitude")))
actual_subsat_lat = float(np.nanmean(self._get_aux_data_lut_vector("subsatellite_latitude")))
actual_sat_alt = float(np.nanmean(self._get_aux_data_lut_vector("platform_altitude")))
# The "try" is a temporary part of the code as long as the AF data are not modified
try :
nominal_and_proj_subsat_lon = float(
Expand Down Expand Up @@ -497,16 +519,6 @@
for coord in "xy":
coord_radian = self.get_and_cache_npxr(measured + "/{:s}".format(coord))

# TODO remove this check when old versions of IDPF test data (<v4) are deprecated.
if coord == "x" and coord_radian.attrs["scale_factor"] > 0:
coord_radian.attrs["scale_factor"] *= -1

# TODO remove this check when old versions of IDPF test data (<v5) are deprecated.
if type(coord_radian.attrs["scale_factor"]) is np.float32:
coord_radian.attrs["scale_factor"] = coord_radian.attrs["scale_factor"].astype("float64")
if type(coord_radian.attrs["add_offset"]) is np.float32:
coord_radian.attrs["add_offset"] = coord_radian.attrs["add_offset"].astype("float64")

coord_radian_num = coord_radian[:] * coord_radian.attrs["scale_factor"] + coord_radian.attrs["add_offset"]

# FCI defines pixels by centroids (see PUG), while pyresample
Expand Down Expand Up @@ -687,15 +699,8 @@
"cannot produce reflectance for {:s}.".format(measured))
return radiance * np.float32(np.nan)

sun_earth_distance = np.mean(
self.get_and_cache_npxr("state/celestial/earth_sun_distance")) / 149597870.7 # [AU]

# TODO remove this check when old versions of IDPF test data (<v5) are deprecated.
if sun_earth_distance < 0.9 or sun_earth_distance > 1.1:
logger.info("The variable state/celestial/earth_sun_distance contains unexpected values"
"(mean value is {} AU). Defaulting to 1 AU for reflectance calculation."
"".format(sun_earth_distance))
sun_earth_distance = 1
sun_earth_distance = np.nanmean(
self._get_aux_data_lut_vector("earth_sun_distance")) / 149597870.7 # [AU]

res = 100 * radiance * np.float32(np.pi) * np.float32(sun_earth_distance) ** np.float32(2) / cesi
return res
Expand Down
Loading