Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Grid SEPTREFHUM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VIPS
Models
GRID
Grid SEPTREFHUM
Commits
2f071e46
Commit
2f071e46
authored
1 year ago
by
Tor-Einar Skog
Browse files
Options
Downloads
Patches
Plain Diff
Add temperature threshold of 8 deg C for Wet hours
parent
69d24132
No related branches found
No related tags found
1 merge request
!3
Add temp threshold
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SEPTREFHUM.py
+7
-2
7 additions, 2 deletions
SEPTREFHUM.py
with
7 additions
and
2 deletions
SEPTREFHUM.py
+
7
−
2
View file @
2f071e46
...
...
@@ -52,8 +52,11 @@ tmpfile_path = "tmp/"
# Names of weather parameters in NetCDF files
RR
=
os
.
getenv
(
"
RR
"
)
UM
=
os
.
getenv
(
"
UM
"
)
TM
=
os
.
getenv
(
"
TM
"
)
local_timezone
=
pytz
.
timezone
(
os
.
getenv
(
"
LOCAL_TIMEZONE
"
))
TEMPERATURE_THRESHOLD
=
8.0
DEBUG
=
False
if
os
.
getenv
(
"
DEBUG
"
)
is
None
or
os
.
getenv
(
"
DEBUG
"
).
lower
()
==
"
false
"
else
True
...
...
@@ -103,7 +106,7 @@ for file_path in sorted(weatherdata_files):
wh_sum_date_str
=
wh_sum_date
.
strftime
(
"
%Y-%m-%d
"
)
wh_sum_hour_str
=
wh_sum_date
.
strftime
(
"
%H
"
)
subprocess
.
run
(
f
'
cdo -s -O -setdate,
{
wh_sum_date_str
}
-settime,
{
wh_sum_hour_str
}
:00:00 -chname,WH,WH_DAYSUM -timsum -selname,WH -aexpr,
"
WH =
{
RR
}
> 0.2 ||
{
UM
}
> 88.0 ? 1 : 0;
"
{
file_path
}
{
tmpfile_path
}
wh_
{
wh_sum_date_str
}
.nc
'
,
f
'
cdo -s -O -setdate,
{
wh_sum_date_str
}
-settime,
{
wh_sum_hour_str
}
:00:00 -chname,WH,WH_DAYSUM -timsum -selname,WH -aexpr,
"
WH =
(
{
TM
}
>=
{
TEMPERATURE_THRESHOLD
}
&& (
{
RR
}
> 0.2 ||
{
UM
}
> 88.0
))
? 1 : 0;
"
{
file_path
}
{
tmpfile_path
}
wh_
{
wh_sum_date_str
}
.nc
'
,
shell
=
True
)
...
...
@@ -175,6 +178,8 @@ subprocess.run(f'cdo -s -seltimestep,1/{number_of_timesteps_to_keep} {tmpfile_pa
# 40 <= WHS --> Red
subprocess
.
run
(
f
'
cdo -s -aexpr,
"
WARNING_STATUS = WHS <= 0 ? 0 : -1; WARNING_STATUS = WHS < 20 && WARNING_STATUS == -1 ? 2 : WARNING_STATUS; WARNING_STATUS = WHS < 40 && WARNING_STATUS == -1 ? 3 : WARNING_STATUS; WARNING_STATUS = WHS >= 40 && WARNING_STATUS == -1 ? 4 : WARNING_STATUS
"
{
tmpfile_path
}
wh_3daysum.nc
{
tmpfile_path
}
result_unmasked.nc
'
,
shell
=
True
)
subprocess
.
run
(
f
"
rm
{
tmpfile_path
}
result.nc
"
,
shell
=
True
)
# Mask results using a CSV file with polygons
# Env variable MASK_FILE must be set
if
os
.
getenv
(
"
MASK_FILE
"
)
is
not
None
:
...
...
@@ -247,5 +252,5 @@ with open(f"{mapfile_outdir}/{model_id}.map", 'w') as f:
# Remove all temporary/intermediary files
subprocess
.
run
(
f
"
rm
{
tmpfile_path
}
wh_3daysum*.nc
"
,
shell
=
True
)
subprocess
.
run
(
f
"
rm
{
tmpfile_path
}
result*.nc
"
,
shell
=
True
)
subprocess
.
run
(
f
"
rm
{
tmpfile_path
}
result
_
*.nc
"
,
shell
=
True
)
subprocess
.
run
(
f
"
rm
{
tmpfile_path
}
result*.tif
"
,
shell
=
True
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment