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

Change sensor attribute to lowercase in FCI L2 NetCDF reader #3048

Merged
Merged
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
3 changes: 3 additions & 0 deletions doc/source/reading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,9 @@ time etc. The following attributes are standardized across all readers:
:class:`~pyresample.geometry.SwathDefinition` if data is geolocated. Areas are used for gridded
projected data and Swaths when data must be described by individual longitude/latitude
coordinates. See the Coordinates section below.
* ``sensor``: The name of the sensor that recorded the data. For full support through Satpy this
should be all lowercase. If the dataset is the result of observations from multiple sensors a
``set`` object can be used to specify more than one sensor name.
* ``reader``: The name of the Satpy reader that produced the dataset.
* ``orbital_parameters``: Dictionary of orbital parameters describing the satellite's position.
See the :ref:`orbital_parameters` section below for more information.
Expand Down
2 changes: 1 addition & 1 deletion satpy/readers/fci_l2_nc.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def spacecraft_name(self):
@property
def sensor_name(self):
"""Return instrument name."""
return self.nc.attrs["data_source"]
return self.nc.attrs["data_source"].lower()

@property
def ssp_lon(self):
Expand Down
36 changes: 18 additions & 18 deletions satpy/tests/reader_tests/test_fci_l2_nc.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def setUp(self):
nc.createDimension("maximum_number_of_layers", 2)

# add global attributes
nc.data_source = "test_data_source"
nc.platform = "test_platform"
nc.data_source = "TEST_DATA_SOURCE"
nc.platform = "TEST_PLATFORM"

# Add datasets
x = nc.createVariable("x", np.float32, dimensions=("number_of_columns",))
Expand Down Expand Up @@ -121,17 +121,17 @@ def tearDown(self):

def test_all_basic(self):
"""Test all basic functionalities."""
assert self.fh.spacecraft_name == "test_platform"
assert self.fh.spacecraft_name == "TEST_PLATFORM"
assert self.fh.sensor_name == "test_data_source"
assert self.fh.ssp_lon == 0.0

global_attributes = self.fh._get_global_attributes()
expected_global_attributes = {
"filename": self.test_file,
"spacecraft_name": "test_platform",
"spacecraft_name": "TEST_PLATFORM",
"ssp_lon": 0.0,
"sensor": "test_data_source",
"platform_name": "test_platform"
"platform_name": "TEST_PLATFORM"
}
assert global_attributes == expected_global_attributes

Expand Down Expand Up @@ -184,7 +184,7 @@ def test_dataset_with_layer(self):
"fill_value": -999,
"file_type": "test_file_type"})
np.testing.assert_allclose(dataset.values, 2 * np.ones((100, 10)))
assert dataset.attrs["spacecraft_name"] == "test_platform"
assert dataset.attrs["spacecraft_name"] == "TEST_PLATFORM"

def test_dataset_with_invalid_filekey(self):
"""Test the correct execution of the get_dataset function with an invalid nc_key."""
Expand Down Expand Up @@ -283,8 +283,8 @@ def setUp(self):
nc.createDimension("number_of_categories", 6)

# add global attributes
nc.data_source = "test_fci_data_source"
nc.platform = "test_fci_platform"
nc.data_source = "TEST_FCI_DATA_SOURCE"
nc.platform = "TEST_FCI_PLATFORM"

# Add datasets
x = nc.createVariable("x", np.float32, dimensions=("number_of_FoR_cols",))
Expand Down Expand Up @@ -326,18 +326,18 @@ def test_all_basic(self):
"""Test all basic functionalities."""
self.fh = FciL2NCSegmentFileHandler(filename=self.seg_test_file, filename_info={}, filetype_info={})

assert self.fh.spacecraft_name == "test_fci_platform"
assert self.fh.spacecraft_name == "TEST_FCI_PLATFORM"
assert self.fh.sensor_name == "test_fci_data_source"
assert self.fh.ssp_lon == 0.0

global_attributes = self.fh._get_global_attributes()

expected_global_attributes = {
"filename": self.seg_test_file,
"spacecraft_name": "test_fci_platform",
"spacecraft_name": "TEST_FCI_PLATFORM",
"ssp_lon": 0.0,
"sensor": "test_fci_data_source",
"platform_name": "test_fci_platform"
"platform_name": "TEST_FCI_PLATFORM"
}
assert global_attributes == expected_global_attributes

Expand Down Expand Up @@ -498,8 +498,8 @@ def setUp(self):
nc_byte.createDimension("number_of_rows", 1)

# add global attributes
nc_byte.data_source = "test_data_source"
nc_byte.platform = "test_platform"
nc_byte.data_source = "TEST_DATA_SOURCE"
nc_byte.platform = "TEST_PLATFORM"

# Add datasets
x = nc_byte.createVariable("x", np.float32, dimensions=("number_of_columns",))
Expand Down Expand Up @@ -571,8 +571,8 @@ def amv_file(tmp_path_factory):
nc.createDimension("number_of_winds", 50000)

# add global attributes
nc.data_source = "test_data_source"
nc.platform = "test_platform"
nc.data_source = "TEST_DATA_SOURCE"
nc.platform = "TEST_PLATFORM"

# Add datasets
latitude = nc.createVariable("latitude", np.float32, dimensions=("number_of_winds",))
Expand Down Expand Up @@ -612,16 +612,16 @@ class TestFciL2NCAMVFileHandler:

def test_all_basic(self, amv_filehandler, amv_file):
"""Test all basic functionalities."""
assert amv_filehandler.spacecraft_name == "test_platform"
assert amv_filehandler.spacecraft_name == "TEST_PLATFORM"
assert amv_filehandler.sensor_name == "test_data_source"
assert amv_filehandler.ssp_lon == 0.0

global_attributes = amv_filehandler._get_global_attributes(product_type="amv")
expected_global_attributes = {
"filename": amv_file,
"spacecraft_name": "test_platform",
"spacecraft_name": "TEST_PLATFORM",
"sensor": "test_data_source",
"platform_name": "test_platform",
"platform_name": "TEST_PLATFORM",
"channel": "test_channel",
"ssp_lon": 0.0,
}
Expand Down
Loading