Skip to content

Commit

Permalink
Merge pull request #706 from PCMDI/663_ao_diurnal
Browse files Browse the repository at this point in the history
Add CMEC formatted metrics to diurnal cycle drivers
  • Loading branch information
gleckler1 authored Mar 15, 2021
2 parents 18cdf9e + ae4845c commit 20d332e
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pcmdi_metrics/diurnal/scripts/savg_fourier.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,24 @@ def main():
default="cmip5.%(model).%(experiment).r0i0p0.fx.atm.fx.sftlf.%(version).latestX.xml",
help="template for sftlf file names")
P.add_argument("--model", default="*")
P.add_argument("--cmec",
dest='cmec',
action='store_true',
default=False,
help="Use to save metrics in CMEC JSON format")
P.add_argument("--no_cmec",
dest='cmec',
action='store_false',
default=False,
help="Use to disable saving metrics in CMEC JSON format")

args = P.get_parameter()
month = args.month
monthname = monthname_d[month]
startyear = args.firstyear
finalyear = args.lastyear
years = "%s-%s" % (startyear, finalyear) # noqa: F841
cmec = args.cmec

print('Specifying latitude / longitude domain of interest ...')
# TRMM (observed) domain:
Expand Down Expand Up @@ -287,6 +298,9 @@ def spacevavg(tvarb1, tvarb2, sftlf, model):
separators=(
',',
': '))
if cmec:
print("Writing cmec file")
OUT.write_cmec(indent=4, separators=(',', ': '))
print('done')


Expand Down
14 changes: 14 additions & 0 deletions pcmdi_metrics/diurnal/scripts/std_of_dailymeans.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,23 @@ def compute(param):
P.add_argument("-t", "--filename_template",
default="pr_%(model)_%(month)_%(firstyear)-%(lastyear)_std_of_dailymeans.nc")
P.add_argument("--model", default="*")
P.add_argument("--cmec",
dest='cmec',
action='store_true',
default=False,
help="Use to save metrics in CMEC JSON format")
P.add_argument("--no_cmec",
dest='cmec',
action='store_false',
default=False,
help="Use to disable saving metrics in CMEC JSON format")

args = P.get_parameter()
month = args.month
monthname = monthname_d[month]
startyear = args.firstyear # noqa: F841
finalyear = args.lastyear # noqa: F841
cmec = args.cmec

template = populateStringConstructor(args.filename_template, args)
template.month = monthname
Expand Down Expand Up @@ -159,6 +170,9 @@ def compute(param):
separators=(
',',
': '))
if cmec:
print("Writing cmec file")
OUT.write_cmec(indent=4, separators=(',', ': '))
print('done')


Expand Down
14 changes: 14 additions & 0 deletions pcmdi_metrics/diurnal/scripts/std_of_hourlyvalues.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,23 @@ def compute(param):
P.add_argument("-t", "--filename_template",
default="pr_%(model)_%(month)_%(firstyear)-%(lastyear)_diurnal_std.nc")
P.add_argument("--model", default="*")
P.add_argument("--cmec",
dest='cmec',
action='store_true',
default=False,
help="Use to save metrics in CMEC JSON format")
P.add_argument("--no_cmec",
dest='cmec',
action='store_false',
default=False,
help="Use to disable saving metrics in CMEC JSON format")

args = P.get_parameter()
month = args.month
monthname = monthname_d[month]
startyear = args.firstyear # noqa: F841
finalyear = args.lastyear # noqa: F841
cmec = args.cmec

template = populateStringConstructor(args.filename_template, args)
template.month = monthname
Expand Down Expand Up @@ -169,6 +180,9 @@ def compute(param):
separators=(
',',
': '))
if cmec:
print("Writing cmec file")
OUT.write_cmec(indent=4, separators=(',', ': '))
print('done')


Expand Down
14 changes: 14 additions & 0 deletions pcmdi_metrics/diurnal/scripts/std_of_meandiurnalcycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,23 @@ def compute(param):
P.add_argument("-t", "--filename_template",
default="pr_%(model)_%(month)_%(firstyear)-%(lastyear)_diurnal_avg.nc")
P.add_argument("--model", default="*")
P.add_argument("--cmec",
dest='cmec',
action='store_true',
default=False,
help="Use to save metrics in CMEC JSON format")
P.add_argument("--no_cmec",
dest='cmec',
action='store_false',
default=False,
help="Use to disable saving metrics in CMEC JSON format")

args = P.get_parameter()
month = args.month
monthname = monthname_d[month]
startyear = args.firstyear # noqa: F841
finalyear = args.lastyear # noqa: F841
cmec = args.cmec

template = populateStringConstructor(args.filename_template, args)
template.month = monthname
Expand Down Expand Up @@ -173,6 +184,9 @@ def compute(param):
separators=(
',',
': '))
if cmec:
print("Writing cmec file")
OUT.write_cmec(indent=4, separators=(',', ': '))
print('done')


Expand Down

0 comments on commit 20d332e

Please sign in to comment.