Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Grid ADASMELIAE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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 ADASMELIAE
Commits
11217d46
Commit
11217d46
authored
11 months ago
by
Lene Wasskog
Browse files
Options
Downloads
Patches
Plain Diff
feat: Ensure warning status 0 on first day after model end date
parent
f8d1db2f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ADASMELIAE.py
+20
-8
20 additions, 8 deletions
ADASMELIAE.py
with
20 additions
and
8 deletions
ADASMELIAE.py
+
20
−
8
View file @
11217d46
...
...
@@ -133,7 +133,6 @@ def remove_old_results():
if
glob
.
glob
(
f
"
rm
{
result_mapfile_dir
}
*.map
"
):
run_command
(
command
=
f
"
rm
{
result_mapfile_dir
}
*.map
"
)
# Get unique dates in given file
def
get_unique_dates
(
input_file
):
result
=
run_command_get_output
(
f
"
cdo showdate
{
input_file
}
"
)
...
...
@@ -228,14 +227,23 @@ if __name__ == "__main__":
for
file
in
timestep_files
:
filename
=
os
.
path
.
basename
(
file
)
date_str
=
filename
.
split
(
"
_
"
)[
1
].
split
(
"
.
"
)[
0
]
current_file_date_str
=
filename
.
split
(
"
_
"
)[
1
].
split
(
"
.
"
)[
0
]
current_file_date
=
datetime
.
strptime
(
current_file_date_str
,
"
%Y-%m-%d
"
).
date
()
with
open
(
"
/dev/null
"
,
"
w
"
)
as
devnull
:
warning_status_lcc
=
f
"
{
tmp_dir
}
result_WARNING_STATUS_
{
date_str
}
_lcc.tif
"
result_lcc
=
f
"
{
tmp_dir
}
result_
{
date_str
}
_lcc.tif
"
warning_status
=
f
"
{
result_tif_dir
}
result_WARNING_STATUS_
{
date_str
}
.tif
"
result
=
f
"
{
result_tif_dir
}
result_
{
date_str
}
.tif
"
warning_status_lcc
=
f
"
{
tmp_dir
}
result_WARNING_STATUS_
{
current_file_date_str
}
_lcc.tif
"
result_lcc
=
f
"
{
tmp_dir
}
result_
{
current_file_date_str
}
_lcc.tif
"
warning_status
=
f
"
{
result_tif_dir
}
result_WARNING_STATUS_
{
current_file_date_str
}
.tif
"
result
=
f
"
{
result_tif_dir
}
result_
{
current_file_date_str
}
.tif
"
logging
.
debug
(
f
"
Calculate result for
{
current_file_date_str
}
"
)
logging
.
debug
(
f
"
Calculate result for
{
date_str
}
"
)
# Ensure warning status 0 for all points on first day after model end date
if
current_file_date
>
model_end_date
:
tmp_file
=
file
+
"
tmp
"
os
.
rename
(
file
,
tmp_file
)
run_command
(
command
=
f
'
cdo -s -aexpr,
"
WARNING_STATUS = 0
"
{
tmp_file
}
{
file
}
'
,
)
# For warning status:
run_command
(
...
...
@@ -247,7 +255,7 @@ if __name__ == "__main__":
command
=
f
"
gdal_translate -ot Float32 -of GTiff NETCDF:
'
{
file
}
'
:
{
tm_max
}
{
result_lcc
}
"
,
stdout
=
devnull
,
)
# Need to reproject the files, to ensure we have the projection given in the generted mapfile. We always use EPSG:4326 for this
# Need to reproject the files, to ensure we have the projection given in the gener
a
ted mapfile. We always use EPSG:4326 for this
run_command
(
command
=
f
"
gdalwarp -t_srs EPSG:4326
{
warning_status_lcc
}
{
warning_status
}
"
,
stdout
=
devnull
,
...
...
@@ -257,6 +265,10 @@ if __name__ == "__main__":
stdout
=
devnull
,
)
# Should not generate grey files for more than one day after model end date
if
current_file_date
>
model_end_date
:
break
# Generate mapfile
# Building data sets for language specific legends
languages
=
[]
...
...
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