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

Climo output name #579

Merged
merged 11 commits into from
Oct 25, 2018
Prev Previous commit
Next Next commit
flake8ed
  • Loading branch information
doutriaux1 committed Oct 11, 2018
commit abc053b06ec62b5ff0eb312049a1ce853de7fcdc
13 changes: 8 additions & 5 deletions src/python/pcmdi/scripts/pcmdi_compute_climatologies.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import cdutil
import numpy
import cdtime
import genutil
from pcmdi_metrics.driver.pmp_parser import PMPParser
import glob

Expand Down Expand Up @@ -66,7 +67,9 @@
help="indexation type")
p.add_argument("-o", "--output_filename_template",
help="template for output filename",
default="%(variable)_PMP_%(model_id)_%(experiment_id)_r%(realization)i%(initialization_method)p%(physics_version)_%(start)-%(end)-clim-%(season).nc"
default="%(variable)_PMP_%(model_id)_%(experiment_id)_" +
"r%(realization)i%(initialization_method)p%(physics_version)" +
"_%(start)-%(end)-clim-%(season).nc"
)
p.add_argument("-f", "--filename_template",
dest="filename_template",
Expand Down Expand Up @@ -145,7 +148,7 @@
filename_in = A.process_templated_argument(os.path.join(A.modpath, A.filename_template))

if A.verbose:
print("filename in after templating:", filename_in())
print("filename in after templating:", filename_in())
filename = glob.glob(filename_in())[0]

if not os.path.exists(filename):
Expand Down Expand Up @@ -557,10 +560,10 @@ def store_attributes(var):
end = "{}{:02d}".format(end_tc.year, end_tc.month)
for k in fnmout.keys():
try:
setattr(fnmout,k,getattr(A,k))
except:
setattr(fnmout, k, getattr(A, k))
except Exception:
pass
setattr(fnmout,k,locals()[k])
setattr(fnmout, k, locals()[k])
nm = os.path.join(A.results_dir, fnmout())
f = cdms2.open(nm, "w")
# Global attributes copied
Expand Down