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 fill value removal for non-integer FCI data #3060

Open
wants to merge 2 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/readers/fci_l1c_nc.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def _get_dataset_measurand(self, key, info=None):
data = _ensure_dataarray(data)

fv = attrs.pop(
"FillValue",
"_FillValue",
default_fillvals.get(data.dtype.str[1:], np.float32(np.nan)))
vr = attrs.get("valid_range", [np.float32(-np.inf), np.float32(np.inf)])
if key["calibration"] == "counts":
Expand Down
19 changes: 18 additions & 1 deletion satpy/tests/reader_tests/test_fci_l1c_nc.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ def _get_test_image_data_for_channel(data, ch_str, n_rows_cols):
"add_offset": -10,
"long_name": "Effective Radiance",
"units": "mW.m-2.sr-1.(cm-1)-1",
"ancillary_variables": "pixel_quality"
"ancillary_variables": "pixel_quality",
"_FillValue": 65535
}
if "38" in ch_path:
fire_line = da.ones((1, n_rows_cols[1]), dtype="uint16", chunks=1024) * 5000
Expand Down Expand Up @@ -890,6 +891,22 @@ def test_load_calibration_negative_rad(self, reader_configs, fh_param):
numpy.testing.assert_array_equal(res2["ir_38"][-1, :], 5) # smallest positive radiance
assert res["ir_38"].dtype == res2["ir_38"].dtype == np.dtype("float32")

@pytest.mark.parametrize("fh_param", [lazy_fixture("FakeFCIFileHandlerFDHSI_fixture")])
def test_drop_fill_value(self, reader_configs, fh_param):
"""Test that _FillValue attribute is dropped for floats.

See https://github.com/pytroll/satpy/issues/3058.
"""
reader = _get_reader_with_filehandlers(fh_param["filenames"], reader_configs)
did = make_dataid(name="ir_105", calibration="brightness_temperature")
res = reader.load([did], pad_data=False)
assert "_FillValue" not in res["ir_105"].attrs

# but for counts it should still be there
did = make_dataid(name="ir_105", calibration="counts")
res = reader.load([did], pad_data=False)
assert "_FillValue" in res["ir_105"].attrs

@pytest.mark.parametrize(("calibration", "channel", "resolution"), [
(calibration, channel, resolution)
for calibration in ["counts", "radiance", "brightness_temperature", "reflectance"]
Expand Down
Loading