From e09656d0e326ddaae4f7f98fc6a2f1eb56ad27e9 Mon Sep 17 00:00:00 2001 From: Andrew Tangborn Date: Tue, 4 Jun 2024 09:38:32 -0500 Subject: [PATCH 1/3] Added tasks to construct aero_diffparm.yaml from template. --- parm/config/gfs/config.aeroanlgenb | 4 ++++ ush/python/pygfs/task/aero_bmatrix.py | 12 +++++++++++- ush/python/pygfs/task/bmatrix.py | 27 +++++++++++++++++++++++++-- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/parm/config/gfs/config.aeroanlgenb b/parm/config/gfs/config.aeroanlgenb index 8f397375d5e..7d7fe4a0e5a 100644 --- a/parm/config/gfs/config.aeroanlgenb +++ b/parm/config/gfs/config.aeroanlgenb @@ -9,5 +9,9 @@ echo "BEGIN: config.aeroanlgenb" source "${EXPDIR}/config.resources" aeroanlgenb export BMATYAML="${PARMgfs}/gdas/aero/berror/aero_diagb.yaml.j2" +export DIFFYAML="${PARMgfs}/gdas/aero/berror/aero_diffparm.yaml.j2" +export iterations=10 +export fixed value=1.0 + echo "END: config.aeroanlgenb" diff --git a/ush/python/pygfs/task/aero_bmatrix.py b/ush/python/pygfs/task/aero_bmatrix.py index 6a559168579..7d45572831a 100644 --- a/ush/python/pygfs/task/aero_bmatrix.py +++ b/ush/python/pygfs/task/aero_bmatrix.py @@ -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") + _diff_yaml = os.path.join(self.runtime_config.DATA, f"{self.runtime_config.CDUMP}.t{self.runtime_config['cyc']:02d}z.chem_diff.yaml") # Create a local dictionary that is repeatedly used across this class local_dict = AttrDict( @@ -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, + 'diff_yaml': _diff_yaml, } ) @@ -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 diff YAML file: {self.task_config.diff_yaml}") + save_as_yaml(self.task_config.diff_config, self.task_config.diff_yaml) + logger.info(f"Wrote diff YAML to: {self.task_config.diff_yaml}") + # create output directory FileHandler({'mkdir': [os.path.join(self.task_config['DATA'], 'stddev')]}).sync() @@ -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_diff = os.path.join(self.task_config['DATA'], f"{self.task_config['CDUMP']}.t{self.runtime_config['cyc']:02d}z.chem_diff.yaml") + dest_diff = os.path.join(self.task_config.COM_CHEM_ANALYSIS, f"{self.task_config['CDUMP']}.t{self.runtime_config['cyc']:02d}z.chem_diff.yaml") yaml_copy = { 'mkdir': [self.task_config.COM_CHEM_ANALYSIS], - 'copy': [[src, dest]] + 'copy': [[src, dest]], + 'copy': [[src_diff, dest_diff]] } FileHandler(yaml_copy).sync() diff --git a/ush/python/pygfs/task/bmatrix.py b/ush/python/pygfs/task/bmatrix.py index 0c8696ff1a7..87b0517b706 100644 --- a/ush/python/pygfs/task/bmatrix.py +++ b/ush/python/pygfs/task/bmatrix.py @@ -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.diff_config = self.get_diff_config() def finalize(self) -> None: super().finalize() @@ -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 + return bmat_config + + def get_diff_config(self) -> Dict[str, Any]: + """Compile a dictionary of diffusion operator configuration from DIFFYAML template file + + Parameters + ---------- + diff_iter + fixed_val + horiz_len + + Returns + ---------- + diff_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.diff_yaml}") + diff_config = parse_j2yaml(self.task_config.DIFFYAML, self.task_config, searchpath=self.gdasapp_j2tmpl_dir) + logger.debug(f"DIFF config:\n{pformat(diff_config)}") + + return diff_config From 62457eb6deb07fc25db4cc55099f68c0b85281cc Mon Sep 17 00:00:00 2001 From: Andrew Tangborn Date: Tue, 4 Jun 2024 16:00:14 -0500 Subject: [PATCH 2/3] changed DIFF -> DIFFUSION and diff -> diffusion in files below --- parm/config/gfs/config.aeroanlgenb | 2 +- ush/python/pygfs/task/aero_bmatrix.py | 16 ++++++++-------- ush/python/pygfs/task/bmatrix.py | 20 ++++++++++---------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/parm/config/gfs/config.aeroanlgenb b/parm/config/gfs/config.aeroanlgenb index 7d7fe4a0e5a..c6d07b1dd38 100644 --- a/parm/config/gfs/config.aeroanlgenb +++ b/parm/config/gfs/config.aeroanlgenb @@ -9,7 +9,7 @@ echo "BEGIN: config.aeroanlgenb" source "${EXPDIR}/config.resources" aeroanlgenb export BMATYAML="${PARMgfs}/gdas/aero/berror/aero_diagb.yaml.j2" -export DIFFYAML="${PARMgfs}/gdas/aero/berror/aero_diffparm.yaml.j2" +export DIFFFFYAML="${PARMgfs}/gdas/aero/berror/aero_diffusionparm.yaml.j2" export iterations=10 export fixed value=1.0 diff --git a/ush/python/pygfs/task/aero_bmatrix.py b/ush/python/pygfs/task/aero_bmatrix.py index 7d45572831a..436142abc1b 100644 --- a/ush/python/pygfs/task/aero_bmatrix.py +++ b/ush/python/pygfs/task/aero_bmatrix.py @@ -25,7 +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") - _diff_yaml = os.path.join(self.runtime_config.DATA, f"{self.runtime_config.CDUMP}.t{self.runtime_config['cyc']:02d}z.chem_diff.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( @@ -42,7 +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, - 'diff_yaml': _diff_yaml, + 'diffusion_yaml': _diffusion_yaml, } ) @@ -66,9 +66,9 @@ def initialize(self: BMatrix) -> None: logger.info(f"Wrote bmat YAML to: {self.task_config.bmat_yaml}") # generate diffusion parameters YAML file - logger.debug(f"Generate diff YAML file: {self.task_config.diff_yaml}") - save_as_yaml(self.task_config.diff_config, self.task_config.diff_yaml) - logger.info(f"Wrote diff YAML to: {self.task_config.diff_yaml}") + 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() @@ -102,12 +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_diff = os.path.join(self.task_config['DATA'], f"{self.task_config['CDUMP']}.t{self.runtime_config['cyc']:02d}z.chem_diff.yaml") - dest_diff = os.path.join(self.task_config.COM_CHEM_ANALYSIS, f"{self.task_config['CDUMP']}.t{self.runtime_config['cyc']:02d}z.chem_diff.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_diff, dest_diff]] + 'copy': [[src_diffusion, dest_diffusion]] } FileHandler(yaml_copy).sync() diff --git a/ush/python/pygfs/task/bmatrix.py b/ush/python/pygfs/task/bmatrix.py index 87b0517b706..59b4683ff38 100644 --- a/ush/python/pygfs/task/bmatrix.py +++ b/ush/python/pygfs/task/bmatrix.py @@ -27,7 +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.diff_config = self.get_diff_config() + self.task_config.diffusion_config = self.get_diffusion_config() def finalize(self) -> None: super().finalize() @@ -50,26 +50,26 @@ def get_bmat_config(self) -> Dict[str, Any]: 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 + return bmat_config - def get_diff_config(self) -> Dict[str, Any]: - """Compile a dictionary of diffusion operator configuration from DIFFYAML template file + def get_diffusion_config(self) -> Dict[str, Any]: + """Compile a dictionary of diffusion operator configuration from DIFFUSIONYAML template file Parameters ---------- - diff_iter + diffusion_iter fixed_val horiz_len Returns ---------- - diff_config : Dict + 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.diff_yaml}") - diff_config = parse_j2yaml(self.task_config.DIFFYAML, self.task_config, searchpath=self.gdasapp_j2tmpl_dir) - logger.debug(f"DIFF config:\n{pformat(diff_config)}") + 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 diff_config + return diffusion_config From 17b6dcc3439fe18ca0590d4030d06ff346c13bc0 Mon Sep 17 00:00:00 2001 From: Cory Martin Date: Wed, 5 Jun 2024 15:19:46 -0400 Subject: [PATCH 3/3] Update parm/config/gfs/config.aeroanlgenb --- parm/config/gfs/config.aeroanlgenb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parm/config/gfs/config.aeroanlgenb b/parm/config/gfs/config.aeroanlgenb index c6d07b1dd38..6a2139ad016 100644 --- a/parm/config/gfs/config.aeroanlgenb +++ b/parm/config/gfs/config.aeroanlgenb @@ -9,7 +9,7 @@ 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" +export DIFFUSIONYAML="${PARMgfs}/gdas/aero/berror/aero_diffusionparm.yaml.j2" export iterations=10 export fixed value=1.0