boutproject / xBOUT

Collects BOUT++ data from parallelized simulations into xarray.
https://xbout.readthedocs.io/en/latest/
Apache License 2.0
21 stars 8 forks source link

Question about analysis methods #260

Open bendudson opened 1 year ago

bendudson commented 1 year ago

I'd like to add a cross-phase diagnostic, to plot the phase difference between two variables as a function of position and frequency. Should this be implemented as a standalone function or as a data array method?

i.e. if ds is a dataset:

result = crossphase(ds['Ne'], ds['phi'])

or

result = ds['Ne'].crossphase(ds['phi'])

?

TomNicholas commented 1 year ago

Should this be implemented as a standalone function or as a data array method?

The difference is only semantic. But the syntax for the second approach would have to be something like

result = ds['Ne'].xbout.crossphase(ds['phi'])

as xarray accessors add methods under a separated namespace.

You should check if this crossphase function in xrft suits your needs first though. You could also wrap that in xbout.