Skip to content

Commit

Permalink
Modif to only replace the missing/filled snod values.
Browse files Browse the repository at this point in the history
  • Loading branch information
jiaruidong2017 committed Nov 13, 2024
1 parent 0c02522 commit e57ac67
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions parm/snow/ioda_bufr_python_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,35 @@
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)

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)
Expand Down

0 comments on commit e57ac67

Please sign in to comment.