diff --git a/CHANGELOG.md b/CHANGELOG.md index 387769bd..5a6a54a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to GCPy will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] - TBD +### Added +- Script `gcpy/benchmark/modules/benchmark_utils.py`, with common benchmark utility functions +- Script `gcpy/benchmark/modules/benchmark_drydep.py`, with code to create drydep velocity plots +- YAML tag `plot_drydep` in `gcpy/benchmark/config/*.yml` files + ### Changed - YAML tag `operations_budget` is now `ops_budget_table` in `gcpy/benchmark/config/1yr_tt_benchmark.yml` diff --git a/gcpy/benchmark/modules/benchmark_drydep.py b/gcpy/benchmark/modules/benchmark_drydep.py index c2eae1fa..a5d54bcf 100644 --- a/gcpy/benchmark/modules/benchmark_drydep.py +++ b/gcpy/benchmark/modules/benchmark_drydep.py @@ -5,9 +5,7 @@ import gc import numpy as np from gcpy import util -from gcpy.constants import skip_these_vars from gcpy.plot.compare_single_level import compare_single_level -from gcpy.plot.compare_zonal_mean import compare_zonal_mean import gcpy.benchmark.modules.benchmark_utils as bmk_util # Suppress numpy divide by zero warnings to prevent output spam @@ -19,18 +17,18 @@ def make_benchmark_drydep_plots( refstr, dev, devstr, - collection, + collection="DryDep", dst="./benchmark", + subdst=None, cmpres=None, - datestr=None, overwrite=False, verbose=False, log_color_scale=False, - weightsdir=".". + weightsdir=".", + sigdiff_files=None, n_job=-1, time_mean=False, - spcdb_dir=None, - var_prefix="DryDepVel" + spcdb_dir=os.path.join(os.path.dirname(__file__), "..", "..") ): """ Creates six-panel comparison plots (PDF format) from GEOS-Chem @@ -48,18 +46,20 @@ def make_benchmark_drydep_plots( data set. devstr: str A string to describe dev (e.g. version number) - collection: str - String name of collection to plot comparisons for. Keyword Args (optional): + collection : str + Name of the diagnostic collection (e.g. "DryDep") dst: str A string denoting the destination folder where a PDF file containing plots will be written. Default value: ./benchmark - datestr: str - A string with date information to be included in both the - plot pdf filename and as a destination folder subdirectory - for writing plots + subdst: str + A string denoting the sub-directory of dst where PDF + files containing plots will be written. In practice, + subdst is only needed for the 1-year benchmark output, + and denotes a date string (such as "Jan2016") that + corresponds to the month that is being plotted. Default value: None benchmark_type: str A string denoting the type of benchmark output to plot, options are @@ -72,13 +72,6 @@ def make_benchmark_drydep_plots( verbose: bool Set this flag to True to print extra informational output. Default value: False. - plots: list of strings - List of plot types to create. - Default value: ['sfc', '500hpa', 'zonalmean'] - normalize_by_area: bool - Set this flag to true to enable normalization of data - by surfacea area (i.e. kg s-1 --> kg s-1 m-2). - Default value: False n_job: int Defines the number of simultaneous workers for parallel plotting. Set to 1 to disable parallel plotting. Value of -1 allows the @@ -90,58 +83,51 @@ def make_benchmark_drydep_plots( time_mean : bool Determines if we should average the datasets over time Default value: False - var_prefix : str - If """ - # Create destination plot directory - bmk_util.make_directory(dst, overwrite) - target_dst = bmk_util.make_collection_subdir(dst, collection, datestr) - - # Defaults for arguments - if plots is None: - plots = ["sfc", "500hpa", "zonalmean"] - if spcdb_dir is None: - spcdb_dir = os.path.join(os.path.dirname(__file__), "..", "..") + # Create directory for plots (if it doesn't exist) + dst = bmk_util.make_output_dir( + dst, + collection, + subdst, + overwrite=overwrite, + ) # Read data - refds, devds = bmk.util_read_ref_and_dev(ref, dev, time_mean) - if refmet is not None and devmet is not None: - refmetds, devmetds = bmk_util.read_ref_and_dev(ref, dev, time_mean) - - # Make sure that Ref and Dev datasets have the same variables. - # Variables that are in Ref but not in Dev will be added to Dev - # with all missing values (NaNs). And vice-versa. - # Turn this off for now since add_missing_variables inserts GCC area into - # GCHP files, which causes problems with area normalization (ewl) - #[refds, devds] = add_missing_variables(refds, devds) + refdata, devdata = bmk_util.read_ref_and_dev( + ref, + dev, + time_mean=time_mean + ) # Get common variables between Ref and Dev varlist = bmk_util.get_common_varnames( - refds, - devds, - var_prefix=var_prefix + refdata, + devdata, + prefix="DryDepVel_", verbose=verbose ) - - # Surface plots - plotfilename = f"{collection}_Surface.pdf" - if datestr is not None: - plotfilename = f"{collection}_Surface_{datestr}.pdf" - pdfname = os.path.join(target_dst, plotfilename) + + # Create surface plots + sigdiff_list = [] + pdfname = bmk_util.pdf_filename( + dst, + collection, + subdst, + plot_type="Surface" + ) compare_single_level( - refds, + refdata, refstr, - devds, + devdata, devstr, varlist=varlist, cmpres=cmpres, ilev=0, - refmet=refmetds, - devmet=devmetds, pdfname=pdfname, - normalize_by_area=normalize_by_area, - extra_title_txt=datestr, + log_color_scale=log_color_scale, + extra_title_txt=subdst, + sigdiff_list=sigdiff_list, weightsdir=weightsdir, n_job=n_job, spcdb_dir=spcdb_dir @@ -150,16 +136,20 @@ def make_benchmark_drydep_plots( pdfname, varlist, remove_prefix=collection + '_', - verbose=verbose) - + verbose=verbose ) + # Write significant differences to file (if there are any) + bmk_util.print_sigdiffs( + sigdiff_files, + sigdiff_list, + diff_type="sfc", + diff_title="DryDepVel" + ) # ------------------------------------------- # Clean up # ------------------------------------------- - del refds - del devds - del refmetds - del devmetds + del refdata + del devdata gc.collect() diff --git a/gcpy/benchmark/modules/benchmark_utils.py b/gcpy/benchmark/modules/benchmark_utils.py index b234d8b9..70e048bd 100644 --- a/gcpy/benchmark/modules/benchmark_utils.py +++ b/gcpy/benchmark/modules/benchmark_utils.py @@ -1,24 +1,21 @@ """ -Specific utilities for creating plots from GEOS-Chem benchmark simulations. - -TODO: Migrate benchmark-specific utilities from gcpy/benchmark.py to here. +Utility functions specific to the benchmark plotting/tabling scripts. +TODO: Migrate other benchmark-specific utilities from gcpy/benchmark.py to here. """ import os -import gc import numpy as np from gcpy import util from gcpy.constants import skip_these_vars -from gcpy.plot.compare_single_level import compare_single_level -from gcpy.plot.compare_zonal_mean import compare_zonal_mean # Suppress numpy divide by zero warnings to prevent output spam np.seterr(divide="ignore", invalid="ignore") -def make_collection_subdir( +def make_output_dir( dst, collection, - datestr + subdst, + overwrite=False ): """ Creates a subdirectory for the given collection type @@ -26,28 +23,33 @@ def make_collection_subdir( Args: ---- - dst (str) : Destination directory - collection (str) : Collection name - datestr (str) : Date string + dst (str ) : Destination directory + collection (str|None) : e.g. "Aerosols", "DryDep", "Oxidants", ... + subdst (str ) : e.g. "AnnualMean", "Apr2019", ... Returns: -------- - target_dst (str) : Directory that was created - + dst (str ) : Path of the directory that was created """ + util.verify_variable_type(dst, str) + util.verify_variable_type(collection, str) + util.verify_variable_type(subdst, (str, None)) - # Make a collection subdirectory - target_dst = os.path.join(dst, collection) - if not os.path.isdir(target_dst): - os.mkdir(target_dst) + # Create the destination folder (if it doesn't exist) + util.make_directory(dst, overwrite) - # If datestr is passed, create a further subdirectory - if datestr is not None: - target_dst = os.path.join(target_dst, datestr) - if not os.path.isdir(target_dst): - os.mkdir(target_dst) + # Make the dst/collection subdirectory + dst = os.path.join(dst, collection) + if not os.path.isdir(dst): + os.mkdir(dst) - return target_dst + # If necessary, make the dst/collection/subdst subdirectory + if subdst is not None: + dst = os.path.join(dst, subdst) + if not os.path.isdir(dst): + os.mkdir(dst) + + return dst def read_ref_and_dev( @@ -59,48 +61,200 @@ def read_ref_and_dev( """ Reads files from the Ref and Dev models into xarray.Dataset objects. - Args: ----- - ref (str or list) : Ref data file(s) - def (str or list) : Ref data file(s) - time_mean (bool) : Return the average over the time dimension + ref (str|list ) : Ref data file(s) + def (str|list ) : Dev data file(s) + time_mean (bool ) : Return the average over the time dimension? Returns: -------- - refds (xarray.Dataset) : Data from the Ref model - devds (xarray.Dataset) : Data from the Dev model + ref_data (xr.Dataset) : Data from the Ref model + dev_data (xr.Dataset) ls: Data from the Dev model """ + util.verify_variable_type(ref, (str, list)) + util.verify_variable_type(dev, (str, list)) + util.verify_variable_type(time_mean, bool) - # Get the function that will read file(s) into a dataset + ref_data = None + dev_data = None reader = util.dataset_reader(time_mean, verbose=verbose) - # Open datasets - refds = reader(ref, drop_variables=skip_these_vars) - devds = reader(dev, drop_variables=skip_these_vars) + if ref is not None: + ref_data = reader(ref, drop_variables=skip_these_vars) + if time_mean: + ref_data = util.dataset_mean(ref_data) - # Take - if time_mean: - refds = util.dataset_mean(refds) - devds = util.dataset_mean(devds) + if dev is not None: + dev_data = reader(dev, drop_variables=skip_these_vars) + if time_mean: + dev_data = util.dataset_mean(dev_data) - return refds, devds + return ref_data, dev_data def get_common_varnames( - refds, - devds, - var_prefix=None, + refdata, + devdata, + prefix, verbose=False, +): """ + Returns an alphabetically-sorted list of common variables two + xr.Dataset objects matching a given prefix. + + Args: + ----- + refdata (xr.Dataset ) : Data from the Ref model. + devdata (xr.Dataset ) : Data from the Dev model. + prefix (str ) : Variable prefix to match. + verbose (bool ) : Toggle verbose printout on/off. + + Returns: + -------- + varlist (list of str) : Sorted list of common variable names. """ - - # Get list of variables in collection - vardict = util.compare_varnames(refds, devds, quiet=not verbose) - varlist = [v for v in vardict["commonvars3D"] if collection + "_" in v] + vardict = util.compare_varnames(refdata, devdata, quiet=not verbose) + varlist = [var for var in vardict["commonvars"] if prefix in var] + + return sorted(varlist) + + +def print_sigdiffs( + sigdiff_files, + sigdiff_list, + sigdiff_type, + sigdiff_cat +): + """ + Write + Appends a list of species showing significant differences in a + benchmark plotting category to a file. + + sigdiff_files (list|None) : + sigdiff_list (list ) : List of significant differences. + sigdiff_cat (str ) : e.g. "Oxidants", "Aerosols", "DryDep", etc. + sigdiff_file (str ) : Filename to which the list will be appended + """ + if sigdiff_files is not None: + for ofile in sigdiff_files: + if sigdiff_type in ofile: + write_sigdiff(sigdiff_list, sigdiff_cat, ofile) + + +def write_sigdiff( + sigdiff_list, + sigdiff_cat, + sigdiff_file, +): + """ + Appends a list of species showing significant differences in a + benchmark plotting category to a file. + + sigdiff_list (list ) : List of significant differences. + sigdiff_cat (str ) : e.g. "Oxidants", "Aerosols", "DryDep", etc. + sigdiff_file (str ) : Filename to which the list will be appended + """ + util.verify_variable_type(sigdiff_list, list) + util.verify_variable_type(sigdiff_title, str) + util.verify_variable_type(sigdiff_file, str) + + with open(sigdiff_file, "a+", encoding="UTF-8") as ofile: + print(f"* {sigdiff_cat}: ", file=ofile, end="") + for var in sigdiff_list: + print(f"{var} ", file=ofile, end="") + print(file=ofile) + ofile.close() + + +def pdf_filename( + dst, + collection, + subdst, + plot_type +): + """ + Creates the absolute path for a PDF file containing benchmark plots. + + Args: + ----- + dst (str ) : Root folder for benchmark output plots + collection (str ) : e.g. "Aerosols", "DryDep", etc. + subdst (str|None) : e.g. "AnnualMean", "Apr2019", etc. + plot_type (str ) : e.g. "Surface", "FullColumnZonalMean", etc. + + Returns: + -------- + pdf_path (str) : Absolute path for the PDF file containing plots + """ + util.verify_variable_type(dst, str) + util.verify_variable_type(collection, str) + util.verify_variable_type(subdst, (str, type(None))) + + pdf_path = f"{collection}_{plot_type}.pdf" + if subdst is not None: + pdf_path = f"{collection}_{plot_type}_{subdst}.pdf" + + return os.path.join(dst, pdf_path) + + +def print_benchmark_info( + config +): + """ + Prints which benchmark plots and tables will be generated. + + Args: + ----- + config (dict) : Inputs from the benchmark config YAML file. + """ + util.verify_variable_type(config, dict) + + conf = config["options"]["bmk_type"] + print(f"The following plots and tables will be created for {conf}") - # Select variables having a common prefix - if var_prefix is not None: - varlist = [v for v in varlist if var_prefix in v] + conf = config["options"]["outputs"] + for key in conf.keys(): + if "plot_conc" in key and conf[key]: + print(" - Concentration plots") + if "plot_emis" in key and conf[key]: + print(" - Emissions plots") + if "plot_jvalues" in key and conf[key]: + print(" - J-values (photolysis rates) plots") + if "plot_aod" in key and conf[key]: + print(" - Aerosol optical depth plots") + if "plot_drydep" in key and conf[key]: + print(" - Drydep velocity plots") + if "plot_wetdep" in key and conf[key]: + print(" - Convective and large-scale wet deposition plots") + if "plot_models_vs_obs" in key and conf[key]: + print(" - Plots of models vs. observations") + if "emis_table" in key and conf[key]: + print(" - Table of emissions totals by species and inventory") + if "rnpbbe_budget" in key and conf[key]: + print(" - Radionuclides budget table") + if "ops_budget_table" in key and conf[key]: + print(" - Operations budget tables") + if "aer_budget_table" in key and conf[key]: + print(" - Aerosol budget/burden tables") + if "mass_table" in key and conf[key]: + print(" - Table of species mass") + if "mass_accum_table" in key and conf[key]: + print(" - Table of species mass accumulation") + if "OH_metrics" in key and conf[key]: + print(" - Table of OH metrics") + if "ste_table" in key and conf[key]: + print(" - Table of strat-trop exchange") + if "cons_table" in key and conf[key]: + print(" - Table of mass conservation") - return varlist.sort() + print("Comparisons will be made for the following combinations:") + conf = config["options"]["comparisons"] + if conf["gcc_vs_gcc"]["run"]: + print(" - GCC vs GCC") + if conf["gchp_vs_gcc"]["run"]: + print(" - GCHP vs GCC") + if conf["gchp_vs_gchp"]["run"]: + print(" - GCHP vs GCHP") + if conf["gchp_vs_gcc_diff_of_diffs"]["run"]: + print(" - GCHP vs GCC diff of diffs") diff --git a/gcpy/benchmark/modules/run_1yr_fullchem_benchmark.py b/gcpy/benchmark/modules/run_1yr_fullchem_benchmark.py index 7321c50a..8f2f28c5 100644 --- a/gcpy/benchmark/modules/run_1yr_fullchem_benchmark.py +++ b/gcpy/benchmark/modules/run_1yr_fullchem_benchmark.py @@ -63,6 +63,11 @@ import gcpy.budget_ox as ox from gcpy import benchmark_funcs as bmk import gcpy.benchmark.modules.benchmark_models_vs_obs as mvo +import gcpy.benchmark.modules.benchmark_utils as bmk_util +#TODO: Peel out routines from benchmark_funcs.py into smaller +# routines in the gcpy/benchmark/modules folder, such as these: +from gcpy.benchmark.modules.benchmark_drydep \ + import make_benchmark_drydep_plots # Tell matplotlib not to look for an X-window os.environ["QT_QPA_PLATFORM"] = "offscreen" @@ -306,41 +311,9 @@ def run_benchmark(config, bmk_year_ref, bmk_year_dev): bmk_sec_per_month_dev = sec_per_month_dev[bmk_mon_inds] # ====================================================================== - # Print the list of plots & tables to the screen + # Print the list of plots & tables being generated # ====================================================================== - - print(f"The following plots and tables will be created for {bmk_type}:") - if config["options"]["outputs"]["plot_conc"]: - print(" - Concentration plots") - if config["options"]["outputs"]["plot_emis"]: - print(" - Emissions plots") - if config["options"]["outputs"]["plot_jvalues"]: - print(" - J-values (photolysis rates) plots") - if config["options"]["outputs"]["plot_aod"]: - print(" - Aerosol optical depth plots") - if config["options"]["outputs"]["ops_budget_table"]: - print(" - Operations budget tables") - if config["options"]["outputs"]["aer_budget_table"]: - print(" - Aerosol budget/burden tables") - if config["options"]["outputs"]["emis_table"]: - print(" - Table of emissions totals by species and inventory") - if config["options"]["outputs"]["mass_table"]: - print(" - Table of species mass") - if config["options"]["outputs"]["OH_metrics"]: - print(" - Table of OH metrics") - if config["options"]["outputs"]["ste_table"]: - print(" - Table of strat-trop exchange") - if config["options"]["outputs"]["plot_models_vs_obs"]: - print(" - Plots of models vs. observations") - print("Comparisons will be made for the following combinations:") - if config["options"]["comparisons"]["gcc_vs_gcc"]["run"]: - print(" - GCC vs GCC") - if config["options"]["comparisons"]["gchp_vs_gcc"]["run"]: - print(" - GCHP vs GCC") - if config["options"]["comparisons"]["gchp_vs_gchp"]["run"]: - print(" - GCHP vs GCHP") - if config["options"]["comparisons"]["gchp_vs_gcc_diff_of_diffs"]["run"]: - print(" - GCHP vs GCC diff of diffs") + bmk_util.print_benchmark_info(config) # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # Create GCC vs GCC benchmark plots and tables @@ -650,6 +623,65 @@ def run_benchmark(config, bmk_year_ref, bmk_year_dev): n_job=config["options"]["n_cores"] ) + # ================================================================== + # GCC vs. GCC drydep plots + # ================================================================== + if config["options"]["outputs"]["plot_drydep"]: + print("\n%%% Creating GCC vs. GCC drydep plots %%%") + + # -------------------------------------------------------------- + # GCC vs GCC drydep plots: Annual mean + # -------------------------------------------------------------- + + # Filepaths + ref = get_filepaths( + gcc_vs_gcc_refdir, + "DryDep", + all_months_ref + )[0] + dev = get_filepaths( + gcc_vs_gcc_devdir, + "DryDep", + all_months_dev + )[0] + + # Create plots + print("\nCreating plots for annual mean") + make_benchmark_drydep_plots( + ref, + gcc_vs_gcc_refstr, + dev, + gcc_vs_gcc_devstr, + dst=gcc_vs_gcc_resultsdir, + subdst="AnnualMean", + time_mean=True, + weightsdir=config["paths"]["weights_dir"], + overwrite=True, + spcdb_dir=spcdb_dir, + n_job=config["options"]["n_cores"] + ) + + # -------------------------------------------------------------- + # GCC vs GCC drydep plots: Seasonal + # -------------------------------------------------------------- + for mon in range(bmk_n_months): + print(f"\nCreating plots for {bmk_mon_strs[mon]}") + + # Create plots + mon_ind = bmk_mon_inds[mon] + make_benchmark_drydep_plots( + ref[mon_ind], + gcc_vs_gcc_refstr, + dev[mon_ind], + gcc_vs_gcc_devstr, + dst=gcc_vs_gcc_resultsdir, + subdst=bmk_mon_yr_strs_dev[mon], + weightsdir=config["paths"]["weights_dir"], + overwrite=True, + spcdb_dir=spcdb_dir, + n_job=config["options"]["n_cores"] + ) + # ================================================================== # GCC vs GCC mass tables # ================================================================== @@ -1194,6 +1226,66 @@ def gcc_vs_gcc_ops_budg(mon): n_job=config["options"]["n_cores"] ) + # ================================================================== + # GCC vs. GCC drydep plots + # ================================================================== + if config["options"]["outputs"]["plot_drydep"]: + print("\n%%% Creating GCHP vs. GCC drydep plots %%%") + + # -------------------------------------------------------------- + # GCC vs GCC drydep plots: Annual mean + # -------------------------------------------------------------- + + # Filepaths + ref = get_filepaths( + gcc_vs_gcc_refdir, + "DryDep", + all_months_ref + )[0] + dev = get_filepaths( + gchp_vs_gcc_devdir, + "DryDep", + all_months_gchp_dev, + is_gchp=True + )[0] + + # Create plots + print("\nCreating plots for annual mean") + make_benchmark_drydep_plots( + ref, + gchp_vs_gcc_refstr, + dev, + gchp_vs_gcc_devstr, + dst=gchp_vs_gcc_resultsdir, + subdst="AnnualMean", + time_mean=True, + weightsdir=config["paths"]["weights_dir"], + overwrite=True, + spcdb_dir=spcdb_dir, + n_job=config["options"]["n_cores"] + ) + + # -------------------------------------------------------------- + # GCC vs GCC drydep plots: Seasonal + # -------------------------------------------------------------- + for mon in range(bmk_n_months): + print(f"\nCreating plots for {bmk_mon_strs[mon]}") + + # Create plots + mon_ind = bmk_mon_inds[mon] + make_benchmark_drydep_plots( + ref[mon_ind], + gchp_vs_gcc_refstr, + dev[mon_ind], + gchp_vs_gcc_devstr, + dst=gchp_vs_gcc_resultsdir, + subdst=bmk_mon_yr_strs_dev[mon], + weightsdir=config["paths"]["weights_dir"], + overwrite=True, + spcdb_dir=spcdb_dir, + n_job=config["options"]["n_cores"] + ) + # ================================================================== # GCHP vs GCC global mass tables # ================================================================== @@ -1786,6 +1878,69 @@ def gchp_vs_gcc_ops_budg(mon): n_job=config["options"]["n_cores"] ) + # ================================================================== + # GCHP vs GCHP drydep plots + # ================================================================== + if config["options"]["outputs"]["plot_drydep"]: + print("\n%%% Creating GCHP vs. GCHP drydep plots %%%") + + # -------------------------------------------------------------- + # GCHP vs GCHP drydep: Annual Mean + # -------------------------------------------------------------- + + # Filepaths + ref = get_filepaths( + gchp_vs_gchp_refdir, + "DryDep", + all_months_gchp_ref, + is_gchp=True + )[0] + dev = get_filepaths( + gchp_vs_gchp_devdir, + "DryDep", + all_months_gchp_dev, + is_gchp=True + )[0] + + # Create plots + print("\nCreating plots for annual mean") + make_benchmark_drydep_plots( + ref, + gchp_vs_gchp_refstr, + dev, + gchp_vs_gchp_devstr, + dst=gchp_vs_gchp_resultsdir, + subdst="AnnualMean", + cmpres=cmpres, + time_mean=True, + weightsdir=config["paths"]["weights_dir"], + overwrite=True, + spcdb_dir=spcdb_dir, + n_job=config["options"]["n_cores"] + ) + + # -------------------------------------------------------------- + # GCHP vs GCHP drydep plots: Seasonal + # -------------------------------------------------------------- + for mon in range(bmk_n_months): + print(f"\nCreating plots for {bmk_mon_strs[mon]}") + + # Create plots + mon_ind = bmk_mon_inds[mon] + make_benchmark_drydep_plots( + ref[mon_ind], + gchp_vs_gchp_refstr, + dev[mon_ind], + gchp_vs_gchp_devstr, + dst=gchp_vs_gchp_resultsdir, + subdst=bmk_mon_yr_strs_dev[mon], + cmpres=cmpres, + weightsdir=config["paths"]["weights_dir"], + overwrite=True, + spcdb_dir=spcdb_dir, + n_job=config["options"]["n_cores"] + ) + # ================================================================== # GCHP vs GCHP global mass tables # ================================================================== diff --git a/gcpy/benchmark/modules/run_1yr_tt_benchmark.py b/gcpy/benchmark/modules/run_1yr_tt_benchmark.py index 878dad76..f7f3ffce 100644 --- a/gcpy/benchmark/modules/run_1yr_tt_benchmark.py +++ b/gcpy/benchmark/modules/run_1yr_tt_benchmark.py @@ -60,6 +60,7 @@ from gcpy import benchmark_funcs as bmk import gcpy.budget_tt as ttbdg import gcpy.ste_flux as ste +import gcpy.benchmark.modules.benchmark_utils as bmk_util # Tell matplotlib not to look for an X-window os.environ["QT_QPA_PLATFORM"] = "offscreen" @@ -298,30 +299,9 @@ def run_benchmark(config, bmk_year_ref, bmk_year_dev): sec_per_yr_dev += days_in_mon * 86400.0 # ======================================================================= - # Print the list of plots & tables to the screen + # Print the list of plots & tables being generated # ======================================================================= - print("The following plots and tables will be created for {}:".format(bmk_type)) - if config["options"]["outputs"]["plot_conc"]: - print(" - Concentration plots") - if config["options"]["outputs"]["plot_wetdep"]: - print(" - Convective and large-scale wet deposition plots") - if config["options"]["outputs"]["rnpbbe_budget"]: - print(" - Radionuclides budget table") - if config["options"]["outputs"]["operations_budget"]: - print(" - Operations budget table") - if config["options"]["outputs"]["ste_table"]: - print(" - Table of strat-trop exchange") - if config["options"]["outputs"]["mass_table"]: - print(" - Table of species mass") - if config["options"]["outputs"]["cons_table"]: - print(" - Table of mass conservation") - print("Comparisons will be made for the following combinations:") - if config["options"]["comparisons"]["gcc_vs_gcc"]["run"]: - print(" - GCC vs GCC") - if config["options"]["comparisons"]["gchp_vs_gcc"]["run"]: - print(" - GCHP vs GCC") - if config["options"]["comparisons"]["gchp_vs_gchp"]["run"]: - print(" - GCHP vs GCHP") + bmk_util.print_benchmark_info(config) # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # Create GCC vs GCC benchmark plots and tables diff --git a/gcpy/benchmark/run_benchmark.py b/gcpy/benchmark/run_benchmark.py index 36b843bc..b82ebcf2 100755 --- a/gcpy/benchmark/run_benchmark.py +++ b/gcpy/benchmark/run_benchmark.py @@ -54,7 +54,8 @@ import run_benchmark as run_1yr_benchmark from gcpy.benchmark.modules.run_1yr_tt_benchmark \ import run_benchmark as run_1yr_tt_benchmark -from gcpy.benchmark.modules.benchmark_6panel_plots \ +import gcpy.benchmark.modules.benchmark_utils as bmk_util +from gcpy.benchmark.modules.benchmark_drydep \ import make_benchmark_drydep_plots # Tell matplotlib not to look for an X-window @@ -330,41 +331,7 @@ def run_benchmark_default(config): # ====================================================================== # Print the list of plots & tables to the screen # ====================================================================== - tmpstr = config["options"]["bmk_type"] - print( - f"The following plots and tables will be created for {tmpstr}" - ) - if config["options"]["outputs"]["plot_conc"]: - print(" - Concentration plots") - if config["options"]["outputs"]["plot_emis"]: - print(" - Emissions plots") - if config["options"]["outputs"]["plot_jvalues"]: - print(" - J-values (photolysis rates) plots") - if config["options"]["outputs"]["plot_aod"]: - print(" - Aerosol optical depth plots") - if config["options"]["outputs"]["plot_drydep"]: - print(" - Drydep velocity plots") - if config["options"]["outputs"]["ops_budget_table"]: - print(" - Operations budget tables") - if config["options"]["outputs"]["emis_table"]: - print(" - Table of emissions totals by spc and inventory") - if config["options"]["outputs"]["mass_table"]: - print(" - Table of species mass") - if config["options"]["outputs"]["mass_accum_table"]: - print(" - Table of species mass accumulation") - if config["options"]["outputs"]["OH_metrics"]: - print(" - Table of OH metrics") - if config["options"]["outputs"]["ste_table"]: - print(" - Table of strat-trop exchange") - print("Comparisons will be made for the following combinations:") - if config["options"]["comparisons"]["gcc_vs_gcc"]["run"]: - print(" - GCC vs GCC") - if config["options"]["comparisons"]["gchp_vs_gcc"]["run"]: - print(" - GCHP vs GCC") - if config["options"]["comparisons"]["gchp_vs_gchp"]["run"]: - print(" - GCHP vs GCHP") - if config["options"]["comparisons"]["gchp_vs_gcc_diff_of_diffs"]["run"]: - print(" - GCHP vs GCC diff of diffs") + bmk_util.print_benchmark_info(config) # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # Create GCC vs GCC benchmark plots and tables @@ -549,7 +516,7 @@ def run_benchmark_default(config): dev = get_filepath(gcc_vs_gcc_devdir, "DryDep", gcc_dev_date) # Create plots - make_benchmark_6panel_plots( + make_benchmark_drydep_plots( ref, gcc_vs_gcc_refstr, dev, @@ -560,7 +527,6 @@ def run_benchmark_default(config): sigdiff_files=gcc_vs_gcc_sigdiff, spcdb_dir=spcdb_dir, n_job=config["options"]["n_cores"], - var_prefix="DryDepVel" ) @@ -693,17 +659,6 @@ def run_benchmark_default(config): if config["options"]["outputs"]["summary_table"]: print("\n%%% Creating GCC vs. GCC summary table %%%") - # Diagnostic collections to check - collections = [ - 'AerosolMass', - 'Aerosols', - 'Emissions', - 'JValues', - 'Metrics', - 'SpeciesConc', - 'StateMet', - ] - # Print summary of which collections are identical # between Ref & Dev, and which are not identical. bmk.create_benchmark_summary_table(