-
Notifications
You must be signed in to change notification settings - Fork 1
/
physics.py
46 lines (42 loc) · 1.89 KB
/
physics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""
Python module containing functions to convert from one physical quantity to another.
E.g. depth (m) -> pressure (bars)
"""
import numpy as np
def depth_to_pressure(depth):
"""
! !DESCRIPTION:
! This function computes pressure in bars from depth in meters
! using a mean density derived from depth-dependent global
! average temperatures and salinities from Levitus 1994, and
! integrating using hydrostatic balance.
!
! References:
!
! Levitus, S., R. Burgett, and T.P. Boyer, World Ocean Atlas
! 1994, Volume 3: Salinity, NOAA Atlas NESDIS 3, US Dept. of
! Commerce, 1994.
!
! Levitus, S. and T.P. Boyer, World Ocean Atlas 1994,
! Volume 4: Temperature, NOAA Atlas NESDIS 4, US Dept. of
! Commerce, 1994.
!
! Dukowicz, J. K., 2000: Reduction of Pressure and Pressure
! Gradient Errors in Ocean Simulations, J. Phys. Oceanogr.,
! submitted.
"""
# Taken from pressure() in POP's state_mod.F90
# Note that this function returns value in units of atm rather than bars
# [consistent with units of atmospheric pressure]
return(0.059808*(np.exp(-0.025*depth)-1.) + 0.100766*depth + 2.28405e-7*depth*depth)
def xkw_to_u10sqr(xkw): # units of xkw should be cm/s
# in marbl_diagnostics_mod.F90: diags(ind_diag%ECOSYS_XKW)%field_2d(:) = piston_velocity(:)
# in marbl_mod.F90: piston_velocity = xkw_coeff*u10_sqr(:)
# in marbl_settings_mod.F90: xkw_coeff = 6.97e-9_r8 ! in s/cm, from a = 0.251 cm/hr s^2/m^2 in Wannikhof 2014
xkw_coeff = 6.97e-9 # s/cm
# Note that this function returns value in units m^/s^2 rather than cm^2/s^2
return((xkw/xkw_coeff)*0.0001)
def get_surface_value(da_in):
new_da = da_in.isel(z_t=0)
new_da.attrs['long_name'] = 'Sea Surface {}'.format(new_da.attrs['long_name'])
return(new_da)