Skip to content

cf.Field.percentile sometimes produces a numpy UserWarning #619

@davidhassell

Description

@davidhassell

Some calls to cf.Field.percentile, whilst giving correct results, report a waning from numpy:

UserWarning: Warning: 'partition' will ignore the 'mask' of the MaskedArray.

This comes from np.percentile operating on a masked array that has no masked elements, and may be fixed by converting the array to a non-masked array in this case.

(See, e.g. https://stackoverflow.com/questions/45786763/median-filter-produces-unexpected-result-on-fits-file)

>>> import cf
>>> cf.environment(paths=False)
Platform: Linux-5.15.0-67-generic-x86_64-with-glibc2.35
HDF5 library: 1.12.1
netcdf library: 4.8.1
udunits2 library: /home/david/miniconda3/lib/libudunits2.so.0
ESMF: 8.2.0
Python: 3.10.9
dask: 2023.3.0
netCDF4: 1.6.0
psutil: 5.9.4
packaging: 23.0
numpy: 1.22.3
scipy: 1.8.1
matplotlib: 3.4.3
cftime: 1.6.2
cfunits: 3.3.5
cfplot: 3.1.31
cfdm: 1.10.0.3
cf: 3.14.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions