Power spectral density (PSD) with "rapsd" function
ZHANGZ1YUE opened this issue · comments
First of all, thank you very much for providing this tool. I very much like it!
Just quick question regarding one of the function rapsd
from utils
.
1: According to the discription, it computes the radially averaged PSD for a 2d array. However, if I want to compute the PSD for a normal cartesian coordinate array (rather than a radial one), how should I implement it?
2: Regarding the output of this function, I am not really sure about the unit and type of each axis. Could you please tell a bit more about this? (Ex. the following figure)
Thank you very much!!
Hello @ZHANGZ1YUE
1: According to the description, it computes the radially averaged PSD for a 2d array. However, if I want to compute the PSD for a normal cartesian coordinate array (rather than a radial one), how should I implement it?
The input to utils.spectal.rapsd
can be a 2d cartesian field. In this case, you must pass the fft_method
argument, e.g. you could pass np.fft
. If fft_method
is None (the default), then is it assumed that the input array is the Fourier transform of the original field.
2: Regarding the output of this function, I am not really sure about the unit and type of each axis. Could you please tell a bit more about this?
You can set return_freq=True
in the above method to get the coordinates of the x axis. The y axis depends on the units of the input array: e.g., if the original field in is "mm" and 1 grid point corresponds to 1 km, the PSD will be in units of mm^2 / km.
Note 1: there is utility function to plot 1D spectra: https://pysteps.readthedocs.io/en/stable/generated/pysteps.visualization.spectral.plot_spectrum1d.html
Note 2: you can have a look a this example on how we typically produce and plot PSD for precipitation fields: https://github.com/pySTEPS/pysteps-publication/blob/415d0bb69e70fa072a06138778085ed829260894/plot_cascade_spectra_SPROG_MEAN.py#L173
Finally, please let us know if you see any opportunity to improve the documentation of the methods above.
Hi @dnerini
Your explanation and the provided example can't be more helpful. I might have more question in future regarding the details but so far, it does plot what I expected.
Finally, please let us know if you see any opportunity to improve the documentation of the methods above.
Definitely! Once I have a deeper understanding about these functions, I'll let you know if I have any suggestions for the documentation.
Thank you very much.