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

added option for dry run #322

Merged
merged 6 commits into from
Jul 20, 2016
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fixed merge conflicts
  • Loading branch information
doutriaux1 committed Jul 19, 2016
commit 7530544a2649cc9b91dd9ab59ee7a0a30d443642
97 changes: 51 additions & 46 deletions src/python/pcmdi/scripts/pcmdi_metrics_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,12 @@ def applyCustomKeys(O, custom_dict, var):
else:
do = OBS.get(var,region=region)
except Exception as err:
dup('failed reading OBS', var, ref, err)
dup.tb = args.traceback
if level is not None:
dup('failed opening 4D OBS', var, ref, err)
else:
dup('failed opening 3D OBS', var, ref, err)
dup.tb = False
continue
grd["GridResolution"] = do.shape[1:]
metrics_dictionary["GridInfo"] = grd
Expand Down Expand Up @@ -556,8 +561,8 @@ def applyCustomKeys(O, custom_dict, var):
#
# METRICS CALCULATIONS
#
metrics_dictionary[model_version] = \
metrics_dictionary.get(
metrics_dictionary["RESULTS"][model_version] = \
metrics_dictionary["RESULTS"].get(
model_version,
{})
# Stores model's simul description
Expand Down Expand Up @@ -641,57 +646,57 @@ def applyCustomKeys(O, custom_dict, var):
parameters.realization,
{})
if not args.dry_run:
pr_rgn = pcmdi_metrics.pcmdi.compute_metrics(
pr_rgn = pcmdi_metrics.pcmdi.compute_metrics(
Var,
dm,
do)
# Calling compute metrics with None for model and
# obs, triggers it to send back the defs.
metrics_def_dictionary.update(
pcmdi_metrics.pcmdi.compute_metrics(
Var,
dm,
do)
# Calling compute metrics with None for model and
# obs, triggers it to send back the defs.
metrics_def_dictionary.update(
pcmdi_metrics.pcmdi.compute_metrics(
None,
None))
#
# The follwoing allow users to plug in a set of
# custom metrics
# Function needs to take in var name,
# model clim, obs clim
#
if hasattr(parameters, "compute_custom_metrics"):
pr_rgn.update(
parameters.compute_custom_metrics(
Var,
None,
None))
#
# The follwoing allow users to plug in a set of
# custom metrics
# Function needs to take in var name,
# model clim, obs clim
#
if hasattr(parameters, "compute_custom_metrics"):
pr_rgn.update(
dm,
do))
# Calling compute metrics with None
# for model and
# obs, triggers it to send back the defs.
# But we are wrapping this in an except/try in
# case user did not implement
try:
metrics_def_dictionary.update(
parameters.compute_custom_metrics(
Var,
dm,
do))
# Calling compute metrics with None
# for model and
# obs, triggers it to send back the defs.
# But we are wrapping this in an except/try in
# case user did not implement
try:
metrics_def_dictionary.update(
parameters.compute_custom_metrics(
Var,
None,
None))
except:
# Better than nothing we will use the doc
# string
metrics_def_dictionary.update(
{"custom": parameters.
compute_custom_metrics.__doc__})
pr[region_name] = collections.OrderedDict(
(k,
pr_rgn[k]) for k in sorted(
pr_rgn.keys()))
None,
None))
except:
# Better than nothing we will use the doc
# string
metrics_def_dictionary.update(
{"custom": parameters.
compute_custom_metrics.__doc__})
pr[region_name] = collections.OrderedDict(
(k,
pr_rgn[k]) for k in sorted(
pr_rgn.keys()))
metrics_dictionary["RESULTS"][model_version][refabbv][
parameters.realization] = pr

# OUTPUT INTERPOLATED MODEL CLIMATOLOGIES
# Only the first time thru an obs set (always the
# same after)
if not args.dry_run and parameters.save_mod_clims and ref == refs[0]:
if not args.dry_run and hasattr(parameters,"save_mod_clims") and parameters.save_mod_clims is True and ref == refs[0]:
CLIM = pcmdi_metrics.io.base.Base(
os.path.join(parameters.
model_clims_interpolated_output,region_name),
Expand Down Expand Up @@ -739,5 +744,5 @@ def applyCustomKeys(O, custom_dict, var):
except Exception as err:
dup.tb = args.traceback
dup("Error while processing variable %s:\n\t%s" % (var, err))

print "Done. Check log at: ", Efile.name
dup.tb = False
dup("Done. Check log at: %s"% Efile.name)
You are viewing a condensed version of this merge commit. You can view the full changes here.