diff --git a/README.md b/README.md index d67affd4..fdfda0d8 100644 --- a/README.md +++ b/README.md @@ -226,6 +226,8 @@ do_mass_download: master_suites: auto_download: strictFileCheck: +dpi: +savepdf: jobs: : @@ -268,6 +270,12 @@ These values are: - `strictFileCheck`: - A boolean which when True will raise an error if input model files are missing. - Default is True, set to False to skip this check. + - `dpi`: + - Output images Dots per inch (dpi) + - dpi=100 is fine for most purposes but 300 is needed for highres posters/publications. + - `savepdf`: + - Outpout the image as a pdf in addition to the standard png. + - This doesn't replace the image in the report, but saves a pdf version of the image in the images directory. - `jobs`: - A list of jobIDs, and some options on how they will appear in the final report. - The options are: diff --git a/bgcval2/analysis_compare.py b/bgcval2/analysis_compare.py index f1d6b833..c19b7ec0 100755 --- a/bgcval2/analysis_compare.py +++ b/bgcval2/analysis_compare.py @@ -192,6 +192,8 @@ def timeseries_compare(jobs, labels = {}, ensembles={}, config_user=None, + dpi=None, + savepdf=False, ): """ timeseries_compare: @@ -423,6 +425,8 @@ def timeseries_compare(jobs, thicknesses=lineThicknesses, linestyles=linestyles, labels=labels, + dpi=dpi, + savepdf=savepdf, ) # Generate a list of comparison images: @@ -504,6 +508,12 @@ def load_comparison_yml(master_compare_yml_fn): details['do_mass_download'] = input_yml_dict.get('do_mass_download', False) details['master_suites'] = input_yml_dict.get('master_suites', []) + # Image output settings: + # dpi: pixels per inch (image resolution) + # savepdf: also save the image as a pdf. + details['dpi'] = input_yml_dict.get('dpi', None) + details['savepdf'] = input_yml_dict.get('savepdf', False) + # auto download, can differ for each job. auto_download = input_yml_dict.get('auto_download', True) auto_download_dict = {jobID: auto_download for jobID in details['jobs'].keys()} @@ -579,6 +589,9 @@ def load_yml_and_run(compare_yml, config_user, skip_timeseries): suites = details['suites'] auto_download = details['auto_download'] strictFileCheck = details.get('strictFileCheck', True) + dpi = details.get('dpi', None) + savepdf = details.get('savepdf', False) + print('---------------------') print('timeseries_compare:', analysis_name) print('job ids:', jobs.keys()) @@ -632,6 +645,9 @@ def load_yml_and_run(compare_yml, config_user, skip_timeseries): linestyles=linestyles, labels=labels, config_user=config_user, + dpi=dpi, + savepdf=savepdf, + ) diff --git a/bgcval2/bgcval2_make_report.py b/bgcval2/bgcval2_make_report.py index 50bd6884..2371a97b 100755 --- a/bgcval2/bgcval2_make_report.py +++ b/bgcval2/bgcval2_make_report.py @@ -1636,7 +1636,7 @@ def newImageLocation(fn): if len(otherFilenames): # I think this is never happens anymore. - assert 0 + #assert 0 href = 'OtherPlots-others' hrefs.append(href) diff --git a/bgcval2/timeseries/timeseriesPlots.py b/bgcval2/timeseries/timeseriesPlots.py index c34115a2..e25f4e45 100644 --- a/bgcval2/timeseries/timeseriesPlots.py +++ b/bgcval2/timeseries/timeseriesPlots.py @@ -35,6 +35,8 @@ import matplotlib.patches as mpatches import cartopy import numpy as np +import pathlib + from numpy import hanning, hamming, bartlett, blackman from scipy import interpolate from collections import defaultdict @@ -706,6 +708,8 @@ def multitimeseries( thicknesses=defaultdict(lambda: 1), linestyles=defaultdict(lambda: '-'), labels={}, + dpi=None, + savepdf=False, ): if 0 in [len(timesD), len(list(timesD.keys()))]: return @@ -1053,7 +1057,16 @@ def multitimeseries( pyplot.suptitle(title) print("multitimeseries:\tsimpletimeseries:\tSaving:", filename) - pyplot.savefig(filename) + if not dpi: + pyplot.savefig(filename) + imext = pathlib.Path(filename).suffix + + # save image as pdf (publication?) + if savepdf: + pyplot.savefig(filename.replace(imext, '.pdf')) + + if pathlib.Path(filename).suffix in ['.png', '.jpg', '.jpeg']: + pyplot.savefig(filename, dpi=dpi) pyplot.close() diff --git a/input_yml/TerraFIRMA_overshoot_runs_minimal.yml b/input_yml/TerraFIRMA_overshoot_runs_minimal.yml index cfa54aac..f0e778ba 100644 --- a/input_yml/TerraFIRMA_overshoot_runs_minimal.yml +++ b/input_yml/TerraFIRMA_overshoot_runs_minimal.yml @@ -16,6 +16,9 @@ strict_file_check: False clean: True +dpi: 300 +savepdf: True + jobs: u-cs495: description: 'PI-Control'