From e4d87080bca43b98e792aa0f89972924e3a12219 Mon Sep 17 00:00:00 2001 From: Florez Ospina Juan Felipe Date: Mon, 19 May 2025 17:10:16 +0200 Subject: [PATCH] Enable all flaggs for use in flagging app and display them in order according to their ranking (see app/flags/ebas_dict.yaml) --- app/components/flagging_dashboard.py | 2 +- app/data_flagging_utils.py | 14 ++++++++++---- app/flags/ebas_dict.yaml | 24 ++++++++++++------------ 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/app/components/flagging_dashboard.py b/app/components/flagging_dashboard.py index 693031f..8046092 100644 --- a/app/components/flagging_dashboard.py +++ b/app/components/flagging_dashboard.py @@ -33,7 +33,7 @@ flagging_dashboard = dbc.Row([ #dbc.Row([ dcc.Dropdown( id='flag-options', - options= data_flagging_utils.filter_flags_by_label(flags_dict,'I'), # displays only flags to invalidate + options= data_flagging_utils.filter_flags_by_label(flags_dict,'all'), # displays only flags to invalidate ), #], #width=12 diff --git a/app/data_flagging_utils.py b/app/data_flagging_utils.py index 01bb515..80e77f4 100644 --- a/app/data_flagging_utils.py +++ b/app/data_flagging_utils.py @@ -32,18 +32,24 @@ def save_file(name, content): def filter_flags_by_label(flags_dict, label): """ Filters the flags dictionary by the specified label. + If label is 'all', returns all flags without filtering. Parameters: ----------- flags_dict (dict): The dictionary containing flags. - label (str): The label to filter by ('I' or 'V'). + label (str): The label to filter by ('I', 'V', or 'all'). Returns: -------- - list: A list of dictionaries with 'label' and 'value' for the specified label. + list: A list of dictionaries with 'label' and 'value' for the specified label, + or all flags if label is 'all'. """ - return [{'label': value['description'], 'value': code} - for code, value in flags_dict.items() if value['validity'] == label] + return [ + {'label': value['description'], 'value': code} + for code, value in flags_dict.items() + if label == 'all' or value['validity'] == label + ] + def create_loaded_file_figure(file_path, instFolder, dataset_name, datetime_var, datetime_var_format, variables): diff --git a/app/flags/ebas_dict.yaml b/app/flags/ebas_dict.yaml index 58fd915..b7d2dbc 100644 --- a/app/flags/ebas_dict.yaml +++ b/app/flags/ebas_dict.yaml @@ -1,7 +1,4 @@ flags: - 0: - validity: "V" - description: "Valid measurement" 100: validity: "V" description: "Checked by data originator. Valid measurement, overrides any invalid flags" @@ -14,27 +11,30 @@ flags: 456: validity: "I" description: "Invalidated by data originator" - 460: - validity: "I" - description: "Contamination suspected" 559: validity: "V" description: "Unspecified contamination or local influence, but considered valid" - 599: - validity: "I" - description: "Unspecified contamination or local influence" 652: validity: "V" description: "Construction/activity nearby" - 659: - validity: "I" - description: "Unspecified instrument/sampling anomaly" 660: validity: "V" description: "Unspecified instrument/sampling anomaly" + 460: + validity: "I" + description: "Contamination suspected" + 599: + validity: "I" + description: "Unspecified contamination or local influence" + 659: + validity: "I" + description: "Unspecified instrument/sampling anomaly" 999: validity: "I" description: "Missing measurement, unspecified reason" + 0: + validity: "V" + description: "Valid measurement" # Define flag rankings with flag 0 as the absolute lowest flag_ranking : {100: 100, 110: 80, 111: 75, 456: 60, 559: 50, 652: 40, 660: 30, 460: 28, 599: 26, 659: 24, 999: 20, 0: 10}