Closed allibco closed 3 years ago
cf_xarray
can do this if the appropriate cell_measures
attribute is set: e.g.: https://cf-xarray.readthedocs.io/en/latest/examples/introduction.html#Feature:-Weight-by-Cell-Measures
ds.cf.weighted("area").mean()
@dcherian Thanks for letting us know - this might make things a lot easier :)
For pop, the weights are here: double TAREA(nlat, nlon) ;
For cam fv, they are here: double gw(lat) ; gw:long_name = "gauss weights" ; double hyai(ilev) ;
For CAM, FV we are just weighting the latitude:
#weights are for lat a_lat = np.average(data,axis=0, weights=weight) a = np.average(a_lat) return a