From 0e01b88860f67d8c3e6d4d2813ffda8b4e9086e9 Mon Sep 17 00:00:00 2001 From: AndrewEichmann-NOAA Date: Fri, 17 Feb 2023 19:19:52 +0000 Subject: [PATCH 1/6] add eva plotting to vrfy script --- scripts/exgdas_global_marine_analysis_vrfy.py | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/scripts/exgdas_global_marine_analysis_vrfy.py b/scripts/exgdas_global_marine_analysis_vrfy.py index 53d0f660b..0299258d8 100755 --- a/scripts/exgdas_global_marine_analysis_vrfy.py +++ b/scripts/exgdas_global_marine_analysis_vrfy.py @@ -23,6 +23,7 @@ import xarray as xr import cartopy import cartopy.crs as ccrs +import subprocess def plot_config(grid_file=[], data_file=[], @@ -100,12 +101,18 @@ def plot_zonal_slice(config): comout = os.getenv('COMOUT') +data = os.getenv('DATA') cyc = os.getenv('cyc') bcyc = str((int(cyc) - 3) % 24) -# TODO: do not write to COM, instead dump figures in DATA and copy to COM. grid_file = os.path.join(comout, 'gdas.t'+bcyc+'z.ocngrid.nc') +# for eva +diagdir = os.path.join(comout, 'diags') +project_source_dir = os.getenv('PROJECT_SOURCE_DIR') +HOMEgfs = os.getenv('HOMEgfs') + + ####################################### # INCREMENT ####################################### @@ -189,3 +196,37 @@ def plot_zonal_slice(config): # Sea surface height config.update({'variable': 'ave_ssh', 'bounds': [0, 0.1]}) plot_horizontal_slice(config) + +####################################### +# eva plots + +evadir = os.path.join(HOMEgfs, 'sorc', 'gdas.cd', 'ush', 'eva') +yamlgen = os.path.join(evadir, 'gen_eva_obs_yaml.py') +marinetemplate = os.path.join(evadir, 'marine_gdas_plots.yaml') +marinepost = os.path.join(evadir, 'marine_eva_post.py') +varyaml = os.path.join(comout, 'yaml', 'var.yaml') + +# it would be better to refrence the dirs explicitly with the comout path +# but eva doesn't allow for specifying output directories +os.chdir(comout) +os.mkdir('preevayamls') +os.mkdir('evayamls') + +# mama, i'm sorry +runlist = [ yamlgen, '-i', varyaml, \ + '-t', marinetemplate, \ + '-o', 'preevayamls'] + +subprocess.run(runlist, check=True) + +files = os.listdir('preevayamls') +for file in files: + infile = os.path.join('preevayamls', file) + runlist = [ marinepost, '-i' , infile, '-o', 'evayamls', '-d', diagdir ] + subprocess.run(runlist, check=True) + +files = os.listdir('evayamls') +for file in files: + infile = os.path.join('evayamls', file) + print('running eva on', infile) + subprocess.run(['eva', infile], check=True) From f14eba78f4696166d1504704495fa73ac014b9bf Mon Sep 17 00:00:00 2001 From: AndrewEichmann-NOAA Date: Tue, 21 Feb 2023 19:29:38 +0000 Subject: [PATCH 2/6] fix bugs in yaml filename construction and mkdirs --- scripts/exgdas_global_marine_analysis_vrfy.py | 6 ++++-- ush/eva/gen_eva_obs_yaml.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/exgdas_global_marine_analysis_vrfy.py b/scripts/exgdas_global_marine_analysis_vrfy.py index 0299258d8..69d35fa27 100755 --- a/scripts/exgdas_global_marine_analysis_vrfy.py +++ b/scripts/exgdas_global_marine_analysis_vrfy.py @@ -209,8 +209,10 @@ def plot_zonal_slice(config): # it would be better to refrence the dirs explicitly with the comout path # but eva doesn't allow for specifying output directories os.chdir(comout) -os.mkdir('preevayamls') -os.mkdir('evayamls') +if not os.path.exists('preevayamls'): + os.makedirs('preevayamls') +if not os.path.exists('evayamls'): + os.makedirs('evayamls') # mama, i'm sorry runlist = [ yamlgen, '-i', varyaml, \ diff --git a/ush/eva/gen_eva_obs_yaml.py b/ush/eva/gen_eva_obs_yaml.py index 18a7a7818..5ec301b09 100755 --- a/ush/eva/gen_eva_obs_yaml.py +++ b/ush/eva/gen_eva_obs_yaml.py @@ -64,7 +64,7 @@ def gen_eva_obs_yaml(inputyaml, templateyaml, outputdir): # now loop over all observation spaces in input JEDI YAML file for obsspace in evaobs: name = obsspace['name'] - cycle = obsspace['diagfile'].split('_')[-2] + cycle = obsspace['diagfile'].split('.')[-2] logging.info(f'Now processing: {name}') # get the dictionary of replacements set up replacements = { From 177b36e5893e1854f29c59c93320ca07b34d672c Mon Sep 17 00:00:00 2001 From: AndrewEichmann-NOAA Date: Tue, 21 Feb 2023 21:15:08 +0000 Subject: [PATCH 3/6] python coding norms --- scripts/exgdas_global_marine_analysis_vrfy.py | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/scripts/exgdas_global_marine_analysis_vrfy.py b/scripts/exgdas_global_marine_analysis_vrfy.py index 69d35fa27..524d198c8 100755 --- a/scripts/exgdas_global_marine_analysis_vrfy.py +++ b/scripts/exgdas_global_marine_analysis_vrfy.py @@ -198,7 +198,7 @@ def plot_zonal_slice(config): plot_horizontal_slice(config) ####################################### -# eva plots +# eva plots evadir = os.path.join(HOMEgfs, 'sorc', 'gdas.cd', 'ush', 'eva') yamlgen = os.path.join(evadir, 'gen_eva_obs_yaml.py') @@ -207,28 +207,28 @@ def plot_zonal_slice(config): varyaml = os.path.join(comout, 'yaml', 'var.yaml') # it would be better to refrence the dirs explicitly with the comout path -# but eva doesn't allow for specifying output directories +# but eva doesn't allow for specifying output directories os.chdir(comout) if not os.path.exists('preevayamls'): - os.makedirs('preevayamls') + os.makedirs('preevayamls') if not os.path.exists('evayamls'): - os.makedirs('evayamls') + os.makedirs('evayamls') # mama, i'm sorry -runlist = [ yamlgen, '-i', varyaml, \ - '-t', marinetemplate, \ - '-o', 'preevayamls'] +runlist = [yamlgen, '-i', varyaml, + '-t', marinetemplate, + '-o', 'preevayamls'] subprocess.run(runlist, check=True) files = os.listdir('preevayamls') for file in files: - infile = os.path.join('preevayamls', file) - runlist = [ marinepost, '-i' , infile, '-o', 'evayamls', '-d', diagdir ] - subprocess.run(runlist, check=True) + infile = os.path.join('preevayamls', file) + runlist = [marinepost, '-i', infile, '-o', 'evayamls', '-d', diagdir] + subprocess.run(runlist, check=True) files = os.listdir('evayamls') for file in files: - infile = os.path.join('evayamls', file) - print('running eva on', infile) - subprocess.run(['eva', infile], check=True) + infile = os.path.join('evayamls', file) + print('running eva on', infile) + subprocess.run(['eva', infile], check=True) From f6033401eec63e7ab89806c986e17663751a7a20 Mon Sep 17 00:00:00 2001 From: AndrewEichmann-NOAA Date: Thu, 23 Feb 2023 15:50:00 +0000 Subject: [PATCH 4/6] remove superfluous and wrong env assignment --- scripts/exgdas_global_marine_analysis_vrfy.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/exgdas_global_marine_analysis_vrfy.py b/scripts/exgdas_global_marine_analysis_vrfy.py index 524d198c8..4a8edb98a 100755 --- a/scripts/exgdas_global_marine_analysis_vrfy.py +++ b/scripts/exgdas_global_marine_analysis_vrfy.py @@ -109,7 +109,6 @@ def plot_zonal_slice(config): # for eva diagdir = os.path.join(comout, 'diags') -project_source_dir = os.getenv('PROJECT_SOURCE_DIR') HOMEgfs = os.getenv('HOMEgfs') From 4e73f859ad0b9cb4cd41fe99210fda1f013feccf Mon Sep 17 00:00:00 2001 From: AndrewEichmann-NOAA Date: Thu, 23 Feb 2023 16:13:24 +0000 Subject: [PATCH 5/6] made this less embarrasing --- scripts/exgdas_global_marine_analysis_vrfy.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/scripts/exgdas_global_marine_analysis_vrfy.py b/scripts/exgdas_global_marine_analysis_vrfy.py index 4a8edb98a..b25e6e24c 100755 --- a/scripts/exgdas_global_marine_analysis_vrfy.py +++ b/scripts/exgdas_global_marine_analysis_vrfy.py @@ -23,6 +23,8 @@ import xarray as xr import cartopy import cartopy.crs as ccrs +import gen_eva_obs_yaml +import marine_eva_post import subprocess @@ -200,9 +202,7 @@ def plot_zonal_slice(config): # eva plots evadir = os.path.join(HOMEgfs, 'sorc', 'gdas.cd', 'ush', 'eva') -yamlgen = os.path.join(evadir, 'gen_eva_obs_yaml.py') marinetemplate = os.path.join(evadir, 'marine_gdas_plots.yaml') -marinepost = os.path.join(evadir, 'marine_eva_post.py') varyaml = os.path.join(comout, 'yaml', 'var.yaml') # it would be better to refrence the dirs explicitly with the comout path @@ -213,18 +213,12 @@ def plot_zonal_slice(config): if not os.path.exists('evayamls'): os.makedirs('evayamls') -# mama, i'm sorry -runlist = [yamlgen, '-i', varyaml, - '-t', marinetemplate, - '-o', 'preevayamls'] - -subprocess.run(runlist, check=True) +gen_eva_obs_yaml.gen_eva_obs_yaml(varyaml, marinetemplate, 'preevayamls') files = os.listdir('preevayamls') for file in files: infile = os.path.join('preevayamls', file) - runlist = [marinepost, '-i', infile, '-o', 'evayamls', '-d', diagdir] - subprocess.run(runlist, check=True) + marine_eva_post.marine_eva_post(infile,'evayamls',diagdir) files = os.listdir('evayamls') for file in files: From 7035829d44e0cc6dda09292473569eb0e564b025 Mon Sep 17 00:00:00 2001 From: AndrewEichmann-NOAA Date: Thu, 23 Feb 2023 16:16:51 +0000 Subject: [PATCH 6/6] python style --- scripts/exgdas_global_marine_analysis_vrfy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/exgdas_global_marine_analysis_vrfy.py b/scripts/exgdas_global_marine_analysis_vrfy.py index b25e6e24c..b6965d381 100755 --- a/scripts/exgdas_global_marine_analysis_vrfy.py +++ b/scripts/exgdas_global_marine_analysis_vrfy.py @@ -218,7 +218,7 @@ def plot_zonal_slice(config): files = os.listdir('preevayamls') for file in files: infile = os.path.join('preevayamls', file) - marine_eva_post.marine_eva_post(infile,'evayamls',diagdir) + marine_eva_post.marine_eva_post(infile, 'evayamls', diagdir) files = os.listdir('evayamls') for file in files: