Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

910 pjg computeclimopts #911

Merged
merged 7 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions pcmdi_metrics/mean_climate/lib/calculate_climatology.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion pcmdi_metrics/mean_climate/pcmdi_compute_climatologies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)