Skip to content

Commit

Permalink
Merge pull request #2923 from pnuu/bugfix-generic_image-float64
Browse files Browse the repository at this point in the history
Fix data promotion in `generic_image` reader and `satpy.composites.add_bands`
  • Loading branch information
mraspaud authored Oct 14, 2024
2 parents 2d7f5ed + b8991c0 commit b02fd62
Show file tree
Hide file tree
Showing 4 changed files with 304 additions and 264 deletions.
1 change: 1 addition & 0 deletions satpy/composites/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,7 @@ def add_bands(data, bands):
alpha = new_data[0].copy()
alpha.data = da.ones((data.sizes["y"],
data.sizes["x"]),
dtype=new_data[0].dtype,
chunks=new_data[0].chunks)
# Rename band to indicate it's alpha
alpha["bands"] = "A"
Expand Down
2 changes: 1 addition & 1 deletion satpy/readers/generic_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def _mask_image_data(data, info):
if not np.issubdtype(data.dtype, np.integer):
raise ValueError("Only integer datatypes can be used as a mask.")
mask = data.data[-1, :, :] == np.iinfo(data.dtype).min
data = data.astype(np.float64)
data = data.astype(np.float32)
masked_data = da.stack([da.where(mask, np.nan, data.data[i, :, :])
for i in range(data.shape[0])])
data.data = masked_data
Expand Down
Loading

0 comments on commit b02fd62

Please sign in to comment.