Skip to content

Instantly share code, notes, and snippets.

@Thomas-Moore-Creative
Last active June 25, 2021 06:25
Show Gist options
  • Save Thomas-Moore-Creative/8e4f6d37423ceab7594dfed5cc6697eb to your computer and use it in GitHub Desktop.
Save Thomas-Moore-Creative/8e4f6d37423ceab7594dfed5cc6697eb to your computer and use it in GitHub Desktop.
def calc_EKE(u, v):
'''
Author1 = {"name": "Thomas Moore", "affiliation": "CSIRO", "email": "thomas.moore@csiro.au", "orcid": "0000-0003-3930-1946"}
u,v are x and y currents as an xarray data array
'''
u_mean = u.mean('time')
v_mean = v.mean('time')
MKE = 0.5*(u_mean**2 + v_mean**2).rename('MKE') # currents
EKE = ( 0.5 * ((u-u_mean)**2 + (v-v_mean)**2) ).rename('EKE') # eddies
return EKE, MKE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment