Skip to content

Single precision latitude/longitude dimensions can cause problems in statevector builds that include a spatial mean #242

Description

@kanchukaitis

When trying to create a statevector build from both spatial data (e.g. a spatial field with lat and lon) and a pre-computed mean value (e.g. a cosine-weighted Hemisphere mean), the presence of single precision data classes in the latitude and longitude in the metadata can cause an error in cell2mat when calling statevector.build.

This appears to be because dimensionless dimensions (e.g. 0x0 or []) are double class - prior to R2025a (when cell2mat became more forgiving), sv.build will fail with a 'All contents of the input cell array must be of the same data type' error from cell2mat.

The fix is to cast the coordinates or latWeights to double before passing to weightedMean for safety:

latWeights = double(cosd(meta.lat(extratropical)));

or do this in weightedMean.m itself:

obj.weights{d} = double(weights{k}(:))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions