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

nwcsaf-geo reader turns uint8 into int64 on numpy 2.0 #2872

Closed
gerritholl opened this issue Aug 6, 2024 · 0 comments · Fixed by #2874
Closed

nwcsaf-geo reader turns uint8 into int64 on numpy 2.0 #2872

gerritholl opened this issue Aug 6, 2024 · 0 comments · Fixed by #2874

Comments

@gerritholl
Copy link
Collaborator

gerritholl commented Aug 6, 2024

Describe the bug

When using numpy 2.0, the nwcsaf-geo reader turns data of type uint8 into int64. This wastes memory and leads to other problems downstream.

To Reproduce

from satpy import Scene
from satpy.utils import debug_on; debug_on()
fn = "/media/nas/x21308/scratch/NWCSAF/202302010730/S_NWC_CT_MSG4_MSG-N-VISIR_20230201T073000Z.nc"
sc = Scene(filenames=[fn], reader=["nwcsaf-geo"])
sc.available_dataset_names()
sc.load(["ct", "ct_pal"])
print(sc["ct"].dtype, sc["ct_pal"].dtype)

Expected behavior

I expect those to be uint8, like in the original data:

$ ncdump -h /media/nas/x21308/scratch/NWCSAF/202302010730/S_NWC_CT_MSG4_MSG-N-VISIR_20230201T073000Z.nc | grep 'ct\('
        ubyte ct(ny, nx) ;

Actual results

[DEBUG: 2024-08-06 14:23:14 : satpy.readers.yaml_reader] Reading ('/data/gholl/checkouts/satpy/satpy/etc/readers/nwcsaf-geo.yaml',)
[DEBUG: 2024-08-06 14:23:14 : satpy.readers.yaml_reader] Assigning to nwcsaf-geo: ['/media/nas/x21308/scratch/NWCSAF/202302010730/S_NWC_CT_MSG4_MSG-N-VISIR_20230201T073000Z.nc']
[DEBUG: 2024-08-06 14:23:14 : satpy.composites.config_loader] Looking for composites config file seviri.yaml
[DEBUG: 2024-08-06 14:23:14 : pyorbital.tlefile] Path to the Pyorbital configuration (where e.g. platforms.txt is found): /data/gholl/mambaforge/envs/py312/lib/python3.12/site-packages/pyorbital/etc
[DEBUG: 2024-08-06 14:23:14 : satpy.composites.config_loader] Looking for composites config file visir.yaml
[DEBUG: 2024-08-06 14:23:14 : satpy.readers.nwcsaf_nc] Reading ct_pal.
[DEBUG: 2024-08-06 14:23:14 : h5py._conv] Creating converter from 7 to 5
[DEBUG: 2024-08-06 14:23:14 : h5py._conv] Creating converter from 5 to 7
[DEBUG: 2024-08-06 14:23:14 : h5py._conv] Creating converter from 7 to 5
[DEBUG: 2024-08-06 14:23:14 : h5py._conv] Creating converter from 5 to 7
[DEBUG: 2024-08-06 14:23:14 : satpy.readers.yaml_reader] No coordinates found for DataID(name='ct_pal', resolution=3000, modifiers=())
[DEBUG: 2024-08-06 14:23:14 : satpy.readers.nwcsaf_nc] Reading ct.
[DEBUG: 2024-08-06 14:23:14 : satpy.readers.nwcsaf_nc] Reading ct_quality.
[DEBUG: 2024-08-06 14:23:14 : satpy.readers.nwcsaf_nc] Reading ct_conditions.
[DEBUG: 2024-08-06 14:23:14 : satpy.readers.nwcsaf_nc] Reading ct_status_flag.
int64 int64

Environment Info:

  • OS: openSUSE Leap 15.3
  • Satpy Version: v0.50.0-38-g6f475f199
  • Numpy version: 2.0

Additional context

Found this while working on #2870. In trollimage, the colormap is scaled unless data are of dtype uint8, so the change of dtype results in a faulty colormap for categorical data (such as cloud type).

This problem exists only with Numy 2.0. Downgrading to numpy 1.24.4 eliminates the problem.

gerritholl added a commit to gerritholl/satpy that referenced this issue Aug 6, 2024
Added a test to make sure that cloud type (or others) are not
accidentally transformed to an inflated dtype.

This currently fails with numpy 2.0; see
pytroll#2872
@gerritholl gerritholl self-assigned this Aug 6, 2024
@gerritholl gerritholl changed the title nwcsaf-geo reader turns uint8 into int64 on numpy 2.0 nwcsaf-geo reader turns uint8 into int64 on numpy 2.0; all images black Aug 7, 2024
@gerritholl gerritholl changed the title nwcsaf-geo reader turns uint8 into int64 on numpy 2.0; all images black nwcsaf-geo reader turns uint8 into int64 on numpy 2.0 Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant