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

Update scale factor and offset [viirs_l1b] #3016

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

zxdawn
Copy link
Member

@zxdawn zxdawn commented Dec 13, 2024

The scale factor and offset should be updated for BT data. The easiest way seems to be updating these parameters using the factor output.

@zxdawn zxdawn requested a review from djhoese as a code owner December 13, 2024 19:57
@zxdawn zxdawn changed the title Update scale factor and offset [viird_l1b] Update scale factor and offset [viirs_l1b] Dec 13, 2024
Copy link

codecov bot commented Dec 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.07%. Comparing base (5984c29) to head (dd11b1e).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3016      +/-   ##
==========================================
- Coverage   96.10%   96.07%   -0.03%     
==========================================
  Files         377      377              
  Lines       55163    55175      +12     
==========================================
- Hits        53012    53011       -1     
- Misses       2151     2164      +13     
Flag Coverage Δ
behaviourtests 3.93% <0.00%> (-0.01%) ⬇️
unittests 96.17% <100.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

satpy/readers/viirs_l1b.py Outdated Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Dec 13, 2024

Pull Request Test Coverage Report for Build 12583702887

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 12 of 12 (100.0%) changed or added relevant lines in 2 files are covered.
  • 8 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.01%) to 96.193%

Files with Coverage Reduction New Missed Lines %
satpy/tests/utils.py 2 93.16%
satpy/tests/reader_tests/gms/test_gms5_vissr_l1b.py 3 98.67%
satpy/tests/reader_tests/gms/test_gms5_vissr_navigation.py 3 97.18%
Totals Coverage Status
Change from base Build 12299617024: -0.01%
Covered Lines: 53260
Relevant Lines: 55368

💛 - Coveralls

@zxdawn zxdawn requested a review from mraspaud as a code owner December 14, 2024 18:30
@djhoese
Copy link
Member

djhoese commented Dec 16, 2024

I think I'm OK merging this, but I just realized that typically I advise things like _FillValue and scale_factor/add_offset to be removed in readers because they are misleading or confusing in later parts of Satpy processing. For example, the factor/offset here are likely for 16-bit integers right? But we don't know if that is signed or unsigned. Or it could be for 8-bit or 32-bit integers, we don't know. Or someone could want to save to a NetCDF 8-bit integer and use these factors and offsets and get incompatible scaled values (out of range).

Additionally, these are being added to ".attrs". Should they maybe be put in .encoding?

@zxdawn
Copy link
Member Author

zxdawn commented Jan 2, 2025

Thanks for the idea! I see the factors are applied for all variables:

        factors = (scale_factor, scale_offset)
        factors = self.adjust_scaling_factors(factors, metadata["file_units"], ds_info.get("units"))
        if factors[0] != 1 or factors[1] != 0:
            data *= factors[0]
            data += factors[1]

The easiest way may be removing these not-updated attrs (if they exist):

        # remove scale_factor and scale_offset
        data.attrs.pop("scale_factor", None)
        data.attrs.pop("add_offset", None)

@djhoese
Copy link
Member

djhoese commented Jan 3, 2025

I think that makes sense to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants