ks905383 / xagg

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

Warning in `xa.aggregate()` #57

Closed ks905383 closed 9 months ago

ks905383 commented 10 months ago

During the aggregated = xa.aggregate(ds_tas, weightmap) step, I am getting the following repeated warning:

RuntimeWarning: invalid value encountered in divide a2 = a2/a2.sum()

Originally posted by @kls2177 in https://github.com/atrisovic/weather-panel.github.io/issues/79#issuecomment-1917866333

ks905383 commented 10 months ago

This is in xa.aux.normalize(); probably because a fully empty (or entirely 0) time series is provided?

Todo: [ ] Check whether this is due to something else breaking [ ] Possibly suppress using something like: if not np.all(np.isnan(a)):

ks905383 commented 10 months ago

@kls2177 thanks for that clarification!

Could you move the issue with the map over to the JOSE review? This repo is for xagg, the code package used in one of the examples.

ks905383 commented 9 months ago

Turns out this only shows up when additional weights are used. It's possible for all weights pixels for a given polygon to = 0 in a location; in this case normalize throws a divide by 0 warning, because the sum of the weights to be normalize = 0. The workaround is for normalize to just return the input vector if all the inputs are 0 or nan.

ks905383 commented 9 months ago

Fixed and implemented in v0.3.2.0