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
4e7f29d4
Commit
4e7f29d4
authored
4 years ago
by
sbiri
Browse files
Options
Download
Email Patches
Plain Diff
Update toy_ASFC.py
parent
7bee76bc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
8 deletions
+22
-8
toy_ASFC.py
toy_ASFC.py
+22
-8
No files found.
toy_ASFC.py
View file @
4e7f29d4
...
@@ -23,7 +23,7 @@ def reject_outliers(data, m=2):
...
@@ -23,7 +23,7 @@ def reject_outliers(data, m=2):
return
x
return
x
def
toy_ASFC
(
inF
,
outF
,
gustIn
,
cskinIn
,
tolIn
,
meth
):
def
toy_ASFC
(
inF
,
outF
,
outS
,
gustIn
,
cskinIn
,
tolIn
,
meth
):
"""
"""
Example routine of how to run AirSeaFluxCode with the test data given
Example routine of how to run AirSeaFluxCode with the test data given
and save output either as .csv or NetCDF
and save output either as .csv or NetCDF
...
@@ -34,6 +34,8 @@ def toy_ASFC(inF, outF, gustIn, cskinIn, tolIn, meth):
...
@@ -34,6 +34,8 @@ def toy_ASFC(inF, outF, gustIn, cskinIn, tolIn, meth):
input filename either data_all.csv or era5_r360x180.nc
input filename either data_all.csv or era5_r360x180.nc
outF : str
outF : str
output filename
output filename
outS : str
output statistics filename
gustIn : float
gustIn : float
gustiness option e.g. [1, 1.2, 800]
gustiness option e.g. [1, 1.2, 800]
cskinIn : int
cskinIn : int
...
@@ -260,6 +262,7 @@ def toy_ASFC(inF, outF, gustIn, cskinIn, tolIn, meth):
...
@@ -260,6 +262,7 @@ def toy_ASFC(inF, outF, gustIn, cskinIn, tolIn, meth):
usr
.
units
=
'm/s'
usr
.
units
=
'm/s'
psim
.
long_name
=
'Momentum stability function'
psim
.
long_name
=
'Momentum stability function'
psit
.
long_name
=
'Heat stability function'
psit
.
long_name
=
'Heat stability function'
psiq
.
long_name
=
'moisture stability function'
u10n
.
long_name
=
'10m neutral wind speed'
u10n
.
long_name
=
'10m neutral wind speed'
u10n
.
units
=
'm/s'
u10n
.
units
=
'm/s'
t10n
.
long_name
=
'10m neutral temperature'
t10n
.
long_name
=
'10m neutral temperature'
...
@@ -554,9 +557,18 @@ elif ((outF[-3:] != '.nc') and (outF[-4:] != '.csv')):
...
@@ -554,9 +557,18 @@ elif ((outF[-3:] != '.nc') and (outF[-4:] != '.csv')):
else
:
else
:
outF
=
outF
outF
=
outF
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
outS
=
input
(
"Give path and statistics file name:
\n
"
)
if
((
outS
==
''
)
and
(
inF
==
"data_all.csv"
)):
outS
=
"RV_"
+
ext
+
"_stats.txt"
elif
((
outS
==
''
)
and
(
inF
==
"era5_r360x180.nc"
)):
outS
=
"era5_"
+
ext
+
"_stats.txt"
elif
(
outS
[
-
4
:]
!=
'.txt'
):
outF
=
outS
+
".txt"
#------------------------------------------------------------------------------
print
(
"
\n
run_ASFC.py, started for method "
+
meth
)
print
(
"
\n
run_ASFC.py, started for method "
+
meth
)
res
,
lon
,
lat
=
toy_ASFC
(
inF
,
outF
,
gustIn
,
cskinIn
,
tolIn
,
meth
)
res
,
lon
,
lat
=
toy_ASFC
(
inF
,
outF
,
outS
,
gustIn
,
cskinIn
,
tolIn
,
meth
)
print
(
"run_ASFC.py took "
,
np
.
round
((
time
.
perf_counter
()
-
start_time
)
/
60
,
2
),
print
(
"run_ASFC.py took "
,
np
.
round
((
time
.
perf_counter
()
-
start_time
)
/
60
,
2
),
"minutes to run"
)
"minutes to run"
)
...
@@ -605,10 +617,11 @@ elif ((np.size(gustIn) < 3) and (gustIn == 0)):
...
@@ -605,10 +617,11 @@ elif ((np.size(gustIn) < 3) and (gustIn == 0)):
if
(
tolIn
==
None
):
if
(
tolIn
==
None
):
tolIn
=
[
'flux'
,
0.01
,
1
,
1
]
tolIn
=
[
'flux'
,
0.01
,
1
,
1
]
print
(
"Input summary"
,
file
=
open
(
'./stats.txt'
,
'a'
))
print
(
"Input summary"
,
file
=
open
(
'./'
+
outS
,
'a'
))
print
(
'input file name: {},
\n
method: {},
\n
gustiness: {},
\n
cskin: {},'
print
(
'input file name: {},
\n
method: {},
\n
gustiness: {},
\n
cskin: {},'
'
\n
tolerance: {}'
.
format
(
inF
,
meth
,
gustIn
,
cskinIn
,
tolIn
),
'
\n
tolerance: {}'
.
format
(
inF
,
meth
,
gustIn
,
cskinIn
,
tolIn
),
file
=
open
(
'./
stats.txt'
,
'a'
))
file
=
open
(
'./
'
+
outS
,
'a'
))
ttl
=
np
.
asarray
([
"tau "
,
"shf "
,
"lhf "
,
"L "
,
"cd "
,
"cdn "
,
ttl
=
np
.
asarray
([
"tau "
,
"shf "
,
"lhf "
,
"L "
,
"cd "
,
"cdn "
,
"ct "
,
"ctn "
,
"cq "
,
"cqn "
,
"tsrv "
,
"tsr "
,
"ct "
,
"ctn "
,
"cq "
,
"cqn "
,
"tsrv "
,
"tsr "
,
"qsr "
,
"usr "
,
"psim "
,
"psit "
,
"psiq "
,
"u10n "
,
"qsr "
,
"usr "
,
"psim "
,
"psit "
,
"psiq "
,
"u10n "
,
...
@@ -630,8 +643,8 @@ if (inF == 'era5_r360x180.nc'):
...
@@ -630,8 +643,8 @@ if (inF == 'era5_r360x180.nc'):
axis
=
0
)]
axis
=
0
)]
print
(
tabulate
(
stats
,
headers
=
header
,
tablefmt
=
"github"
,
numalign
=
"left"
,
print
(
tabulate
(
stats
,
headers
=
header
,
tablefmt
=
"github"
,
numalign
=
"left"
,
floatfmt
=
(
"s"
,
"2.2e"
,
"2.2e"
,
"2.2e"
,
"2.2e"
,
"2.2e"
,
floatfmt
=
(
"s"
,
"2.2e"
,
"2.2e"
,
"2.2e"
,
"2.2e"
,
"2.2e"
,
"2.2e"
)),
file
=
open
(
'./
stats.txt'
,
'a'
))
"2.2e"
)),
file
=
open
(
'./
'
+
outS
,
'a'
))
print
(
'-'
*
79
+
'
\n
'
,
file
=
open
(
'./
stats.txt'
,
'a'
))
print
(
'-'
*
79
+
'
\n
'
,
file
=
open
(
'./
'
+
outS
,
'a'
))
elif
(
inF
==
"data_all.csv"
):
elif
(
inF
==
"data_all.csv"
):
a
=
res
.
loc
[:,
"tau"
:
"rh"
].
to_numpy
(
dtype
=
"float64"
).
T
a
=
res
.
loc
[:,
"tau"
:
"rh"
].
to_numpy
(
dtype
=
"float64"
).
T
stats
=
np
.
c_
[
stats
,
np
.
nanmean
(
a
,
axis
=
1
)]
stats
=
np
.
c_
[
stats
,
np
.
nanmean
(
a
,
axis
=
1
)]
...
@@ -642,8 +655,9 @@ elif (inF == "data_all.csv"):
...
@@ -642,8 +655,9 @@ elif (inF == "data_all.csv"):
stats
=
np
.
c_
[
stats
,
np
.
nanpercentile
(
a
,
95
,
axis
=
1
)]
stats
=
np
.
c_
[
stats
,
np
.
nanpercentile
(
a
,
95
,
axis
=
1
)]
print
(
tabulate
(
stats
,
headers
=
header
,
tablefmt
=
"github"
,
numalign
=
"left"
,
print
(
tabulate
(
stats
,
headers
=
header
,
tablefmt
=
"github"
,
numalign
=
"left"
,
floatfmt
=
(
"s"
,
"2.2e"
,
"2.2e"
,
"2.2e"
,
"2.2e"
,
"2.2e"
,
floatfmt
=
(
"s"
,
"2.2e"
,
"2.2e"
,
"2.2e"
,
"2.2e"
,
"2.2e"
,
"2.2e"
)),
file
=
open
(
'./stats.txt'
,
'a'
))
"2.2e"
)),
print
(
'-'
*
79
+
'
\n
'
,
file
=
open
(
'./stats.txt'
,
'a'
))
file
=
open
(
'./'
+
outS
,
'a'
))
print
(
'-'
*
79
+
'
\n
'
,
file
=
open
(
'./'
+
outS
,
'a'
))
del
a
del
a
print
(
'input file name: {},
\n
method: {},
\n
gustiness: {},
\n
cskin: {},'
print
(
'input file name: {},
\n
method: {},
\n
gustiness: {},
\n
cskin: {},'
...
...
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