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
56f9baab
Commit
56f9baab
authored
1 year ago
by
Lene Wasskog
Browse files
Options
Downloads
Patches
Plain Diff
feat: Add warning status medium risk
IDEC-461
parent
b4b2e417
No related branches found
No related tags found
No related merge requests found
Pipeline
#3762
passed
1 year ago
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ADASMELIAE.py
+9
-8
9 additions, 8 deletions
ADASMELIAE.py
mapfile/template.j2
+16
-4
16 additions, 4 deletions
mapfile/template.j2
with
25 additions
and
12 deletions
ADASMELIAE.py
+
9
−
8
View file @
56f9baab
...
@@ -73,7 +73,9 @@ logging.basicConfig(
...
@@ -73,7 +73,9 @@ logging.basicConfig(
)
)
tm_max
=
"
air_temperature_2m_max
"
tm_max
=
"
air_temperature_2m_max
"
THRESHOLD
=
15
THRESHOLD_HIGH
=
15
THRESHOLD_MEDIUM
=
12
# Run given command using subprocess.run. Handle logging.
# Run given command using subprocess.run. Handle logging.
...
@@ -188,13 +190,12 @@ if __name__ == "__main__":
...
@@ -188,13 +190,12 @@ if __name__ == "__main__":
)
)
# Classifying warning status for the model
# Classifying warning status for the model
# temperature < 15 --> 2 (Yellow)
# temperature < 12 --> 2 (Yellow)
# temperature >= 15 --> 4 (Red)
# 12 <= temperature < 15 --> 3 (Orange)
logging
.
info
(
# temperature >= 15 --> 4 (Red)
f
"
Calculate warning status by checking if
{
tm_max
}
is below or above
{
THRESHOLD
}
"
logging
.
info
(
f
"
Calculate warning status by checking
{
tm_max
}
"
)
)
run_command
(
run_command
(
command
=
f
"
cdo -s -aexpr,
'
WARNING_STATUS =
{
tm_max
}
<
{
THRESHOLD
}
? 2 :
4
'
{
max_temp_in_period_file
}
{
unmasked_result_file
}
"
,
command
=
f
"
cdo -s -aexpr,
'
WARNING_STATUS =
{
tm_max
}
<
{
THRESHOLD
_MEDIUM
}
? 2 :
-1; WARNING_STATUS =
{
tm_max
}
<
{
THRESHOLD_HIGH
}
&& WARNING_STATUS == -1 ? 3 : WARNING_STATUS ; WARNING_STATUS =
{
tm_max
}
>=
{
THRESHOLD_HIGH
}
&& WARNING_STATUS == -1 ? 4 : WARNING_STATUS
'
{
max_temp_in_period_file
}
{
unmasked_result_file
}
"
,
)
)
# Mask results using a CSV file with polygons. Env variable MASK_FILE must be set, or else we use the file as it is.
# Mask results using a CSV file with polygons. Env variable MASK_FILE must be set, or else we use the file as it is.
...
@@ -286,7 +287,7 @@ if __name__ == "__main__":
...
@@ -286,7 +287,7 @@ if __name__ == "__main__":
)
)
with
open
(
f
"
{
result_mapfile_dir
}
/
{
model_id
}
.map
"
,
"
w
"
)
as
f
:
with
open
(
f
"
{
result_mapfile_dir
}
/
{
model_id
}
.map
"
,
"
w
"
)
as
f
:
f
.
write
(
output
)
f
.
write
(
output
)
remove_temporary_files
()
#
remove_temporary_files()
end_time
=
time
.
time
()
end_time
=
time
.
time
()
logging
.
info
(
logging
.
info
(
...
...
This diff is collapsed.
Click to expand it.
mapfile/template.j2
+
16
−
4
View file @
56f9baab
...
@@ -128,6 +128,11 @@ LAYER
...
@@ -128,6 +128,11 @@ LAYER
\"legendLabel\": \"{{ language.low_risk }}\",
\"legendLabel\": \"{{ language.low_risk }}\",
\"legendIconCSS\": \"width: 25px; background-color: #FFCC00;\"
\"legendIconCSS\": \"width: 25px; background-color: #FFCC00;\"
},
},
{
\"classification\": 3,
\"legendLabel\": \"{{ language.medium_risk }}\",
\"legendIconCSS\": \"width: 25px; background-color: #FFCC99;\"
},
{
{
\"classification\": 4,
\"classification\": 4,
\"legendLabel\": \"{{ language.high_risk }}\",
\"legendLabel\": \"{{ language.high_risk }}\",
...
@@ -143,15 +148,22 @@ LAYER
...
@@ -143,15 +148,22 @@ LAYER
# class using simple string comparison, equivalent to ([pixel] = 0)
# class using simple string comparison, equivalent to ([pixel] = 0)
CLASS
CLASS
NAME "Low
migra
tion risk"
NAME "Low
infec
tion risk"
EXPRESSION ([pixel] >= 0 AND [pixel] <
3
)
EXPRESSION ([pixel] >= 0 AND [pixel] <
= 2
)
STYLE
STYLE
COLOR 255 204 0
COLOR 255 204 0
END
END
END
END
CLASS
CLASS
NAME "High migration risk"
NAME "Medium infection risk"
EXPRESSION ([pixel] >= 3)
EXPRESSION ([pixel] > 2 AND [pixel] <= 3)
STYLE
COLOR 255 153 0
END
END
CLASS
NAME "High infection risk"
EXPRESSION ([pixel] > 3)
STYLE
STYLE
COLOR 255 0 0
COLOR 255 0 0
END
END
...
...
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