Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
NOCSurfaceProcesses
AirSeaFluxCode
Commits
d952a829
Commit
d952a829
authored
3 years ago
by
Richard Cornes
Browse files
Options
Download
Email Patches
Plain Diff
Changed certain short parameter names to longer strings
parent
e4813126
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
16 deletions
+16
-16
Code/AirSeaFluxCode.py
Code/AirSeaFluxCode.py
+15
-15
Code/AirSeaFluxCode_test.py
Code/AirSeaFluxCode_test.py
+1
-1
No files found.
Code/AirSeaFluxCode.py
View file @
d952a829
...
...
@@ -20,7 +20,7 @@ class S88:
self
.
wind
[
ind
]
=
np
.
sqrt
(
np
.
power
(
np
.
copy
(
self
.
spd
[
ind
]),
2
)
+
np
.
power
(
get_gust
(
self
.
gust
[
1
],
self
.
Ta
[
ind
],
self
.
usr
[
ind
],
self
.
tsrv
[
ind
],
self
.
gust
[
2
],
self
.
g
[
ind
]),
2
))
self
.
g
rav
[
ind
]),
2
))
def
get_heights
(
self
,
hin
,
hout
=
10
):
self
.
hout
=
hout
self
.
hin
=
hin
...
...
@@ -151,7 +151,7 @@ class S88:
self
.
_wind_firstguess
()
# Rb eq. 11 Grachev & Fairall 1997
Rb
=
self
.
g
*
10
*
(
self
.
dtv
)
/
(
np
.
where
(
self
.
T
<
200
,
np
.
copy
(
self
.
T
)
+
CtoK
,
np
.
copy
(
self
.
T
))
*
np
.
power
(
self
.
wind
,
2
))
Rb
=
self
.
g
rav
*
10
*
(
self
.
dtv
)
/
(
np
.
where
(
self
.
T
<
200
,
np
.
copy
(
self
.
T
)
+
CtoK
,
np
.
copy
(
self
.
T
))
*
np
.
power
(
self
.
wind
,
2
))
self
.
monob
=
1
/
Rb
# eq. 12 Grachev & Fairall 1997
# ------------
...
...
@@ -169,7 +169,7 @@ class S88:
self
.
u10n
=
self
.
wind
*
np
.
log
(
10
/
1e-4
)
/
np
.
log
(
self
.
hin
[
0
]
/
1e-4
)
self
.
usr
=
0.035
*
self
.
u10n
self
.
cd10n
=
cdn_calc
(
self
.
u10n
,
self
.
usr
,
self
.
Ta
,
self
.
g
,
self
.
meth
)
self
.
cd10n
=
cdn_calc
(
self
.
u10n
,
self
.
usr
,
self
.
Ta
,
self
.
g
rav
,
self
.
meth
)
self
.
cd
=
cd_calc
(
self
.
cd10n
,
self
.
h_in
[
0
],
self
.
ref_ht
,
self
.
psim
)
self
.
usr
=
np
.
sqrt
(
self
.
cd
*
np
.
power
(
self
.
wind
,
2
))
...
...
@@ -189,11 +189,11 @@ class S88:
zo
=
ref_ht
/
np
.
exp
(
kappa
/
np
.
sqrt
(
cd10n
))
return
zo
def
iterate
(
self
,
n
=
30
,
tol
=
None
):
def
iterate
(
self
,
n
iter
=
30
,
tol
=
None
):
if
n
<
5
:
if
n
iter
<
5
:
warnings
.
warn
(
"Iteration number <5 - resetting to 5."
)
n
=
5
n
iter
=
5
# Decide which variables to use in tolerances based on tolerance specification
tol
=
[
'all'
,
0.01
,
0.01
,
1e-05
,
1e-3
,
0.1
,
0.1
]
if
tol
is
None
else
tol
...
...
@@ -227,13 +227,13 @@ class S88:
ii
=
True
while
ii
:
it
+=
1
if
it
>
n
:
break
if
it
>
n
iter
:
break
# Set the old variables (for comparison against "new")
old
=
np
.
array
([
np
.
copy
(
getattr
(
self
,
i
))
for
i
in
old_vars
])
# Calculate cdn
self
.
cd10n
[
ind
]
=
cdn_calc
(
self
.
u10n
[
ind
],
self
.
usr
[
ind
],
self
.
Ta
[
ind
],
self
.
g
[
ind
],
self
.
meth
)
self
.
cd10n
[
ind
]
=
cdn_calc
(
self
.
u10n
[
ind
],
self
.
usr
[
ind
],
self
.
Ta
[
ind
],
self
.
g
rav
[
ind
],
self
.
meth
)
if
(
np
.
all
(
np
.
isnan
(
self
.
cd10n
))):
break
...
...
@@ -281,7 +281,7 @@ class S88:
self
.
q10n
[
ind
]
=
(
self
.
qair
[
ind
]
-
self
.
qsr
[
ind
]
/
kappa
*
(
np
.
log
(
self
.
h_in
[
2
,
ind
]
/
self
.
ref_ht
)
-
self
.
psiq
[
ind
]))
self
.
tv10n
[
ind
]
=
self
.
t10n
[
ind
]
*
(
1
+
0.6077
*
self
.
q10n
[
ind
])
self
.
tsrv
[
ind
],
self
.
monob
[
ind
],
self
.
Rb
[
ind
]
=
get_L
(
self
.
L
,
self
.
g
[
ind
],
self
.
usr
[
ind
],
self
.
tsr
[
ind
],
self
.
qsr
[
ind
],
self
.
h_in
[:,
ind
],
self
.
Ta
[
ind
],
self
.
tsrv
[
ind
],
self
.
monob
[
ind
],
self
.
Rb
[
ind
]
=
get_L
(
self
.
L
,
self
.
g
rav
[
ind
],
self
.
usr
[
ind
],
self
.
tsr
[
ind
],
self
.
qsr
[
ind
],
self
.
h_in
[:,
ind
],
self
.
Ta
[
ind
],
(
self
.
SST
[
ind
]
+
self
.
dter
[
ind
]
*
self
.
cskin
+
self
.
dtwl
[
ind
]
*
self
.
wl
),
self
.
qair
[
ind
],
self
.
qsea
[
ind
],
self
.
wind
[
ind
],
np
.
copy
(
self
.
monob
[
ind
]),
self
.
zo
[
ind
],
self
.
zot
[
ind
],
self
.
psim
[
ind
],
self
.
meth
)
...
...
@@ -322,7 +322,7 @@ class S88:
# End of iteration loop
self
.
itera
[
ind
]
=
-
1
self
.
itera
=
np
.
where
(
self
.
itera
>
n
,
-
1
,
self
.
itera
)
self
.
itera
=
np
.
where
(
self
.
itera
>
n
iter
,
-
1
,
self
.
itera
)
logging
.
info
(
'method %s | # of iterations:%s'
,
self
.
meth
,
it
)
logging
.
info
(
'method %s | # of points that did not converge :%s
\n
'
,
self
.
meth
,
self
.
ind
[
0
].
size
)
...
...
@@ -480,7 +480,7 @@ class S88:
self
.
hum
=
[
'no'
,
np
.
full
(
SST
.
shape
,
80
)]
if
hum
is
None
else
hum
self
.
SST
=
np
.
where
(
SST
<
200
,
np
.
copy
(
SST
)
+
CtoK
,
np
.
copy
(
SST
))
self
.
lat
=
np
.
full
(
self
.
arr_shp
,
45
)
if
lat
is
None
else
lat
self
.
g
=
gc
(
self
.
lat
)
self
.
g
rav
=
gc
(
self
.
lat
)
self
.
P
=
np
.
full
(
n
,
1013
)
if
P
is
None
else
P
# mask to preserve missing values when initialising variables
...
...
@@ -573,7 +573,7 @@ class UA(S88):
np
.
sqrt
(
np
.
power
(
np
.
copy
(
self
.
spd
[
ind
]),
2
)
+
np
.
power
(
get_gust
(
self
.
gust
[
1
],
self
.
tv
[
ind
],
self
.
usr
[
ind
],
self
.
tsrv
[
ind
],
self
.
gust
[
2
],
self
.
g
[
ind
]),
self
.
gust
[
2
],
self
.
g
rav
[
ind
]),
2
)))
# Zeng et al. 1998 (20)
def
__init__
(
self
):
self
.
meth
=
"UA"
...
...
@@ -613,7 +613,7 @@ class Beljaars(C30):
def
AirSeaFluxCode
(
spd
,
T
,
SST
,
lat
=
None
,
hum
=
None
,
P
=
None
,
hin
=
18
,
hout
=
10
,
Rl
=
None
,
Rs
=
None
,
cskin
=
None
,
skin
=
"C35"
,
wl
=
0
,
gust
=
None
,
meth
=
"S88"
,
qmeth
=
"Buck2"
,
tol
=
None
,
n
=
30
,
out
=
0
,
L
=
None
):
meth
=
"S88"
,
qmeth
=
"Buck2"
,
tol
=
None
,
n
iter
=
30
,
out
=
0
,
L
=
None
):
"""
Calculates turbulent surface fluxes using different parameterizations
Calculates height adjusted values for spd, T, q
...
...
@@ -674,7 +674,7 @@ def AirSeaFluxCode(spd, T, SST, lat=None, hum=None, P=None, hin=18, hout=10,
option : 'all' to set tolerance limits for both fluxes and height
adjustment lim1-6
default is tol=['all', 0.01, 0.01, 1e-05, 1e-3, 0.1, 0.1]
n : int
n
iter
: int
number of iterations (defautl = 10)
out : int
set 0 to set points that have not converged, negative values of
...
...
@@ -749,7 +749,7 @@ def AirSeaFluxCode(spd, T, SST, lat=None, hum=None, P=None, hin=18, hout=10,
iclass
.
get_heights
(
hin
,
hout
)
iclass
.
get_specHumidity
(
qmeth
=
qmeth
)
iclass
.
set_coolskin_warmlayer
(
wl
=
wl
,
cskin
=
cskin
,
skin
=
skin
,
Rl
=
Rl
,
Rs
=
Rs
)
iclass
.
iterate
(
tol
=
tol
,
n
=
n
)
iclass
.
iterate
(
tol
=
tol
,
n
iter
=
niter
)
resAll
=
iclass
.
get_output
(
out
=
out
)
return
resAll
This diff is collapsed.
Click to expand it.
Code/AirSeaFluxCode_test.py
View file @
d952a829
...
...
@@ -615,7 +615,7 @@ del hu, ht, inDt
# run AirSeaFluxCode
# res = AirSeaFluxCode_OLD(spd, t, sst, lat=lat, hin=hin, P=p, cskin=0,n=10,hum=None,
# tol=['all', 0.01, 0.01, 1e-05, 1e-3, 0.1, 0.1], L="Rb",meth="UA", Rs=Rs,Rl=Rs,gust=None)
res1
=
AirSeaFluxCode
(
spd
,
t
,
sst
,
lat
=
lat
,
hin
=
hin
,
P
=
p
,
cskin
=
0
,
n
=
10
,
hum
=
None
,
res1
=
AirSeaFluxCode
(
spd
,
t
,
sst
,
lat
=
lat
,
hin
=
hin
,
P
=
p
,
cskin
=
0
,
n
iter
=
10
,
hum
=
None
,
tol
=
[
'all'
,
0.01
,
0.01
,
1e-05
,
1e-3
,
0.1
,
0.1
],
L
=
"Rb"
,
meth
=
"UA"
,
Rs
=
Rs
,
Rl
=
Rs
,
gust
=
None
)
print
(
res1
)
print
(
res
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment