Cloud-Drift / clouddrift

CloudDrift accelerates the use of Lagrangian data for atmospheric, oceanic, and climate sciences.
https://clouddrift.org/
MIT License
37 stars 8 forks source link

clouddrift.wavelet + xarray #280

Open selipot opened 1 year ago

selipot commented 1 year ago

I am sharing a snippet of code showing how the wavelet transform function from clouddrift can be used with xarray dataarrays. It doesn't work directly because of the np.moveaxis function to start with. The proposed solution is to use xr.apply_ufunc, which seems to work with dask arrays as well. A remaining issue that I have not solved is that I would like to use morse_wavelet then wavelet_transform in order to calculate the wavelet only once in this case of time series of common length, instead of using morse_wavelet_transform which calculates the wavelet for each iteration, so not necessarily efficient.

https://gist.github.com/selipot/93c061f7715b95ce3ec3bcf169c1165a

I'd like to discuss!

milancurcic commented 1 year ago

I can reproduce your behavior and don't yet understand what's causing the error with the last one. Will need to study it more.