diff --git a/ush/soca/soca_vrfy.py b/ush/soca/soca_vrfy.py index a4060fecd..6ad0ec27e 100755 --- a/ush/soca/soca_vrfy.py +++ b/ush/soca/soca_vrfy.py @@ -43,7 +43,7 @@ def plotConfig(grid_file=[], 'ave_ssh': 'meter', 'Temp': 'deg C', 'Salt': 'psu', - 'aice_h': 'meter', + 'aice_h': 'unitless', 'hi_h': 'meter', 'hs_h': 'meter', 'u': 'm/s', diff --git a/utils/soca/fig_gallery/exgdas_global_marine_analysis_vrfy_manual.py b/utils/soca/fig_gallery/exgdas_global_marine_analysis_vrfy_manual.py index ccb37a55c..e824376a6 100644 --- a/utils/soca/fig_gallery/exgdas_global_marine_analysis_vrfy_manual.py +++ b/utils/soca/fig_gallery/exgdas_global_marine_analysis_vrfy_manual.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import os import numpy as np import gen_eva_obs_yaml @@ -11,11 +13,19 @@ com_ice_history = os.getenv('COM_ICE_HISTORY_PREV') com_ocean_history = os.getenv('COM_OCEAN_HISTORY_PREV') cyc = os.getenv('cyc') +bcyc = os.getenv('bcyc') +gcyc = os.getenv('gcyc') RUN = os.getenv('RUN') -bcyc = str((int(cyc) - 3) % 24).zfill(2) -gcyc = str((int(cyc) - 6) % 24).zfill(2) -grid_file = os.path.join(comout, f'{RUN}.t'+bcyc+'z.ocngrid.nc') +# Construct the first potential grid_file path +vrfy_grid_file = os.path.join(comout, f'{RUN}.t'+bcyc+'z.ocngrid.nc') + +# Check if the file exists, then decide on grid_file +if os.path.exists(vrfy_grid_file): + grid_file = vrfy_grid_file +else: + grid_file = '/scratch1/NCEPDEV/da/common/validation/vrfy/gdas.t21z.ocngrid.nc' + layer_file = os.path.join(comout, f'{RUN}.t'+cyc+'z.ocninc.nc') # for eva @@ -26,7 +36,8 @@ run_ensemble_analysis = os.getenv('RUN_ENSENBLE_ANALYSIS', 'OFF').upper() == 'ON' run_bkgerr_analysis = os.getenv('RUN_BACKGROUND_ERROR_ANALYSIS', 'OFF').upper() == 'ON' run_bkg_analysis = os.getenv('RUN_BACKGROUND_ANALYSIS', 'OFF').upper() == 'ON' -run_increment_analysis = os.getenv('RUN_INCREMENT_ANLYSIS', 'OFF').upper() == 'ON' +run_increment_analysis = os.getenv('RUN_INCREMENT_ANALYSIS', 'OFF').upper() == 'ON' +run_eva_analysis = os.getenv('RUN_EVA_ANALYSIS', 'OFF').upper() == 'ON' # Initialize an empty list for the main config configs = [plotConfig(grid_file=grid_file, @@ -76,23 +87,32 @@ if run_bkgerr_analysis: config_bkgerr = [plotConfig(grid_file=grid_file, + data_file=os.path.join(comout, os.path.pardir, os.path.pardir, + 'bmatrix', 'ice', f'{RUN}.t'+cyc+'z.ice.bkgerr_stddev.nc'), + variables_horiz={'aice_h': [0.0, 0.5], + 'hi_h': [0.0, 2.0], + 'hs_h': [0.0, 0.2]}, + colormap='jet', + projs=['North', 'South', 'Global'], + comout=os.path.join(comout, 'vrfy', 'bkgerr')), # sea ice baigerr stddev + plotConfig(grid_file=grid_file, layer_file=layer_file, data_file=os.path.join(comout, os.path.pardir, os.path.pardir, - 'bmatrix', 'ocean', f'{RUN}.t'+cyc+'z.ocean.bkgerr_stddev.nc'), + 'bmatrix', 'ocean', f'{RUN}.t'+cyc+'z.ocean.bkgerr_stddev.nc'), lats=np.arange(-60, 60, 10), lons=np.arange(-280, 80, 30), variables_zonal={'Temp': [0, 2], 'Salt': [0, 0.2], - 'u': [0, 0.2], - 'v': [0, 0.2]}, + 'u': [0, 5], + 'v': [0, 5]}, variables_meridional={'Temp': [0, 2], 'Salt': [0, 0.2], - 'u': [0, 0.2], - 'v': [0, 0.2]}, + 'u': [0, 5], + 'v': [0, 5]}, variables_horiz={'Temp': [0, 2], 'Salt': [0, 0.2], - 'u': [0, 0.2], - 'v': [0, 0.2], + 'u': [0, 5], + 'v': [0, 5], 'ave_ssh': [0, 0.1]}, colormap='jet', comout=os.path.join(comout, 'vrfy', 'bkgerr'))] # ocn bkgerr stddev @@ -113,12 +133,18 @@ lats=np.arange(-60, 60, 10), lons=np.arange(-280, 80, 30), variables_zonal={'Temp': [-1.8, 34.0], - 'Salt': [32, 40]}, + 'Salt': [32, 40], + 'u': [-1.0, 1.0], + 'v': [-1.0, 1.0]}, variables_meridional={'Temp': [-1.8, 34.0], - 'Salt': [32, 40]}, + 'Salt': [32, 40], + 'u': [-1.0, 1.0], + 'v': [-1.0, 1.0]}, variables_horiz={'ave_ssh': [-1.8, 1.3], 'Temp': [-1.8, 34.0], - 'Salt': [32, 40]}, + 'Salt': [32, 40], + 'u': [-1.0, 1.0], + 'v': [-1.0, 1.0]}, colormap='nipy_spectral', comout=os.path.join(comout, 'vrfy', 'bkg'))] configs.extend(config_bkg) @@ -185,32 +211,33 @@ def plot_marine_vrfy(config): ####################################### # eva plots ####################################### - -evadir = os.path.join(HOMEgfs, 'sorc', f'{RUN}.cd', 'ush', 'eva') -marinetemplate = os.path.join(evadir, 'marine_gdas_plots.yaml') -varyaml = os.path.join(comout, 'yaml', 'var_original.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(os.path.join(comout, 'vrfy')) -if not os.path.exists('preevayamls'): - os.makedirs('preevayamls') -if not os.path.exists('evayamls'): - os.makedirs('evayamls') - -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) - marine_eva_post.marine_eva_post(infile, 'evayamls', diagdir) - -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) - +if run_eva_analysis: + evadir = os.path.join(HOMEgfs, 'sorc', f'{RUN}.cd', 'ush', 'eva') + marinetemplate = os.path.join(evadir, 'marine_gdas_plots.yaml') + 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(os.path.join(comout, 'vrfy')) + if not os.path.exists('preevayamls'): + os.makedirs('preevayamls') + if not os.path.exists('evayamls'): + os.makedirs('evayamls') + + 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) + marine_eva_post.marine_eva_post(infile, 'evayamls', diagdir) + + 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) +else: + print("RUN_EVA_PLOT is set to OFF. Skipping EVA plot generation.") ####################################### # calculate diag statistics ####################################### diff --git a/utils/soca/fig_gallery/run_marine_analysis_vrfy_manual.job b/utils/soca/fig_gallery/run_marine_analysis_vrfy_manual.job index 38ce48ffc..c9b9145cb 100644 --- a/utils/soca/fig_gallery/run_marine_analysis_vrfy_manual.job +++ b/utils/soca/fig_gallery/run_marine_analysis_vrfy_manual.job @@ -11,10 +11,18 @@ #SBATCH --mem=24GB # Request 24GB of memory #SBATCH --time=00:30:00 # Set the walltime limit to 30 minutes -# Define HOMEgfs -export HOMEgfs="/scratch1/NCEPDEV/da/Mindo.Choi/workflow_11122024/global-workflow/" +# Define Your HOMEgfs +export HOMEgfs="/scratch1/NCEPDEV/da/Mindo.Choi/wk_01152025/global-workflow/" + +# Define Base_Direcrory (to the achieves for v2) +base_dir="/scratch1/NCEPDEV/global/John.Steffen/hpss_arch/marine_test_112024_v2" + +# Define Target Date and cycle +tdate="20210701" +cyc="00" # Load EVA module +module purge module use ${HOMEgfs}sorc/gdas.cd/modulefiles module load EVA/hera @@ -28,18 +36,34 @@ $PYTHONPATH" export RUN_ENSENBLE_ANALYSIS=OFF # Check if ensemble run is ON export RUN_BACKGROUND_ERROR_ANALYSIS=ON export RUN_BACKGROUND_ANALYSIS=ON -export RUN_INCREMENT_ANLYSIS=ON +export RUN_INCREMENT_ANALYSIS=ON +export RUN_EVA_ANALYSIS=ON # Define and export the environment variables -export cyc="00" +# Calculate bcyc and gcyc +bcyc=$(printf "%02d" $(( (10#$cyc - 3 + 24) % 24 ))) +gcyc=$(printf "%02d" $(( (10#$cyc - 6 + 24) % 24 ))) + +# Determine PDY_PREV if cyc is "00" +if [ "$cyc" == "00" ]; then + PDY_PREV=$(date -d "$tdate -1 day" +%Y%m%d) +else + PDY_PREV="$tdate" +fi + +# Export the necessary environment variables +export cyc="$cyc" +export bcyc="$bcyc" +export gcyc="$gcyc" +export PDY="$tdate" +export PDY_PREV="$PDY_PREV" export RUN="gdas" export PSLOT="gdas_test" -export PDY="20210827" # Define and export environment variables with paths -export COM_OCEAN_ANALYSIS="/scratch1/NCEPDEV/da/Mindo.Choi/sandbox/marine_vrfy/gdas.20210827/00/analysis/ocean" -export COM_ICE_HISTORY_PREV="/scratch1/NCEPDEV/da/Mindo.Choi/sandbox/marine_vrfy/gdas.20210826/18/model/ice/history" -export COM_OCEAN_HISTORY_PREV="/scratch1/NCEPDEV/da/Mindo.Choi/sandbox/marine_vrfy/gdas.20210826/18/model/ocean/history" +export COM_OCEAN_ANALYSIS="${base_dir}/${tdate}${cyc}/${RUN}.${tdate}/${cyc}/analysis/ocean" +export COM_ICE_HISTORY_PREV="${base_dir}/${PDY_PREV}${gcyc}/${RUN}.${PDY_PREV}/${gcyc}/model/ice/history" +export COM_OCEAN_HISTORY_PREV="${base_dir}/${PDY_PREV}${gcyc}/${RUN}.${PDY_PREV}/${gcyc}/model/ocean/history" # Excute Marine Verify Analysis python3 ${HOMEgfs}sorc/gdas.cd/utils/soca/fig_gallery/exgdas_global_marine_analysis_vrfy_manual.py