ks905383 / xagg

Aggregating gridded data (xarray) to polygons
https://xagg.readthedocs.io/
GNU General Public License v3.0
83 stars 15 forks source link

silent=True not suppressing messages #55

Closed helsharif closed 5 months ago

helsharif commented 10 months ago

Hello, In using pixel_overlaps and aggregate functions I include silent=True, but I still get the same messages printed to the screen whether I include that or not. I was expecting for there to be no output to screen.

helsharif commented 10 months ago

Hello, Below I'm adding a screenshot of the warning messages I get when running pixel_overlaps and aggregate even with silent=True

image

ks905383 commented 10 months ago

Yeah fair -

Looks like there are a few causes of that

  1. Use of .dims instead of .sizes (easy enough to fix)
  2. Not suppressing the print() calls
  3. That one xagg warning as well.

I'll see if I can fix that in the next version.

In the interim,

import warnings
with warnings.catch_warnings():
    warnings.filterwarnings('ignore')
    [xagg code here]

Should get rid of at least the warnings.

ks905383 commented 9 months ago

https://github.com/ks905383/xagg/pull/63#issuecomment-1954112998

One subfunction still doesn't have silent piped into it. This is through this line https://github.com/ks905383/xagg/blob/db8df95664c2ccceae4ad1f7dd5fb711af07bc38/xagg/core.py#L616, which should have silent=silent show up in the subset_find() call.

@helsharif can you confirm this is the only place where silent=True is still not producing the desired results?

helsharif commented 9 months ago

Hi, yes I confirm. It seems like the other warning messages have gone away with the latest version. The only messages I still see are: "adjusting grid... (this may happen because only a subset of pixels were used for aggregation for efficiency - i.e. [subset_bbox=True] in xa.pixel_overlaps())" and "grid adjustment successful"

ks905383 commented 6 months ago

@helsharif sorry for the delay - I think it should now be fixed in v0.3.2.1. You can also now set silent=True as a global option with

xa.set_options(silent=True).

Let me know if it doesn't work!

helsharif commented 5 months ago

Thanks! Yes it is working and the extra messages are suppressed. I just started a new project that involves a lot of use of xagg today, so this is a big help! Best regards. I think it is safe to close this thread.

helsharif commented 5 months ago

thanks!