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)