-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
gridding data with groupby_bins in 2 dim #2488
Comments
I wrote a work around for my purpose but I guess I could still be faster ... |
%%time
#geop_mean = geop1.groupby_bins('lon', lon_bin, labels=lon_cent).apply(group_lat) group into lat boxesl = 0 for x in list(geop_mean.keys()): Now the data is sorted into boxes and still contains all metadataNow get the mean values for each boxl = 0 gp = xr.Dataset({'geopot': (['lat','lon'], for k in range(d.shape[0]): |
I am open for suggestions to get the code running faster :D |
In order to maintain a list of currently relevant issues, we mark issues as stale after a period of inactivity If this issue remains relevant, please comment here or remove the |
This will be addressed as part of multi-variable groupby. |
Dear everybody,
I am just starting to get to know the xarray datastructures and python so I am really still a beginner.
I am working with scattered data wich need to be brought to a regular grid.
Now i found your function groupby_bins which only works in one dimension - on github
I couldn't find anything to wether grouping in 2d is now possible or not.
It would be very helpful to get some more info about that.
Here is just a code example with a small data set:
geop1 =
<xarray.Dataset>
Dimensions: (pos_compl: 44229)
Coordinates:
lon (pos_compl) float64 -29.8 -31.14 -32.65 ... -25.26 -16.4 -43.75
lat (pos_compl) float64 46.48 46.07 45.66 46.18 ... 45.34 61.06 53.19
z (pos_compl) float64 -3.205e+03 -3.197e+03 ... -3.758e+03
time (pos_compl) float64 7.299e+05 7.299e+05 ... 7.367e+05 7.367e+05
Data variables:
geopot (pos_compl) float64 9.363 7.93 8.218 8.621 ... 10.44 4.293 0.4243
---- groupby bins
---- 0.25
lat_bin = np.arange(mat4['lat_range'][0,0]-0.25/2,mat4['lat_range'][0,1]+0.25,0.25)
----0.5
lon_bin = np.arange(mat4['lon_range'][0,0]-0.5/2,mat4['lon_range'][0,1]+0.5,0.5)
----define bin center
---- 0.25
lat_cent = np.arange(mat4['lat_range'][0,0],mat4['lat_range'][0,1]+0.25,0.25)
-0.5
lon_cent = np.arange(mat4['lon_range'][0,0],mat4['lon_range'][0,1]+0.5,0.5)
---- Now only these two options are possible
geop_mean_lon = geop1.geopot.groupby_bins('lon', lon_bin, labels=lon_cent)
geop_mean_lat = geop1.geopot.groupby_bins('lat', lat_bin, labels=lat_cent)
It would be really nice to have all the information in each grid box - Or is there some other way gridding like this on big datasets is recommended?
Thank you for your help!
The text was updated successfully, but these errors were encountered: