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

Call MDTF from ADF, and allow list of hist_str to be processed for timeseries #293

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a95d1f7
enable ADF to call MDTF, writing input file
bitterbark Oct 4, 2023
fd14603
merge call_mdtf_from_adf
bitterbark Feb 29, 2024
e7fcf8e
merged with latest ADF, plus ts file copied for mdtf
bitterbark Mar 15, 2024
3436cbc
made method to move ts files for mdtf
bitterbark Mar 16, 2024
5c761c8
mdtf options to use default dirs
bitterbark Mar 16, 2024
4260775
made defaults for MDTF working and outdir
bitterbark Mar 20, 2024
f34f6cd
code cleanup
bitterbark Apr 4, 2024
4e15640
code cleanup round 2
bitterbark Apr 4, 2024
b86bb76
change python version for linting
bitterbark Apr 4, 2024
ca08a56
code cleanup round 3
bitterbark Apr 4, 2024
bfcb4f9
black formatter
bitterbark Apr 4, 2024
80f1481
black formatter
bitterbark Apr 4, 2024
4a98928
Update config_amwg_default_plots.yaml
bitterbark May 22, 2024
079d6da
Update config_amwg_default_plots.yaml
bitterbark May 22, 2024
dbfeb97
Update lib/adf_diag.py
bitterbark May 22, 2024
d6a9d4b
Update lib/adf_diag.py
bitterbark May 22, 2024
808eeab
Update lib/adf_diag.py
bitterbark May 22, 2024
19860ef
Update lib/adf_diag.py
bitterbark May 23, 2024
3658321
Update lib/adf_diag.py
bitterbark May 23, 2024
16af726
Update lib/adf_diag.py
bitterbark May 23, 2024
9558127
Apply suggestions from code review
bitterbark May 23, 2024
f3e0381
filter files by hist_str=h0
bitterbark May 31, 2024
546b360
requested cleanup
bitterbark Jun 10, 2024
12bd282
cleanup
bitterbark Jun 11, 2024
e5817a7
merge to head
bitterbark Jun 12, 2024
db77e0d
Merge branch 'main' into call_mdtf_fixed
bitterbark Jun 12, 2024
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: 2 additions & 2 deletions .github/workflows/ADF_linting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
# acquire github action routines
- uses: actions/checkout@v3
# acquire specific version of python
- name: Set up Python 3.8
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.8' # Use python 3.8
python-version: '3.11' # Use python 3.11
# install required python packages
- name: Install dependencies
run: |
Expand Down
98 changes: 90 additions & 8 deletions config_amwg_default_plots.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ user: 'USER-NAME-NOT-SET'
#This first set of variables specify basic info used by all diagnostic runs:
diag_basic_info:

#History file string to match (eg. cam.h0 or ocn.pop.h.ecosys.nday1)
# Only affects timeseries as everything else uses timeseries
# Leave off trailing '.'
#Default: cam.h0
hist_str: cam.h0

#Is this a model vs observations comparison?
#If "false" or missing, then a model-model comparison is assumed:
compare_obs: false
Expand Down Expand Up @@ -130,6 +124,12 @@ diag_basic_info:
#This second set of variables provides info for the CAM simulation(s) being diagnosed:
diag_cam_climo:

# History file list of strings to match
# eg. cam.h0 or ocn.pop.h.ecosys.nday1 or hist_str: [cam.h2,cam.h0]
# Only affects timeseries as everything else uses the created timeseries
# Default:
hist_str: cam.h0

#Calculate climatologies?
#If false, the climatology files will not be created:
calc_cam_climo: true
Expand Down Expand Up @@ -202,7 +202,13 @@ diag_cam_climo:
#This only matters if "compare_obs" is false:
diag_cam_baseline_climo:

#Calculate cam baseline climatologies?
# History file list of strings to match
# eg. cam.h0 or ocn.pop.h.ecosys.nday1 or hist_str: [cam.h2,cam.h0]
# Only affects timeseries as everything else uses the created timeseries
# Default:
hist_str: cam.h0

#Calculate cam baseline climatologies?
#If false, the climatology files will not be created:
calc_cam_climo: true

Expand Down Expand Up @@ -290,6 +296,71 @@ diag_cvdp_info:
# tar up CVDP results?
cvdp_tar: false

# This set of variables provides settings for calling NOAA's
# Model Diagnostic Task Force (MDTF) diagnostic package.
# https://github.com/NOAA-GFDL/MDTF-diagnostics
#
# If mdtf_run: true, the MDTF will be set up and
# run in background mode, likely completing after the ADF has completed.
#
# The variables required depend on the diagnostics (PODs) selected.
# AMWG-developed PODS and their required variables:
# (Note that PRECT can be computed from PRECC & PRECL)
# - MJO_suite: daily PRECT, FLUT, U850, U200, V200 (all required)
# - Wheeler-Kiladis Wavenumber Frequency Spectra: daily PRECT, FLUT, U200, U850, OMEGA500
# (will use what is available)
# - Blocking (Rich Neale): daily OMEGA500
# - Precip Diurnal Cycle (Rich Neale): 3-hrly PRECT
#
# Many other diagnostics are available; see
# https://mdtf-diagnostics.readthedocs.io/en/main/sphinx/start_overview.html

