pytroll / satpy

Python package for earth-observing satellite data processing
http://satpy.readthedocs.org/en/latest/
GNU General Public License v3.0
1.08k stars 298 forks source link

Fix default AWIPS tiled _FillValue of -1 for newer versions of xarray #2858

Closed djhoese closed 4 months ago

djhoese commented 4 months ago

Fixes compatibility with (currently unstable) xarray for the AWIPS tiled (awips_tiled) writer when using the default _Unsigned fill value of -1. Starting with

https://github.com/pydata/xarray/pull/9136

Xarray automatically converts the _FillValue to the proper dtype in a way that does not allow (or rather numpy does not allow) certain values to be automatically cast between types. In the case of this -1 it was trying to cast it directly to the unsigned type (give or take some bit depth differences) and failing. The -1 was just a convenience in the writer code anyway. I've added the necessary code to specify the fill value as the unsigned numpy type so that xarray can convert it when the file is saved.

djhoese commented 4 months ago

Merging this could wait a bit for the discussion in the xarray PR to settle to know if this is needed at all. Either way, the datetime change in this PR should be included.

codecov[bot] commented 4 months ago

Codecov Report

Attention: Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 95.95%. Comparing base (4011541) to head (b62f10b). Report is 454 commits behind head on main.

Files with missing lines Patch % Lines
satpy/writers/awips_tiled.py 66.66% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #2858 +/- ## ========================================== - Coverage 95.95% 95.95% -0.01% ========================================== Files 366 366 Lines 53619 53617 -2 ========================================== - Hits 51452 51448 -4 - Misses 2167 2169 +2 ``` | [Flag](https://app.codecov.io/gh/pytroll/satpy/pull/2858/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pytroll) | Coverage Δ | | |---|---|---| | [behaviourtests](https://app.codecov.io/gh/pytroll/satpy/pull/2858/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pytroll) | `4.04% <0.00%> (-0.01%)` | :arrow_down: | | [unittests](https://app.codecov.io/gh/pytroll/satpy/pull/2858/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pytroll) | `96.05% <66.66%> (-0.01%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pytroll#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

coveralls commented 4 months ago

Pull Request Test Coverage Report for Build 9979397064

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
satpy/writers/awips_tiled.py 2 3 66.67%
<!-- Total: 2 3 66.67% -->
Totals Coverage Status
Change from base Build 9973181832: 0.0%
Covered Lines: 51677
Relevant Lines: 53800

💛 - Coveralls
djhoese commented 4 months ago

Oh I should have made this a draft instead of just posting my previouscomment. I have an xarray PR that should make this unnecessary.

mraspaud commented 4 months ago

Ah, sorry, missed the comment...