Skip to content

Commit

Permalink
Merge pull request #330 from bitterbark/mdtf_weblink
Browse files Browse the repository at this point in the history
add website link to external packages (MDTF)
  • Loading branch information
justin-richling authored Oct 8, 2024
2 parents 031e636 + 5f825af commit 95918f4
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 20 deletions.
8 changes: 2 additions & 6 deletions config_amwg_default_plots.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ diag_cvdp_info:
# If mdtf_run: true, the MDTF will be set up and
# run in background mode, likely completing after the ADF has completed.
#
# WARNING: This currently only runs on CASPER (not derecho)
#
# 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)
Expand Down Expand Up @@ -332,12 +334,6 @@ diag_mdtf_info:
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

Expand Down
11 changes: 4 additions & 7 deletions config_cam_baseline_example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,8 @@ diag_cvdp_info:
# If mdtf_run: true, the MDTF will be set up and
# run in background mode, likely completing after the ADF has completed.
#
# WARNING: This currently only runs on CASPER (not derecho)
#
# 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)
Expand Down Expand Up @@ -417,12 +419,6 @@ diag_mdtf_info:
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

Expand Down Expand Up @@ -510,7 +506,8 @@ diag_var_list:

#<Add more variables here.>
# MDTF recommended variables
# - OMEGA
# - FLUT
# - OMEGA500
# - PRECT
# - PS
# - PSL
Expand Down
7 changes: 3 additions & 4 deletions lib/adf_diag.py
Original file line number Diff line number Diff line change
Expand Up @@ -1311,8 +1311,7 @@ def setup_run_mdtf(self):
case_idx = 0
plot_path = os.path.join(self.plot_location[case_idx], "mdtf")
for var in ["WORKING_DIR", "OUTPUT_DIR"]:
if mdtf_info[var] == "default":
mdtf_info[var] = plot_path
mdtf_info[var] = plot_path

#
# Write the input settings json file
Expand Down Expand Up @@ -1401,15 +1400,15 @@ def move_tsfiles_for_mdtf(self, verbose):
adf_file_list = glob.glob(adf_file_str)

if len(adf_file_list) == 1:
if verbose > 2:
if verbose > 1:
print(f"Copying ts file: {adf_file_list} to MDTF dir")
elif len(adf_file_list) > 1:
if verbose > 0:
print(
f"WARNING: found multiple timeseries files {adf_file_list}. Continuing with best guess; suggest cleaning up multiple dates in ts dir"
)
else:
if verbose > 0:
if verbose > 1:
print(
f"WARNING: No files matching {case_name}.{hist_str}.{var} found in {adf_file_str}. Skipping"
)
Expand Down
27 changes: 25 additions & 2 deletions lib/adf_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,27 @@ def __init__(self, config_file, debug=False):
#Specify where CSS files will be stored:
css_files_dir = website_dir / "templates"

#Add links to external packages (if applicable)
self.external_package_links = {}

#MDTF puts directory under case[0]
if self.get_mdtf_info('mdtf_run'):
syear = self.climo_yrs["syears"]
eyear = self.climo_yrs["eyears"]
mdtf_path = f"../mdtf/MDTF_{case_name}"
mdtf_path += f"_{syear[0]}_{eyear[0]}"
self.external_package_links['MDTF'] = mdtf_path
#End if

#Add all relevant paths to dictionary for specific case:
self.__case_web_paths[case_name] = {'website_dir': website_dir,
'img_pages_dir': img_pages_dir,
'assets_dir': assets_dir,
'table_pages_dir': table_pages_dir,
'css_files_dir': css_files_dir}



#End for
#--------------------------------

Expand All @@ -171,6 +186,8 @@ def __init__(self, config_file, debug=False):
'css_files_dir': css_files_dir}
#End if



#########

# Create property needed to return "create_html" logical to user:
Expand Down Expand Up @@ -691,6 +708,10 @@ def jinja_list(seas_list):
if ptype not in avail_plot_types:
avail_plot_types.append(plot_types)


# External packages that can be run through ADF
avail_external_packages = {'MDTF':'mdtf_html_path', 'CVDP':'cvdp_html_path'}

#Construct index.html
index_title = "AMP Diagnostics Prototype"
index_tmpl = jinenv.get_template('template_index.html')
Expand All @@ -700,7 +721,9 @@ def jinja_list(seas_list):
case_yrs=case_yrs,
baseline_yrs=baseline_yrs,
plot_types=plot_types,
avail_plot_types=avail_plot_types)
avail_plot_types=avail_plot_types,
avail_external_packages=avail_external_packages,
external_package_links=self.external_package_links)

#Write Mean diagnostics index HTML file:
with open(index_html_file, 'w', encoding='utf-8') as ofil:
Expand Down Expand Up @@ -759,4 +782,4 @@ def jinja_list(seas_list):
print(" ...Webpages have been generated successfully.")
#++++++++++++++++++++
#End Class definition
#++++++++++++++++++++
#++++++++++++++++++++
20 changes: 19 additions & 1 deletion lib/website_templates/template_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,23 @@ <h1>Plot Types</h1>
{% endfor %}
</div><!--grid-container-ptype-->

<div class="center">
<h1>External Diagnostic Packages</h1>
</div>

<div class="grid-container">
{% for avail_type in avail_external_packages %}
{% if avail_type in external_package_links.keys() %}
<div class="grid-item">
<a href={{ external_package_links[avail_type] }} style="font-size: 30px;"> &nbsp; {{ avail_type }} </a>
</div><!--grid-item-->
{% else %}
<div class="grid-item-blocked">
<a-blocked style="font-size: 30px;">{{ avail_type }}</a-blocked>
</div><!--grid-item-blocked-->
{% endif %}
{% endfor %}
</div><!--grid-container-external-plots-->

</body>
</html>
</html>

0 comments on commit 95918f4

Please sign in to comment.