Skip to content

Cube.collapsed() should produce an un-masked Cube if the original is un-masked #5314

Open
@trexfeathers

Description

@trexfeathers

✨ Feature Request

Motivation

For consistency with Cube.aggregated_by(). Many aggregators return masked arrays regardless of the input array, and we do not want to unnecessarily propagate masks where they are not needed. Users that genuinely want masked arrays can do so by making sure the Cube is masked before collapsing. Detailed discussion here: #4970 (comment)

Additional context

Click to expand this section...

Relevant lines in Cube.aggregated_by():

iris/lib/iris/cube.py

Lines 4235 to 4239 in c0153ae

# Ensure plain ndarray is output if plain ndarray was input.
if ma.isMaskedArray(aggregateby_data) and not ma.isMaskedArray(
input_data
):
aggregateby_data = ma.getdata(aggregateby_data)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions