Skip to content
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

Added tasks to construct aero_diffparm.yaml from template. #3

Merged
merged 3 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions parm/config/gfs/config.aeroanlgenb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ echo "BEGIN: config.aeroanlgenb"
source "${EXPDIR}/config.resources" aeroanlgenb

export BMATYAML="${PARMgfs}/gdas/aero/berror/aero_diagb.yaml.j2"
export DIFFFFYAML="${PARMgfs}/gdas/aero/berror/aero_diffusionparm.yaml.j2"
CoryMartin-NOAA marked this conversation as resolved.
Show resolved Hide resolved
export iterations=10
export fixed value=1.0


echo "END: config.aeroanlgenb"
12 changes: 11 additions & 1 deletion ush/python/pygfs/task/aero_bmatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def __init__(self, config: Dict[str, Any]) -> None:
_res_anl = int(self.config['CASE_ANL'][1:])

_bmat_yaml = os.path.join(self.runtime_config.DATA, f"{self.runtime_config.CDUMP}.t{self.runtime_config['cyc']:02d}z.chem_diagb.yaml")
_diffusion_yaml = os.path.join(self.runtime_config.DATA, f"{self.runtime_config.CDUMP}.t{self.runtime_config['cyc']:02d}z.chem_diffusion.yaml")

# Create a local dictionary that is repeatedly used across this class
local_dict = AttrDict(
Expand All @@ -41,6 +42,7 @@ def __init__(self, config: Dict[str, Any]) -> None:
'APREFIX': f"{self.runtime_config.CDUMP}.t{self.runtime_config.cyc:02d}z.", # TODO: CDUMP is being replaced by RUN
'GPREFIX': f"gdas.t{self.runtime_config.previous_cycle.hour:02d}z.",
'bmat_yaml': _bmat_yaml,
'diffusion_yaml': _diffusion_yaml,
}
)

Expand All @@ -63,6 +65,11 @@ def initialize(self: BMatrix) -> None:
save_as_yaml(self.task_config.bmat_config, self.task_config.bmat_yaml)
logger.info(f"Wrote bmat YAML to: {self.task_config.bmat_yaml}")

# generate diffusion parameters YAML file
logger.debug(f"Generate diffusion YAML file: {self.task_config.diffusion_yaml}")
save_as_yaml(self.task_config.diffusion_config, self.task_config.diffusion_yaml)
logger.info(f"Wrote diffusion YAML to: {self.task_config.diffusion_yaml}")

# create output directory
FileHandler({'mkdir': [os.path.join(self.task_config['DATA'], 'stddev')]}).sync()

Expand Down Expand Up @@ -95,9 +102,12 @@ def finalize(self) -> None:
# copy full YAML from executable to ROTDIR
src = os.path.join(self.task_config['DATA'], f"{self.task_config['CDUMP']}.t{self.runtime_config['cyc']:02d}z.chem_diagb.yaml")
dest = os.path.join(self.task_config.COM_CHEM_ANALYSIS, f"{self.task_config['CDUMP']}.t{self.runtime_config['cyc']:02d}z.chem_diagb.yaml")
src_diffusion = os.path.join(self.task_config['DATA'], f"{self.task_config['CDUMP']}.t{self.runtime_config['cyc']:02d}z.chem_diffusion.yaml")
dest_diffusion = os.path.join(self.task_config.COM_CHEM_ANALYSIS, f"{self.task_config['CDUMP']}.t{self.runtime_config['cyc']:02d}z.chem_diffusion.yaml")
yaml_copy = {
'mkdir': [self.task_config.COM_CHEM_ANALYSIS],
'copy': [[src, dest]]
'copy': [[src, dest]],
'copy': [[src_diffusion, dest_diffusion]]
}
FileHandler(yaml_copy).sync()

Expand Down
25 changes: 24 additions & 1 deletion ush/python/pygfs/task/bmatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def initialize(self) -> None:
super().initialize()
# all BMatrix tasks need a config
self.task_config.bmat_config = self.get_bmat_config()
self.task_config.diffusion_config = self.get_diffusion_config()

def finalize(self) -> None:
super().finalize()
Expand All @@ -44,9 +45,31 @@ def get_bmat_config(self) -> Dict[str, Any]:
a dictionary containing the fully rendered B matrix yaml configuration
"""

# generate JEDI YAML file
# generate JEDI YAML file for stddev
logger.info(f"Generate B Matrix YAML config: {self.task_config.bmat_yaml}")
bmat_config = parse_j2yaml(self.task_config.BMATYAML, self.task_config, searchpath=self.gdasapp_j2tmpl_dir)
logger.debug(f"BMAT config:\n{pformat(bmat_config)}")

return bmat_config

def get_diffusion_config(self) -> Dict[str, Any]:
"""Compile a dictionary of diffusion operator configuration from DIFFUSIONYAML template file

Parameters
----------
diffusion_iter
fixed_val
horiz_len

Returns
----------
diffusion_config : Dict
a dictionary containing the fully rendered diffusion operator yaml configuration
"""

# generate JEDI YAML file for diffusion parameters
logger.info(f"Generate Diff Parmameter YAML config: {self.task_config.diffusion_yaml}")
diffusion_config = parse_j2yaml(self.task_config.DIFFUSIONYAML, self.task_config, searchpath=self.gdasapp_j2tmpl_dir)
logger.debug(f"DIFFUSION config:\n{pformat(diffusion_config)}")

return diffusion_config
Loading