From 55f965c0d20ea95624a0c1ae3b38dfa9942e5f94 Mon Sep 17 00:00:00 2001 From: lewa <lene.wasskog@nibio.no> Date: Mon, 27 May 2024 14:15:05 +0200 Subject: [PATCH] feat: Change to two warning statuses - green and red --- ADASMELIAE.cfg | 6 ++---- ADASMELIAE.py | 11 ++++------- mapfile/template.j2 | 24 ++++++------------------ 3 files changed, 12 insertions(+), 29 deletions(-) diff --git a/ADASMELIAE.cfg b/ADASMELIAE.cfg index 8709db1..5b2a9c7 100644 --- a/ADASMELIAE.cfg +++ b/ADASMELIAE.cfg @@ -3,13 +3,11 @@ languages=en,nb [i18n.en] -low_risk = Low migration risk -medium_risk = Medium migration risk -high_risk = High migration risk +low_risk = Low risk of migration of adult pollen beetle +high_risk = High risk of migration of adult pollen beetle temperature = Maximum air temperature [i18n.nb] low_risk = Lav migreringsrisiko -medium_risk = Middels migreringsrisiko high_risk = Høy migreringsrisiko temperature = Maksimum lufttemperatur \ No newline at end of file diff --git a/ADASMELIAE.py b/ADASMELIAE.py index 4894b41..707b5da 100755 --- a/ADASMELIAE.py +++ b/ADASMELIAE.py @@ -74,8 +74,7 @@ logging.basicConfig( tm_max = "air_temperature_2m_max" -THRESHOLD_HIGH = 15 -THRESHOLD_MEDIUM = 12 +THRESHOLD = 15 # Run given command using subprocess.run. Handle logging. @@ -190,12 +189,10 @@ if __name__ == "__main__": ) # Classifying warning status for the model - # temperature < 12 --> 2 (Yellow) - # 12 <= temperature < 15 --> 3 (Orange) - # temperature >= 15 --> 4 (Red) - logging.info(f"Calculate warning status by checking {tm_max}") + # temperature < 15 --> 2 (Green) + # temperature >= 15 --> 4 (Red) run_command( - 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}", + command=f'cdo -s -aexpr,"WARNING_STATUS = {tm_max} < {THRESHOLD} ? 2 : 4" {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. diff --git a/mapfile/template.j2 b/mapfile/template.j2 index 7004f2f..1181313 100644 --- a/mapfile/template.j2 +++ b/mapfile/template.j2 @@ -122,17 +122,12 @@ LAYER { \"classification\": 2, \"legendLabel\": \"{{ language.low_risk }}\", - \"legendIconCSS\": \"width: 25px; background-color: #FFDF00;\" - }, - { - \"classification\": 3, - \"legendLabel\": \"{{ language.medium_risk }}\", - \"legendIconCSS\": \"width: 25px; background-color: #FF8C00;\" + \"legendIconCSS\": \"width: 25px; background-color: #3ac47d;\" }, { \"classification\": 4, \"legendLabel\": \"{{ language.high_risk }}\", - \"legendIconCSS\": \"width: 25px; background-color: #FF0000;\" + \"legendIconCSS\": \"width: 25px; background-color: #d92550;\" } ] } @@ -145,23 +140,16 @@ LAYER CLASS NAME "Low infection risk" - EXPRESSION ([pixel] >= 0 AND [pixel] <= 2) - STYLE - COLOR 255 223 0 # Yellow - END - END - CLASS - NAME "Medium infection risk" - EXPRESSION ([pixel] > 2 AND [pixel] <= 3) + EXPRESSION ([pixel] >= 0 AND [pixel] < 15) STYLE - COLOR 255 140 0 # Orange + COLOR 58 196 125 # Green END END CLASS NAME "High infection risk" - EXPRESSION ([pixel] > 3) + EXPRESSION ([pixel] >= 15) STYLE - COLOR 255 0 0 # Red + COLOR 217 37 80 # Red END END END # Layer -- GitLab