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
0909754b
Commit
0909754b
authored
3 years ago
by
sbiri
Browse files
Options
Download
Email Patches
Plain Diff
change name convention LY04 to NCAR
parent
c164b7c0
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
407 deletions
+20
-407
ASFC_notebook.ipynb
ASFC_notebook.ipynb
+0
-387
AirSeaFluxCode.py
AirSeaFluxCode.py
+8
-8
flux_subs.py
flux_subs.py
+6
-6
get_init.py
get_init.py
+3
-3
toy_ASFC.py
toy_ASFC.py
+3
-3
No files found.
ASFC_notebook.ipynb
deleted
100644 → 0
View file @
c164b7c0
This diff is collapsed.
Click to expand it.
AirSeaFluxCode.py
View file @
0909754b
...
...
@@ -58,7 +58,7 @@ def AirSeaFluxCode(spd, T, SST, lat=None, hum=None, P=None, hin=18, hout=10,
default for UA, ecmwf [1, 1, 1000]
default else [1, 1.2, 800]
meth : str
"S80", "S88", "LP82", "YT96", "UA", "
LY04
", "C30", "C35",
"S80", "S88", "LP82", "YT96", "UA", "
NCAR
", "C30", "C35",
"ecmwf", "Beljaars"
qmeth : str
is the saturation evaporation method to use amongst
...
...
@@ -80,7 +80,7 @@ def AirSeaFluxCode(spd, T, SST, lat=None, hum=None, P=None, hin=18, hout=10,
set 1 to keep points
L : str
Monin-Obukhov length definition options
"tsrv" : default for "S80", "S88", "LP82", "YT96", "UA", "
LY04
",
"tsrv" : default for "S80", "S88", "LP82", "YT96", "UA", "
NCAR
",
"C30", "C35"
"Rb" : following ecmwf (IFS Documentation cy46r1), default for
"ecmwf", "Beljaars"
...
...
@@ -155,10 +155,10 @@ def AirSeaFluxCode(spd, T, SST, lat=None, hum=None, P=None, hin=18, hout=10,
h_in
=
get_heights
(
hin
,
len
(
spd
))
# heights of input measurements/fields
h_out
=
get_heights
(
hout
,
1
)
# desired height of output variables
logging
.
info
(
'method %s, inputs: lat: %s | P: %s | Rl: %s |'
' Rs: %s | gust: %s | cskin: %s | L : %s'
,
meth
,
np
.
nanmedian
(
lat
),
np
.
round
(
np
.
nanmedian
(
P
),
2
),
np
.
round
(
np
.
nanmedian
(
Rl
),
2
),
np
.
round
(
np
.
nanmedian
(
Rs
),
2
),
gust
,
cskin
,
L
)
' Rs: %s | gust: %s | cskin: %s | L : %s'
,
meth
,
np
.
nanmedian
(
lat
),
np
.
round
(
np
.
nanmedian
(
P
),
2
),
np
.
round
(
np
.
nanmedian
(
Rl
),
2
),
np
.
round
(
np
.
nanmedian
(
Rs
),
2
),
gust
,
cskin
,
L
)
# set up/calculate temperatures and specific humidities
th
=
np
.
where
(
T
<
200
,
(
np
.
copy
(
T
)
+
CtoK
)
*
np
.
power
(
1000
/
P
,
287.1
/
1004.67
),
...
...
@@ -291,7 +291,7 @@ def AirSeaFluxCode(spd, T, SST, lat=None, hum=None, P=None, hin=18, hout=10,
ct
[
ind
],
cq
[
ind
]
=
ctcq_calc
(
cd10n
[
ind
],
cd
[
ind
],
ct10n
[
ind
],
cq10n
[
ind
],
h_in
[:,
ind
],
[
ref_ht
,
ref_ht
,
ref_ht
],
psit
[
ind
],
psiq
[
ind
])
if
(
meth
==
"
LY04
"
):
if
(
meth
==
"
NCAR
"
):
cd
=
np
.
maximum
(
np
.
copy
(
cd
),
1e-4
)
ct
=
np
.
maximum
(
np
.
copy
(
ct
),
1e-4
)
cq
=
np
.
maximum
(
np
.
copy
(
cq
),
1e-4
)
...
...
@@ -525,7 +525,7 @@ def AirSeaFluxCode(spd, T, SST, lat=None, hum=None, P=None, hin=18, hout=10,
(
np
.
char
.
find
(
flag
.
astype
(
str
),
'u'
)
==
-
1
)
&
(
np
.
char
.
find
(
flag
.
astype
(
str
),
'q'
)
==
-
1
)),
flag
+
[
","
]
+
[
"o"
],
flag
))
elif
(
meth
==
"
LY04
"
):
elif
(
meth
==
"
NCAR
"
):
flag
=
np
.
where
((
utmp
<
0.5
)
&
(
flag
==
"n"
),
"o"
,
np
.
where
((
utmp
<
0.5
)
&
((
flag
!=
"n"
)
&
...
...
This diff is collapsed.
Click to expand it.
flux_subs.py
View file @
0909754b
...
...
@@ -36,7 +36,7 @@ def cdn_calc(u10n, usr, Ta, lat, meth="S80"):
# convert usr in eq. 21 to cdn to expand for low wind speeds
cdn
=
np
.
power
((
0.10038
+
u10n
*
2.17e-3
+
np
.
power
(
u10n
,
2
)
*
2.78e-3
-
np
.
power
(
u10n
,
3
)
*
4.4e-5
)
/
u10n
,
2
)
elif
(
meth
==
"
LY04
"
):
elif
(
meth
==
"
NCAR
"
):
cdn
=
np
.
where
(
u10n
>
0.5
,
(
0.142
+
2.7
/
u10n
+
u10n
/
13.09
-
3.14807e-10
*
np
.
power
(
u10n
,
6
))
*
1e-3
,
(
0.142
+
2.7
/
0.5
+
0.5
/
13.09
-
...
...
@@ -156,7 +156,7 @@ def ctcqn_calc(zol, cdn, usr, zo, Ta, meth="S80"):
elif
(
meth
==
"LP82"
):
cqn
=
np
.
where
((
zol
<=
0
),
1.15
*
0.001
,
1
*
0.001
)
ctn
=
np
.
where
((
zol
<=
0
),
1.13
*
0.001
,
0.66
*
0.001
)
elif
(
meth
==
"
LY04
"
):
elif
(
meth
==
"
NCAR
"
):
cqn
=
np
.
maximum
(
34.6
*
0.001
*
np
.
sqrt
(
cdn
),
0.1e-3
)
ctn
=
np
.
maximum
(
np
.
where
(
zol
<=
0
,
32.7
*
0.001
*
np
.
sqrt
(
cdn
),
18
*
0.001
*
np
.
sqrt
(
cdn
)),
0.1e-3
)
...
...
@@ -242,7 +242,7 @@ def get_stabco(meth="S80"):
coeffs : float
"""
alpha
,
beta
,
gamma
=
0
,
0
,
0
if
(
meth
==
"S80"
or
meth
==
"S88"
or
meth
==
"
LY04
"
or
if
(
meth
==
"S80"
or
meth
==
"S88"
or
meth
==
"
NCAR
"
or
meth
==
"UA"
or
meth
==
"ecmwf"
or
meth
==
"C30"
or
meth
==
"C35"
or
meth
==
"Beljaars"
):
alpha
,
beta
,
gamma
=
16
,
0.25
,
5
# Smith 1980, from Dyer (1974)
...
...
@@ -883,7 +883,7 @@ def get_L(L, lat, usr, tsr, qsr, hin, Ta, sst, qair, qsea, wind, monob, zo,
----------
L : str
Monin-Obukhov length definition options
"tsrv" : default for S80, S88, LP82, YT96, UA, C30, C35 and
LY04
"tsrv" : default for S80, S88, LP82, YT96, UA, C30, C35 and
NCAR
"Rb" : following ecmwf (IFS Documentation cy46r1), default for ecmwf
and Beljaars
lat : float
...
...
@@ -916,7 +916,7 @@ def get_L(L, lat, usr, tsr, qsr, hin, Ta, sst, qair, qsea, wind, monob, zo,
momentum stability function
meth : str
bulk parameterisation method option: "S80", "S88", "LP82", "YT96",
"UA", "
LY04
", "C30", "C35", "ecmwf", "Beljaars"
"UA", "
NCAR
", "C30", "C35", "ecmwf", "Beljaars"
Returns
-------
...
...
@@ -997,7 +997,7 @@ def get_strs(hin, monob, wind, zo, zot, zoq, dt, dq, dter, dqer, dtwl, ct, cq,
warm layer correction switch
meth : str
bulk parameterisation method option: "S80", "S88", "LP82", "YT96", "UA",
"
LY04
", "C30", "C35", "ecmwf", "Beljaars"
"
NCAR
", "C30", "C35", "ecmwf", "Beljaars"
Returns
-------
...
...
This diff is collapsed.
Click to expand it.
get_init.py
View file @
0909754b
...
...
@@ -49,7 +49,7 @@ def get_init(spd, T, SST, lat, hum, P, Rl, Rs, cskin, skin, wl, gust, L, tol,
n : int
number of iterations
meth : str
"S80","S88","LP82","YT96","UA","
LY04
","C30","C35","ecmwf",
"S80","S88","LP82","YT96","UA","
NCAR
","C30","C35","ecmwf",
"Beljaars"
qmeth : str
is the saturation evaporation method to use amongst
...
...
@@ -93,7 +93,7 @@ def get_init(spd, T, SST, lat, hum, P, Rl, Rs, cskin, skin, wl, gust, L, tol,
(
SST
.
dtype
not
in
[
'float64'
,
'float32'
])):
sys
.
exit
(
"input dtype of spd, T and SST should be float"
)
# if input values are nan break
if
meth
not
in
[
"S80"
,
"S88"
,
"LP82"
,
"YT96"
,
"UA"
,
"
LY04
"
,
"C30"
,
"C35"
,
if
meth
not
in
[
"S80"
,
"S88"
,
"LP82"
,
"YT96"
,
"UA"
,
"
NCAR
"
,
"C30"
,
"C35"
,
"ecmwf"
,
"Beljaars"
]:
sys
.
exit
(
"unknown method"
)
if
qmeth
not
in
[
"HylandWexler"
,
"Hardy"
,
"Preining"
,
"Wexler"
,
...
...
@@ -117,7 +117,7 @@ def get_init(spd, T, SST, lat, hum, P, Rl, Rs, cskin, skin, wl, gust, L, tol,
P
=
np
.
ones
(
spd
.
shape
)
*
np
.
copy
(
P
)
if
((
cskin
==
None
)
and
(
meth
==
"S80"
or
meth
==
"S88"
or
meth
==
"LP82"
or
meth
==
"YT96"
or
meth
==
"UA"
or
meth
==
"
LY04
"
)):
meth
==
"
NCAR
"
)):
cskin
=
0
elif
((
cskin
==
None
)
and
(
meth
==
"C30"
or
meth
==
"C35"
or
meth
==
"ecmwf"
or
meth
==
"Beljaars"
)):
...
...
This diff is collapsed.
Click to expand it.
toy_ASFC.py
View file @
0909754b
...
...
@@ -507,7 +507,7 @@ start_time = time.perf_counter()
#------------------------------------------------------------------------------
inF
=
input
(
"Give input file name (data_all.csv or era5_r360x180.nc):
\n
"
)
meth
=
input
(
"Give prefered method:
\n
"
)
while
meth
not
in
[
"S80"
,
"S88"
,
"LP82"
,
"YT96"
,
"UA"
,
"
LY04
"
,
"C30"
,
"C35"
,
while
meth
not
in
[
"S80"
,
"S88"
,
"LP82"
,
"YT96"
,
"UA"
,
"
NCAR
"
,
"C30"
,
"C35"
,
"ecmwf"
,
"Beljaars"
]:
print
(
"method unknown"
)
meth
=
input
(
"Give prefered method:
\n
"
)
...
...
@@ -545,7 +545,7 @@ if (cskinIn == ''):
cskinIn
=
None
if
((
cskinIn
==
None
)
and
(
meth
==
"S80"
or
meth
==
"S88"
or
meth
==
"LP82"
or
meth
==
"YT96"
or
meth
==
"UA"
or
meth
==
"
LY04
"
)):
or
meth
==
"
NCAR
"
)):
cskinIn
=
0
ext
=
ext
+
'noskin_'
elif
((
cskinIn
==
None
)
and
(
meth
==
"C30"
or
meth
==
"C35"
...
...
@@ -641,7 +641,7 @@ print("run_ASFC.py took ", np.round((time.perf_counter()-start_time)/60, 2),
#%% generate txt file with statistics
if
((
cskinIn
==
None
)
and
(
meth
==
"S80"
or
meth
==
"S88"
or
meth
==
"LP82"
or
meth
==
"YT96"
or
meth
==
"UA"
or
meth
==
"
LY04
"
)):
meth
==
"
NCAR
"
)):
cskinIn
=
0
elif
((
cskinIn
==
None
)
and
(
meth
==
"C30"
or
meth
==
"C35"
or
meth
==
"ecmwf"
or
meth
==
"Beljaars"
)):
...
...
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