#
diag_mdtf_info:
# Run the MDTF on the model cases
mdtf_run: false

# The file that will be written by ADF to input to MDTF. Call this whatever you want.
mdtf_input_settings_filename : mdtf_input.json

## MDTF code path, sets the location of the MDTF codebase and pre-compiled conda envs
# CHANGE if you have any: your own MDTF code, installed conda envs and/or obs_data

mdtf_codebase_path : /glade/campaign/cgd/amp/amwg/mdtf
mdtf_codebase_loc : ${mdtf_codebase_path}/MDTF-diagnostics.v3.1.20230817.ADF
conda_root : ${mdtf_codebase_path}/miniconda2
conda_env_root : ${mdtf_codebase_path}/miniconda2/envs.MDTFv3.1.20230412/
OBS_DATA_ROOT : ${mdtf_codebase_path}/obs_data



# Set to default for same as the ADF plot_location. Anything else here overrides that
OUTPUT_DIR : default
WORKING_DIR : default

# SET this to a writable dir. The ADF will place ts files here for the MDTF to read (adds the casename)
MODEL_DATA_ROOT : ${diag_cam_climo.cam_ts_loc}/mdtf/inputdata/model

# Choose diagnostics (PODs). Full list of available PODs: https://github.com/NOAA-GFDL/MDTF-diagnostics
pod_list : [ "MJO_suite" ]

# Intermediate/output file settings
make_variab_tar: false # tar up MDTF results
save_ps : false # save postscript figures in addition to bitmaps
save_nc : true # save netCDF files of processed data (recommend true when starting with new model data)
overwrite: true # overwrite results in OUTPUT_DIR; otherwise results saved under a unique name

# Settings used in debugging:
verbose : 3 # Log verbosity level.
test_mode: false # Set to true for framework test. Data is fetched but PODs are not run.
dry_run : false # Framework test. No external commands are run and no remote data is copied. Implies test_mode.

# Settings that shouldn't change in ADF implementation for now
data_type : single_run # single_run or multi_run (only works with single right now)
data_manager : Local_File # Fetch data or it is local?
environment_manager : Conda # Manage dependencies



#+++++++++++++++++++++++++++++++++++++++++++++++++++
#These variables below only matter if you are using
Expand Down Expand Up @@ -323,8 +394,10 @@ plotting_scripts:
- global_latlon_map
- global_latlon_vect_map
- zonal_mean
- meridional_mean
- polar_map
- cam_taylor_diagram
- qbo
bitterbark marked this conversation as resolved.
Show resolved Hide resolved
#- tape_recorder
#- tem
#- regional_map_multicase #To use this please un-comment and fill-out
Expand Down Expand Up @@ -375,7 +448,16 @@ diag_var_list:
- LANDFRAC

#<Add more variables here.>

# MDTF recommended variables
# - OMEGA
# - PRECT
# - PS
# - PSL
# - U200
# - U850
# - V200
# - V850

# Options for multi-case regional contour plots (./plotting/regional_map_multicase.py)
# region_multicase:
# region_spec: [slat, nlat, wlon, elon]
Expand Down
96 changes: 88 additions & 8 deletions config_cam_baseline_example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,6 @@ user: 'USER-NAME-NOT-SET'
#This first set of variables specify basic info used by all diagnostic runs:
bitterbark marked this conversation as resolved.
Show resolved Hide resolved
diag_basic_info:

#History file string to match (eg. cam.h0 or ocn.pop.h.ecosys.nday1)
# Only affects timeseries as everything else uses timeseries
# Leave off trailing '.'
#Default: cam.h0
hist_str: cam.h0

#Is this a model vs observations comparison?
#If "false" or missing, then a model-model comparison is assumed:
compare_obs: false
Expand Down Expand Up @@ -130,6 +124,12 @@ diag_basic_info:
#This second set of variables provides info for the CAM simulation(s) being diagnosed:
diag_cam_climo:

# History file list of strings to match
# eg. cam.h0 or ocn.pop.h.ecosys.nday1 or hist_str: [cam.h2,cam.h0]
# Only affects timeseries as everything else uses the created timeseries
# Default:
hist_str: cam.h0

#Calculate climatologies?
#If false, the climatology files will not be created:
calc_cam_climo: true
Expand Down Expand Up @@ -286,7 +286,13 @@ diag_cam_climo:
#This only matters if "compare_obs" is false:
diag_cam_baseline_climo:

#Calculate cam baseline climatologies?
# History file list of strings to match
# eg. cam.h0 or ocn.pop.h.ecosys.nday1 or hist_str: [cam.h2,cam.h0]
# Only affects timeseries as everything else uses the created timeseries
# Default:
hist_str: cam.h0

#Calculate cam baseline climatologies?
#If false, the climatology files will not be created:
calc_cam_climo: true

Expand Down Expand Up @@ -375,6 +381,71 @@ diag_cvdp_info:
# tar up CVDP results?
cvdp_tar: false

# This set of variables provides settings for calling NOAA's
# Model Diagnostic Task Force (MDTF) diagnostic package.
# https://github.com/NOAA-GFDL/MDTF-diagnostics
#
# If mdtf_run: true, the MDTF will be set up and
# run in background mode, likely completing after the ADF has completed.
#
# The variables required depend on the diagnostics (PODs) selected.
# AMWG-developed PODS and their required variables:
# (Note that PRECT can be computed from PRECC & PRECL)
# - MJO_suite: daily PRECT, FLUT, U850, U200, V200 (all required)
# - Wheeler-Kiladis Wavenumber Frequency Spectra: daily PRECT, FLUT, U200, U850, OMEGA500
# (will use what is available)
# - Blocking (Rich Neale): daily OMEGA500
# - Precip Diurnal Cycle (Rich Neale): 3-hrly PRECT
#
# Many other diagnostics are available; see
# https://mdtf-diagnostics.readthedocs.io/en/main/sphinx/start_overview.html

#
diag_mdtf_info:
# Run the MDTF on the model cases
mdtf_run: false

# The file that will be written by ADF to input to MDTF. Call this whatever you want.
mdtf_input_settings_filename : mdtf_input.json

## MDTF code path, sets the location of the MDTF codebase and pre-compiled conda envs
# CHANGE if you have any: your own MDTF code, installed conda envs and/or obs_data

mdtf_codebase_path : /glade/campaign/cgd/amp/amwg/mdtf
mdtf_codebase_loc : ${mdtf_codebase_path}/MDTF-diagnostics.v3.1.20230817.ADF
conda_root : ${mdtf_codebase_path}/miniconda2
conda_env_root : ${mdtf_codebase_path}/miniconda2/envs.MDTFv3.1.20230412/
OBS_DATA_ROOT : ${mdtf_codebase_path}/obs_data



# Set to default for same as the ADF plot_location. Anything else here overrides that
OUTPUT_DIR : default
WORKING_DIR : default

# SET this to a writable dir. The ADF will place ts files here for the MDTF to read (adds the casename)
MODEL_DATA_ROOT : ${diag_cam_climo.cam_ts_loc}/mdtf/inputdata/model

# Choose diagnostics (PODs). Full list of available PODs: https://github.com/NOAA-GFDL/MDTF-diagnostics
pod_list : [ "MJO_suite" ]

# Intermediate/output file settings
make_variab_tar: false # tar up MDTF results
save_ps : false # save postscript figures in addition to bitmaps
save_nc : true # save netCDF files of processed data (recommend true when starting with new model data)
overwrite: true # overwrite results in OUTPUT_DIR; otherwise results saved under a unique name

# Settings used in debugging:
verbose : 3 # Log verbosity level.
test_mode: false # Set to true for framework test. Data is fetched but PODs are not run.
dry_run : false # Framework test. No external commands are run and no remote data is copied. Implies test_mode.

# Settings that shouldn't change in ADF implementation for now
data_type : single_run # single_run or multi_run (only works with single right now)
data_manager : Local_File # Fetch data or it is local?
environment_manager : Conda # Manage dependencies



#+++++++++++++++++++++++++++++++++++++++++++++++++++
#These variables below only matter if you are using
Expand Down Expand Up @@ -438,7 +509,16 @@ diag_var_list:
- LANDFRAC

#<Add more variables here.>

# MDTF recommended variables
# - OMEGA
# - PRECT
# - PS
# - PSL
# - U200
# - U850
# - V200
# - V850

# Options for multi-case regional contour plots (./plotting/regional_map_multicase.py)
# region_multicase:
# region_spec: [slat, nlat, wlon, elon]
Expand Down
5 changes: 4 additions & 1 deletion lib/adf_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def expand_references(self, config_dict):
#Loop through dictionary:
for key, value in config_dict_copy.items():

#Skipe non-strings (as they won't contain a keyword):
#Skip non-strings (as they won't contain a keyword):
if not isinstance(value, str):
continue

Expand Down Expand Up @@ -274,6 +274,9 @@ def read_config_var(self, varname, conf_dict=None, required=False):
raise TypeError(emsg)
#End if

if varname == "ALL":
return var_dict

#Check that variable name exists in dictionary:
if varname not in var_dict.keys():
#If variable is required, then throw an error:
Expand Down
Loading
Loading