opendatacube / odc-algo

Apache License 2.0
5 stars 1 forks source link

error while doing `to_rgba` #10

Open krishnaglodha opened 3 months ago

krishnaglodha commented 3 months ago

Im trying to generate rgba based on https://odc-stac.readthedocs.io/en/v0.2.1/notebooks/stac-load-S2-ms.html?highlight=to_rgba#Import-some-tools-from-odc.{algo,ui} , on last step when I'm trying to plot data

fig = one.plot.imshow(
    col_wrap=3, size=3, aspect=1, interpolation="bicubic"
)

I'm getting following error

FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.
  valid = np.ones(r.shape, dtype=np.bool)
2024-06-06 14:41:03,758 - distributed.worker - WARNING - Compute Failed
Key:       ('ro_rgba-getitem-3d06572d2318cfa62cf34a5c287be2e5', 0, 0, 0)
Function:  execute_task
args:      ((<function getitem at 0x10ec5dda0>, (subgraph_callable-50060dfb59da626c0ba2a1475506b301, None, (<class 'tuple'>, [1, 3000]), array([[[1748., 1748., 1748., 2012., 2012., 1875., 1875., 1875., 1594.,
         1594., 1661., 1661., 1661., 1903., 1903., 2019.,   nan],
        [1666., 1666., 1666., 2004., 2004., 1943., 1943., 1943., 1734.,
         1734., 1632., 1632., 1632., 1926., 1926., 2014.,   nan],
        [1666., 1666., 1666., 2004., 2004., 1943., 1943., 1943., 1734.,
         1734., 1632., 1632., 1632., 1926., 1926., 2014.,   nan],
        [1666., 1666., 1666., 2004., 2004., 1943., 1943., 1943., 1734.,
         1734., 1632., 1632., 1632., 1926., 1926., 2014.,   nan],
        [1648., 1648., 1648., 2040., 2040., 1746., 1746., 1746., 1554.,
         1554., 1791., 1791., 1791., 1894., 1894., 1626.,   nan],
        [1648., 1648., 1648., 2040., 2040., 1746., 1746., 1746., 1554.,
         1554., 1791., 1791., 1791., 1894., 1894., 1626.,   nan],
        [1544., 1544., 1544., 1930., 1930., 19
kwargs:    {}
Exception: 'AttributeError("module \'numpy\' has no attribute \'bool\'.\\n`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.\\nThe aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:\\n    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations")'
robbibt commented 3 months ago

Hey @krishnaglodha, can you please try the to_rgba() functionality from odc-geo instead? It's much more up to date; the function here will likely be deprecated. https://odc-geo.readthedocs.io/en/latest/_api/odc.geo.xr.to_rgba.html#odc.geo.xr.to_rgba

You can either use it directly via the func, or use the nifty .odc. functionality that's automatically added to your data when you import odc.geo.xr:

import odc.geo.xr

your_data.odc.to_rgba()
robbibt commented 3 months ago

Ah, actually - I think you might be using an old version of that documentation - it's different in the latest version: https://odc-stac.readthedocs.io/en/latest/notebooks/stac-load-S2-ms.html