-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the "state of ground" to bring in the extra snow depth reports #1368
base: develop
Are you sure you want to change the base?
Changes from all commits
1c8096f
365675d
aee4dc2
0c02522
e57ac67
4376049
244693c
76a5e94
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,11 @@ | |
halo size: 250e3 | ||
obsdatain: | ||
engine: | ||
type: bufr | ||
type: script | ||
script file: "{{ USHgfs }}/bufr2ioda_sfcsno_bufr_encoder.py" | ||
args: | ||
input_path: '{{ DATA }}/obs/{{ OPREFIX }}sfcsno.tm00.bufr_d' | ||
obsfile: '{{ DATA }}/obs/{{ OPREFIX }}sfcsno.tm00.bufr_d' | ||
Comment on lines
+11
to
12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't forget to add an issue so they do not assume the formatting of the YAML file (obsfile variable shoould not be necessary). Reading the backend engines YAML breaks encapsulation (external modules should not be dependent on the private configuration for a backend type. Some backends may not have any kind of file associated with them (like a db...). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes thanks @rmclaren I'm aware of that issue, I/we/others need to figure out how best to handle it on the workflow side. |
||
mapping file: '{{ DATA }}/obs/bufr_sfcsno_mapping.yaml' | ||
obsdataout: | ||
engine: | ||
type: H5File | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import numpy as np | ||
import bufr | ||
from pyioda.ioda.Engines.Bufr import Encoder | ||
|
||
|
||
def mask_container(container, mask): | ||
new_container = bufr.DataContainer() | ||
for var_name in container.list(): | ||
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) & snod.mask] = 0.0 | ||
snod[(sogr == 15.0) & snod.mask] = 0.0 | ||
container.replace('variables/totalSnowDepth', snod) | ||
|
||
masked_container = mask_container(container, (~snod.mask)) | ||
|
||
data = next(iter(Encoder(YAML_PATH).encode(masked_container).values())) | ||
|
||
return data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my understanding:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I previously put this large number (10000m) here for removing the missing values. Here, we don't need this any more because we need to set the missing snod values to 0 when sogr satisfies the defined conditions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might still have missing values though wouldn't we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The missing values will be removed after applying sogr conditions.