Skip to content
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 statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gw.open bug?? #271

Closed
mmann1123 opened this issue Jun 6, 2023 · 5 comments
Closed

gw.open bug?? #271

mmann1123 opened this issue Jun 6, 2023 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@mmann1123
Copy link
Collaborator

mmann1123 commented Jun 6, 2023

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 mmann1123 added the bug Something isn't working label Jun 6, 2023
@mmann1123
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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

Resolved with:

with gw.config.update(ref_image=files[-1]):

@mmann1123 mmann1123 added enhancement New feature or request and removed bug Something isn't working labels Jun 6, 2023
@jgrss
Copy link
Owner

jgrss commented Jun 6, 2023

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
Copy link
Collaborator Author

mmann1123 commented Jun 7, 2023 via email

@jgrss
Copy link
Owner

jgrss commented Jul 1, 2023

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

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

No branches or pull requests

2 participants