USGS-R / drb_gridmet_tools

Repository with functions to aggregate raster data from pixel grid to hru polygon grid. This repository heavily relies on grd2shp_xagg library.
Other
3 stars 2 forks source link

Processing time for `np.agg()` long #10

Closed msleckman closed 2 years ago

msleckman commented 2 years ago

Processing time for running group by on gridmet data, already converted to xarray ds is very long when using np.agg() such as:

gridmet_drb_gdf..groupby(['PRMS_segid',"time"]).agg(
    area = ("hru_area_m2", "sum"),
    pr = ("pr", 'sum'),
    tmmx = ("tmmx", area_weighted_avg),
    tmmn = ("tmmn", area_weighted_avg),
    srad = ('srad', area_weighted_avg),
    vs = ('vs', area_weighted_avg),
    rmax = ('rmax',area_weighted_avg),
    rmin = ('rmin', area_weighted_avg),
    sph = ('sph',  area_weighted_avg)
)
msleckman commented 2 years ago

Fixed by splitting the agg steps in a function gridmet_prms_area_avg_agg(). Found in new pushed file gridmet_aggregation_PRMS.py