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

fix: li missing platform name #2993

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Changes from 7 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
13 changes: 13 additions & 0 deletions satpy/readers/fci_base.py
Original file line number Diff line number Diff line change
@@ -18,6 +18,19 @@
"""Common functionality for FCI data readers."""
from __future__ import annotations

# Platform names according to the MTG FCI L1 Product User Guide,
# EUM/MTG/USR/13/719113 from 2019-06-27, pages 32 and 124, are MTI1, MTI2,
# MTI3, and MTI4, but we want to use names such as described in WMO OSCAR
# MTG-I1, MTG-I2, MTG-I3, and MTG-I4.
#
# Not sure how the numbering will be considering MTG-S1 and MTG-S2 will be launched
# in-between.
platform_name_translate = {
"MTI1": "Meteosat-12",
"MTI2": "MTG-I2",
"MTI3": "MTG-I3",
"MTI4": "MTG-I4"}


def calculate_area_extent(area_dict):
"""Calculate the area extent seen by MTG FCI instrument.
18 changes: 2 additions & 16 deletions satpy/readers/fci_l1c_nc.py
Original file line number Diff line number Diff line change
@@ -129,6 +129,7 @@

from satpy.readers._geos_area import get_geos_area_naming
from satpy.readers.eum_base import get_service_mode
from satpy.readers.fci_base import platform_name_translate

from .netcdf_utils import NetCDF4FsspecFileHandler

@@ -193,21 +194,6 @@ class using the :mod:`~satpy.Scene.load` method with the reader
``"fci_l1c_nc"``.

"""

# Platform names according to the MTG FCI L1 Product User Guide,
# EUM/MTG/USR/13/719113 from 2019-06-27, pages 32 and 124, are MTI1, MTI2,
# MTI3, and MTI4, but we want to use names such as described in WMO OSCAR
# MTG-I1, MTG-I2, MTG-I3, and MTG-I4.
#
# After launch: translate to METEOSAT-xx instead? Not sure how the
# numbering will be considering MTG-S1 and MTG-S2 will be launched
# in-between.
_platform_name_translate = {
"MTI1": "MTG-I1",
"MTI2": "MTG-I2",
"MTI3": "MTG-I3",
"MTI4": "MTG-I4"}

def __init__(self, filename, filename_info, filetype_info):
"""Initialize file handler."""
super().__init__(filename, filename_info,
@@ -391,7 +377,7 @@ def _get_dataset_measurand(self, key, info=None):
res.attrs.update(info)
res.attrs.update(attrs)

res.attrs["platform_name"] = self._platform_name_translate.get(
res.attrs["platform_name"] = platform_name_translate.get(
self["attr/platform"], self["attr/platform"])

# remove unpacking parameters for calibrated data
5 changes: 3 additions & 2 deletions satpy/readers/fci_l2_nc.py
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@
from satpy._compat import cached_property
from satpy.readers._geos_area import get_geos_area_naming, make_ext
from satpy.readers.eum_base import get_service_mode
from satpy.readers.fci_base import platform_name_translate
from satpy.readers.file_handlers import BaseFileHandler
from satpy.resample import get_area_def
from satpy.utils import get_legacy_chunk_size
@@ -74,10 +75,10 @@ def _get_global_attributes(self):
"""
attributes = {
"filename": self.filename,
"spacecraft_name": self.spacecraft_name,
"spacecraft_name": platform_name_translate.get(self.spacecraft_name, self.spacecraft_name),
"ssp_lon": self.ssp_lon,
"sensor": self.sensor_name,
"platform_name": self.spacecraft_name,
"platform_name": platform_name_translate.get(self.spacecraft_name, self.spacecraft_name)
}
return attributes

4 changes: 4 additions & 0 deletions satpy/readers/li_base_nc.py
Original file line number Diff line number Diff line change
@@ -191,6 +191,7 @@
import xarray as xr
from pyproj import Proj

from satpy.readers.fci_l1c_nc import _platform_name_translate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're now using this across modules, should we remove the _ prefix?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my view yes. But will wait for other feedback.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without viewing the rest of this PR, I agree that something imported across modules should not have the _ prefix.

from satpy.readers.netcdf_utils import NetCDF4FsspecFileHandler

logger = logging.getLogger(__name__)
@@ -516,10 +517,13 @@ def register_dataset(self, var_name, oc_name=None):

ds_name = var_name if oc_name is None else f"{var_name}_{oc_name}_sector"

platform = self.filename_info["mission_prefix"] + "I" + self.filename_info["spacecraft_id"]

ds_info = {
"name": ds_name,
"variable_name": var_name,
"sensor": "li",
"platform_name": _platform_name_translate[platform],
"file_type": self.filetype_info["file_type"]
}

2 changes: 1 addition & 1 deletion satpy/tests/reader_tests/test_fci_l1c_nc.py
Original file line number Diff line number Diff line change
@@ -1027,7 +1027,7 @@ def test_platform_name(self, reader_configs, fh_param):
"""
reader = _get_reader_with_filehandlers(fh_param["filenames"], reader_configs)
res = reader.load(["vis_06"], pad_data=False)
assert res["vis_06"].attrs["platform_name"] == "MTG-I1"
assert res["vis_06"].attrs["platform_name"] == "Meteosat-12"

@pytest.mark.parametrize(("fh_param", "compare_tuples"),
[(lazy_fixture("FakeFCIFileHandlerFDHSI_fixture"), (67, 10,
Loading