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
cb2fc7be
Commit
cb2fc7be
authored
3 years ago
by
sbiri
Browse files
Options
Download
Email Patches
Plain Diff
Update Code/AirSeaFluxCode.py, Code/flux_subs.py files
parent
3c731e18
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
21 deletions
+72
-21
Code/AirSeaFluxCode.py
Code/AirSeaFluxCode.py
+14
-21
Code/flux_subs.py
Code/flux_subs.py
+58
-0
No files found.
Code/AirSeaFluxCode.py
View file @
cb2fc7be
...
@@ -10,7 +10,7 @@ from cs_wl_subs import *
...
@@ -10,7 +10,7 @@ from cs_wl_subs import *
class
S88
:
class
S88
:
def
_wind_iterate
(
self
,
ind
):
def
_wind_iterate
(
self
,
ind
):
if
self
.
gust
[
0
]
in
[
1
,
2
,
3
]
:
if
self
.
gust
[
0
]
in
range
(
1
,
5
)
:
self
.
wind
[
ind
]
=
np
.
sqrt
(
np
.
power
(
np
.
copy
(
self
.
spd
[
ind
]),
2
)
+
self
.
wind
[
ind
]
=
np
.
sqrt
(
np
.
power
(
np
.
copy
(
self
.
spd
[
ind
]),
2
)
+
np
.
power
(
get_gust
(
self
.
gust
[
1
],
np
.
power
(
get_gust
(
self
.
gust
[
1
],
self
.
theta
[
ind
],
self
.
theta
[
ind
],
...
@@ -19,16 +19,14 @@ class S88:
...
@@ -19,16 +19,14 @@ class S88:
self
.
gust
[
2
],
self
.
gust
[
2
],
self
.
grav
[
ind
]),
2
))
self
.
grav
[
ind
]),
2
))
# ratio of gusty to horizontal wind
# ratio of gusty to horizontal wind
self
.
GustFact
[
ind
]
=
self
.
wind
[
ind
]
/
self
.
spd
[
ind
]
self
.
GustFact
=
apply_GF
(
self
.
gust
,
self
.
spd
,
self
.
wind
,
"u"
)
# remove effect of gustiness following Fairall et al. (2003)
self
.
u10n
[
ind
]
=
self
.
spd
[
ind
]
-
self
.
usr
[
ind
]
/
kappa
/
\
self
.
u10n
[
ind
]
=
self
.
spd
[
ind
]
-
self
.
usr
[
ind
]
/
kappa
/
np
.
sqrt
(
self
.
GustFact
[
ind
]
*
(
np
.
log
(
self
.
h_in
[
0
,
ind
]
/
self
.
ref10
)
-
self
.
GustFact
[
ind
])
*
(
np
.
log
(
self
.
h_in
[
0
,
ind
]
/
self
.
ref10
)
-
self
.
psim
[
ind
])
self
.
psim
[
ind
])
if
self
.
gust
[
0
]
==
3
:
if
self
.
gust
[
0
]
==
2
:
self
.
GustFact
[
ind
]
=
1
# option to not remove GustFact
# option to not remove GustFact
self
.
u10n
[
ind
]
=
self
.
wind
[
ind
]
-
self
.
usr
[
ind
]
/
kappa
*
(
self
.
u10n
[
ind
]
=
self
.
wind
[
ind
]
-
self
.
usr
[
ind
]
/
kappa
*
(
np
.
log
(
self
.
h_in
[
0
,
ind
]
/
self
.
ref10
)
-
self
.
psim
[
ind
])
np
.
log
(
self
.
h_in
[
0
,
ind
]
/
self
.
ref10
)
-
self
.
psim
[
ind
])
else
:
else
:
# initalisation of wind
# initalisation of wind
self
.
wind
[
ind
]
=
np
.
copy
(
self
.
spd
[
ind
])
self
.
wind
[
ind
]
=
np
.
copy
(
self
.
spd
[
ind
])
...
@@ -330,15 +328,10 @@ class S88:
...
@@ -330,15 +328,10 @@ class S88:
# usr is divided by (GustFact)^0.5 (here applied to sensible and
# usr is divided by (GustFact)^0.5 (here applied to sensible and
# latent as well as tau)
# latent as well as tau)
# GustFact should be 1 if gust is OFF or gust[0]=2
# GustFact should be 1 if gust is OFF or gust[0]=2
self
.
tau
=
self
.
rho
*
np
.
power
(
self
.
usr
,
2
)
/
self
.
GustFact
self
.
GustFact
=
apply_GF
(
self
.
gust
,
self
.
spd
,
self
.
wind
,
"TSF"
)
if
self
.
gust
[
0
]
==
3
:
self
.
tau
=
self
.
rho
*
np
.
power
(
self
.
usr
,
2
)
/
self
.
GustFact
[
0
]
self
.
sensible
=
self
.
rho
*
self
.
cp
*
self
.
usr
*
self
.
tsr
self
.
sensible
=
self
.
rho
*
self
.
cp
*
(
self
.
usr
/
self
.
GustFact
[
1
])
*
self
.
tsr
self
.
latent
=
self
.
rho
*
self
.
lv
*
self
.
usr
*
self
.
qsr
self
.
latent
=
self
.
rho
*
self
.
lv
*
(
self
.
usr
/
self
.
GustFact
[
2
])
*
self
.
qsr
else
:
self
.
sensible
=
self
.
rho
*
self
.
cp
*
self
.
usr
/
\
np
.
sqrt
(
self
.
GustFact
)
*
self
.
tsr
self
.
latent
=
self
.
rho
*
self
.
lv
*
self
.
usr
/
\
np
.
sqrt
(
self
.
GustFact
)
*
self
.
qsr
# Set the new variables (for comparison against "old")
# Set the new variables (for comparison against "old")
new
=
np
.
array
([
np
.
copy
(
getattr
(
self
,
i
))
for
i
in
new_vars
])
new
=
np
.
array
([
np
.
copy
(
getattr
(
self
,
i
))
for
i
in
new_vars
])
...
@@ -395,9 +388,10 @@ class S88:
...
@@ -395,9 +388,10 @@ class S88:
self
.
_get_humidity
()
# Get the Relative humidity
self
.
_get_humidity
()
# Get the Relative humidity
self
.
_flag
(
out
=
out
)
# Get flags
self
.
_flag
(
out
=
out
)
# Get flags
self
.
GustFact
=
apply_GF
(
self
.
gust
,
self
.
spd
,
self
.
wind
,
"u"
)
# remove effect of gustiness following Fairall et al. (2003)
# remove effect of gustiness following Fairall et al. (2003)
# usr is divided by (GustFact)^0.5
# usr is divided by (GustFact)^0.5
self
.
uref
=
self
.
spd
-
self
.
usr
/
kappa
/
np
.
sqrt
(
self
.
GustFact
)
*
\
self
.
uref
=
self
.
spd
-
self
.
usr
/
kappa
/
self
.
GustFact
*
\
(
np
.
log
(
self
.
h_in
[
0
]
/
self
.
h_out
[
0
])
-
self
.
psim
+
(
np
.
log
(
self
.
h_in
[
0
]
/
self
.
h_out
[
0
])
-
self
.
psim
+
psim_calc
(
self
.
h_out
[
0
]
/
self
.
monob
,
self
.
meth
))
psim_calc
(
self
.
h_out
[
0
]
/
self
.
monob
,
self
.
meth
))
# include lapse rate adjustment as theta is well-mixed
# include lapse rate adjustment as theta is well-mixed
...
@@ -501,8 +495,7 @@ class S88:
...
@@ -501,8 +495,7 @@ class S88:
gust
=
[
0
,
0
,
0
]
gust
=
[
0
,
0
,
0
]
assert
np
.
size
(
gust
)
==
3
,
"gust input must be a 3x1 array"
assert
np
.
size
(
gust
)
==
3
,
"gust input must be a 3x1 array"
assert
gust
[
0
]
in
[
assert
gust
[
0
]
in
range
(
6
),
"gust at position 0 must be 0 to 5"
0
,
1
,
2
,
3
],
"gust at position 0 must be 0, 1, 2 or 3"
self
.
gust
=
gust
self
.
gust
=
gust
def
_class_flag
(
self
):
def
_class_flag
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Code/flux_subs.py
View file @
cb2fc7be
...
@@ -593,6 +593,64 @@ def get_gust(beta, Ta, usr, tsrv, zi, grav):
...
@@ -593,6 +593,64 @@ def get_gust(beta, Ta, usr, tsrv, zi, grav):
# ---------------------------------------------------------------------
# ---------------------------------------------------------------------
def
apply_GF
(
gust
,
spd
,
wind
,
step
):
"""
Apply gustiness factor according if gustiness ON.
There are different ways to remove the effect of gustiness according to
the user's choice.
Parameters
----------
gust : int
option on how to apply gustiness
0: gustiness is switched OFF
1: gustiness is switched ON following Fairall et al.
2: gustiness is switched ON and GF is removed from TSFs u10n, uref
3: gustiness is switched ON and GF=1
4: gustiness is switched ON following Zeng et al. 1998 or
Brodeau et al. 2006 for ECMWF
5: gustiness is switched ON following C35 matlab code
spd : float
wind speed [ms^{-1}]
wind : float
wind speed including gust [ms^{-1}]
step : str
step during AirSeaFluxCode the GF is applied: "u", "TSF"
Returns
-------
GustFact : float
gustiness factor.
"""
# 1. following C35 documentation, 2. use GF to TSF, u10n uzout,
# 3. GF=1, 4. UA, 5. C35 code 6. ecmwf aerobulk)
# ratio of gusty to horizontal wind; gustiness factor
if
step
in
[
"u"
]:
GustFact
=
wind
*
0
+
1
if
gust
[
0
]
in
[
1
,
2
]:
GustFact
=
np
.
sqrt
(
wind
/
spd
)
elif
gust
[
0
]
==
5
:
# as in C35 matlab code
GustFact
=
wind
/
spd
elif
step
==
"TSF"
:
# remove effect of gustiness from TSFs
# here it is a 3xspd.shape array
GustFact
=
np
.
empty
([
3
,
spd
.
shape
[
0
]],
dtype
=
float
)
*
np
.
nan
GustFact
[
0
,
:]
=
wind
/
spd
GustFact
[
1
:
3
,
:]
=
wind
*
0
+
1
# following Fairall et al. (2003)
if
gust
[
0
]
==
2
:
# usr is divided by (GustFact)^0.5 (here applied to sensible and
# latent as well as tau)
GustFact
[
1
:
3
,
:]
=
np
.
sqrt
(
wind
/
spd
)
elif
gust
[
0
]
==
3
:
GustFact
[
0
,
:]
=
wind
*
0
+
1
return
GustFact
# ---------------------------------------------------------------------
def
get_strs
(
hin
,
monob
,
wind
,
zo
,
zot
,
zoq
,
dt
,
dq
,
cd
,
ct
,
cq
,
meth
):
def
get_strs
(
hin
,
monob
,
wind
,
zo
,
zot
,
zoq
,
dt
,
dq
,
cd
,
ct
,
cq
,
meth
):
"""
"""
Calculate star wind speed, temperature and specific humidity.
Calculate star wind speed, temperature and specific humidity.
...
...
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