From e57ac67561baee301284815a0edc233836bb64a6 Mon Sep 17 00:00:00 2001 From: Jiarui Dong Date: Wed, 13 Nov 2024 18:29:36 -0500 Subject: [PATCH] Modif to only replace the missing/filled snod values. --- parm/snow/ioda_bufr_python_encoder.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/parm/snow/ioda_bufr_python_encoder.py b/parm/snow/ioda_bufr_python_encoder.py index 1132b416f..f8f9c0f58 100644 --- a/parm/snow/ioda_bufr_python_encoder.py +++ b/parm/snow/ioda_bufr_python_encoder.py @@ -6,7 +6,6 @@ def mask_container(container, mask): new_container = bufr.DataContainer() for var_name in container.list(): - print(f" ... variable name: {var_name} ...") var = container.get(var_name) paths = container.get_paths(var_name) new_container.add(var_name, var[mask], paths) @@ -14,15 +13,28 @@ def mask_container(container, mask): return new_container def create_obs_group(input_path): + """Create the ioda snow observations + This method: + - reads state of ground (sogr) and snow depth (snod) + - applys sogr conditions to the missing snod values + - removes the filled/missing snow values and creates the masked container + - encoders the new container. + + Parameters + ---------- + input_path + The input bufr file + """ + YAML_PATH = "./obs/bufr_sfcsno_mapping.yaml" container = bufr.Parser(input_path, YAML_PATH).parse() sogr = container.get('variables/groundState') snod = container.get('variables/totalSnowDepth') - snod[(sogr <= 11.0) | (sogr == 15.0)] = 0.0 + snod[(sogr <= 11.0) & snod.mask] = 0.0 + snod[(sogr == 15.0) & snod.mask] = 0.0 container.replace('variables/totalSnowDepth', snod) - print(f" ... Remove filled/missing snow values ...") masked_container = mask_container(container, (~snod.mask)) encoder = Encoder(YAML_PATH)