diff --git a/pcmdi_metrics/mean_climate/lib/calculate_climatology.py b/pcmdi_metrics/mean_climate/lib/calculate_climatology.py index 28f05920d..1197f81e2 100644 --- a/pcmdi_metrics/mean_climate/lib/calculate_climatology.py +++ b/pcmdi_metrics/mean_climate/lib/calculate_climatology.py @@ -10,7 +10,7 @@ def calculate_climatology( var, infile, outfile=None, outpath=None, outfilename=None, - start=None, end=None, ver=None): + start=None, end=None, ver=None, periodinname=None, climlist=None): if ver is None: ver=datetime.datetime.now().strftime("v%Y%m%d") @@ -84,8 +84,14 @@ def calculate_climatology( d_clim_dict['SON'] = d_clim.isel(time=3) d_clim_dict['AC'] = d_ac - for s in ["AC", "DJF", "MAM", "JJA", "SON"]: - addf = ( + if climlist is None: + clims = ["AC", "DJF", "MAM", "JJA", "SON"] + else: + clims = climlist + + for s in clims: + if periodinname is None: + addf = ( "." + start_yr_str + start_mo_str @@ -96,8 +102,15 @@ def calculate_climatology( + s + "." + ver - + ".nc" - ) + + ".nc") + if periodinname is not None: + addf = ( + "." + + s + + "." + + ver + + ".nc") + if outfilename is not None: out = os.path.join(outdir, outfilename) out_season = out.replace(".nc", addf) diff --git a/pcmdi_metrics/mean_climate/pcmdi_compute_climatologies.py b/pcmdi_metrics/mean_climate/pcmdi_compute_climatologies.py index 62a8c5307..2cb1285ca 100755 --- a/pcmdi_metrics/mean_climate/pcmdi_compute_climatologies.py +++ b/pcmdi_metrics/mean_climate/pcmdi_compute_climatologies.py @@ -31,6 +31,10 @@ ) P.add_argument("--end", dest="end", help="Defines end year and month", required=False) +P.add_argument("--periodinname", dest="periodinname", help="Include clim period in name (default yes) or not", required=False) + +P.add_argument("--climlist", dest="climlist", help="Defines list of clim seasons to output (default='all')", required=False) + args = P.get_parameter() infile_template = args.infile @@ -40,6 +44,8 @@ varlist = args.vars start = args.start end = args.end +periodinname = args.periodinname +climlist = args.climlist print("start and end are ", start, " ", end) print("variable list: ", varlist) @@ -68,4 +74,4 @@ print('outpath:', outpath) # calculate climatologies for this variable - calculate_climatology(var, infile, outfile, outpath, outfilename, start, end, ver) + calculate_climatology(var, infile, outfile, outpath, outfilename, start, end, ver, periodinname, climlist)