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, ...@@ -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) format='%(asctime)s %(message)s',level=logging.INFO)
logging.captureWarnings(True) logging.captureWarnings(True)
# check input values and set defaults where appropriate # check input values and set defaults where appropriate
lat, P, Rl, Rs, cskin, skin, wl, gust, tol, L = get_init(spd, T, SST, lat, lat, hum, P, Rl, Rs, cskin, skin, wl, gust, tol, L = get_init(spd, T, SST,
P, Rl, Rs, cskin, lat, hum, P,
skin, wl, gust, L, Rl, Rs,
tol, meth, qmeth) cskin, skin,
wl, gust, L,
tol, meth,
qmeth)
flag = np.ones(spd.shape, dtype="object")*"n" flag = np.ones(spd.shape, dtype="object")*"n"
flag = np.where(np.isnan(spd+T+SST+lat+hum[1]+P+Rs) & (flag == "n"), flag = np.where(np.isnan(spd+T+SST+lat+hum[1]+P+Rs), "m", flag)
"m", np.where(np.isnan(spd+T+SST+lat+hum[1]+P+Rs) &
(flag != "n"), flag+[","]+["m"], flag))
ref_ht = 10 # reference height ref_ht = 10 # reference height
h_in = get_heights(hin, len(spd)) # heights of input measurements/fields h_in = get_heights(hin, len(spd)) # heights of input measurements/fields
h_out = get_heights(hout, 1) # desired height of output variables h_out = get_heights(hout, 1) # desired height of output variables
......
import numpy as np import numpy as np
import sys 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): qmeth):
""" """
Checks initial input values and sets defaults if needed 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, ...@@ -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 sea surface temperature in K
lat : float lat : float
latitude (deg), default 45deg latitude (deg), default 45deg
hum : float
relative humidity, if None is set to 80%
P : float P : float
air pressure (hPa), default 1013hPa air pressure (hPa), default 1013hPa
Rl : float Rl : float
...@@ -100,6 +102,11 @@ def get_init(spd, T, SST, lat, P, Rl, Rs, cskin, skin, wl, gust, L, tol, meth, ...@@ -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) lat = 45*np.ones(spd.shape)
elif ((np.all(lat != None)) and (np.size(lat) == 1)): elif ((np.all(lat != None)) and (np.size(lat) == 1)):
lat = np.ones(spd.shape)*np.copy(lat) 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))): if ((np.all(P == None)) or np.all(np.isnan(P))):
P = np.ones(spd.shape)*1013 P = np.ones(spd.shape)*1013
elif (((np.all(P != None)) or np.all(~np.isnan(P))) and np.size(P) == 1): 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, ...@@ -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] tol = ['flux', 1e-3, 0.1, 0.1]
elif (tol[0] not in ['flux', 'ref', 'all']): elif (tol[0] not in ['flux', 'ref', 'all']):
sys.exit("unknown tolerance input") 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): ...@@ -372,11 +372,7 @@ def get_hum(hum, T, sst, P, qmeth):
specific humidity over sea surface specific humidity over sea surface
""" """
if (hum == None): if (hum[0] not in ['rh', 'q', 'Td']):
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']):
sys.exit("unknown humidity input") sys.exit("unknown humidity input")
qair, qsea = np.nan, np.nan qair, qsea = np.nan, np.nan
elif (hum[0] == 'rh'): 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