jgrss / geowombat

GeoWombat: Utilities for geospatial data
https://geowombat.readthedocs.io
MIT License
182 stars 10 forks source link

gw.open bug?? #271

Closed mmann1123 closed 9 months ago

mmann1123 commented 1 year ago

I just noticed some odd behavior with a large list of images:

files = sorted(glob("./data/**/annual_features/**/**.tif"))
band_names = [os.path.basename(f).split(".")[0] for f in files]
with gw.open(
    files[0], stack_dim="band", band_names=["B11__abs_energy__mar_aug_2023"]
) as src:
    display(src.sel(band="B11__abs_energy__mar_aug_2023").values)
array([[1.67773550e+14, 1.61079000e+14, 1.58792825e+14, ...,
        0.00000000e+00, 0.00000000e+00, 0.00000000e+00],
       [1.66920525e+14, 1.61026500e+14, 1.55651125e+14, ...,
        4.86036503e+12, 4.73214950e+12, 4.49955339e+12],
       [1.65927025e+14, 1.63141325e+14, 1.57437950e+14, ...,
        4.70524968e+12, 4.64354268e+12, 4.72971472e+12],
       ...,
       [1.84472915e+15, 1.63278968e+15, 1.65995495e+15, ...,
        9.28195000e+14, 0.00000000e+00, 0.00000000e+00],
       [1.96579332e+15, 1.74856515e+15, 1.57986068e+15, ...,
        1.17136742e+15, 0.00000000e+00, 0.00000000e+00],
       [0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ...,
        1.59239900e+15, 0.00000000e+00, 0.00000000e+00]])

Same image but as part of a stack:

with gw.open(
    files,
    stack_dim="band",
    band_names=band_names,
) as src:
    display(src.sel(band="B11__abs_energy__mar_aug_2023").values)
array([[          nan, 0.0000000e+00,           nan, ...,           nan,
                  nan, 0.0000000e+00],
       [          nan,           nan,           nan, ...,           nan,
                  nan,           nan],
       [          nan,           nan,           nan, ...,           nan,
                  nan,           nan],
       ...,
       [          nan,           nan,           nan, ...,           nan,
                  nan,           nan],
       [          nan, 1.6777355e+14,           nan, ...,           nan,
                  nan, 0.0000000e+00],
       [          nan,           nan,           nan, ...,           nan,
                  nan,           nan]])
mmann1123 commented 1 year ago

Interestingly not a problem with:

from geowombat.data import l8_224078_20200518

with gw.open([l8_224078_20200518]) as src:
    display(src[0].values)

with gw.open(
    [l8_224078_20200518]*800,
    stack_dim="band",
  ) as src:
    display(src[0].values)
mmann1123 commented 1 year ago

Issue was bands had different resolutions, should we throw an error in this case?

Resolved with:

with gw.config.update(ref_image=files[-1]):
jgrss commented 1 year ago

I would have expected xarray to throw an error. By different resolutions, you mean the image had different row/column dimensions and still got stacked (albeit incorrectly)?

mmann1123 commented 1 year ago

yep different row/col without an error.

On Tue, Jun 6, 2023 at 5:01 PM Jordan Graesser @.***> wrote:

I would have expected xarray to throw an error. By different resolutions, you mean the image had different row/column dimensions and still got stacked (albeit incorrectly)?

— Reply to this email directly, view it on GitHub https://github.com/jgrss/geowombat/issues/271#issuecomment-1579445646, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABHR6VFCP5E47LBIEYUEYF3XJ6LBDANCNFSM6AAAAAAY4XUN3I . You are receiving this because you authored the thread.Message ID: @.***>

jgrss commented 1 year ago

Can you share some of those images so that I can test the errors we should check for?