-
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
2a72e4d
a2d87fd
fbd1bb9
db46314
91f160e
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,12 @@ | |
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' | ||
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. Suggestion:
This will make it clear that the script backend requires two inputs: bufr file and the mapping file 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. Thanks @emilyhcliu for the suggestions. I made the changes as suggested. |
||
mapping_path: '{{ DATA }}/obs/bufr_sfcsno_mapping.yaml' | ||
obsfile: '{{ DATA }}/obs/{{ OPREFIX }}sfcsno.tm00.bufr_d' | ||
mapping file: '{{ DATA }}/obs/bufr_sfcsno_mapping.yaml' | ||
obsdataout: | ||
engine: | ||
type: H5File | ||
|
@@ -54,7 +57,7 @@ | |
where: | ||
- variable: | ||
name: MetaData/stationElevation | ||
minvalue: -999.0 | ||
maxvalue: 999999999.9 | ||
- filter: Domain Check # land only | ||
where: | ||
- variable: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
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, mapping_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 | ||
mapping_path: The input bufr2ioda mapping file | ||
|
||
""" | ||
|
||
YAML_PATH = mapping_path | ||
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.