From 2d852011609b383919c2db1ce3c3509651168f0a Mon Sep 17 00:00:00 2001 From: bitterbark Date: Thu, 12 Sep 2024 16:36:13 -0600 Subject: [PATCH] add website link to external packages (MDTF) --- config_amwg_default_plots.yaml | 6 ----- config_cam_baseline_example.yaml | 9 ++------ lib/adf_diag.py | 7 +++--- lib/adf_web.py | 27 +++++++++++++++++++++-- lib/website_templates/template_index.html | 20 ++++++++++++++++- 5 files changed, 49 insertions(+), 20 deletions(-) diff --git a/config_amwg_default_plots.yaml b/config_amwg_default_plots.yaml index ce22d562c..9b77b46d8 100644 --- a/config_amwg_default_plots.yaml +++ b/config_amwg_default_plots.yaml @@ -332,12 +332,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 diff --git a/config_cam_baseline_example.yaml b/config_cam_baseline_example.yaml index c7037a92e..18f97d573 100644 --- a/config_cam_baseline_example.yaml +++ b/config_cam_baseline_example.yaml @@ -417,12 +417,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 @@ -510,7 +504,8 @@ diag_var_list: # # MDTF recommended variables -# - OMEGA +# - FLUT +# - OMEGA500 # - PRECT # - PS # - PSL diff --git a/lib/adf_diag.py b/lib/adf_diag.py index bf87cb498..8458563f7 100644 --- a/lib/adf_diag.py +++ b/lib/adf_diag.py @@ -1266,8 +1266,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 @@ -1357,7 +1356,7 @@ 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: @@ -1365,7 +1364,7 @@ def move_tsfiles_for_mdtf(self, verbose): 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" ) diff --git a/lib/adf_web.py b/lib/adf_web.py index f7b3e0d3d..ed21e655c 100644 --- a/lib/adf_web.py +++ b/lib/adf_web.py @@ -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 #-------------------------------- @@ -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: @@ -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') @@ -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: @@ -759,4 +782,4 @@ def jinja_list(seas_list): print(" ...Webpages have been generated successfully.") #++++++++++++++++++++ #End Class definition -#++++++++++++++++++++ \ No newline at end of file +#++++++++++++++++++++ diff --git a/lib/website_templates/template_index.html b/lib/website_templates/template_index.html index 4b2659cf8..db49975e1 100644 --- a/lib/website_templates/template_index.html +++ b/lib/website_templates/template_index.html @@ -48,5 +48,23 @@

Plot Types

{% endfor %} +
+

External Diagnostic Packages

+
+ +
+ {% for avail_type in avail_external_packages %} + {% if avail_type in external_package_links.keys() %} + + {% else %} +
+ {{ avail_type }} +
+ {% endif %} + {% endfor %} +
+ - \ No newline at end of file +