8000 DeprecationWarning: NumPy will stop allowing conversion of out-of-bound Python integers to integer arrays · Issue #293 · sot/mica · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

DeprecationWarning: NumPy will stop allowing conversion of out-of-bound Python integers to integer arrays #293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy stateme 8000 nt. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
javierggt opened this issue Feb 14, 2024 · 1 comment · Fixed by #297
Labels

Comments

@javierggt
Copy link
Contributor

The following code:

import warnings
warnings.simplefilter("always")
from mica.archive import aca_l0
imgs = aca_l0.get_l0_images(467055635, 467055639, slot=7)

Produces this warning

/Users/javierg/SAO/miniconda3/envs/ska3-flight-2024.0rc8/lib/python3.11/site-packages/numpy/ma/core.py:429: DeprecationWarning: NumPy will stop allowing conversion of out-of-bound Python integers to integer arrays.  The conversion of -9999 to uint8 will fail in the future.

The exact point where this happens is https://github.com/sot/mica/blob/4.35.0/mica/archive/aca_l0.py#L237:

dat = dat.filled(-9999)

where data is an arbitrary array, but in the specific call that causes the warning during testing the type is

dtype([('TIME', '>f8'), ('QUALITY', '>i4'), ('INTEG', '>f4'), ('IMGFUNC1', 'u1'), ('IMGSTAT', 'u1'), ('IMGSCALE', '>i2'), ('BGDAVG', '>i2'), ('IMGRAW', '>f4', (64,)), ('IMGSIZE', '>i4')])
@taldcroft
Copy link
Member
taldcroft commented Feb 18, 2024

I think something like this will work?

    # Masked array col access ~100 times slower than ndarray so convert
    dat_new = np.empty(dat.shape, dtype=dat.dtype)
    for name in dat.dtype.names:
        # Fill uint8 or int8 with 127 and others with -9999. All columns are numeric.
        dat_new[name] = dat[name].filled(127 if dat[name].itemsize == 1 else -9999)
    dat = dat_new

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0