'''
Created on 2010-11-26, adapted from PyGeode on 2013-08-24

Some default physical constants.

@author: Andre R. Erler, GPL v3
'''

from numpy import pi, sin

# actual constants
R = 8.31447215 # J/(mol K), universal gas constant (Wikipedia)
cp = 1005.7 # J/(kg K), specific heat of dry air per mass (AMS Glossary)
g0 = 9.80665 # m/s**2, for geopotential altitude (else actually y-dependent g(y))
Mair = 0.0289644 # kg/mol, Molecular mass of dry air
Re = 6371229 # m, Radius of planet earth
T0 = 273.15 # K, Temperature at 0 deg C, i.e. negative absolute zero in Celsius
Omega = 2*pi/((23*60+56)*60+4.1) # 1/s, Earth's rotation rate (using siderial day)
# some derived constants, for convenience
Cp = cp*Mair # J/(mol K), specific heat of dry air per mole
Rd = R/Mair # gas constant for dry air
kappa = R/Cp # ~7/2, adiabatic exponent for dry air
# not exactly physical constants
fc = 2*Omega*sin(pi/4) # Coriolis parameter at 45 deg N
p0 = 1e5 # reference pressure (e.g. for potential temperature)
sig = 5.67051e-8 # Stefan-Boltzmann constant (AMS Glossary, WRF)
lw =  2.45e6 # latent heat of vaporization [J/kg] of water at 20 deg Celsius and mean sealevel pressure (FAO)

# thresholds for wet-day variables (from AMS glossary and ETCCDI Climate Change Indices) 
precip_thresholds = [0.2, 1., 10., 20.]
# N.B.: importing from wrfavg in WRF Tools causes a name collition; the variable is placed here
#       to avoid further import errors, because this module does not import anything non-standard 
