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

Fix bucket resamplers trying to print non-existent name #1648

Merged
merged 2 commits into from May 18, 2021

Conversation

BENR0
Copy link
Collaborator

@BENR0 BENR0 commented Apr 22, 2021

This fixes bucket resampler AttributeError from log message in compute methods.

@codecov
Copy link

codecov bot commented Apr 22, 2021

Codecov Report

❗ No coverage uploaded for pull request base (main@cb3e197). Click here to learn what that means.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1648   +/-   ##
=======================================
  Coverage        ?   92.30%           
=======================================
  Files           ?      258           
  Lines           ?    38088           
  Branches        ?        0           
=======================================
  Hits            ?    35157           
  Misses          ?     2931           
  Partials        ?        0           
Flag Coverage Δ
behaviourtests 4.84% <0.00%> (?)
unittests 92.84% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
satpy/resample.py 80.24% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cb3e197...1619173. Read the comment docs.

@djhoese
Copy link
Member

djhoese commented Apr 22, 2021

Do you have an example piece of code that shows you running in to this error? As far as I can tell Satpy should always be passing a DataArray to .compute. 🤔 unless the resampler in pyresample does something different.

@BENR0
Copy link
Collaborator Author

BENR0 commented Apr 22, 2021

I just use scn.resample(area_def, resampler="bucket_avg"). In Line 1112 the np.array is extracted from the DataArray and then handed to the compute method of the resampler:

data_arr = data.data

At least for the bucket_avg resampler the bug was introduced in #1539 I think.

@djhoese
Copy link
Member

djhoese commented Apr 22, 2021

@pnuu do you know if the compute method is supposed to be expecting a dask array or a DataArray? The referenced pull request adds the log message by @ameraner but the DataArray -> dask change was there before.

@pnuu
Copy link
Member

pnuu commented May 12, 2021

According to the docstring resampler.get_average() expects to receive either dask or Numpy array. I think @BENR0 is correct and the resamplers are always passed a plain dask array.

@djhoese
Copy link
Member

djhoese commented May 12, 2021

Ok so dask arrays should have a .name if I remember correctly, but I don't think it is useful as it is usually based on the last task in the dask graph and includes a generated UUID most of the time (not super human-readable). If we are trying to get the name of the DataArray then we should really be doing data_arr.attrs['name']...but if we are trying to print out the DataArray's identifier then we should really be printing out its DataID. @mraspaud is the proper way to get the DataID for a DataArray to check for .attrs['_satpy_id']?

@mraspaud
Copy link
Member

Yes

satpy/resample.py Outdated Show resolved Hide resolved
@djhoese djhoese changed the title fix: data has no name attribute error in resampler compute Fix bucket resamplers trying to print non-existent name May 18, 2021
@djhoese djhoese self-assigned this May 18, 2021
@djhoese djhoese merged commit 378a2c5 into pytroll:main May 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bucket resamplers AttributeError in logging message
4 participants