Skip to content

Commit

Permalink
remove scale_factor and add_offset
Browse files Browse the repository at this point in the history
  • Loading branch information
zxdawn committed Jan 2, 2025
1 parent 9f9dbda commit 45f7774
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
4 changes: 2 additions & 2 deletions satpy/readers/viirs_l1b.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ def get_dataset(self, dataset_id, ds_info):
data += factors[1]

# update scale_factor and scale_offset
data.attrs["scale_factor"] = factors[0]
data.attrs["add_offset"] = factors[1]
data.attrs.pop("scale_factor", None)
data.attrs.pop("add_offset", None)

# rename dimensions to correspond to satpy's 'y' and 'x' standard
if "number_of_lines" in data.dims:
Expand Down
13 changes: 3 additions & 10 deletions satpy/tests/reader_tests/test_viirs_l1b.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def test_load_dnb_angles(self):
assert v.attrs["sensor"] == "viirs"

def test_scale_factor_and_offset_update(self):
"""Test if scale_factor and add_offset are updated correctly."""
"""Test if scale_factor and add_offset are removed correctly."""
from satpy.readers import load_reader
from satpy.tests.utils import make_dataid
r = load_reader(self.reader_configs)
Expand All @@ -356,15 +356,8 @@ def test_scale_factor_and_offset_update(self):
make_dataid(name="I04", calibration="radiance"),
])
for v in datasets.values():
if v.attrs["units"] == "%":
assert int(v.attrs["scale_factor"]) == 110
assert int(v.attrs["add_offset"]) == 10
elif v.attrs["units"] == "K":
assert v.attrs["scale_factor"] == 1
assert v.attrs["add_offset"] == 0
elif v.attrs["calibration"] == "radiance" and v.attrs["units"] == "W m-2 um-1 sr-1":
assert v.attrs["scale_factor"] == 1.1
assert v.attrs["add_offset"] == 0.1
assert ('scale_factor' not in v.attrs)
assert ('add_offset' not in v.attrs)


class TestVIIRSL1BReaderDayNight(TestVIIRSL1BReaderDay):
Expand Down

0 comments on commit 45f7774

Please sign in to comment.