Skip to content

Regridding produces wrong chunktype for lazy masked arrays #5988

@bouweandela

Description

@bouweandela

🐛 Bug Report

Regridding sets the chunktype to numpy.ndarray when it should be numpy.MaskedArray. This can result in ignoring the mask when subsequently using iris.cube.Cube.rolling_window.

How To Reproduce

Steps to reproduce the behaviour:

import iris
import dask.array as da

global_air_temp = iris.load_cube(iris.sample_data_path('air_temp.pp'))
rotated_psl = iris.load_cube(iris.sample_data_path('rotated_pole.nc'))

global_air_temp.data = da.ma.masked_array(global_air_temp.core_data())
print(global_air_temp.core_data())
# prints dask.array<masked_array, shape=(73, 96), dtype=float32, chunksize=(73, 96), chunktype=numpy.MaskedArray>

rotated_air_temp = global_air_temp.regrid(rotated_psl, iris.analysis.Linear())
print(rotated_air_temp.core_data())
# prints dask.array<_regrid, shape=(22, 36), dtype=float32, chunksize=(22, 36), chunktype=numpy.ndarray>

Expected behaviour

I would expect the second print statement above to produce

dask.array<_regrid, shape=(22, 36), dtype=float32, chunksize=(22, 36), chunktype=numpy.MaskedArray>

Environment

  • OS & Version: Ubuntu 23.10
  • Iris Version: 3.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions