Skip to content

Commit

Permalink
jinja2 templates in snow DA (#947)
Browse files Browse the repository at this point in the history
This PR:
- updates the snowDA yamls to jinja2 templates removing all `$( )` and
`${ }` template forms.
- all inclusion is now performed via jinja2 `include` with the
appropriate indentation.
- jinja2 templates for yamls now carry a `.j2` extension to identify
them as templates.
- requires `feature/jinja2_includes` branch from `wxflow`. 

`parse_j2yaml` from `wxflow` now does not render the `$( )` templates.
This change is **not** backwards compatible.

Corressponding PRs in `wxflow` and `global-workflow` are:
- NOAA-EMC/wxflow#15
- NOAA-EMC/global-workflow#2371
  • Loading branch information
aerorahul authored Mar 4, 2024
1 parent 79f1b02 commit 37a28d1
Show file tree
Hide file tree
Showing 19 changed files with 394 additions and 388 deletions.
31 changes: 0 additions & 31 deletions parm/snow/hofx/hofx_nomodel.yaml

This file was deleted.

35 changes: 35 additions & 0 deletions parm/snow/hofx/hofx_nomodel.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
time window:
begin: '{{ SNOW_WINDOW_BEGIN | to_isotime }}'
length: {{ SNOW_WINDOW_LENGTH }}
geometry:
fms initialization:
namelist filename: '{{ DATA }}/fv3jedi/fmsmpp.nml'
field table filename: '{{ DATA }}/fv3jedi/field_table'
akbk: '{{ DATA }}/fv3jedi/akbk.nc4'
layout:
- {{ layout_x }}
- {{ layout_y }}
npx: {{ npx_ges }}
npy: {{ npy_ges }}
npz: {{ npz_ges }}
field metadata override: '{{ DATA }}/fv3jedi/fv3jedi_fieldmetadata_restart.yaml'
time invariant fields:
state fields:
datetime: '{{ SNOW_WINDOW_BEGIN | to_isotime }}'
filetype: fms restart
skip coupler file: true
state variables: [orog_filt]
datapath: '{{ FIXgfs }}/fix_orog/{{ CASE }}/'
filename_orog: '{{ CASE }}_oro_data.nc'
state:
datapath: '{{ DATA }}/bkg'
filetype: fms restart
datetime: '{{ current_cycle | to_isotime }}'
filename_sfcd: '{{ current_cycle | to_fv3time }}.sfc_data.nc'
filename_cplr: '{{ current_cycle | to_fv3time }}.coupler.res'
state variables: [snwdph,vtype,slmsk]
observations:
{% filter indent(width=2) %}
{% set snow_obs_list = 'OBS_LIST' | getenv('snow/obs/lists/gdas_snow.yaml.j2') %}
{% include snow_obs_list %}
{% endfilter %}
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
geometry:
fms initialization:
namelist filename: $(DATA)/fv3jedi/fmsmpp.nml
field table filename: $(DATA)/fv3jedi/field_table
akbk: $(DATA)/fv3jedi/akbk.nc4
namelist filename: {{ DATA }}/fv3jedi/fmsmpp.nml
field table filename: {{ DATA }}/fv3jedi/field_table
akbk: {{ DATA }}/fv3jedi/akbk.nc4
layout:
- $(layout_x)
- $(layout_y)
npx: $(npx_ges)
npy: $(npy_ges)
npz: $(npz_ges)
field metadata override: $(DATA)/fv3jedi/fv3jedi_fieldmetadata_restart.yaml
- {{ layout_x }}
- {{ layout_y }}
npx: {{ npx_ges }}
npy: {{ npy_ges }}
npz: {{ npz_ges }}
field metadata override: {{ DATA }}/fv3jedi/fv3jedi_fieldmetadata_restart.yaml
time invariant fields:
state fields:
datetime: '{{ SNOW_WINDOW_BEGIN | to_isotime }}'
filetype: fms restart
skip coupler file: true
state variables: [orog_filt]
datapath: $(FIXgfs)/orog/${CASE}/
filename_orog: $(CASE).mx$(OCNRES)_oro_data.nc
datapath: {{ FIXgfs }}/orog/{{ CASE }}/
filename_orog: {{ CASE }}.mx{{ OCNRES }}_oro_data.nc

time window:
begin: '{{ SNOW_WINDOW_BEGIN | to_isotime }}'
length: $(SNOW_WINDOW_LENGTH)
length: {{ SNOW_WINDOW_LENGTH }}
bound to include: begin

background:
Expand All @@ -31,14 +31,18 @@ background:
datetime: '{{ current_cycle | to_isotime }}'
filetype: fms restart
state variables: [snodl,vtype,slmsk]
datapath: $(DATA)/bkg/mem%mem%/RESTART
datapath: {{ DATA }}/bkg/mem%mem%/RESTART
filename_sfcd: '{{ current_cycle | to_fv3time }}.sfc_data.nc'
filename_cplr: '{{ current_cycle | to_fv3time }}.coupler.res'
pattern: '%mem%'
nmembers: 2
zero padding: 3

observations: !INC ${OBS_LIST}
observations:
{% filter indent(width=2) %}
{% set snow_obs_list = 'OBS_LIST' | getenv('snow/obs/lists/obs_list.yaml.j2') %}
{% include snow_obs_list %}
{% endfilter %}

driver:
save posterior mean: false
Expand All @@ -53,7 +57,7 @@ local ensemble DA:
mult: 1.0

output increment:
datapath: $(DATA)/anl
datapath: {{ DATA }}/anl
prefix: snowinc
filetype: fms restart
filename_sfcd: '{{ current_cycle | to_fv3time }}.sfc_data.nc'
Expand Down
110 changes: 0 additions & 110 deletions parm/snow/obs/config/adpsfc_snow.yaml

This file was deleted.

109 changes: 109 additions & 0 deletions parm/snow/obs/config/adpsfc_snow.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
- obs space:
name: adpsfc_snow
distribution:
name: Halo
halo size: 250e3
obsdatain:
engine:
type: H5File
obsfile: '{{ DATA }}/obs/{{ OPREFIX }}adpsfc_snow.nc4'
obsdataout:
engine:
type: H5File
obsfile: '{{ DATA }}/diags/diag_adpsfc_snow.nc4'
simulated variables: [totalSnowDepth]
obs operator:
name: Composite
components:
- name: Identity
- name: BackgroundErrorIdentity
obs error:
covariance model: diagonal
obs localizations:
- localization method: Horizontal SOAR
lengthscale: 250e3
soar horizontal decay: 0.000021
max nobs: 50
- localization method: Vertical Brasnett
vertical lengthscale: 700
obs pre filters:
- filter: Perform Action
filter variables:
- name: totalSnowDepth
action:
name: assign error
error parameter: 40.0
- filter: Variable Assignment
assignments:
- name: GrossErrorProbability/totalSnowDepth
type: float
value: 0.02
- name: BkgError/totalSnowDepth_background_error
type: float
value: 30.0
obs prior filters:
- filter: Bounds Check
filter variables:
- name: totalSnowDepth
minvalue: 0.0
maxvalue: 2000.0
action:
name: reject
- filter: Domain Check
where:
- variable:
name: MetaData/stationElevation
minvalue: -999.0
- filter: Domain Check # land only
where:
- variable:
name: GeoVaLs/slmsk
minvalue: 0.5
maxvalue: 1.5
- filter: RejectList # no land-ice
where:
- variable:
name: GeoVaLs/vtype
minvalue: 14.5
maxvalue: 15.5
- filter: BlackList
where:
- variable:
name: MetaData/stationIdentification
is_in: [71120,71397,71621,71727,71816]
size where true: 5
obs post filters:
- filter: Background Check # gross error check
filter variables:
- name: totalSnowDepth
threshold: 6.25
action:
name: reject
- filter: Temporal Thinning
min_spacing: '{{ SNOW_WINDOW_LENGTH }}'
seed_time: '{{ current_cycle | to_isotime }}'
category_variable:
name: MetaData/stationIdentification
- filter: Met Office Buddy Check
filter variables:
- name: totalSnowDepth
rejection_threshold: 0.5
traced_boxes: # trace all observations
min_latitude: -90
max_latitude: 90
min_longitude: -180
max_longitude: 180
search_radius: 150 # km
station_id_variable:
name: MetaData/stationIdentification
num_zonal_bands: 24
sort_by_pressure: false
max_total_num_buddies: 15
max_num_buddies_from_single_band: 10
max_num_buddies_with_same_station_id: 5
use_legacy_buddy_collector: false
horizontal_correlation_scale: { "-90": 150, "90": 150 }
temporal_correlation_scale: PT6H
damping_factor_1: 1.0
damping_factor_2: 1.0
background_error_group: BkgError
Loading

0 comments on commit 37a28d1

Please sign in to comment.