Skip to content
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

How to reimplement grid coarsening and statistics-in-boxes in oocgcm ? #25

Open
lesommer opened this issue May 24, 2016 · 7 comments
Open
Labels

Comments

@lesommer
Copy link
Owner

The functionnality available in GriddedData.py for coarsening a 2d field or reorganizing an array for building statistics out from values in a box would be a neat feature for oocgcm. But the current method works only for 2d numpy array. how to proceed ?

@lesommer
Copy link
Owner Author

would xarray future multidimensional groupby operator be useful for this ?

@lesommer
Copy link
Owner Author

would cab-lab be useful for this ?

@lesommer lesommer changed the title How to reimplement grid coarsening and box statistics in oocgcm ? How to reimplement grid coarsening and statistics-in-boxes in oocgcm ? May 24, 2016
@rabernat
Copy link

would xarray future multidimensional groupby operator be useful for this ?

Definitely could be done, but if your coarse graining is very regular (i.e. coarsen the grid by a specific factor, e.g. x2, x4, etc.) there is a faster implementation

In this gist, I have an implementation of coarse-graining using dask's map_blocks
https://gist.github.com/rabernat/10029776541cfe018905

@rabernat
Copy link

Here is just the aggregation function on its own:
https://gist.github.com/rabernat/cb4f97be6289ffd8fa9b

@lesommer
Copy link
Owner Author

thanks for the suggestion and for sharing your code.

Wrapping a function designed for numpy arrays is probably a good way to proceed.

Do you have an idea of how efficient is building a list of sliced arrays for large arrays ?

result = reduce(np.add, [data[sl] for sl in slices])

with GriddedData.py mentionned above, I paid attention to avoid iterating on list of chunks. In practice I am using only numpy.reshape and numpy.swapaxes (see here)

@lesommer
Copy link
Owner Author

Another question is how to implement the possibility to reorganize lazily the data so that you can reshape it from say (Nx,Ny) in to (Nx/nx, Ny/ny, nx,ny) which can be usefull for building more advanced descriptive statistics than just variance and means in boxes.

@lesommer
Copy link
Owner Author

lesommer commented May 26, 2016

This discussion thread is probably relevant to the current issue. See also this discussion about stack/unstack on xarray.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants