Commit 7934c1c1 authored by sbiri's avatar sbiri
Browse files

Update AirSeaFluxCode.py, get_init.py, hum_subs.py files

parent 94f700e2
......@@ -136,14 +136,15 @@ def AirSeaFluxCode(spd, T, SST, lat=None, hum=None, P=None, hin=18, hout=10,
format='%(asctime)s %(message)s',level=logging.INFO)
logging.captureWarnings(True)
# check input values and set defaults where appropriate
lat, P, Rl, Rs, cskin, skin, wl, gust, tol, L = get_init(spd, T, SST, lat,
P, Rl, Rs, cskin,
skin, wl, gust, L,
tol, meth, qmeth)
lat, hum, P, Rl, Rs, cskin, skin, wl, gust, tol, L = get_init(spd, T, SST,
lat, hum, P,
Rl, Rs,
cskin, skin,
wl, gust, L,
tol, meth,
qmeth)
flag = np.ones(spd.shape, dtype="object")*"n"
flag = np.where(np.isnan(spd+T+SST+lat+hum[1]+P+Rs) & (flag == "n"),
"m", np.where(np.isnan(spd+T+SST+lat+hum[1]+P+Rs) &
(flag != "n"), flag+[","]+["m"], flag))
flag = np.where(np.isnan(spd+T+SST+lat+hum[1]+P+Rs), "m", flag)
ref_ht = 10 # reference height
h_in = get_heights(hin, len(spd)) # heights of input measurements/fields
h_out = get_heights(hout, 1) # desired height of output variables
......
import numpy as np
import sys
def get_init(spd, T, SST, lat, P, Rl, Rs, cskin, skin, wl, gust, L, tol, meth,
def get_init(spd, T, SST, lat, hum, P, Rl, Rs, cskin, skin, wl, gust, L, tol, meth,
qmeth):
"""
Checks initial input values and sets defaults if needed
......@@ -17,6 +17,8 @@ def get_init(spd, T, SST, lat, P, Rl, Rs, cskin, skin, wl, gust, L, tol, meth,
sea surface temperature in K
lat : float
latitude (deg), default 45deg
hum : float
relative humidity, if None is set to 80%
P : float
air pressure (hPa), default 1013hPa
Rl : float
......@@ -100,6 +102,11 @@ def get_init(spd, T, SST, lat, P, Rl, Rs, cskin, skin, wl, gust, L, tol, meth,
lat = 45*np.ones(spd.shape)
elif ((np.all(lat != None)) and (np.size(lat) == 1)):
lat = np.ones(spd.shape)*np.copy(lat)
if (hum == None):
RH = np.ones(SST.shape)*80
hum = ['rh', RH]
else:
hum = hum
if ((np.all(P == None)) or np.all(np.isnan(P))):
P = np.ones(spd.shape)*1013
elif (((np.all(P != None)) or np.all(~np.isnan(P))) and np.size(P) == 1):
......@@ -149,4 +156,4 @@ def get_init(spd, T, SST, lat, P, Rl, Rs, cskin, skin, wl, gust, L, tol, meth,
tol = ['flux', 1e-3, 0.1, 0.1]
elif (tol[0] not in ['flux', 'ref', 'all']):
sys.exit("unknown tolerance input")
return lat, P, Rl, Rs, cskin, skin, wl, gust, tol, L
return lat, hum, P, Rl, Rs, cskin, skin, wl, gust, tol, L
......@@ -372,11 +372,7 @@ def get_hum(hum, T, sst, P, qmeth):
specific humidity over sea surface
"""
if (hum == None):
RH = np.ones(sst.shape)*80
qsea = qsat_sea(sst, P, qmeth)/1000 # surface water q (kg/kg)
qair = qsat_air(T, P, RH, qmeth)/1000 # q of air (kg/kg)
elif (hum[0] not in ['rh', 'q', 'Td']):
if (hum[0] not in ['rh', 'q', 'Td']):
sys.exit("unknown humidity input")
qair, qsea = np.nan, np.nan
elif (hum[0] == 'rh'):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment