Skip to content
Snippets Groups Projects
Commit 56f9baab authored by Lene Wasskog's avatar Lene Wasskog
Browse files

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
...@@ -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(
......
...@@ -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 migration risk" NAME "Low infection 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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment