You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the tke function is designed to perform the calculation as averaged over the entire input time series. Often it is desirable to average over a smaller time period. This is easy to do for calculation of something like variance with Xarray; var = data.resample(freq='1Min').var(). It would be useful to have a similar functionality within Metpy, where calculation like TKE and similar (I'm hoping to add some others) would be performed on a user-specified resample frequency, or be designed to accept an Xarray resample object. Below is a working example, though probably not robust enough yet.
def turbulence_kinetic_energy(*args, freq=None, dim=None):
terms = []
for arg in args:
if freq is None:
perturbation = arg - arg.mean()
term = (perturbation**2).mean()
else:
perturbation = arg - arg.mean(dim=dim)
term = (perturbation**2).resample(time=freq).mean(dim=dim)
terms.append(term)
return 0.5 * (sum(terms))
And an example of a function that accepts resample objects:
def turbulence_intensity(ws, dim=None):
sdev = ws.std(dim=dim)
mean = ws.mean(dim=dim)
return sdev / mean
The text was updated successfully, but these errors were encountered:
Currently the
tke
function is designed to perform the calculation as averaged over the entire input time series. Often it is desirable to average over a smaller time period. This is easy to do for calculation of something like variance with Xarray;var = data.resample(freq='1Min').var()
. It would be useful to have a similar functionality within Metpy, where calculation like TKE and similar (I'm hoping to add some others) would be performed on a user-specified resample frequency, or be designed to accept an Xarray resample object. Below is a working example, though probably not robust enough yet.And an example of a function that accepts resample objects:
The text was updated successfully, but these errors were encountered: