[cmor] 18/22: Update python3 patch
Alastair McKinstry
mckinstry at moszumanska.debian.org
Tue Dec 20 11:10:51 UTC 2016
This is an automated email from the git hooks/post-receive script.
mckinstry pushed a commit to branch debian/master
in repository cmor.
commit 6ed76ba5254b8bf57b477cec1a5cbb408945b7e3
Author: Alastair McKinstry <mckinstry at debian.org>
Date: Mon Dec 19 20:53:35 2016 +0000
Update python3 patch
---
debian/patches/python3.patch | 2100 ++++++++++++++----------------------------
1 file changed, 717 insertions(+), 1383 deletions(-)
diff --git a/debian/patches/python3.patch b/debian/patches/python3.patch
index 90a9ce2..8c89c9a 100644
--- a/debian/patches/python3.patch
+++ b/debian/patches/python3.patch
@@ -1,18 +1,18 @@
Author: Alastair McKinstry <mckinstry at debian.org>
Description: Fixes needed to make code python2/3 compatible. NOTE: INCOMPLETE
-Last-Updated: 2013-06-12
+Last-Updated: 2016-12-19
Forwarded: no
-Index: cmor-2.8.3/Lib/git2svn.py
+Index: cmor-3.2.0/Lib/git2svn.py
===================================================================
---- cmor-2.8.3.orig/Lib/git2svn.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Lib/git2svn.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Lib/git2svn.py
++++ cmor-3.2.0/Lib/git2svn.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
import os,sys
svn=sys.argv[1]
-@@ -17,15 +18,15 @@
+@@ -17,15 +18,15 @@ for l in git:
for f in modfiles+newfiles:
cmd = "cp -pf %s %s/%s" % (f,svn,f)
@@ -31,74 +31,78 @@ Index: cmor-2.8.3/Lib/git2svn.py
- print 'svn del :',cmd
+ print('svn del :',cmd)
os.popen(cmd).readlines()
-Index: cmor-2.8.3/Lib/pywrapper.py
+Index: cmor-3.2.0/Lib/pywrapper.py
===================================================================
---- cmor-2.8.3.orig/Lib/pywrapper.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Lib/pywrapper.py 2013-06-15 10:54:40.000000000 +0100
-@@ -1,5 +1,5 @@
--
--import cmor_const,numpy,os,_cmor
-+from . import cmor_const,_cmor
-+import numpy,os
+--- cmor-3.2.0.orig/Lib/pywrapper.py
++++ cmor-3.2.0/Lib/pywrapper.py
+@@ -1,8 +1,8 @@
+ import numpy
+ import os
+
+-import cmor_const
+-import _cmor
++from . import cmor_const
++from . import _cmor
+ from _cmor import CMORError
try:
- import cdtime
-@@ -37,25 +37,25 @@
- missing_value : scalar that is used to indicate missing data for this variable. It must be the same type as the data that will be passed to cmor_write. This missing_value will in general be replaced by a standard missing_value specified in the MIP table. If there are no missing data, and the user chooses not to declare the missing value, then this argument may be either omitted or assigned the value 'none' (i.e., missing_value='none').
+@@ -46,26 +46,26 @@ def time_varying_grid_coordinate(grid_id
+ omitted or assigned the value 'none' (i.e., missing_value='none').
"""
- if not isinstance(table_entry,str):
+ if not isinstance(table_entry, str):
- raise Exception, "Error you must pass a string for the variable table_entry"
+ raise Exception("Error you must pass a string for the variable table_entry")
-
- if not isinstance(units,str):
+
+ if not isinstance(units, str):
- raise Exception, "Error you must pass a string for the variable units"
+ raise Exception("Error you must pass a string for the variable units")
- if not isinstance(type,str):
+ if not isinstance(type, str):
- raise Exception, "error tpye must a a string"
-+ raise Exception("error tpye must a a string")
++ raise Exception( "error tpye must a a string")
type = type.lower()
if type == 's':
- type ='c'
- if not type in ["c","d","f","l","i"]:
+ type = 'c'
+ if type not in ["c", "d", "f", "l", "i"]:
- raise Exception, 'error unknown type: "%s", must be one of: "c","d","f","l","i"'
-+ raise Exception('error unknown type: "%s", must be one of: "c","d","f","l","i"')
++ raise Exception ('error unknown type: "%s", must be one of: "c","d","f","l","i"')
- if not isinstance(grid_id,(int,numpy.int,numpy.int32)):
+ if not isinstance(grid_id, (int, numpy.int, numpy.int32)):
- raise Exception, "error grid_id must be an integer"
+ raise Exception("error grid_id must be an integer")
+
grid_id = int(grid_id)
if missing_value is not None:
- if not isinstance(missing_value,(float,int,numpy.float,numpy.float32,numpy.int,numpy.int32)):
+ if not isinstance(missing_value, (float, int, numpy.float, numpy.float32, numpy.int, numpy.int32)):
- raise Exception, "error missing_value must be a number, you passed: %s" % type(missing_value)
-+ raise Exception("error missing_value must be a number, you passed: %s" % type(missing_value))
++ raise Exception ("error missing_value must be a number, you passed: %s" % type(missing_value))
missing_value = float(missing_value)
-
- return _cmor.time_varying_grid_coordinate(grid_id,table_entry,units,type,missing_value)
-@@ -68,7 +68,7 @@
+
+ return _cmor.time_varying_grid_coordinate(grid_id, table_entry, units, type, missing_value)
+@@ -78,7 +78,7 @@ def _to_numpy(vals, message):
try:
vals = numpy.ascontiguousarray(vals.filled())
except:
- raise Exception, "Error could not convert %s to a numpy array" % message
-+ raise Exception("Error could not convert %s to a numpy array" % message)
-
++ raise Exception ("Error could not convert %s to a numpy array" % message)
+
return vals
-@@ -92,32 +92,32 @@
+@@ -102,32 +102,32 @@ def grid(axis_ids,latitude=None,longitud
elif isinstance(axis_ids,(list,tuple)):
axis_ids = numpy.ascontiguousarray(axis_ids)
elif not isinstance(axis_ids, numpy.ndarray):
- raise Exception, "Error could not convert axis_ids list to a numpy array"
-+ raise Exception("Error could not convert axis_ids list to a numpy array")
++ raise Exception( "Error could not convert axis_ids list to a numpy array")
- if numpy.rank(axis_ids)>1:
+ if numpy.ndim(axis_ids)>1:
- raise Exception, "error axes list/array must be 1D"
+ raise Exception("error axes list/array must be 1D")
if latitude is not None:
latitude = _to_numpy(latitude, 'latitude')
-
- if numpy.rank(latitude)!=len(axis_ids):
+
+ if numpy.ndim(latitude)!=len(axis_ids):
- raise Exception, "latitude's rank does not match number of axes passed via axis_ids"
+ raise Exception("latitude's rank does not match number of axes passed via axis_ids")
@@ -110,12 +114,11 @@ Index: cmor-2.8.3/Lib/pywrapper.py
longitude = _to_numpy(longitude, 'longitude')
- if numpy.rank(longitude)!=len(axis_ids):
+ if numpy.ndim(longitude)!=len(axis_ids):
- raise Exception, "longitude's rank does not match number of axes passed via axis_ids"
+ raise Exception("longitude's rank does not match number of axes passed via axis_ids")
-
-- ## print 'longitude type:',longitude.dtype.char
-+ ## print('longitude type:',longitude.dtype.char)
+
+ ## print 'longitude type:',longitude.dtype.char
if longitude.dtype.char!=type:
longitude = longitude.astype(type)
elif longitude is not None:
@@ -124,14 +127,13 @@ Index: cmor-2.8.3/Lib/pywrapper.py
else:
type='f'
if nvertices is None :
-@@ -129,19 +129,19 @@
+@@ -139,19 +139,19 @@ def grid(axis_ids,latitude=None,longitud
latitude_vertices = _to_numpy(latitude_vertices, 'latitude_vertices')
- if numpy.rank(latitude_vertices)!=len(axis_ids)+1:
+ if numpy.ndim(latitude_vertices)!=len(axis_ids)+1:
- raise Exception, "latitude_vertices's rank does not match number of axes passed via axis_ids +1 (for vertices)"
--## print 'latitude_vert type:',latitude_vertices.dtype.char
-+ raise Exception("latitude_vertices's rank does not match number of axes passed via axis_ids +1 (for vertices)")
-+## print('latitude_vert type:',latitude_vertices.dtype.char)
++ raise Exception( "latitude_vertices's rank does not match number of axes passed via axis_ids +1 (for vertices)")
+ ## print 'latitude_vert type:',latitude_vertices.dtype.char
if latitude_vertices.dtype.char!=type:
latitude_vertices = latitude_vertices.astype(type)
nvert = latitude_vertices.shape[-1]
@@ -139,16 +141,16 @@ Index: cmor-2.8.3/Lib/pywrapper.py
if nvert!=nvertices:
- raise Exception,"you passed nvertices as: %i, but from your latitude_vertices it seems to be: %i" % (nvertices,nvert)
+ raise Exception("you passed nvertices as: %i, but from your latitude_vertices it seems to be: %i" % (nvertices,nvert))
-
+
if longitude_vertices is not None:
longitude_vertices = _to_numpy(longitude_vertices, 'longitude_vertices')
- if numpy.rank(longitude_vertices)!=len(axis_ids)+1:
+ if numpy.ndim(longitude_vertices)!=len(axis_ids)+1:
- raise Exception, "longitude_vertices's rank does not match number of axes passed via axis_ids +1 (for vertices)"
+ raise Exception("longitude_vertices's rank does not match number of axes passed via axis_ids +1 (for vertices)")
## print 'longitude_vert type:',longitude_vertices.dtype.char
if longitude_vertices.dtype.char!=type:
longitude_vertices = longitude_vertices.astype(type)
-@@ -149,10 +149,10 @@
+@@ -159,10 +159,10 @@ def grid(axis_ids,latitude=None,longitud
if latitude_vertices is None:
nvert = nvert2
elif nvert!=nvert2:
@@ -159,9 +161,9 @@ Index: cmor-2.8.3/Lib/pywrapper.py
- raise Exception,"you passed nvertices as: %i, but from your longitude_vertices it seems to be: %i" % (nvertices,nvert)
+ raise Exception("you passed nvertices as: %i, but from your longitude_vertices it seems to be: %i" % (nvertices,nvert))
-
+
## if area is not None:
-@@ -160,9 +160,9 @@
+@@ -170,9 +170,9 @@ def grid(axis_ids,latitude=None,longitud
## try:
## area = numpy.ascontiguousarray(area.filled())
## except:
@@ -173,7 +175,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
## if area.dtype.char!=type:
## area = area.astype(type)
n = len(axis_ids)
-@@ -181,27 +181,31 @@
+@@ -191,27 +191,31 @@ def set_grid_mapping(grid_id,mapping_nam
parameter_values :: array/list of parameter values in the same order of parameter_names (ignored if parameter_names is ditcionary)
parameter_units :: array/list of parameter units in the same order of parameter_names (ignored if parameter_names is ditcionary)
"""
@@ -212,7 +214,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
for v in val:
if isinstance(v,str):
punit.append(v)
-@@ -210,20 +214,20 @@
+@@ -220,20 +224,20 @@ def set_grid_mapping(grid_id,mapping_nam
except:
pass
if len(pvals)!=len(punits) or len(pvals)!=len(pnams):
@@ -239,7 +241,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
punit = list(parameter_units)
if isinstance(parameter_values,(list,tuple)):
pvals = list(parameter_values)
-@@ -231,11 +235,11 @@
+@@ -241,11 +245,11 @@ def set_grid_mapping(grid_id,mapping_nam
try:
pvals = numpy.ascontiguousarray(parameter_values.filled())
except:
@@ -254,7 +256,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
pvals = numpy.ascontiguousarray(pvals).astype('d')
return _cmor.set_grid_mapping(grid_id,mapping_name,pnms,pvals,punit)
-@@ -255,11 +259,11 @@
+@@ -265,11 +269,11 @@ def axis(table_entry,units=None,length=N
interval: a string used for time axes only (???)
"""
if not isinstance(table_entry,str):
@@ -268,43 +270,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
else:
if has_cdms2 and isinstance(coord_vals,cdms2.axis.TransientAxis):
if units is None:
-@@ -286,10 +290,10 @@
- coord_vals = numpy.ascontiguousarray(coord_vals.filled())
-
- if not isinstance(coord_vals,numpy.ndarray):
-- raise Exception, "Error coord_vals must be an array or cdms2 axis or list/tuple"
-+ raise Exception("Error coord_vals must be an array or cdms2 axis or list/tuple")
-
- if numpy.rank(coord_vals)>1:
-- raise Exception, "Error, you must pass a 1D array!"
-+ raise Exception("Error, you must pass a 1D array!")
-
- if numpy.ma.isMA(cell_bounds):
- cell_bounds = numpy.ascontiguousarray(cell_bounds.filled())
-@@ -304,18 +308,18 @@
-
- if cell_bounds is not None:
- if numpy.rank(cell_bounds)>2:
-- raise Exception, "Error cell_bounds rank must be at most 2"
-+ raise Exception("Error cell_bounds rank must be at most 2")
- if numpy.rank(cell_bounds)==2:
- if cell_bounds.shape[0]!=coord_vals.shape[0]:
-- raise Exception, "Error, coord_vals and cell_bounds do not have the same length"
-+ raise Exception("Error, coord_vals and cell_bounds do not have the same length")
- if cell_bounds.shape[1]!=2:
-- raise Exception, "Error, cell_bounds' second dimension must be of length 2"
-+ raise Exception("Error, cell_bounds' second dimension must be of length 2")
- cbnds = 2
- cell_bounds = numpy.ascontiguousarray(numpy.ravel(cell_bounds))
- else:
- cbnds = 1
- if len(cell_bounds)!=len(coord_vals)+1:
-- raise Exception, "error cell_bounds are %i long and axes coord_vals are %i long this is not consistent" % (len(cell_bounds),len(coord_vals))
-+ raise Exception("error cell_bounds are %i long and axes coord_vals are %i long this is not consistent" % (len(cell_bounds),len(coord_vals)))
- else:
- cbnds = 0
-
-@@ -324,7 +328,7 @@
+@@ -334,7 +338,7 @@ def axis(table_entry,units=None,length=N
type = coord_vals.dtype.char[0]
if not type in ['i','l','f','d','S']:
@@ -313,71 +279,16 @@ Index: cmor-2.8.3/Lib/pywrapper.py
if type == 'S':
type = 'c'
-@@ -344,7 +348,7 @@
-
+@@ -354,7 +358,7 @@ def axis(table_entry,units=None,length=N
+
if units is None:
if coord_vals is not None:
- raise Exception, "Error you need to provide the units your coord_vals are in"
+ raise Exception("Error you need to provide the units your coord_vals are in")
else:
units = "1"
-
-@@ -359,26 +363,26 @@
- def variable(table_entry,units,axis_ids,type='f',missing_value=None,tolerance = 1.e-4,positive=None,original_name=None,history=None,comment=None):
-
- if not isinstance(table_entry,str):
-- raise Exception, "Error you must pass a string for the variable table_entry"
-+ raise Exception("Error you must pass a string for the variable table_entry")
-
- if not isinstance(units,str):
-- raise Exception, "Error you must pass a string for the variable units"
-+ raise Exception("Error you must pass a string for the variable units")
- if original_name is not None:
- if not isinstance(original_name,str):
-- raise Exception, "Error you must pass a string for the variable original_name"
-+ raise Exception("Error you must pass a string for the variable original_name")
- else:
- original_name = ""
-
- if history is not None:
- if not isinstance(history,str):
-- raise Exception, "Error you must pass a string for the variable history"
-+ raise Exception("Error you must pass a string for the variable history")
- else:
- history = ""
-
- if comment is not None:
- if not isinstance(comment,str):
-- raise Exception, "Error you must pass a string for the variable comment"
-+ raise Exception("Error you must pass a string for the variable comment")
- else:
- comment = ""
-
-@@ -391,18 +395,18 @@
- elif isinstance(axis_ids,(list,tuple)):
- axis_ids = numpy.ascontiguousarray(axis_ids)
- elif not isinstance(axis_ids, numpy.ndarray):
-- raise Exception, "Error could not convert axis_ids list to a numpy array"
-+ raise Exception("Error could not convert axis_ids list to a numpy array")
-
- if numpy.rank(axis_ids)>1:
-- raise Exception, "error axis_ids list/array must be 1D"
-+ raise Exception("error axis_ids list/array must be 1D")
-
- if not isinstance(type,str):
-- raise Exception, "error tpye must a a string"
-+ raise Exception("error tpye must a a string")
- type = type.lower()
- if type == 's':
- type ='c'
- if not type in ["c","d","f","l","i"]:
-- raise Exception, 'error unknown type: "%s", must be one of: "c","d","f","l","i"'
-+ raise Exception('error unknown type: "%s", must be one of: "c","d","f","l","i"')
-
- ndims = len(axis_ids)
-
-@@ -422,13 +426,13 @@
+@@ -432,13 +436,13 @@ def variable(table_entry,units,axis_ids,
comment = str(comment)
if not isinstance(tolerance,(float,int,numpy.float,numpy.float32,numpy.int,numpy.int32)):
@@ -393,38 +304,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
missing_value = float(missing_value)
-@@ -438,14 +442,14 @@
- def zfactor(zaxis_id,zfactor_name,units="",axis_ids=None,type=None,zfactor_values=None,zfactor_bounds=None):
-
- if not isinstance(zaxis_id,(int,numpy.int,numpy.int32)):
-- raise Exception, "error zaxis_id must be a number"
-+ raise Exception("error zaxis_id must be a number")
- zaxis_id = int(zaxis_id)
-
- if not isinstance(zfactor_name,str):
-- raise Exception, "Error you must pass a string for the variable zfactor_name"
-+ raise Exception("Error you must pass a string for the variable zfactor_name")
-
- if not isinstance(units,str):
-- raise Exception, "Error you must pass a string for the variable units"
-+ raise Exception("Error you must pass a string for the variable units")
-
- if numpy.ma.isMA(axis_ids):
- axis_ids = numpy.ascontiguousarray(axis_ids.filled())
-@@ -462,10 +466,10 @@
- elif isinstance(axis_ids,(int,numpy.int,numpy.int32)):
- axis_ids = numpy.array([axis_ids,])
- elif not isinstance(axis_ids, numpy.ndarray):
-- raise Exception, "Error could not convert axis_ids list to a numpy array"
-+ raise Exception("Error could not convert axis_ids list to a numpy array")
-
- if numpy.rank(axis_ids)>1:
-- raise Exception, "error axis_ids list/array must be 1D"
-+ raise Exception("error axis_ids list/array must be 1D")
-
- if axis_ids is None:
- ndims = 0
-@@ -474,9 +478,9 @@
+@@ -484,9 +488,9 @@ def zfactor(zaxis_id,zfactor_name,units=
ndims = len(axis_ids)
## if ndims>1 and zfactor_values is not None:
@@ -436,7 +316,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
if zfactor_values is not None:
if isinstance(zfactor_values,(float,int,numpy.float,numpy.float32,numpy.int,numpy.int32)):
-@@ -490,7 +494,7 @@
+@@ -500,7 +504,7 @@ def zfactor(zaxis_id,zfactor_name,units=
elif isinstance(zfactor_values,(list,tuple)):
zfactor_values = numpy.ascontiguousarray(zfactor_values)
elif not isinstance(zfactor_values, numpy.ndarray):
@@ -445,53 +325,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
if type is None:
try:
-@@ -501,18 +505,18 @@
- elif isinstance(zfactor_values,(int,numpy.int,numpy.int32)):
- type = 'd'
- else:
-- raise Exception, "Error unknown type for zfactor_values: %s" % repr(zfactor_values)
-+ raise Exception("Error unknown type for zfactor_values: %s" % repr(zfactor_values))
- elif type is None:
- type='d'
-
-
- if not isinstance(type,str):
-- raise Exception, "error tpye must a a string"
-+ raise Exception("error tpye must a a string")
- type = type.lower()
- if type == 's':
- type ='c'
- if not type in ["c","d","f","l","i"]:
-- raise Exception, 'error unknown type: "%s", must be one of: "c","d","f","l","i"'
-+ raise Exception('error unknown type: "%s", must be one of: "c","d","f","l","i"')
-
- if zfactor_bounds is not None:
- if numpy.ma.isMA(zfactor_bounds):
-@@ -524,19 +528,19 @@
- elif isinstance(zfactor_bounds,(list,tuple)):
- zfactor_bounds = numpy.ascontiguousarray(zfactor_bounds)
- elif not isinstance(zfactor_bounds, numpy.ndarray):
-- raise Exception, "Error could not convert zfactor_bounds to a numpy array"
-+ raise Exception("Error could not convert zfactor_bounds to a numpy array")
- if numpy.rank(zfactor_bounds)>2:
-- raise Exception, "error zfactor_bounds must be rank 2 at most"
-+ raise Exception("error zfactor_bounds must be rank 2 at most")
- elif numpy.rank(zfactor_bounds)==2:
- if zfactor_bounds.shape[1]!=2:
-- raise Exception, "error zfactor_bounds' 2nd dimension must be of length 2"
-+ raise Exception("error zfactor_bounds' 2nd dimension must be of length 2")
- bnds =[]
- b = zfactor_bounds[0]
- for i in range(zfactor_bounds.shape[0]):
- b = zfactor_bounds[i]
- bnds.append(b[0])
- if (i<zfactor_bounds.shape[0]-1) and (b[1]!=zfactor_bounds[i+1][0]):
-- raise Exception, "error zfactor_bounds have gaps between them"
-+ raise Exception("error zfactor_bounds have gaps between them")
- bnds.append(zfactor_bounds[-1][1])
- zfactor_bounds=numpy.array(bnds)
- axis_ids = axis_ids.astype('i')
-@@ -551,15 +555,15 @@
+@@ -561,15 +565,15 @@ def write(var_id,data,ntimes_passed=None
ierr = write(var_id,data,ntimes_passed=None,file_suffix="",time_vals=None,time_bnds=None,store_with=None
"""
if not isinstance(var_id,(int,numpy.int,numpy.int32)):
@@ -510,7 +344,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
store_with = int(store_with)
if numpy.ma.isMA(data):
-@@ -573,7 +577,7 @@
+@@ -583,7 +587,7 @@ def write(var_id,data,ntimes_passed=None
elif isinstance(data,(list,tuple)):
data = numpy.ascontiguousarray(data)
elif not isinstance(data, numpy.ndarray):
@@ -519,7 +353,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
if time_vals is None:
-@@ -594,12 +598,12 @@
+@@ -604,12 +608,12 @@ def write(var_id,data,ntimes_passed=None
try:
time_vals = numpy.ascontiguousarray(time_vals)
except:
@@ -532,9 +366,9 @@ Index: cmor-2.8.3/Lib/pywrapper.py
- raise Exception, "Error time_vals type must one of: 'f','d','i','l', please convert first"
+ raise Exception("Error time_vals type must one of: 'f','d','i','l', please convert first")
time_vals=time_vals.astype("d")
-
-@@ -609,7 +613,7 @@
+
+@@ -619,7 +623,7 @@ def write(var_id,data,ntimes_passed=None
else:
ntimes_passed = len(time_vals)
if not isinstance(ntimes_passed,(int,numpy.int,numpy.int32)):
@@ -543,33 +377,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
ntimes_passed = int(ntimes_passed)
-@@ -627,7 +631,7 @@
- if goodshape[i]!=0:
- if sh[j]!=goodshape[i]:
- if goodshape[i]!=1:
-- raise Exception,"error your data shape (%s) does not match the expect variable shape (%s)" % (str(osh),str(ogoodshape))
-+ raise Exception("error your data shape (%s) does not match the expect variable shape (%s)" % (str(osh),str(ogoodshape)))
- j+=1
- elif ntimes_passed!=1:
- j+=1
-@@ -649,13 +653,13 @@
- elif isinstance(time_bnds,(list,tuple)):
- time_bnds = numpy.ascontiguousarray(time_bnds)
- elif not isinstance(time_bnds, numpy.ndarray):
-- raise Exception, "Error could not convert time_bnds to a numpy array"
-+ raise Exception("Error could not convert time_bnds to a numpy array")
-
- if numpy.rank(time_bnds)>2:
-- raise Exception, "bounds rank cannot be greater than 2"
-+ raise Exception("bounds rank cannot be greater than 2")
- elif numpy.rank(time_bnds)==2:
- if time_bnds.shape[1]!=2:
-- raise Exception, "error time_bnds' 2nd dimension must be of length 2"
-+ raise Exception("error time_bnds' 2nd dimension must be of length 2")
- bnds =[]
- if time_bnds.shape[0] > 1:
- _check_time_bounds_contiguous(time_bnds)
-@@ -669,7 +673,7 @@
+@@ -679,7 +683,7 @@ def write(var_id,data,ntimes_passed=None
else:
ltv=len(time_vals)
if len(time_bnds)!=ltv+1:
@@ -578,7 +386,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
bnds=[]
for i in range(ltv):
bnds.append([time_bnds[i],time_bnds[i+1]])
-@@ -680,12 +684,12 @@
+@@ -690,12 +694,12 @@ def write(var_id,data,ntimes_passed=None
if time_bnds is not None:
type = time_bnds.dtype.char
if not type in ['f','d','i','l']:
@@ -591,9 +399,9 @@ Index: cmor-2.8.3/Lib/pywrapper.py
- raise Exception, "Error data type must one of: 'f','d','i','l', please convert first"
+ raise Exception("Error data type must one of: 'f','d','i','l', please convert first")
- return _cmor.write(var_id,data,type,file_suffix,ntimes_passed,time_vals,time_bnds,store_with)
+ return _cmor.write(var_id,data,type,ntimes_passed,time_vals,time_bnds,store_with)
-@@ -696,7 +700,7 @@
+@@ -706,7 +710,7 @@ def _check_time_bounds_contiguous(time_b
for i in range(time_bnds.shape[0] - 1 ):
b = time_bnds[i]
if b[1]!=time_bnds[i+1][0]:
@@ -602,7 +410,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
def _flatten_time_bounds(time_bnds):
'''
-@@ -721,21 +725,21 @@
+@@ -731,21 +735,21 @@ def setup(inpath='.',netcdf_file_action=
create_subdirectories: 1 to create subdirectories structure, 0 to dump files directly where cmor_dataset tells to
"""
if not isinstance(exit_control,int) or not exit_control in [ cmor_const.CMOR_EXIT_ON_WARNING, cmor_const.CMOR_EXIT_ON_MAJOR, cmor_const.CMOR_NORMAL]:
@@ -629,7 +437,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
return _cmor.setup(inpath,netcdf_file_action,set_verbosity,exit_control,logfile,create_subdirectories)
def load_table(table):
-@@ -744,7 +748,7 @@
+@@ -754,7 +758,7 @@ def load_table(table):
load_table(table)
"""
if not isinstance(table,str):
@@ -638,58 +446,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
## if not os.path.exists(table):
## raise Exception, "Error, the table you specified (%s) does not exists" % table
return _cmor.load_table(table)
-@@ -782,7 +786,7 @@
- if not isinstance(st,str):
- for o in dir():
- if locals()[o] is st:
-- raise Exception, "Error argument %s must be a string" % o
-+ raise Exception("Error argument %s must be a string" % o)
-
- calendar = calendar.lower()
-
-@@ -790,7 +794,7 @@
- if not isinstance(i,int):
- for o in dir():
- if locals()[o] is i:
-- raise Exception, "Error argument %s must be an integer" % o
-+ raise Exception("Error argument %s must be an integer" % o)
- if isinstance(month_lengths,(list,tuple)):
- month_lengths = numpy.array(month_lengths)
- elif has_cdms2 and cdms2.isVariable(month_lengths):
-@@ -802,26 +806,26 @@
-
- if isinstance(month_lengths,numpy.ndarray):
- if not numpy.rank(month_lengths)==1:
-- raise Exception, "Error month_lengths must be 1D"
-+ raise Exception("Error month_lengths must be 1D")
- if len(month_lengths)!=12:
-- raise Exception, "Error month_lengths must have 12 elements exactly"
-+ raise Exception("Error month_lengths must have 12 elements exactly")
- months_lengths = numpy.ascontiguousarray(month_lengths)
- elif month_lengths is not None:
-- raise Exception, "Error month_lengths must be a 12 elts array or list"
-+ raise Exception("Error month_lengths must be a 12 elts array or list")
- if initialization_method is not None:
- if not isinstance(initialization_method,int):
-- raise Exception, "initialization_method must be an int"
-+ raise Exception("initialization_method must be an int")
- else:
- initialization_method=0
- if physics_version is not None:
- if not isinstance(physics_version,int):
-- raise Exception, "physics_version must be an int"
-+ raise Exception("physics_version must be an int")
- else:
- physics_version=0
-
- if branch_time is not None:
- if not isinstance(branch_time,(float,int,numpy.float,numpy.float32,numpy.int,numpy.int32)):
-- raise Exception,"branch_time must be a float"
-+ raise Exception("branch_time must be a float")
- else:
- branch_time=float(branch_time)
-
-@@ -829,7 +833,7 @@
+@@ -772,7 +776,7 @@ def dataset_json(rcfile):
def set_table(table):
if not isinstance(table,int):
@@ -698,7 +455,7 @@ Index: cmor-2.8.3/Lib/pywrapper.py
return _cmor.set_table(table)
def close(var_id=None,file_name=False, preserve=False):
-@@ -842,7 +846,7 @@
+@@ -785,7 +789,7 @@ def close(var_id=None,file_name=False, p
[preserve] True/False (default False) if True: close the file but preserve the var definition in CMOR to write more data with this variable (into a new file)
"""
if var_id is not None and not isinstance(var_id,int):
@@ -707,460 +464,16 @@ Index: cmor-2.8.3/Lib/pywrapper.py
if (preserve is False):
if (file_name is False):
-Index: cmor-2.8.3/Lib/__init__.py
-===================================================================
---- cmor-2.8.3.orig/Lib/__init__.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Lib/__init__.py 2013-06-15 10:54:40.000000000 +0100
-@@ -1,9 +1,9 @@
--from cmor_const import *
--
--from pywrapper import axis,variable,write,setup,load_table,dataset,set_table,zfactor,close,grid,set_grid_mapping,time_varying_grid_coordinate,set_cur_dataset_attribute,get_cur_dataset_attribute,has_cur_dataset_attribute,create_output_path,set_variable_attribute,get_variable_attribute,has_variable_attribute
-+from __future__ import print_function # Be python2/python3 agnostic
-+from .cmor_const import *
-+from .pywrapper import axis,variable,write,setup,load_table,dataset,set_table,zfactor,close,grid,set_grid_mapping,time_varying_grid_coordinate,set_cur_dataset_attribute,get_cur_dataset_attribute,has_cur_dataset_attribute,create_output_path,set_variable_attribute,get_variable_attribute,has_variable_attribute
-
- try:
-- from check_CMOR_compliant import checkCMOR
--except Exception,err:
-- print err
-+ from .check_CMOR_compliant import checkCMOR
-+except Exception as err:
-+ print(err)
- pass
-Index: cmor-2.8.3/Lib/check_CMOR_compliant.py
+Index: cmor-3.2.0/Test/check_results.py
===================================================================
---- cmor-2.8.3.orig/Lib/check_CMOR_compliant.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Lib/check_CMOR_compliant.py 2013-06-15 10:54:40.000000000 +0100
-@@ -1,3 +1,4 @@
-+from __future__ import print_function
- import cdms2
- import os
- import unidata
-@@ -8,14 +9,19 @@
- import time
- VERBOSE=-999
-
-+
- #ok now we are going online to pull the file that has the control md5s
- try:
- f=open("Tables/md5s")
- ctrl_md5s=eval(f.read())
- except:
- try:
-- import urllib2
-- url=urllib2.urlopen("http://esgf.org/gitweb/?p=cmip5-cmor-tables.git;a=blob_plain;f=Tables/md5s;hb=HEAD")
-+ try:
-+ import urllib2
-+ url=urllib2.urlopen("http://esgf.org/gitweb/?p=cmip5-cmor-tables.git;a=blob_plain;f=Tables/md5s;hb=HEAD")
-+ except ImportError:
-+ import urllib.request, urllib.error, urllib.parse
-+ url=urllib.request.urlopen("http://esgf.org/gitweb/?p=cmip5-cmor-tables.git;a=blob_plain;f=Tables/md5s;hb=HEAD")
- ctrl_md5s=eval(url.read())
- url.close()
- del(url)
-@@ -53,11 +59,11 @@
- color=34
- else:
- return
-- print >> fout, "%c[%d;%d;%dm" % (0X1B,2,color,47)
-+ print("%c[%d;%d;%dm" % (0X1B,2,color,47),file=fout)
- return
-
- def delcoloring(fout):
-- print >> fout,"%c[%dm" % (0X1B,0)
-+ print("%c[%dm" % (0X1B,0), file=fout)
- return
-
- def manageLog(fout,error,*msg_bits):
-@@ -67,35 +73,35 @@
- msg+=" "+str(m)
- msg=msg.lstrip()
-
--## print >>fout, 'No error is:',noerror
-+## print( 'No error is:',noerror,file=fout)
- if error == cmor.CMOR_CRITICAL:
-- raise CMORError,[msg,]
-+ raise CMORError([msg,])
- elif error == VERBOSE:
- fout.write( msg)
- if msg_bits[-1]!="":
-- print >> fout
-+ print(file=fout)
- return
-
- addcoloring(fout,error)
-- print >>fout, '@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%'
-- print >>fout, '@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%'
-+ print('@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%',file=fout)
-+ print('@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%',file=fout)
- if error == cmor.CMOR_NORMAL:
-- print >>fout, '@#%@#%@#%@#%@#% ERROR %@#%@#%@#%@#%@#%@#%@#%'
-+ print('@#%@#%@#%@#%@#% ERROR %@#%@#%@#%@#%@#%@#%@#%',file=fout)
- elif error == cmor.CMOR_WARNING:
-- print >>fout, '@#%@#%@#%@#%@#% WARNING %@#%@#%@#%@#%@#%@#%@#%'
-- print >>fout, '@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%'
-- print >>fout, '@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%'
-+ print('@#%@#%@#%@#%@#% WARNING %@#%@#%@#%@#%@#%@#%@#%',file=fout)
-+ print('@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%',file=fout)
-+ print('@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%',file=fout)
- delcoloring(fout)
-- print >>fout
-+ print(file=fout)
- addcoloring(fout,error)
-- print >>fout, msg
-+ print(msg,file=fout)
- delcoloring(fout)
-- print >>fout
-+ print(file=fout)
- addcoloring(fout,error)
-- print >>fout, '@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%'
-- print >>fout, '@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%'
-+ print('@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%',file=fout)
-+ print('@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%@#%',file=fout)
- delcoloring(fout)
-- print >>fout
-+ print(file=fout)
- return 1
-
- def split_expt_ids(val):
-@@ -143,7 +149,7 @@
- st=st.split('!')[0].strip()
- if st[0]=="'":
- st=st[1:-1]
-- if gen_attributes.has_key(kw):
-+ if kw in gen_attributes:
- if isinstance(gen_attributes[kw],str):
- gen_attributes[kw]=[gen_attributes[kw],st]
- else:
-@@ -156,11 +162,11 @@
- sp=l.split('_entry:')
- entry_type=sp[0]
- entry=sp[1].strip()
-- if not e.has_key(entry_type):
-+ if entry_type not in e:
- e[entry_type]={}
- e[entry_type][entry]=e[entry_type].get(entry,{})
-
--## print >>fout, e[entry_type][entry]
-+## print(e[entry_type][entry],file=fout)
- cont=1
- while cont:
- l = ln.pop(0)[:-1]
-@@ -176,26 +182,26 @@
- sp=l.split(':')
- kw=sp[0].strip()
- val=":".join(sp[1:]).split('!')[0].strip()
-- ## print 'dic is:',e[entry_type][entry]
-- if e[entry_type][entry].has_key(kw):
-+ ## print('dic is:',e[entry_type][entry])
-+ if kw in e[entry_type][entry]:
- if kw in lists_kw:
- e[entry_type][entry][kw]="".join(e[entry_type][entry][kw])
- e[entry_type][entry][kw]+=' '+val
- else:
- e[entry_type][entry][kw]=val
--## print >>fout, 'After:',e[entry_type][entry][kw]
-+## print('After:',e[entry_type][entry][kw],file=fout)
- if kw in lists_kw:
--## print >>fout, 'splitting:',kw,e[entry_type][entry][kw].split()
-+## print('splitting:',kw,e[entry_type][entry][kw].split(),file=fout)
- e[entry_type][entry][kw]=e[entry_type][entry][kw].split()
- if len(ln)==0:
- cont=0
- e['general']=gen_attributes
- ## for type in e.keys():
--## print >>fout, 'Type:',type
-+## print('Type:',type,file=fout)
- ## for k in e[type].keys():
--## print >>fout, '\t Entry:',k
-+## print('\t Entry:',k,file=fout)
- ## for a in e[type][k].keys():
--## print >>fout, '\t\t',a,':',e[type][k][a]
-+## print('\t\t',a,':',e[type][k][a],file=fout)
- return e
-
-
-@@ -227,9 +233,9 @@
- for ex in extra_req:
- if not ex in req_glbl_att:
- req_glbl_att.append(ex)
-- for v in Vars.keys():
-+ for v in list(Vars.keys()):
- IPCC_std_vars.append(Vars[v].get('out_name',v))
-- for a in Axes.keys():
-+ for a in list(Axes.keys()):
- onm = Axes[a].get('out_name',a)
- if not onm in IPCC_std_axes:
- IPCC_std_axes.append(onm)
-@@ -264,7 +270,7 @@
- manageLog(fout,VERBOSE, 'Checking file argument',IPCC_std_axes)
- manageLog(fout,VERBOSE, 'Checking path structure for path:',pthroot)
- manageLog(fout,VERBOSE, 'Checking file structure for file:',fnm)
-- print >> fout, 'Checking the file starts with variable name'
-+ print('Checking the file starts with variable name',file=fout)
- ok = False
- for v in IPCC_std_vars:
- n = len(v)
-@@ -275,8 +281,8 @@
- nerr+=manageLog(fout, noerror, ''+shrt_fnm+' does not start with standard %s variable name followed by _' % file.project_id)
- vf=v
- #Check the variable is actually in the file
-- if not v in file.variables.keys():
-- nerr+=manageLog(fout,noerror,"Your file name says it contains variable",v,"but it is not in your file, your file contains:",file.variables.keys())
-+ if not v in list(file.variables.keys()):
-+ nerr+=manageLog(fout,noerror,"Your file name says it contains variable",v,"but it is not in your file, your file contains:",list(file.variables.keys()))
- if hasattr(file,'cmor_version'):
- up = False
- rew = False
-@@ -447,7 +453,7 @@
- nwarn+=1
- manageLog(fout,cmor.CMOR_WARNING, '\t\tIt is often helpful to define the global attribute: ',att)
-
-- for att in file.attributes.keys():
-+ for att in list(file.attributes.keys()):
- ncheck+=1
- if not att in req_glbl_att and not att in opt_glbl_att:
- nwarn+=1
-@@ -483,7 +489,7 @@
- ctrlmd5=tmd5s.get(tbl_date,None)
- if ctrlmd5 is None:
- nwarn+=1
-- manageLog(fout,cmor.CMOR_WARNING, '\t\tCould not obtain control md5s for table %s for project %s dated on %s, valid tables dates are: ' % (tbl_id,file.project_id,tbl_date),sorted(tmd5s.keys()))
-+ manageLog(fout,cmor.CMOR_WARNING, '\t\tCould not obtain control md5s for table %s for project %s dated on %s, valid tables dates are: ' % (tbl_id,file.project_id,tbl_date),sorted(list(tmd5s.keys())))
- else:
- ncheck+=1
- if ctrlmd5!=tbl_md5:
-@@ -492,7 +498,7 @@
-
-
-
-- except Exception,err:
-+ except Exception as err:
- #no md5 stored in file
- pass
- ttbl_id = e['general'].get("table_id").split()[1]
-@@ -538,7 +544,7 @@
- else:
- spoffset=0
-
-- print len(sp)
-+ print(len(sp))
- if len(sp)<n:
- nerr+=manageLog(fout, noerror, 'your file name does not seem to match the profile: varid_tableid_modelid_exptid_rid[iid][pid][_startdate-enddate][_suffix][_clim].nc')
-
-@@ -874,7 +880,7 @@
- manageLog(fout,VERBOSE, 'Ok user asked to check the following variable:',variable,'with from bounds =',fb)
- manageLog(fout,VERBOSE, 'Checking variable name is %s compliant' % file.project_id)
- if not var in IPCC_std_vars:
-- if var in Vars.keys():
-+ if var in list(Vars.keys()):
- nerr+=manageLog(fout, noerror, var+' is not valid, did you mean :'+Vars[var]['out_name']+' ?')
- else:
- nerr+=manageLog(fout, noerror, 'Variable name :'+var+' is not %s compliant' % file.project_id)
-@@ -895,7 +901,7 @@
- for ax in axes:
- manageLog(fout,VERBOSE, 'Checking axis name is valid for:',ax.id,'on var:',V.id)
- if not ax.id in IPCC_std_axes:
-- if ax.id in Axes.keys():
-+ if ax.id in list(Axes.keys()):
- if major <2:
- ncheck+=1
- nwarn+=1
-@@ -970,8 +976,8 @@
- gnm=nm
- manageLog(fout,VERBOSE, '\tChecking special case %s, i.e' % (nm),'')
- tmpax=V.getLevel()
-- print>>fout, tmpax.id,tmpax.standard_name
-- for x in Axes.keys():
-+ print(tmpax.id,tmpax.standard_name,file=fout)
-+ for x in list(Axes.keys()):
- tmp=Axes[x].get('standard_name',None)
- if tmp is not None: tmp=tmp.strip()
- if tmp is not None and tmp==tmpax.standard_name:
-@@ -1089,7 +1095,7 @@
- manageLog(fout,VERBOSE, r,'')
- val=getattr(ax,r,None)
- if val is None:
-- print >>fout
-+ print(file=fout)
- nerr+=manageLog(fout, noerror, 'attribute '+r+' is required for axis '+ax.id)
- if r!='units':
- good_val=Axes[nm].get(r,None)
-@@ -1097,8 +1103,8 @@
- if val!=good_val:
- nerr+=manageLog(fout, noerror, 'axis attribute '+r+' should be: '+str(good_val)+' but is:'+str(val))
- if r=='formula_terms':
-- print 'Formula:',Axes[anm]['formula'],val
-- print >>fout
-+ print('Formula:',Axes[anm]['formula'],val,file=fout)
-+ print(file=fout)
- if not 'units' in Axes[nm].get('ignored',[]):
- if not 'units' in Axes[nm].get('optional',[]) or ('units' in Axes[nm].get('optional',[]) and hasattr(ax,'units')):
- if not ax.isTime():
-@@ -1200,7 +1206,7 @@
- manageLog(fout,VERBOSE, '\t\tChecking that the latitude are in degrees (not rads)')
- min,max=genutil.minmax(ax[:])
- if 0.<max-min<3.2:
-- print ax[:]
-+ print(ax[:])
- nerr+=manageLog(fout, noerror, 'latitude must be stored in degree span is:'+str(max-min)+' looks like rad')
- elif ax.isTime() and len(ax[:])>1:
- manageLog(fout,VERBOSE, '\t\tChecking for axis attribute')
-@@ -1212,7 +1218,7 @@
- manageLog(fout,VERBOSE, '\t\tView calendar attribute: ','')
- c=getattr(ax,'calendar',None)
- if c is None:
-- print >>fout
-+ print(file=fout)
- nerr+=manageLog(fout, noerror, 'calendar attribute must be defined on time axis')
- else:
- manageLog(fout,VERBOSE, c)
-@@ -1255,7 +1261,7 @@
- t=t.split()[-1]
- ## manageLog(fout,VERBOSE, 'Now it is:',t)
- sp2=ft.split(t+':')[1].split()[0]
-- if not sp2 in file.variables.keys():
-+ if not sp2 in list(file.variables.keys()):
- nerr+=manageLog(fout, noerror, 'formula_terms attribute indicates variable '+sp2+' should be stored in file')
-
- if not docoord:
-@@ -1329,7 +1335,7 @@
- nerr+=manageLog(fout, noerror, 'dimension:'+Nm+' has no associated bounds')
- else:
- manageLog(fout,VERBOSE, '\t\tChecking that defined bounds variable is in file')
-- if not b in file.variables.keys():
-+ if not b in list(file.variables.keys()):
- nerr+=manageLog(fout, noerror, 'dimension '+Nm+' associated bounds are defined to be '+b+' but the variable is not present in file')
- if ax.isTime():
- interv = Axes[nm].get('interval',None)
-@@ -1345,7 +1351,7 @@
- else:
- c=ax.getCalendar()
-
--## print 'Used calendar:',c
-+## print('Used calendar:',c,file=fout)
- beg=cdtime.reltime(b[0],ax.units).tocomp(c)
- end=cdtime.reltime(b[1],ax.units).tocomp(c)
- mid=cdtime.reltime(ax[ib],ax.units).tocomp(c)
-@@ -1363,7 +1369,7 @@
- opt_var_Att=['original_name','history','long_name','comment','coordinates','cell_methods','original_units',"cell_measures"]
- for etmp in etables:
- ev = etmp['variable']
-- for v in ev.keys():
-+ for v in list(ev.keys()):
- if v == var:
- for p in ev[v].get("optional",[]):
- if p in req_var_Att:
-@@ -1408,7 +1414,7 @@
- if val.find(sp[i+1]+"_")==-1:
- nerr+=manageLog(fout,noerror,"associated files should point to file containing:",sp[i+1],'you have:',val)
-
-- print >>fout
-+ print(file=fout)
- tp=Vars[V.id].get('type','real')
- manageLog(fout,VERBOSE, '\tChecking Variable typecode is',tp)
- if tp == 'double' : tp='d'
-@@ -1430,7 +1436,7 @@
- '1 '+V.units+' is actually :'+str(U2))
- except:
- nerr+=manageLog(fout, noerror, 'variable units:'+V.units+' do not match IPCC units:'+Vars[var]['units'])
-- if 'standard_name' in Vars[var].keys():
-+ if 'standard_name' in list(Vars[var].keys()):
- manageLog(fout,VERBOSE, '\tChecking standard name (case independent)')
- if getattr(V,'standard_name','').lower().strip()!=Vars[var]['standard_name']:
- nerr+=manageLog(fout, noerror, 'standard_name for '+var+' should be:'+Vars[var]['standard_name'])
-@@ -1479,10 +1485,10 @@
- if cm!=[]:
- manageLog(fout,VERBOSE, '\tChecking for cell_methods: ','')
- if not hasattr(V,'cell_methods'):
-- print >> fout
-+ print(file=fout)
- nerr+=manageLog(fout, noerror, 'Variable '+var+' should have "cell_methods" attribute')
- else:
-- print >> fout,V.cell_methods
-+ print(V.cell_methods,file=fout)
-
- cmv=getattr(V,'cell_methods','')
- sp=cm.split('(')
-@@ -1505,8 +1511,8 @@
- for s in sp[1:]:
- dicv[kw]=s.split()[0].strip()
- kw=s.split()[-1].strip()
-- for kw in dic.keys():
-- if not kw in dicv.keys():
-+ for kw in list(dic.keys()):
-+ if not kw in list(dicv.keys()):
- nerr+=manageLog(fout, noerror, 'cell_methods must include '+kw+' defined (to: '+dic[kw]+' )')
- elif not dicv[kw]==dic[kw]:
- nerr+=manageLog(fout, noerror, 'cell_method: '+kw+' definition does not match table, it is :'+dicv[kw]+' but should be: '+dic[kw])
-@@ -1515,7 +1521,7 @@
- if not hasattr(V,att):
- nwarn+=1
- manageLog(fout,cmor.CMOR_WARNING, '\t\tWhen appropriate, it is often helpful to define the variable attribute: ',att)
-- for att in V.attributes.keys():
-+ for att in list(V.attributes.keys()):
- ncheck+=1
- if not att in req_var_Att and not att in opt_var_Att:
- nwarn+=1
-@@ -1535,8 +1541,8 @@
- nerr+=nerr
- manageLog(fout,cmor.CMOR_WARNING, '%d warnings issued out of %d checked for (%5.2f%%)' % (nwarn,ncheck,float(nwarn)/ncheck*100))
- if nerr!=0:
-- print 'Nerr:',nerr
-- raise CMORError,'%i CMOR errors were raise, please check output and correct your file !!!!' % (nerr)
-+ print('Nerr:',nerr)
-+ raise CMORError('%i CMOR errors were raise, please check output and correct your file !!!!' % (nerr))
-
- file.close()
- return nwarn,ncheck,nerr
-@@ -1585,7 +1591,7 @@
- if o in ['--grid_table','-g']:
- grid_table=p
- if o in ['--help','-h','-?']:
-- print help
-+ print(help)
- sys.exit()
- if o in ['--noerror','-e']:
- if p.lower() in ['off','0']:
-@@ -1595,16 +1601,16 @@
- if o in ['--out','-o']:
- out=p
-
-- print 'File is:',file,file.find('*')
-+ print('File is:',file,file.find('*'))
- if os.path.isdir(file):
- files=os.popen('ls '+file+'/*.nc').readlines()
- elif file.find('*')>=0:
- files=os.popen('ls '+file).readlines()
- else:
- files=[file]
-- print 'Files:',files
-+ print('Files:',files)
- for file in files:
-- print 'Dealing with ',file.strip()
-+ print('Dealing with ',file.strip())
- if out.lower()=='screen':
- fout=sys.stdout
- elif out.lower()=='file':
-@@ -1617,6 +1623,6 @@
- else:
- try:
- checkCMOR(fout,file.strip(),table,other_tables=[grid_table,],noerror=noerror,variable=var)
-- except Exception,err:
-- print err
-+ except Exception as err:
-+ print(err)
-
-Index: cmor-2.8.3/Test/check_results.py
-===================================================================
---- cmor-2.8.3.orig/Test/check_results.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/check_results.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/check_results.py
++++ cmor-3.2.0/Test/check_results.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
from out_files import out
from in_files import input_tables
import sys,os
-@@ -10,7 +11,7 @@
+@@ -10,7 +11,7 @@ test = os.path.split(test)[1]
if test[-4:].lower()=='.f90':
test=test[:-4]
@@ -1169,7 +482,7 @@ Index: cmor-2.8.3/Test/check_results.py
outfiles = out.get(test,[])
intables = input_tables.get(test,['IPCC_test_table_A',])
-@@ -22,12 +23,12 @@
+@@ -22,12 +23,12 @@ class CMORResultCheckError(Exception):
nfiles = 0
@@ -1184,7 +497,7 @@ Index: cmor-2.8.3/Test/check_results.py
sys.exit()
tables=[]
for t in intables:
-@@ -39,13 +40,13 @@
+@@ -39,13 +40,13 @@ for f in outfiles:
if os.path.exists(fnm):
nfiles+=1
gotfiles.append(fnm)
@@ -1202,101 +515,17 @@ Index: cmor-2.8.3/Test/check_results.py
elif nfiles!=len(outfiles):
- raise CMORResultCheckError,["Error checking output files for test: Test/%s.f90 we could only find %i files when %i were expected.\n\n Expected files: \n\t%s\n\nPresent files: \n\t%s\n\nMissing files: \n\t%s\n" % (test,nfiles,len(outfiles),repr(outfiles),repr(gotfiles),repr(missing)),]
+ raise CMORResultCheckError(["Error checking output files for test: Test/%s.f90 we could only find %i files when %i were expected.\n\n Expected files: \n\t%s\n\nPresent files: \n\t%s\n\nMissing files: \n\t%s\n" % (test,nfiles,len(outfiles),repr(outfiles),repr(gotfiles),repr(missing)),])
-Index: cmor-2.8.3/Test/cmor_speed_and_compression_01.py
+Index: cmor-3.2.0/setup.py.in
===================================================================
---- cmor-2.8.3.orig/Test/cmor_speed_and_compression_01.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/cmor_speed_and_compression_01.py 2013-06-15 10:54:40.000000000 +0100
-@@ -1,11 +1,13 @@
-+from __future__ import print_function
- import cmor,numpy,sys,os
+--- cmor-3.2.0.orig/setup.py.in
++++ cmor-3.2.0/setup.py.in
+@@ -1,3 +1,5 @@
+
- try:
- import cdms2
- cdms2.setNetcdfShuffleFlag(0)
- cdms2.setNetcdfDeflateFlag(0)
- cdms2.setNetcdfDeflateLevelFlag(0)
- except:
-- print "This test code needs a recent cdms2 interface for i/0"
-+ print("This test code needs a recent cdms2 interface for i/0")
- sys.exit()
-
- if len(sys.argv)>1:
-@@ -52,7 +54,7 @@
-
- tables=[]
- tables.append(cmor.load_table("mytable"))
--print 'Tables ids:',tables
-+print('Tables ids:',tables)
-
-
- ## read in data, just one slice
-@@ -98,11 +100,11 @@
- mincdms=1000
- c0=st
- f=cdms2.open("Test/crap.nc","w")
--#print 'Time:',i
--print s.filled().shape
-+#print('Time:',i)
-+print(s.filled().shape)
- cmor.write(myvars[0],s.filled(),ntimes_passed=ntimes)
- c=time.time()
--#print 'cmor write time:',c-c0
-+#printi('cmor write time:',c-c0)
- totcmor+=c-c0
- if maxcmor<c-c0:
- maxcmor=c-c0
-@@ -111,7 +113,7 @@
- c0=c
- f.write(s,id=varout)
- c=time.time()
--#print 'cdms time:',c-c0
-+#print('cdms time:',c-c0)
- totcdms+=c-c0
- if maxcdms<c-c0:
- maxcdms=c-c0
-@@ -124,12 +126,12 @@
- import cdtime,os
- ltime = cdtime.reltime(ntimes-1,'month since 1980').tocomp()
- lcmor = os.stat("Test/CMIP5/output/PCMDI/GICCM1/lgm/mon/atmos/tas/r1i1p1/tas_Amon_GICCM1_lgm_r1i1p1_198401-198412.nc")[6]
--print 'level:',level,"shuffle:",shuffle
--print 'total cmor:',totcmor,mincmor,totcmor/ntimes,maxcmor,lcmor
-+print('level:',level,"shuffle:",shuffle)
-+print('total cmor:',totcmor,mincmor,totcmor/ntimes,maxcmor,lcmor)
- lcdms = os.stat("Test/crap.nc")[6]
--print 'total cdms:',totcdms,mincdms,totcdms/ntimes,maxcdms,lcdms
--print 'Size diff:',float(lcmor)/float(lcdms)
--print 'speed diff:', totcmor/totcdms
-+print('total cdms:',totcdms,mincdms,totcdms/ntimes,maxcdms,lcdms)
-+print('Size diff:',float(lcmor)/float(lcdms))
-+print('speed diff:', totcmor/totcdms)
-
- if os.path.exists("summary.txt"):
- f = open("summary.txt")
-@@ -144,7 +146,7 @@
- for i in range(10):
- a = dic.get((i,0),"N/A")
- b = dic.get((i,1),"N/A")
-- print 'Level: ',i,"no suffle:",a,"shuffle",b
-+ print('Level: ',i,"no suffle:",a,"shuffle",b)
- f=open("summary.txt","w")
- f.write(repr(dic))
- f.close()
-Index: cmor-2.8.3/setup.py.in
-===================================================================
---- cmor-2.8.3.orig/setup.py.in 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/setup.py.in 2013-06-15 10:54:40.000000000 +0100
-@@ -1,8 +1,10 @@
+from __future__ import print_function # to be python2/python3 agnostic
import numpy
from numpy.distutils.core import setup, Extension
#from numpy.distutils.ccompiler import CCompiler
- import os,sys,string
-
-+
- include_dirs = [numpy.lib.utils.get_include(),"include","include/cdTime"]
-
- library_dirs = [ os.path.join("@prefix@","lib") ,'.']
-@@ -38,12 +40,12 @@
+@@ -40,12 +42,12 @@ for p in include_dirs:
ld.append(p)
include_dirs=ld
@@ -1314,23 +543,21 @@ Index: cmor-2.8.3/setup.py.in
+print('macros:',macros)
setup (name = "CMOR",
- version='2.0',
-Index: cmor-2.8.3/Test/cmor_speed_and_compression_02.py
+ version='3.2',
+Index: cmor-3.2.0/Test/cmor_speed_and_compression_02.py
===================================================================
---- cmor-2.8.3.orig/Test/cmor_speed_and_compression_02.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/cmor_speed_and_compression_02.py 2013-06-15 10:54:40.000000000 +0100
-@@ -1,8 +1,9 @@
-+from __future__ import print_function
- import cmor,numpy,sys,os
+--- cmor-3.2.0.orig/Test/cmor_speed_and_compression_02.py
++++ cmor-3.2.0/Test/cmor_speed_and_compression_02.py
+@@ -5,7 +5,7 @@ today = strftime("%Y%m%d", localtime())
try:
import cdms2
except:
- print "This test code needs cdms2 interface for i/0"
-+ print("This test code needs cdms2 interface for I/O")
++ print ("This test code needs cdms2 interface for i/0")
sys.exit()
cdms2.setNetcdfShuffleFlag(0)
-@@ -52,7 +53,7 @@
+@@ -55,7 +55,7 @@ cmor.dataset(
tables=[]
tables.append(cmor.load_table("mytable"))
@@ -1339,7 +566,7 @@ Index: cmor-2.8.3/Test/cmor_speed_and_compression_02.py
## read in data, just one slice
-@@ -75,7 +76,7 @@
+@@ -78,7 +78,7 @@ except:
except:
missing_value=None
@@ -1348,7 +575,7 @@ Index: cmor-2.8.3/Test/cmor_speed_and_compression_02.py
#missing_value = -999.
myaxes[0] = cmor.axis(table_entry = 'latitude',
units = 'degrees_north',
-@@ -115,7 +116,7 @@
+@@ -118,7 +118,7 @@ c0=st
f=cdms2.open("Test/crap.nc","w")
step=10
for i in range(0,ntimes,step):
@@ -1357,7 +584,7 @@ Index: cmor-2.8.3/Test/cmor_speed_and_compression_02.py
j1=i
j2=i+step
cmor.write(myvars[0],s[j1:j2].filled(),step,file_suffix="speed-comp-02")
-@@ -154,15 +155,15 @@
+@@ -157,15 +157,15 @@ cmor.close()
import cdtime,os
ltime = cdtime.reltime(Tim[ntimes-1],Tim.units).tocomp()
ftime = cdtime.reltime(Tim[0],Tim.units).tocomp()
@@ -1380,7 +607,7 @@ Index: cmor-2.8.3/Test/cmor_speed_and_compression_02.py
if os.path.exists("summary.txt"):
f = open("summary.txt")
-@@ -177,7 +178,7 @@
+@@ -180,7 +180,7 @@ dic[(level,shuffle)]=(float(lcmor)/float
for i in range(10):
a = dic.get((i,0),"N/A")
b = dic.get((i,1),"N/A")
@@ -1389,16 +616,16 @@ Index: cmor-2.8.3/Test/cmor_speed_and_compression_02.py
f=open("summary.txt","w")
f.write(repr(dic))
f.close()
-Index: cmor-2.8.3/Test/cmor_speed_and_compression.py
+Index: cmor-3.2.0/Test/cmor_speed_and_compression.py
===================================================================
---- cmor-2.8.3.orig/Test/cmor_speed_and_compression.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/cmor_speed_and_compression.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/cmor_speed_and_compression.py
++++ cmor-3.2.0/Test/cmor_speed_and_compression.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
import cmor,numpy,sys,os
- try:
- import cdms2
-@@ -5,7 +6,7 @@
+ from time import localtime, strftime
+ today = strftime("%Y%m%d", localtime())
+@@ -8,7 +9,7 @@ try:
cdms2.setNetcdfDeflateFlag(0)
cdms2.setNetcdfDeflateLevelFlag(0)
except:
@@ -1407,7 +634,7 @@ Index: cmor-2.8.3/Test/cmor_speed_and_compression.py
sys.exit()
if len(sys.argv)>1:
-@@ -52,7 +53,7 @@
+@@ -41,7 +42,7 @@ cmor.dataset_json("Test/common_user_inpu
tables=[]
tables.append(cmor.load_table("mytable"))
@@ -1416,7 +643,7 @@ Index: cmor-2.8.3/Test/cmor_speed_and_compression.py
## read in data, just one slice
-@@ -98,7 +99,7 @@
+@@ -89,7 +90,7 @@ mincdms=1000
c0=st
s2=s*1
sh=list(s.shape)
@@ -1425,25 +652,25 @@ Index: cmor-2.8.3/Test/cmor_speed_and_compression.py
sh.insert(0,1)
s2=MV2.reshape(s2,sh)
s2.setAxis(1,s.getLatitude())
-@@ -135,12 +136,12 @@
- import cdtime,os
+@@ -127,12 +128,12 @@ import cdtime,os
ltime = cdtime.reltime(ntimes-1,'month since 1980').tocomp()
- lcmor = os.stat("Test/CMIP5/output/PCMDI/GICCM1/historical/mon/atmos/tas/r1i1p1/tas_Amon_GICCM1_historical_r1i1p1_198001-%i%.2i.nc" % (ltime.year,ltime.month))[6]
+ #lcmor = os.stat("CMIP6/CMIP/CSIRO-BOM/NICAM/piControl/r1i1p1f1/Amon/tas/gn/v%s/tas_Amon_piControl_NICAM_r1i1p1f1_gn_198001-%i%.2i.nc" % (today,ltime.year,ltime.month))[6]
+ lcmor = os.stat("CMIP6/ISMIP6/PCMDI/PCMDI-test-1-0/piControl-withism/r11i1p1f1/Amon/tas/gr/v%s/tas_Amon_piControl-withism_PCMDI-test-1-0_r11i1p1f1_gr_198001-%i%.2i.nc" % (today,ltime.year,ltime.month))[6]
-print 'level:',level,"shuffle:",shuffle
-print 'total cmor:',totcmor,mincmor,totcmor/ntimes,maxcmor,lcmor
-+print('level:',level,"shuffle:",shuffle)
-+print('total cmor:',totcmor,mincmor,totcmor/ntimes,maxcmor,lcmor)
++print ('level:',level,"shuffle:",shuffle)
++print ('total cmor:',totcmor,mincmor,totcmor/ntimes,maxcmor,lcmor)
lcdms = os.stat("Test/crap.nc")[6]
-print 'total cdms:',totcdms,mincdms,totcdms/ntimes,maxcdms,lcdms
-print 'Size diff:',float(lcmor)/float(lcdms)
-print 'speed diff:', totcmor/totcdms
-+print('total cdms:',totcdms,mincdms,totcdms/ntimes,maxcdms,lcdms)
-+print('Size diff:',float(lcmor)/float(lcdms))
-+print('speed diff:', totcmor/totcdms)
++print ('total cdms:',totcdms,mincdms,totcdms/ntimes,maxcdms,lcdms)
++print ('Size diff:',float(lcmor)/float(lcdms))
++print ('speed diff:', totcmor/totcdms)
if os.path.exists("summary.txt"):
f = open("summary.txt")
-@@ -155,7 +156,7 @@
+@@ -147,7 +148,7 @@ dic[(level,shuffle)]=(float(lcmor)/float
for i in range(10):
a = dic.get((i,0),"N/A")
b = dic.get((i,1),"N/A")
@@ -1452,10 +679,10 @@ Index: cmor-2.8.3/Test/cmor_speed_and_compression.py
f=open("summary.txt","w")
f.write(repr(dic))
f.close()
-Index: cmor-2.8.3/Test/jamie_hybrid_height.py
+Index: cmor-3.2.0/Test/jamie_hybrid_height.py
===================================================================
---- cmor-2.8.3.orig/Test/jamie_hybrid_height.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/jamie_hybrid_height.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/jamie_hybrid_height.py
++++ cmor-3.2.0/Test/jamie_hybrid_height.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-
@@ -1463,17 +690,17 @@ Index: cmor-2.8.3/Test/jamie_hybrid_height.py
import cmor
import numpy
-@@ -45,22 +45,22 @@
+@@ -36,22 +36,22 @@ def main():
axis_id = cmor.axis(**axis)
axis_ids.append(axis_id)
- print 'cmor.axis calls complete'
-+ print('cmor.axis calls complete')
++ print ('cmor.axis calls complete')
cmor.zfactor(axis_ids[3], 'b', '', axis_ids[3:4], 'd', [0., 0.5], [[0., 0.25], [0.25, 1.]])
cmor.zfactor(axis_ids[3], 'orog', 'm', axis_ids[1:3], 'd', [[0.]])
- print 'cmor.zfactor calls complete'
-+ print('cmor.zfactor calls complete')
++ print ('cmor.zfactor calls complete')
varid = cmor.variable('ua',
'm s-1',
axis_ids,
@@ -1481,19 +708,19 @@ Index: cmor-2.8.3/Test/jamie_hybrid_height.py
)
- print 'cmor.variable call complete'
-+ print('cmor.variable call complete')
++ print ('cmor.variable call complete')
- cmor.write(varid, values, time_vals = [6.0])
+ cmor.write(varid, values, time_vals = [6.0], time_bnds = [3., 12.])
- print 'cmor.write call complete'
-+ print('cmor.write call complete')
++ print ('cmor.write call complete')
cmor.close()
-Index: cmor-2.8.3/Test/nc2asc.py
+Index: cmor-3.2.0/Test/nc2asc.py
===================================================================
---- cmor-2.8.3.orig/Test/nc2asc.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/nc2asc.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/nc2asc.py
++++ cmor-3.2.0/Test/nc2asc.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-
@@ -1501,7 +728,7 @@ Index: cmor-2.8.3/Test/nc2asc.py
import cdms2,sys, genutil
cdms2.setAutoBounds('on')
-@@ -20,18 +20,18 @@
+@@ -20,18 +20,18 @@ else:
f=cdms2.open(fnm)
ntimes= 3
@@ -1523,7 +750,7 @@ Index: cmor-2.8.3/Test/nc2asc.py
try:
p=s.getLevel()
p.id='pressure'
-@@ -44,41 +44,41 @@
+@@ -44,41 +44,41 @@ f.close()
f=open(fout,'w')
ndim=s.rank()
@@ -1583,131 +810,10 @@ Index: cmor-2.8.3/Test/nc2asc.py
+print(j,s[-1])
f.close()
-Index: cmor-2.8.3/Src/_cmormodule.c
-===================================================================
---- cmor-2.8.3.orig/Src/_cmormodule.c 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Src/_cmormodule.c 2013-06-16 17:19:30.000000000 +0100
-@@ -2,6 +2,26 @@
- #include "numpy/arrayobject.h"
- #include "cmor.h"
-
-+
-+#if PY_MAJOR_VERSION >= 3
-+#define PyInt_AsLong PyLong_AsLong
-+#define PyInt_FromLong PyLong_FromLong
-+#define PyString_AsString PyUnicode_AsUTF8String
-+#endif
-+
-+
-+struct module_state {
-+ PyObject *error;
-+};
-+
-+
-+#if PY_MAJOR_VERSION >= 3
-+#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
-+#else
-+#define GETSTATE(m) (&_state)
-+static struct module_state _state;
-+#endif
-+
- static PyObject *
- PyCMOR_get_original_shape(PyObject *self,PyObject *args)
- {
-@@ -315,7 +335,11 @@
- char *units;
- char *interval;
- int length;
-+#if PY_MAJOR_VERSION >= 3
-+ int type;
-+#else
- char type;
-+#endif
- void *coord_vals;
- void *cell_bounds;
- int cell_bounds_ndim;
-@@ -324,7 +348,11 @@
- PyArrayObject *coords=NULL,*bounds=NULL;
-
- /* HUGE assumtion here is that the data is contiguous! */
-+#if PY_MAJOR_VERSION >=3
-+ if (!PyArg_ParseTuple(args,"ssiOCOis",&name,&units,&length,&coords_obj,&type,&bounds_obj,&cell_bounds_ndim,&interval))
-+#else
- if (!PyArg_ParseTuple(args,"ssiOcOis",&name,&units,&length,&coords_obj,&type,&bounds_obj,&cell_bounds_ndim,&interval))
-+#endif
- return NULL;
-
- if (coords_obj == Py_None) {
-@@ -799,11 +827,62 @@
- {NULL, NULL} /*sentinel */
- };
-
--PyMODINIT_FUNC init_cmor(void)
-+#if PY_MAJOR_VERSION >= 3
-+
-+static int MyExtract_traverse(PyObject *m, visitproc visit, void *arg) {
-+ Py_VISIT(GETSTATE(m)->error);
-+ return 0;
-+}
-+
-+static int MyExtract_clear(PyObject *m) {
-+ Py_CLEAR(GETSTATE(m)->error);
-+ return 0;
-+}
-+
-+static struct PyModuleDef moduledef = {
-+ PyModuleDef_HEAD_INIT,
-+ "_cmor",
-+ NULL,
-+ sizeof(struct module_state),
-+ MyExtractMethods,
-+ NULL,
-+ MyExtract_traverse,
-+ MyExtract_clear,
-+ NULL
-+};
-+
-+
-+#define INITERROR return NULL
-+
-+PyObject * PyInit__cmor(void)
-+
-+#else
-+#define INITERROR return
-+
-+void init_cmor(void)
-+#endif
-+
- {
-- (void) Py_InitModule("_cmor", MyExtractMethods);
-+#if PY_MAJOR_VERSION >= 3
-+ PyObject *module = PyModule_Create(&moduledef);
-+#else
-+ PyObject *module = Py_InitModule("_cmor", MyExtractMethods);
-+#endif
- import_array();
--
-+
-+ if (module == NULL)
-+ INITERROR;
-+ struct module_state *st = GETSTATE(module);
-+
-+ st->error = PyErr_NewException("_cmor.Error", NULL, NULL);
-+ if (st->error == NULL) {
-+ Py_DECREF(module);
-+ INITERROR;
-+ }
-+
-+#if PY_MAJOR_VERSION >= 3
-+ return module;
-+#endif
- }
-
- /* int main(int argc,char **argv) */
-Index: cmor-2.8.3/Test/test_compression.py
+Index: cmor-3.2.0/Test/test_compression.py
===================================================================
---- cmor-2.8.3.orig/Test/test_compression.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_compression.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_compression.py
++++ cmor-3.2.0/Test/test_compression.py
@@ -1,8 +1,9 @@
+from __future__ import print_function
import sys,os
@@ -1719,7 +825,7 @@ Index: cmor-2.8.3/Test/test_compression.py
sys.exit()
import cmor,numpy
-@@ -44,12 +45,12 @@
+@@ -34,12 +35,12 @@ for ax in Saxes[1:]:
#Now creates a dummy HUGE axis for resizing s as really big
factor = 100
nt = s.shape[0]*factor
@@ -1734,20 +840,20 @@ Index: cmor-2.8.3/Test/test_compression.py
var_id1 = cmor.variable(s.id,s.units,axes)
## the one with 2 at the end is compressed
var_id2 = cmor.variable(s.id,s.units,axes)
-@@ -58,7 +59,7 @@
+@@ -48,7 +49,7 @@ sh[0]=nt
s=numpy.resize(s,sh)
#s=numpy.where(numpy.greater(s,100.),100,s)
- s=numpy.random.random(s.shape)*100.
+ s=numpy.random.random(s.shape)*10000.
-print s.shape
-+print(s.shape)
++print (s.shape)
cmor.write(var_id1,s)
cmor.close(var_id1)
cmor.write(var_id2,s)
-Index: cmor-2.8.3/Test/test_grid_stub_jamie.py
+Index: cmor-3.2.0/Test/test_grid_stub_jamie.py
===================================================================
---- cmor-2.8.3.orig/Test/test_grid_stub_jamie.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_grid_stub_jamie.py 2013-06-15 10:54:40.000000000 +0100
-@@ -71,7 +71,7 @@
+--- cmor-3.2.0.orig/Test/test_grid_stub_jamie.py
++++ cmor-3.2.0/Test/test_grid_stub_jamie.py
+@@ -71,7 +71,7 @@ class TestGridCallErrors(unittest.TestCa
try:
grid([[1], [2]])
self.fail('should raise exception')
@@ -1756,7 +862,7 @@ Index: cmor-2.8.3/Test/test_grid_stub_jamie.py
self.assertEquals('error axes list/array must be 1D', str(e))
def test_error_on_axis_ids(self):
-@@ -80,7 +80,7 @@
+@@ -80,7 +80,7 @@ class TestGridCallErrors(unittest.TestCa
try:
grid(axis_ids)
self.fail('should raise exception')
@@ -1765,7 +871,7 @@ Index: cmor-2.8.3/Test/test_grid_stub_jamie.py
self.assertEquals('Error could not convert axis_ids list to a numpy array',
str(e))
-@@ -88,14 +88,14 @@
+@@ -88,14 +88,14 @@ class TestGridCallErrors(unittest.TestCa
try:
grid([0], latitude = numpy.arange(2))
self.fail('should raise exception')
@@ -1782,7 +888,7 @@ Index: cmor-2.8.3/Test/test_grid_stub_jamie.py
self.assertEquals("latitude and longitude must be BOTH an array or None", str(e))
def test_error_type_lats(self):
-@@ -104,7 +104,7 @@
+@@ -104,7 +104,7 @@ class TestGridCallErrors(unittest.TestCa
try:
grid([0, 11], latitude = lats, longitude = lons)
self.fail('should raise exception')
@@ -1791,7 +897,7 @@ Index: cmor-2.8.3/Test/test_grid_stub_jamie.py
self.assertEquals('Error could not convert latitude to a numpy array', str(e))
def test_error_type_lons(self):
lats = numpy.arange(2*3).reshape(2,3)
-@@ -112,7 +112,7 @@
+@@ -112,7 +112,7 @@ class TestGridCallErrors(unittest.TestCa
try:
grid([0, 1], latitude = lats, longitude = lons)
self.fail('should raise exception')
@@ -1800,7 +906,7 @@ Index: cmor-2.8.3/Test/test_grid_stub_jamie.py
self.assertEquals('Error could not convert longitude to a numpy array', str(e))
def test_error_rank_lons(self):
axis_ids = [1, 2]
-@@ -121,7 +121,7 @@
+@@ -121,7 +121,7 @@ class TestGridCallErrors(unittest.TestCa
try:
grid(axis_ids, latitude = lats, longitude = lons)
self.fail('should raise exception')
@@ -1809,7 +915,7 @@ Index: cmor-2.8.3/Test/test_grid_stub_jamie.py
self.assertEquals("longitude's rank does not match number of axes passed via axis_ids", str(e))
def test_error_rank_lats(self):
-@@ -131,7 +131,7 @@
+@@ -131,7 +131,7 @@ class TestGridCallErrors(unittest.TestCa
try:
grid(axis_ids, latitude = lats, longitude = lons)
self.fail('should raise exception')
@@ -1818,7 +924,7 @@ Index: cmor-2.8.3/Test/test_grid_stub_jamie.py
self.assertEquals("latitude's rank does not match number of axes passed via axis_ids", str(e))
def test_error_rank_lat_verts(self): # this test may be fragile?
-@@ -143,7 +143,7 @@
+@@ -143,7 +143,7 @@ class TestGridCallErrors(unittest.TestCa
grid(axis_ids, latitude = lats, longitude = lons,
latitude_vertices = lat_verts)
self.fail('should raise exception')
@@ -1827,7 +933,7 @@ Index: cmor-2.8.3/Test/test_grid_stub_jamie.py
self.assertEquals("latitude_vertices's rank does not match number of axes passed via axis_ids +1 (for vertices)",
str(e))
-@@ -156,7 +156,7 @@
+@@ -156,7 +156,7 @@ class TestGridCallErrors(unittest.TestCa
grid(axis_ids, latitude = lats, longitude = lons,
longitude_vertices = lon_verts)
self.fail('should raise exception')
@@ -1836,17 +942,17 @@ Index: cmor-2.8.3/Test/test_grid_stub_jamie.py
self.assertEquals("longitude_vertices's rank does not match number of axes passed via axis_ids +1 (for vertices)",
str(e))
-Index: cmor-2.8.3/Test/test_python_2Gb_file.py
+Index: cmor-3.2.0/Test/test_python_2Gb_file.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_2Gb_file.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_2Gb_file.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_2Gb_file.py
++++ cmor-3.2.0/Test/test_python_2Gb_file.py
@@ -1,4 +1,4 @@
-
+from __future__ import print_function
import cmor,numpy
-@@ -37,12 +37,12 @@
+@@ -36,12 +36,12 @@ ntimes=250
data = numpy.random.random((nlev,nlat,nlon))*30+273.15
for i in range(ntimes):
@@ -1862,51 +968,62 @@ Index: cmor-2.8.3/Test/test_python_2Gb_file.py
-print 'hello'
+print('hello')
-Index: cmor-2.8.3/Test/test_python_2Gb_slice.py
+Index: cmor-3.2.0/Test/test_python_2Gb_slice.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_2Gb_slice.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_2Gb_slice.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_2Gb_slice.py
++++ cmor-3.2.0/Test/test_python_2Gb_slice.py
@@ -1,4 +1,4 @@
-
+from __future__ import print_function
import cmor,numpy
-@@ -20,7 +20,7 @@
+@@ -20,7 +20,7 @@ blons = numpy.arange(0,360.+dlon,dlon)
- levs = numpy.array([1000.,925,900,850,800,700,600,500,400,300,250,200,150,100,75,70,50,30,20,10,7.5,5,2.5,1])
+ levs = numpy.array([1000.,925,900,850,800,700,600,500,400,300,250,200,150,100,75,70,50,30,20,10,7.5,5,2.5,1,.5,.1])
alllevs = numpy.arange(1000,0,-dlev).tolist()
-print len(alllevs)
+print(len(alllevs))
- cmor.setup(inpath='.',netcdf_file_action=cmor.CMOR_REPLACE)
- cmor.dataset('historical', 'ukmo', 'pcmdi-10b HadCM3', 'gregorian',model_id='pcmdi-10b',outpath='Test',forcing='N/A', parent_experiment_id="lgm", parent_experiment_rip="r1i1p1",contact="Bruce Bochy",branch_time=0,institute_id="yep")
-@@ -40,12 +40,12 @@
+ cmor.setup(inpath='Tables', netcdf_file_action=cmor.CMOR_REPLACE)
+ cmor.dataset_json("Test/common_user_input.json")
+@@ -37,19 +37,19 @@ axes=[itim,ilev,ilat,ilon]
+
+ var = cmor.variable(table_entry='ta',units='K',axis_ids=axes)
+
+-print "allocating mem for data"
++print ("allocating mem for data")
data = numpy.random.random((nlev,nlat,nlon))*30+273.15
+-print "moving on to writing"
++print ("moving on to writing")
for i in range(ntimes):
-- if i%10==0 : print 'Writing time:',i
-+ if i%10==0 : print('Writing time:',i)
+- print 'Writing time:',i
++ print ('Writing time:',i)
cmor.write(var,data,time_vals=numpy.array([float(i),]),time_bnds=numpy.array([i,i+1.]))
+-print "closing var"
-print cmor.close(var_id=var,file_name=True)
-+print(cmor.close(var_id=var,file_name=True))
++print ("closing var")
++print (cmor.close(var_id=var,file_name=True))
+ print "closing cmor"
cmor.close()
-
+-print "done"
++print ("done")
-print 'hello'
-+print('hello')
-Index: cmor-2.8.3/Test/test_python_3hr.py
++print ('hello')
+Index: cmor-3.2.0/Test/test_python_3hr.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_3hr.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_3hr.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_3hr.py
++++ cmor-3.2.0/Test/test_python_3hr.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
import cmor,numpy
- error_flag = cmor.setup(inpath='Test', netcdf_file_action=cmor.CMOR_REPLACE)
-@@ -39,7 +40,7 @@
+ error_flag = cmor.setup(inpath='Tables', netcdf_file_action=cmor.CMOR_REPLACE)
+@@ -22,7 +23,7 @@ iloc = cmor.axis("location",units="1",co
igrid = cmor.grid(axis_ids=[iloc,itm])
@@ -1915,16 +1032,16 @@ Index: cmor-2.8.3/Test/test_python_3hr.py
ilat = cmor.time_varying_grid_coordinate(igrid,table_entry='latitude',units='degrees_north')
ilon = cmor.time_varying_grid_coordinate(igrid,table_entry='longitude',units='degrees_east')
-Index: cmor-2.8.3/Test/test_python_appending.py
+Index: cmor-3.2.0/Test/test_python_appending.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_appending.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_appending.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_appending.py
++++ cmor-3.2.0/Test/test_python_appending.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
import cmor,numpy
nlat = 90
-@@ -13,7 +14,7 @@
+@@ -13,7 +14,7 @@ def mywrite(data = None, time_vals = Non
bnds_req=numpy.array(bnds_req)
bnds_req.shape=(7,2)
@@ -1933,7 +1050,7 @@ Index: cmor-2.8.3/Test/test_python_appending.py
levs=[]
-@@ -22,14 +23,14 @@
+@@ -22,14 +23,14 @@ def mywrite(data = None, time_vals = Non
levs=numpy.array(levs)
@@ -1950,13 +1067,13 @@ Index: cmor-2.8.3/Test/test_python_appending.py
cmor.setup(inpath=ipth,
set_verbosity=cmor.CMOR_NORMAL,
netcdf_file_action = mode,
-@@ -65,22 +66,22 @@
+@@ -54,22 +55,22 @@ def mywrite(data = None, time_vals = Non
#itim = cmor.axis(table_entry='time',units='month since 2008',coord_vals=numpy.arange(0,12,1))
ilat = cmor.axis(table_entry='latitude',coord_vals=lats,units='degrees_north',cell_bounds=bnds_lat)
ilon = cmor.axis(table_entry='longitude',coord_vals=lons,units='degrees_east',cell_bounds=bnds_lon)
- print 'so far',itim,ilat,ilon
-+ print('so far',itim,ilat,ilon)
- ilev = cmor.axis(table_entry="plevs",coord_vals=plevs,units="Pa")
++ print ('so far',itim,ilat,ilon)
+ ilev = cmor.axis(table_entry="plev19",coord_vals=plevs,units="Pa")
iv = cmor.variable(table_entry='ta',axis_ids=numpy.array((itim,ilev,ilat,ilon)),units='K')
@@ -1964,22 +1081,22 @@ Index: cmor-2.8.3/Test/test_python_appending.py
if append_to is None:
- print 'time:',time_vals
- print 'bnds:',cell_bounds
-+ print('time:',time_vals)
-+ print('bnds:',cell_bounds)
++ print ('time:',time_vals)
++ print ('bnds:',cell_bounds)
cmor.write(iv,data,time_vals=time_vals,time_bnds=cell_bounds)#,file_suffix="with-appending")
else:
- print 'Ok writing with a suffix',append_to
-+ print('Ok writing with a suffix',append_to)
++ print ('Ok writing with a suffix',append_to)
cmor.write(iv,data,time_vals=time_vals,file_suffix=append_to,time_bnds=cell_bounds)
- print 'and back'
-+ print('and back')
++ print ('and back')
file = cmor.close(iv,file_name=True)
- print 'Ok dumped to:',file
-+ print('Ok dumped to:',file)
++ print ('Ok dumped to:',file)
cmor.close()
return file
-@@ -90,6 +91,6 @@
+@@ -79,6 +80,6 @@ data = numpy.random.random((ntime,19,nla
f1 = mywrite(data = data[:6], time_vals = numpy.arange(0,6,1),cell_bounds=numpy.arange(0,7,1))
@@ -1988,16 +1105,16 @@ Index: cmor-2.8.3/Test/test_python_appending.py
f2 = mywrite(data = data[6:], time_vals = numpy.arange(6,12,1), cell_bounds=numpy.arange(6,13,1), append_to=f1)
-print f2
+print(f2)
-Index: cmor-2.8.3/Test/test_python_bad_date.py
+Index: cmor-3.2.0/Test/test_python_bad_date.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_bad_date.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_bad_date.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_bad_date.py
++++ cmor-3.2.0/Test/test_python_bad_date.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
import cmor
import numpy
-@@ -22,16 +23,16 @@
+@@ -22,16 +23,16 @@ def setup_data():
tbnds = list(tvals)
tbnds.append(43200)
tbnds=numpy.array(tbnds)-3.
@@ -2019,7 +1136,7 @@ Index: cmor-2.8.3/Test/test_python_bad_date.py
axes = [ {'table_entry': 'time1',
'units': tunits,
-@@ -85,7 +86,7 @@
+@@ -85,7 +86,7 @@ def main():
cmor_initialisation()
values,axes = setup_data()
vid = cmor_define_and_write(values, axes)
@@ -2028,16 +1145,16 @@ Index: cmor-2.8.3/Test/test_python_bad_date.py
if __name__ == '__main__':
-Index: cmor-2.8.3/Test/test_python_bentley_01.py
+Index: cmor-3.2.0/Test/test_python_bentley_01.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_bentley_01.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_bentley_01.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_bentley_01.py
++++ cmor-3.2.0/Test/test_python_bentley_01.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
import cmor
import numpy
import cdtime
-@@ -26,7 +27,7 @@
+@@ -26,7 +27,7 @@ def setup_data():
'coord_vals': [0]},
{'table_entry': 'hybrid_height',
'units': 'm',
@@ -2046,7 +1163,7 @@ Index: cmor-2.8.3/Test/test_python_bentley_01.py
'cell_bounds': [[x-0.5, x+0.5] for x in range(2)],
},
]
-@@ -45,7 +46,7 @@
+@@ -45,7 +46,7 @@ def cmor_define_and_write(values, axes):
igrid = cmor.grid([axis_ids[1]], [0.], [0.])
cmor.zfactor(axis_ids[2], 'b', axis_ids = [axis_ids[2]],
@@ -2055,7 +1172,7 @@ Index: cmor-2.8.3/Test/test_python_bentley_01.py
zfactor_bounds = [[x-0.5, x+0.5] for x in range(2)])
cmor.zfactor(axis_ids[2], 'orog', 'm', axis_ids = [igrid],
-@@ -62,7 +63,7 @@
+@@ -62,7 +63,7 @@ def cmor_define_and_write(values, axes):
for time in [x * 1800./ 86400 for x in range(48)]:
time += 1./3600./24.
tr = cdtime.reltime(time,axes[0]["units"])
@@ -2064,7 +1181,7 @@ Index: cmor-2.8.3/Test/test_python_bentley_01.py
cmor.write(varid, values, time_vals = [time])
return varid
-@@ -73,7 +74,7 @@
+@@ -73,7 +74,7 @@ def main():
values, axes = setup_data()
varid = cmor_define_and_write(values, axes)
fname = cmor.close(varid, file_name = True)
@@ -2073,16 +1190,16 @@ Index: cmor-2.8.3/Test/test_python_bentley_01.py
if __name__ == '__main__':
-Index: cmor-2.8.3/Test/test_python_bounds_request.py
+Index: cmor-3.2.0/Test/test_python_bounds_request.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_bounds_request.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_bounds_request.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_bounds_request.py
++++ cmor-3.2.0/Test/test_python_bounds_request.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
import cmor,numpy
breq = "100000. 80000. 80000. 68000. 68000. 56000. 56000. 44000. 44000. 31000. 31000. 18000. 18000. 0.".split()
-@@ -9,7 +10,7 @@
+@@ -9,7 +10,7 @@ for b in breq:
bnds_req=numpy.array(bnds_req)
bnds_req.shape=(7,2)
@@ -2091,29 +1208,31 @@ Index: cmor-2.8.3/Test/test_python_bounds_request.py
levs=[]
-@@ -18,7 +19,7 @@
+@@ -18,7 +19,7 @@ for b in bnds_req:
levs=numpy.array(levs)
-print levs
+print(levs)
- ipth="Test"
- cmor.setup(inpath=ipth,
-@@ -51,7 +52,7 @@
+ cmor.setup(inpath="Tables",
+ set_verbosity=cmor.CMOR_NORMAL,
+@@ -44,8 +45,8 @@ data = numpy.random.random((ntime,7,nlat
itim = cmor.axis(table_entry='time',coord_vals=numpy.arange(0,ntime,1),units='month since 2008')
ilat = cmor.axis(table_entry='latitude',coord_vals=lats,units='degrees_north')
ilon = cmor.axis(table_entry='longitude',coord_vals=lons,units='degrees_east')
-print 'so far',itim,ilat,ilon
-+print('so far',itim,ilat,ilon)
+-print bnds_req
++print ('so far',itim,ilat,ilon)
++print (bnds_req)
ilev = cmor.axis(table_entry="pressure2",coord_vals=levs,cell_bounds=bnds_req,units="Pa")
iv = cmor.variable(table_entry='ta',axis_ids=numpy.array((itim,ilev,ilat,ilon)),units='K')
-Index: cmor-2.8.3/Test/test_python_cfmip_site_axis_test.py
+Index: cmor-3.2.0/Test/test_python_cfmip_site_axis_test.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_cfmip_site_axis_test.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_cfmip_site_axis_test.py 2013-06-15 10:54:40.000000000 +0100
-@@ -28,6 +28,7 @@
+--- cmor-3.2.0.orig/Test/test_python_cfmip_site_axis_test.py
++++ cmor-3.2.0/Test/test_python_cfmip_site_axis_test.py
+@@ -28,6 +28,7 @@ variables:
lev:formula_terms = "a: lev b: b orog: orog";
...
'''
@@ -2121,67 +1240,67 @@ Index: cmor-2.8.3/Test/test_python_cfmip_site_axis_test.py
import cmor
import numpy
-@@ -64,41 +65,41 @@
+@@ -57,41 +58,41 @@ if __name__ == '__main__' :
# Create CMOR axes and grids
- table_id = cmor.load_table('CMIP5_cfSites')
+ table_id = cmor.load_table('CMIP6_cfSites.json')
taxis_id = cmor.axis('time1', units='days since 2000-01-01 00:00:00') #, length=1, interval='30 minutes')
- print 'ok: created time axis'
-+ print('ok: created time axis')
++ print ('ok: created time axis')
saxis_id = cmor.axis('site', units='1', coord_vals=[1,2,3])
- print 'ok: created site axis',saxis_id
-+ print('ok: created site axis',saxis_id)
++ print ('ok: created site axis',saxis_id)
zaxis_id = cmor.axis('hybrid_height', units='m', coord_vals=[1.0], cell_bounds=[0.0,2.0])
- print 'ok: created height axis',zaxis_id
-+ print('ok: created height axis',zaxis_id)
++ print ('ok: created height axis',zaxis_id)
# Create zfactors for b and orog for hybrid height axis.
# Where do these get used, if anywhere?
bfact_id = cmor.zfactor(zaxis_id, 'b', '1', [zaxis_id], 'd', zfactor_values=[1.0],
zfactor_bounds=[0.0,2.0])
- print 'ok: created b zfactors'
-+ print('ok: created b zfactors')
++ print ('ok: created b zfactors')
# Create grid object to link site-dimensioned variables to (lat,long).
- # Need to make CMIP5_grids the current MIP table for this to work.
- table_id = cmor.load_table('CMIP5_grids')
+ # Need to make CMIP6_grids the current MIP table for this to work.
+ table_id = cmor.load_table('CMIP6_grids.json')
gaxis_id = cmor.grid([saxis_id], site_lats, site_lons)
- print 'ok: created site grid'
-+ print('ok: created site grid')
++ print ('ok: created site grid')
# Create CMOR variable for cloud area fraction: MIP name = 'cl', STASH = m01s02i261*100
- table_id = cmor.load_table('CMIP5_cfSites')
+ table_id = cmor.load_table('CMIP6_cfSites.json')
var_id = cmor.variable('cl', '%', [taxis_id, gaxis_id, zaxis_id], type='f',
missing_value=-99.0, original_name='STASH m01s02i261*100')
- print 'ok: created variable for "cl"'
-+ print('ok: created variable for "cl"')
++ print ('ok: created variable for "cl"')
ofact_id = cmor.zfactor(zaxis_id, 'orog', 'm', [gaxis_id], 'd',
zfactor_values=[123.0])
- print 'ok: created orog zfactors'
-+ print('ok: created orog zfactors')
++ print ('ok: created orog zfactors')
# Write some data to this variable. First convert raw data to numpy arrays.
shape = (1, 3, 1)
data = numpy.array([10, 20, 30], dtype=numpy.float32)
data = data.reshape(shape)
cmor.write(var_id, data, time_vals=[1.0])
- print 'ok: wrote variable data'
-+ print('ok: wrote variable data')
++ print ('ok: wrote variable data')
# Close CMOR.
cmor.close()
-Index: cmor-2.8.3/Test/test_python_clim_bounds.py
+Index: cmor-3.2.0/Test/test_python_clim_bounds.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_clim_bounds.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_clim_bounds.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_clim_bounds.py
++++ cmor-3.2.0/Test/test_python_clim_bounds.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from __future__ import print_function
import cmor
import numpy
-@@ -37,7 +38,7 @@
+@@ -37,7 +38,7 @@ def main():
axis_ids = list()
for axis in axes:
@@ -2190,17 +1309,17 @@ Index: cmor-2.8.3/Test/test_python_clim_bounds.py
axis_id = cmor.axis(**axis)
axis_ids.append(axis_id)
-Index: cmor-2.8.3/Test/test_python_clim_bounds_02.py
+Index: cmor-3.2.0/Test/test_python_clim_bounds_02.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_clim_bounds_02.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_clim_bounds_02.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_clim_bounds_02.py
++++ cmor-3.2.0/Test/test_python_clim_bounds_02.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from __future__ import print_function
import cmor
import numpy
-@@ -50,7 +51,7 @@
+@@ -50,7 +51,7 @@ def main():
axis_ids = list()
for axis in axes:
@@ -2209,17 +1328,17 @@ Index: cmor-2.8.3/Test/test_python_clim_bounds_02.py
axis_id = cmor.axis(**axis)
axis_ids.append(axis_id)
-Index: cmor-2.8.3/Test/test_python_clim_bounds_03.py
+Index: cmor-3.2.0/Test/test_python_clim_bounds_03.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_clim_bounds_03.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_clim_bounds_03.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_clim_bounds_03.py
++++ cmor-3.2.0/Test/test_python_clim_bounds_03.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from __future__ import print_function
import cmor
import numpy
-@@ -50,7 +51,7 @@
+@@ -50,7 +51,7 @@ def main():
axis_ids = list()
for axis in axes:
@@ -2228,7 +1347,7 @@ Index: cmor-2.8.3/Test/test_python_clim_bounds_03.py
axis_id = cmor.axis(**axis)
axis_ids.append(axis_id)
-@@ -62,7 +63,7 @@
+@@ -62,7 +63,7 @@ def main():
history = 'variable history',
missing_value = -99
)
@@ -2237,17 +1356,17 @@ Index: cmor-2.8.3/Test/test_python_clim_bounds_03.py
cmor.write(varid, values)#, ntimes_passed=1)
-Index: cmor-2.8.3/Test/test_python_clim_bounds_04.py
+Index: cmor-3.2.0/Test/test_python_clim_bounds_04.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_clim_bounds_04.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_clim_bounds_04.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_clim_bounds_04.py
++++ cmor-3.2.0/Test/test_python_clim_bounds_04.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from __future__ import print_function
import cmor
import numpy
-@@ -50,7 +51,7 @@
+@@ -50,7 +51,7 @@ def main():
[45959, 52925]],}
axis_ids = list()
for axis in axes:
@@ -2256,16 +1375,16 @@ Index: cmor-2.8.3/Test/test_python_clim_bounds_04.py
axis_id = cmor.axis(**axis)
axis_ids.append(axis_id)
-Index: cmor-2.8.3/Test/test_python_YYYMMDDHH_exp_fmt.py
+Index: cmor-3.2.0/Test/test_python_YYYMMDDHH_exp_fmt.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_YYYMMDDHH_exp_fmt.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_YYYMMDDHH_exp_fmt.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_YYYMMDDHH_exp_fmt.py
++++ cmor-3.2.0/Test/test_python_YYYMMDDHH_exp_fmt.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
import cmor
def path_test():
-@@ -32,7 +33,7 @@
+@@ -30,7 +31,7 @@ def path_test():
cmor.write(varid, [273])
path=cmor.close(varid, file_name=True)
@@ -2274,109 +1393,94 @@ Index: cmor-2.8.3/Test/test_python_YYYMMDDHH_exp_fmt.py
if __name__ == '__main__':
path_test()
-Index: cmor-2.8.3/Test/test_python_direct_calls.py
+Index: cmor-3.2.0/Test/test_python_direct_calls.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_direct_calls.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_direct_calls.py 2013-06-16 17:20:26.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_direct_calls.py
++++ cmor-3.2.0/Test/test_python_direct_calls.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
from test_python_common import * # common subroutines
import cmor._cmor
import os
-@@ -32,7 +33,7 @@
- a = cmor._cmor.load_table("Tables/CMIP5_Omon")
+@@ -19,7 +20,7 @@ tables=[]
+ a = cmor._cmor.load_table("Tables/CMIP6_Omon.json")
tables.append(a)
- tables.append(cmor._cmor.load_table("Tables/CMIP5_Amon"))
+ tables.append(cmor._cmor.load_table("Tables/CMIP6_Amon.json"))
-print 'Tables ids:',tables
-+print('Tables ids:',tables)
++print ('Tables ids:',tables)
axes=[]
-@@ -48,7 +49,7 @@
+@@ -35,7 +36,7 @@ units="degrees_east"
myaxes[2] = cmor._cmor.axis(id,units,lon,alons,'d',bnds_lon,2,interval)
- id="plevs"
+ id="plev19"
units="Pa"
-print plevs.astype("d")
+print(plevs.astype("d"))
myaxes[3] = cmor._cmor.axis(id,units,lev2,plevs.astype("d"),'d',None,0,interval)
-@@ -75,31 +76,31 @@
+@@ -62,31 +63,31 @@ myaxes2[1] = myaxes[3];
myaxes2[2] = myaxes[1];
myaxes2[3] = myaxes[2];
-print 'ok doing the vars thing'
-+print('ok doing the vars thing')
++print ('ok doing the vars thing')
myvars[0] = cmor._cmor.variable(entry2d[0],units2d[0],3,myaxes,'d',None,dtmp2,positive2d[0],varin2d[0],"no history","no future")
-print 'vars 2'
-+print('vars 2')
- myvars[1] = cmor._cmor.variable(entry3d[2],units3d[2],4,myaxes2,'d',None,dtmp2,"",varin3d[2],"no history","no future")
++print ('vars 2')
+ myvars[1] = cmor._cmor.variable(entry3d[2],units3d[2],4,myaxes2,'d',None,dtmp2,"down",varin3d[2],"no history","no future")
-print 'vars 2'
-+print('vars 2')
++print ('vars 2')
myaxes2[1] = myaxes[4];
- myvars[2] = cmor._cmor.variable(entry3d[0],units3d[0],4,myaxes2,'d',None,dtmp2,"",varin3d[0],"no history","no future")
+ myvars[2] = cmor._cmor.variable(entry3d[0],units3d[0],4,myaxes2,'d',None,dtmp2,"down",varin3d[0],"no history","no future")
-print 'vars 2'
-+print('vars 2')
++print ('vars 2')
-print 'zfact',type(numpy.array(myaxes2[1])),type(myaxes2)
-+print('zfact',type(numpy.array(myaxes2[1])),type(myaxes2))
++print ('zfact',type(numpy.array(myaxes2[1])),type(myaxes2))
myvars[3] = cmor._cmor.zfactor(int(myaxes2[1]),"p0","Pa",0,None,'d',p0,None)
-print 'zfact',myaxes2[1]
-+print('zfact',myaxes2[1])
++print ('zfact',myaxes2[1])
myvars[3] = cmor._cmor.zfactor(int(myaxes2[1]),"b","",1,myaxes2[1],'d',b_coeff,b_coeff_bnds)
-print 'zfact',myaxes2[1]
-+print('zfact',myaxes2[1])
++print ('zfact',myaxes2[1])
myvars[3] = cmor._cmor.zfactor(int(myaxes2[1]),"a","",1,myaxes2[1],'d',a_coeff,a_coeff_bnds)
#/* printf("defining ap\n"); */
#/* for(i=0;i<5;i++) {a_coeff[i]*=1.e3;printf("sending acoef: %i, %lf\n",i,a_coeff[i]);} */
#/* for(i=0;i<6;i++) {a_coeff_bnds[i]*=1.e5;printf("sending acoef: %i, %lf\n",i,a_coeff_bnds[i]);} */
#/* ierr = cmor_zfactor(&myvars[3],myaxes2[1],"ap","hPa",1,&myaxes2[1],'d',&a_coeff,&a_coeff_bnds); */
-print 'zfact before last'
-+print('zfact before last')
++print ('zfact before last')
myvars[3] = cmor._cmor.zfactor(int(myaxes2[1]),"ps","hPa",3,myaxes,'d',None,None)
-print 'zfact last'
-+print('zfact last')
++print ('zfact last')
# /* ok here we decalre a variable for region axis testing */
cmor.set_table(tables[0])
-@@ -114,7 +115,7 @@
+@@ -101,7 +102,7 @@ cmor.set_table(tables[1])
for i in range(ntimes):
data2d = read_2d_input_files(i, varin2d[0], lat,lon)
- print 'writing time',i,data2d.shape,data2d,numpy.average(data2d)
-+ print('writing time',i,data2d.shape,data2d,numpy.average(data2d))
- cmor._cmor.write(myvars[0],numpy.ravel(data2d),data2d.dtype.char,"",1,None,None,None);
++ print ('writing time',i,data2d.shape,data2d,numpy.average(data2d))
+ cmor._cmor.write(myvars[0],numpy.ravel(data2d),data2d.dtype.char,1,None,None,None);
cmor._cmor.close(None,0,0)
-Index: cmor-2.8.3/Test/test_python_fx.py
+Index: cmor-3.2.0/Test/test_python_grid_and_ocn_sigma.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_fx.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_fx.py 2013-06-15 10:54:40.000000000 +0100
-@@ -1,3 +1,4 @@
-+from __future__ import print_function
- import cmor
- import numpy
-
-@@ -45,4 +46,4 @@
- fnm = cmor.close(varid,file_name=True)
- cmor.close()
- return fnm
--print test_mode(cmor.CMOR_REPLACE)
-+print(test_mode(cmor.CMOR_REPLACE))
-Index: cmor-2.8.3/Test/test_python_grid_and_ocn_sigma.py
-===================================================================
---- cmor-2.8.3.orig/Test/test_python_grid_and_ocn_sigma.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_grid_and_ocn_sigma.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_grid_and_ocn_sigma.py
++++ cmor-3.2.0/Test/test_python_grid_and_ocn_sigma.py
@@ -1,4 +1,4 @@
-
+from __future__ import print_function
import cmor,numpy
import os
ntimes=2
-@@ -43,7 +43,7 @@
+@@ -43,7 +43,7 @@ def gen_irreg_grid(lon,lat):
lat_vertices[j,i,1] = lat_coords[j,i]-delta_lat;
lat_vertices[j,i,2] = lat_coords[j,i];
lat_vertices[j,i,3] = lat_coords[j,i]+delta_lat;
@@ -2385,22 +1489,22 @@ Index: cmor-2.8.3/Test/test_python_grid_and_ocn_sigma.py
return x,y,lon_coords,lat_coords,lon_vertices,lat_vertices
-@@ -86,12 +86,12 @@
- a = cmor.load_table("Tables/CMIP5_grids")
+@@ -61,12 +61,12 @@ tables=[]
+ a = cmor.load_table("CMIP6_grids.json")
tables.append(a)
- tables.append(cmor.load_table("Tables/CMIP5_Omon"))
+ tables.append(cmor.load_table("CMIP6_Omon.json"))
-print 'Tables ids:',tables
-+print('Tables ids:',tables)
++print ('Tables ids:',tables)
cmor.set_table(tables[0])
x,y,lon_coords,lat_coords,lon_vertices,lat_vertices = gen_irreg_grid(lon,lat)
-print lon_vertices.shape,lat_vertices.shape,x.shape,y.shape
-+print(lon_vertices.shape,lat_vertices.shape,x.shape,y.shape)
++print (lon_vertices.shape,lat_vertices.shape,x.shape,y.shape)
myaxes[1] = cmor.axis(table_entry = 'y',
units = 'm',
-@@ -100,13 +100,13 @@
+@@ -75,13 +75,13 @@ myaxes[0] = cmor.axis(table_entry = 'x',
units = 'm',
coord_vals = x)
@@ -2416,7 +1520,7 @@ Index: cmor-2.8.3/Test/test_python_grid_and_ocn_sigma.py
myaxes[2] = grid_id
## mapnm = 'lambert_conformal_conic'
-@@ -127,19 +127,19 @@
+@@ -102,19 +102,19 @@ myaxes[3] = cmor.axis(table_entry = 'tim
# Now sets up the ocn sigma stuff
levs=-numpy.arange(lev)/float(lev+1.)
blevs=-numpy.arange(lev+1)/float(lev+1.)
@@ -2442,7 +1546,7 @@ Index: cmor-2.8.3/Test/test_python_grid_and_ocn_sigma.py
myvars[0] = cmor.variable( table_entry = 'thetao',
units = 'K',
axis_ids = pass_axes,
-@@ -154,8 +154,8 @@
+@@ -129,8 +129,8 @@ for i in range(ntimes):
eta = numpy.random.random((lon,lat,ntimes))*10000.
#print 'writing time: ',i,data3d.shape,data3d
#print Time[i],bnds_time[2*i:2*i+2]
@@ -2453,32 +1557,32 @@ Index: cmor-2.8.3/Test/test_python_grid_and_ocn_sigma.py
+ print('Writing time',i,'for eta')
cmor.write(ieta,eta,1,time_vals=Time[i],time_bnds=bnds_time[2*i:2*i+2],store_with=myvars[0])
cmor.close()
-Index: cmor-2.8.3/Test/test_python_index_coord.py
+Index: cmor-3.2.0/Test/test_python_index_coord.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_index_coord.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_index_coord.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_index_coord.py
++++ cmor-3.2.0/Test/test_python_index_coord.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
import cmor,numpy
ipth="Test"
-@@ -41,4 +42,4 @@
+@@ -41,4 +42,4 @@ iv = cmor.variable(table_entry='thetao',
cmor.write(iv,data)
f1 = cmor.close(iv,file_name=True)
-print f1
+print(f1)
-Index: cmor-2.8.3/Test/test_python_jamie_10.py
+Index: cmor-3.2.0/Test/test_python_jamie_10.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_jamie_10.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_jamie_10.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_jamie_10.py
++++ cmor-3.2.0/Test/test_python_jamie_10.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from __future__ import print_function
import cmor
import numpy
-@@ -37,7 +38,7 @@
+@@ -29,7 +30,7 @@ def main():
axis_ids = list()
for axis in axes:
@@ -2487,10 +1591,10 @@ Index: cmor-2.8.3/Test/test_python_jamie_10.py
axis_id = cmor.axis(**axis)
axis_ids.append(axis_id)
-Index: cmor-2.8.3/Test/test_python_jamie_12.py
+Index: cmor-3.2.0/Test/test_python_jamie_12.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_jamie_12.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_jamie_12.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_jamie_12.py
++++ cmor-3.2.0/Test/test_python_jamie_12.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-
@@ -2498,7 +1602,7 @@ Index: cmor-2.8.3/Test/test_python_jamie_12.py
import cmor
import numpy
-@@ -9,7 +9,7 @@
+@@ -9,7 +9,7 @@ def define_axes(axes):
axis_id = cmor.axis(**axis)
axis_ids.append(axis_id)
@@ -2507,16 +1611,16 @@ Index: cmor-2.8.3/Test/test_python_jamie_12.py
return axis_ids
def define_write_var(axis_ids, entry, unit, values):
-Index: cmor-2.8.3/Test/test_python_jamie_2.py
+Index: cmor-3.2.0/Test/test_python_jamie_2.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_jamie_2.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_jamie_2.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_jamie_2.py
++++ cmor-3.2.0/Test/test_python_jamie_2.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
import cmor
def multi_call_test():
-@@ -31,15 +32,15 @@
+@@ -25,15 +26,15 @@ def multi_call_test():
axis_ids.append(axis_id)
varid = cmor.variable('ts', 'K', axis_ids)
cmor.write(varid, [275], time_vals = [15], time_bnds = [ [0,30] ])
@@ -2536,16 +1640,16 @@ Index: cmor-2.8.3/Test/test_python_jamie_2.py
if __name__ == '__main__':
-Index: cmor-2.8.3/Test/test_python_jamie_6.py
+Index: cmor-3.2.0/Test/test_python_jamie_6.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_jamie_6.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_jamie_6.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_jamie_6.py
++++ cmor-3.2.0/Test/test_python_jamie_6.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
import cmor,numpy
error_flag = cmor.setup(inpath='Test', netcdf_file_action=cmor.CMOR_REPLACE)
-@@ -106,7 +107,7 @@
+@@ -91,7 +92,7 @@ if table_entry == 'hybrid_height':
units='m' ,
zfactor_values = data2d)
else:
@@ -2554,10 +1658,10 @@ Index: cmor-2.8.3/Test/test_python_jamie_6.py
ilev = cmor.axis(
table_entry='standard_sigma',
units='1',
-Index: cmor-2.8.3/Test/test_python_jamie_8.py
+Index: cmor-3.2.0/Test/test_python_jamie_8.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_jamie_8.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_jamie_8.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_jamie_8.py
++++ cmor-3.2.0/Test/test_python_jamie_8.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-
@@ -2565,7 +1669,7 @@ Index: cmor-2.8.3/Test/test_python_jamie_8.py
import cmor
import numpy
-@@ -9,7 +9,7 @@
+@@ -9,7 +9,7 @@ def define_axes(axes):
axis_id = cmor.axis(**axis)
axis_ids.append(axis_id)
@@ -2574,7 +1678,7 @@ Index: cmor-2.8.3/Test/test_python_jamie_8.py
return axis_ids
def define_write_var(axis_ids, entry, unit, values):
-@@ -19,11 +19,11 @@
+@@ -19,11 +19,11 @@ def define_write_var(axis_ids, entry, un
missing_value = -99
)
@@ -2588,17 +1692,17 @@ Index: cmor-2.8.3/Test/test_python_jamie_8.py
def cmor_ini():
-Index: cmor-2.8.3/Test/test_python_jamie_9.py
+Index: cmor-3.2.0/Test/test_python_jamie_9.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_jamie_9.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_jamie_9.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_jamie_9.py
++++ cmor-3.2.0/Test/test_python_jamie_9.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from __future__ import print_function
import cmor
import numpy
-@@ -37,7 +38,7 @@
+@@ -29,7 +30,7 @@ def main():
axis_ids = list()
for axis in axes:
@@ -2607,16 +1711,16 @@ Index: cmor-2.8.3/Test/test_python_jamie_9.py
axis_id = cmor.axis(**axis)
axis_ids.append(axis_id)
-Index: cmor-2.8.3/Test/test_python_jamie_site_surface.py
+Index: cmor-3.2.0/Test/test_python_jamie_site_surface.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_jamie_site_surface.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_jamie_site_surface.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_jamie_site_surface.py
++++ cmor-3.2.0/Test/test_python_jamie_site_surface.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
import cmor
import numpy
-@@ -55,7 +56,7 @@
+@@ -46,7 +47,7 @@ def main():
cmor_initialisation()
values, axes = setup_data()
cmor_define_and_write(values, axes)
@@ -2625,25 +1729,25 @@ Index: cmor-2.8.3/Test/test_python_jamie_site_surface.py
if __name__ == '__main__':
-Index: cmor-2.8.3/Test/test_python_joerg_10.py
+Index: cmor-3.2.0/Test/test_python_joerg_10.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_joerg_10.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_joerg_10.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_joerg_10.py
++++ cmor-3.2.0/Test/test_python_joerg_10.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
from test_python_common import * # common subroutines
import cmor._cmor
-@@ -42,7 +43,7 @@
- a = cmor.load_table("Tables/CMIP5_grids")
+@@ -24,7 +25,7 @@ tables=[]
+ a = cmor.load_table("Tables/CMIP6_grids.json")
tables.append(a)
- tables.append(cmor.load_table("Tables/CMIP5_Omon"))
+ tables.append(cmor.load_table("Tables/CMIP6_Omon.json"))
-print 'Tables ids:',tables
-+print('Tables ids:',tables)
++print ('Tables ids:',tables)
cmor.set_table(tables[0])
-@@ -62,7 +63,7 @@
+@@ -45,7 +46,7 @@ grid_id = cmor.grid(axis_ids = myaxes[:2
longitude = lon_coords,
latitude_vertices = lat_vertices,
longitude_vertices = lon_vertices)
@@ -2652,44 +1756,48 @@ Index: cmor-2.8.3/Test/test_python_joerg_10.py
myaxes[2] = grid_id
## mapnm = 'lambert_conformal_conic'
-@@ -83,7 +84,7 @@
+@@ -70,7 +71,7 @@ myaxes[3] = cmor.axis(table_entry = 'tim
- pass_axes = [myaxes[3],myaxes[2]]
+ pass_axes = [myaxes[3],myaxes[4],myaxes[2]]
-print 'ok going to cmorvar'
+print('ok going to cmorvar')
myvars[0] = cmor.variable( table_entry = 'calc',
units = 'mol m-3',
axis_ids = pass_axes,
-@@ -97,7 +98,7 @@
- data2d_1 = read_2d_input_files(i, varin2d[0], lat,lon)
- data2d_2 = read_2d_input_files(i+1, varin2d[0], lat,lon)
+@@ -88,9 +89,9 @@ for i in range(0,ntimes,2):
data2d=numpy.array((data2d_1,data2d_2))
-- print 'writing time: ',i,data2d.shape,data2d
+ #data2d=numpy.expand_dims(data2d, axis=0)
+ #print data2d.shape
+- print 'writing time: ',i
+- print data2d.shape
+- print data2d
- print Time[i:i+2],bnds_time[2*i:2*i+4]
-+ print('writing time: ',i,data2d.shape,data2d)
-+ print(Time[i:i+2],bnds_time[2*i:2*i+4])
++ print ('writing time: ',i)
++ print (data2d.shape)
++ print (data2d)
++ print (Time[i:i+2],bnds_time[2*i:2*i+4])
cmor.write(myvars[0],data2d,2,time_vals=numpy.arange(i,i+2),time_bnds=numpy.arange(i,i+3))
cmor.close()
-Index: cmor-2.8.3/Test/test_python_joerg_11.py
+Index: cmor-3.2.0/Test/test_python_joerg_11.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_joerg_11.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_joerg_11.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_joerg_11.py
++++ cmor-3.2.0/Test/test_python_joerg_11.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
from test_python_common import * # common subroutines
import cmor._cmor
-@@ -41,7 +42,7 @@
- a = cmor.load_table("Tables/CMIP5_grids")
+@@ -18,7 +19,7 @@ tables=[]
+ a = cmor.load_table("Tables/CMIP6_grids.json")
tables.append(a)
- tables.append(cmor.load_table("Tables/CMIP5_Omon"))
+ tables.append(cmor.load_table("Tables/CMIP6_Omon.json"))
-print 'Tables ids:',tables
-+print('Tables ids:',tables)
++print ('Tables ids:',tables)
cmor.set_table(tables[0])
-@@ -61,7 +62,7 @@
+@@ -38,7 +39,7 @@ grid_id = cmor.grid(axis_ids = myaxes[:2
longitude = lon_coords,
latitude_vertices = lat_vertices,
longitude_vertices = lon_vertices)
@@ -2698,7 +1806,7 @@ Index: cmor-2.8.3/Test/test_python_joerg_11.py
myaxes[2] = grid_id
## mapnm = 'lambert_conformal_conic'
-@@ -85,7 +86,7 @@
+@@ -62,7 +63,7 @@ myaxes[4] = cmor.axis(table_entry = 'oli
pass_axes = [myaxes[3],myaxes[4]]
@@ -2707,7 +1815,7 @@ Index: cmor-2.8.3/Test/test_python_joerg_11.py
myvars[0] = cmor.variable( table_entry = 'mfo',
units = 'kg s-1',
axis_ids = pass_axes,
-@@ -94,7 +95,7 @@
+@@ -71,7 +72,7 @@ myvars[0] = cmor.variable( table_entry =
)
for i in range(ntimes):
data2d = numpy.random.random((1,15))
@@ -2717,25 +1825,25 @@ Index: cmor-2.8.3/Test/test_python_joerg_11.py
+ print(Time[i],bnds_time[2*i:2*i+2] )
cmor.write(myvars[0],data2d,1,time_vals=Time[i],time_bnds=bnds_time[2*i:2*i+2])
cmor.close()
-Index: cmor-2.8.3/Test/test_python_joerg_12.py
+Index: cmor-3.2.0/Test/test_python_joerg_12.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_joerg_12.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_joerg_12.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_joerg_12.py
++++ cmor-3.2.0/Test/test_python_joerg_12.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
from test_python_common import * # common subroutines
import cmor._cmor
-@@ -41,7 +42,7 @@
- a = cmor.load_table("Tables/CMIP5_grids")
+@@ -22,7 +23,7 @@ tables=[]
+ a = cmor.load_table("Tables/CMIP6_grids.json")
tables.append(a)
- tables.append(cmor.load_table("Tables/CMIP5_Lmon"))
+ tables.append(cmor.load_table("Tables/CMIP6_Lmon.json"))
-print 'Tables ids:',tables
-+print('Tables ids:',tables)
++print ('Tables ids:',tables)
cmor.set_table(tables[0])
-@@ -61,7 +62,7 @@
+@@ -42,7 +43,7 @@ grid_id = cmor.grid(axis_ids = myaxes[:2
longitude = lon_coords,
latitude_vertices = lat_vertices,
longitude_vertices = lon_vertices)
@@ -2744,7 +1852,7 @@ Index: cmor-2.8.3/Test/test_python_joerg_12.py
myaxes[2] = grid_id
## mapnm = 'lambert_conformal_conic'
-@@ -85,7 +86,7 @@
+@@ -66,7 +67,7 @@ myaxes[4] = cmor.axis(table_entry = 'veg
pass_axes = [myaxes[2],myaxes[3],myaxes[4]]
@@ -2753,7 +1861,7 @@ Index: cmor-2.8.3/Test/test_python_joerg_12.py
myvars[0] = cmor.variable( table_entry = 'landCoverFrac',
units = '%',
axis_ids = pass_axes,
-@@ -94,7 +95,7 @@
+@@ -75,7 +76,7 @@ myvars[0] = cmor.variable( table_entry =
)
for i in range(ntimes):
data2d = numpy.random.random((3,4,3))
@@ -2763,17 +1871,17 @@ Index: cmor-2.8.3/Test/test_python_joerg_12.py
+ print(Time[i],bnds_time[2*i:2*i+2] )
cmor.write(myvars[0],data2d,1,time_vals=Time[i],time_bnds=bnds_time[2*i:2*i+2])
cmor.close()
-Index: cmor-2.8.3/Test/test_python_joerg_2.py
+Index: cmor-3.2.0/Test/test_python_joerg_2.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_joerg_2.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_joerg_2.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_joerg_2.py
++++ cmor-3.2.0/Test/test_python_joerg_2.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from __future__ import print_function
import cmor
import numpy
-@@ -57,7 +58,7 @@
+@@ -52,7 +53,7 @@ def test_mode(mode,i,suffix=''):
'coord_vals': levels},
]
@@ -2782,16 +1890,16 @@ Index: cmor-2.8.3/Test/test_python_joerg_2.py
axis_ids = list()
for axis in axes:
axis_id = cmor.axis(**axis)
-@@ -70,7 +71,7 @@
+@@ -65,7 +66,7 @@ def test_mode(mode,i,suffix=''):
history = 'variable history',
missing_value = -99
)
-- print 'suffix is:',suffix
-+ print('suffix is:',suffix)
- cmor.write(varid, values, time_vals = [i], time_bnds = [ [i,i+1] ],file_suffix=suffix)
+- print "Sending time bounds:",[[i,i+1]]
++ print ("Sending time bounds:",[[i,i+1]])
+ cmor.write(varid, values, time_vals = [i], time_bnds = [ [i,i+1] ])
fnm = cmor.close(varid,file_name=True)
-@@ -79,7 +80,7 @@
+@@ -74,7 +75,7 @@ def test_mode(mode,i,suffix=''):
fnm=''
for i in range(5):
@@ -2800,66 +1908,71 @@ Index: cmor-2.8.3/Test/test_python_joerg_2.py
if i==0:
mode = cmor.CMOR_REPLACE
else:
-Index: cmor-2.8.3/Test/test_python_joerg_3.py
+Index: cmor-3.2.0/Test/test_python_joerg_3.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_joerg_3.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_joerg_3.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_joerg_3.py
++++ cmor-3.2.0/Test/test_python_joerg_3.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
import cmor,numpy
ntimes=1
-@@ -127,24 +128,24 @@
+@@ -107,27 +108,27 @@ for d in range(2):
for i in range(4):
tval = [i/4.+d]
- tbnd = [i/4.+d-.125,i/4.+d+.125]
-- print 'writing time:',i,i/4.,file_suffix1
-+ print('writing time:',i,i/4.,file_suffix1)
+ tbnd = [i/4.+d-0.125,i/4.+d+0.125]
+- print 'tvar',tval
+- print 'tbnd',tbnd
+- print 'writing time:',i,i/4.
++ print ('tvar',tval)
++ print ('tbnd',tbnd)
++ print ('writing time:',i,i/4.)
data=numpy.random.random((ntimes,nlev,nlat,nlon))*30.+273
data=data.astype("f")
- cmor.write(ivar1,data,time_vals=tval,time_bnds=tbnd,file_suffix=file_suffix1)
+ cmor.write(ivar1,data,time_vals=tval,time_bnds=tbnd)
- print 'wrote var 1 time:',i
-+ print('wrote var 1 time:',i)
++ print ('wrote var 1 time:',i)
data=numpy.random.random((ntimes,nlev,nlat,nlon))
data=data.astype("f")
- cmor.write(ivar2,data,time_vals=tval,time_bnds=tbnd,file_suffix=file_suffix2)
+ cmor.write(ivar2,data,time_vals=tval,time_bnds=tbnd)
- print 'wrote var 2 time:',i
-+ print('wrote var 2 time:',i)
++ print ('wrote var 2 time:',i)
data=numpy.random.random((ntimes,nlat,nlon))*8.+96300.
data=data.astype("f")
cmor.write(ips1,data,store_with=ivar1,ntimes_passed=1,time_vals=tval,time_bnds=tbnd)
- print 'wrote ps in var 1 time:',i
-+ print('wrote ps in var 1 time:',i)
++ print ('wrote ps in var 1 time:',i)
cmor.write(ips2,data,store_with=ivar2,ntimes_passed=1,time_vals=tval,time_bnds=tbnd)
- print 'wrote ps in var 2 time:',i
-+ print('wrote ps in var 2 time:',i)
- file_suffix1=cmor.close(ivar1,True)
- file_suffix2=cmor.close(ivar2,True)
-- print 'File:',file_suffix1,file_suffix2
-+ print('File:',file_suffix1,file_suffix2)
++ print ('wrote ps in var 2 time:',i)
+ file1=cmor.close(ivar1,True)
+ file2=cmor.close(ivar2,True)
+- print 'File1:',file1
+- print 'File2:',file2
++ print ('File1:',file1)
++ print ('File2:',file2)
cmor.close()
--print cmor.close(ivar1,True)
-+print(cmor.close(ivar1,True))
+ print cmor.close(ivar1,True)
cmor.close()
-Index: cmor-2.8.3/Test/test_python_joerg_8.py
+Index: cmor-3.2.0/Test/test_python_joerg_8.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_joerg_8.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_joerg_8.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_joerg_8.py
++++ cmor-3.2.0/Test/test_python_joerg_8.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
from test_python_common import * # common subroutines
import cmor._cmor
-@@ -41,7 +42,7 @@
- a = cmor.load_table("Tables/CMIP5_grids")
+@@ -22,7 +23,7 @@ tables=[]
+ a = cmor.load_table("Tables/CMIP6_grids.json")
tables.append(a)
- tables.append(cmor.load_table("Tables/CMIP5_Omon"))
+ tables.append(cmor.load_table("Tables/CMIP6_Omon.json"))
-print 'Tables ids:',tables
-+print('Tables ids:',tables)
++print ('Tables ids:',tables)
cmor.set_table(tables[0])
-@@ -61,7 +62,7 @@
+@@ -42,7 +43,7 @@ grid_id = cmor.grid(axis_ids = myaxes[:2
longitude = lon_coords,
latitude_vertices = lat_vertices,
longitude_vertices = lon_vertices)
@@ -2868,16 +1981,16 @@ Index: cmor-2.8.3/Test/test_python_joerg_8.py
myaxes[2] = grid_id
## mapnm = 'lambert_conformal_conic'
-@@ -82,7 +83,7 @@
+@@ -63,7 +64,7 @@ myaxes[3] = cmor.axis(table_entry = 'tim
pass_axes = [myaxes[3],myaxes[2]]
-print 'ok going to cmorvar'
-+print('ok going to cmorvar')
- myvars[0] = cmor.variable( table_entry = 'epc100',
++print ('ok going to cmorvar')
+ myvars[0] = cmor.variable( table_entry = 'exparag100',
units = 'mol m-2 s-1',
axis_ids = pass_axes,
-@@ -93,7 +94,7 @@
+@@ -74,7 +75,7 @@ myvars[0] = cmor.variable( table_entry =
)
for i in range(ntimes):
data2d = read_2d_input_files(i, varin2d[0], lat,lon)
@@ -2887,16 +2000,16 @@ Index: cmor-2.8.3/Test/test_python_joerg_8.py
+ print(Time[i],bnds_time[2*i:2*i+2] )
cmor.write(myvars[0],data2d,1,time_vals=Time[i],time_bnds=bnds_time[2*i:2*i+2])
cmor.close()
-Index: cmor-2.8.3/Test/test_python_joerg_9.py
+Index: cmor-3.2.0/Test/test_python_joerg_9.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_joerg_9.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_joerg_9.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_joerg_9.py
++++ cmor-3.2.0/Test/test_python_joerg_9.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
import cmor,numpy,cdms2
f=cdms2.open("Test/GR30s_halo.nc")
-@@ -75,7 +76,7 @@
+@@ -75,7 +76,7 @@ var_ids = cmor.variable(
fnm=""
for i in range(ntimes):
@@ -2905,7 +2018,7 @@ Index: cmor-2.8.3/Test/test_python_joerg_9.py
data = numpy.random.random((nlon,nlat))
error_flag = cmor.write(
var_id = var_ids,
-@@ -86,6 +87,6 @@
+@@ -86,6 +87,6 @@ for i in range(ntimes):
time_bnds = bnds_time[i:i+2])
fnm = cmor.close(var_ids,file_name=True,preserve=True)
@@ -2913,17 +2026,17 @@ Index: cmor-2.8.3/Test/test_python_joerg_9.py
+ print('dumped to:',fnm)
cmor.close()
-Index: cmor-2.8.3/Test/test_python_joerg_tim2_clim.py
+Index: cmor-3.2.0/Test/test_python_joerg_tim2_clim.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_joerg_tim2_clim.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_joerg_tim2_clim.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_joerg_tim2_clim.py
++++ cmor-3.2.0/Test/test_python_joerg_tim2_clim.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from __future__ import print_function
import cmor
import numpy
-@@ -40,12 +41,12 @@
+@@ -40,12 +41,12 @@ def main():
axis_ids = list()
for axis in axes:
@@ -2938,16 +2051,16 @@ Index: cmor-2.8.3/Test/test_python_joerg_tim2_clim.py
varid = cmor.variable(var,
units,
axis_ids,
-Index: cmor-2.8.3/Test/test_python_max_variables_2.py
+Index: cmor-3.2.0/Test/test_python_max_variables_2.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_max_variables_2.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_max_variables_2.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_max_variables_2.py
++++ cmor-3.2.0/Test/test_python_max_variables_2.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
import cmor,numpy
error_flag = cmor.setup(inpath='Test', netcdf_file_action=cmor.CMOR_REPLACE)
-@@ -84,11 +85,11 @@
+@@ -68,11 +69,11 @@ for it in range(ntimes):
if (it == ntimes-1) :
fnm = cmor.close(var3d_ids, True)
@@ -2961,11 +2074,11 @@ Index: cmor-2.8.3/Test/test_python_max_variables_2.py
else:
ierr = cmor.close(var3d_ids, False, True)
-Index: cmor-2.8.3/Test/test_python_memory_check.py
+Index: cmor-3.2.0/Test/test_python_memory_check.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_memory_check.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_memory_check.py 2013-06-15 10:54:40.000000000 +0100
-@@ -5,7 +5,7 @@
+--- cmor-3.2.0.orig/Test/test_python_memory_check.py
++++ cmor-3.2.0/Test/test_python_memory_check.py
+@@ -5,7 +5,7 @@ Note the memory size from repeated calls
Memory stats are taken from http://code.activestate.com/recipes/286222/
'''
@@ -2974,7 +2087,7 @@ Index: cmor-2.8.3/Test/test_python_memory_check.py
import os
_proc_status = '/proc/%d/status' % os.getpid()
-@@ -124,7 +124,7 @@
+@@ -120,7 +120,7 @@ def memory_check():
cmor.write(varid, [275])
mem,res,stk = memory_usage(sys.stdout,mem,res,stk)
#mem,res,stk = memory_usage(sys.stdout,memi,resi,stki)
@@ -2983,17 +2096,17 @@ Index: cmor-2.8.3/Test/test_python_memory_check.py
cmor.close(varid)
-Index: cmor-2.8.3/Test/test_python_open_close_cmor_multiple.py
+Index: cmor-3.2.0/Test/test_python_open_close_cmor_multiple.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_open_close_cmor_multiple.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_open_close_cmor_multiple.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_open_close_cmor_multiple.py
++++ cmor-3.2.0/Test/test_python_open_close_cmor_multiple.py
@@ -1,4 +1,4 @@
-
+from __future__ import print_function
import cmor,numpy
-@@ -50,10 +50,10 @@
+@@ -46,10 +46,10 @@ for var in tvars:
cmor.write(var,data)
path=cmor.close(var, file_name=True)
@@ -3006,16 +2119,16 @@ Index: cmor-2.8.3/Test/test_python_open_close_cmor_multiple.py
-print 'hello'
+print('hello')
-Index: cmor-2.8.3/Test/test_python_reverted_lats.py
+Index: cmor-3.2.0/Test/test_python_reverted_lats.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_reverted_lats.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_reverted_lats.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_reverted_lats.py
++++ cmor-3.2.0/Test/test_python_reverted_lats.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
import cmor,numpy
nlat = 10
-@@ -34,7 +35,7 @@
+@@ -34,7 +35,7 @@ ivar = cmor.variable(table_entry='tasmin
cmor.write(ivar,data,ntimes_passed=1,time_vals=[0.],time_bnds=[0.,1.])
fnm = cmor.close(ivar,file_name=True)
@@ -3024,10 +2137,10 @@ Index: cmor-2.8.3/Test/test_python_reverted_lats.py
ivar2 = cmor.variable(table_entry='tasmin',units='K',axis_ids=[itim,ilat2,ilon])
cmor.write(ivar2,data,ntimes_passed=1,time_vals=[1.],time_bnds=[1.,2.])
-Index: cmor-2.8.3/Test/test_python_singleton_anywhere_in_table_def.py
+Index: cmor-3.2.0/Test/test_python_singleton_anywhere_in_table_def.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_singleton_anywhere_in_table_def.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_singleton_anywhere_in_table_def.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_singleton_anywhere_in_table_def.py
++++ cmor-3.2.0/Test/test_python_singleton_anywhere_in_table_def.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-
@@ -3035,7 +2148,7 @@ Index: cmor-2.8.3/Test/test_python_singleton_anywhere_in_table_def.py
from test_python_common import * # common subroutines
import cmor._cmor
-@@ -56,7 +56,7 @@
+@@ -56,7 +56,7 @@ ts='days'
tscl=2.e-2
tables.append(cmor.load_table("/git/cmip5-cmor-tables/Tables/%s" % t))
@@ -3044,7 +2157,7 @@ Index: cmor-2.8.3/Test/test_python_singleton_anywhere_in_table_def.py
cmor.set_table(tables[0])
-@@ -76,7 +76,7 @@
+@@ -76,7 +76,7 @@ grid_id = cmor.grid(axis_ids = myaxes[:2
longitude = lon_coords,
latitude_vertices = lat_vertices,
longitude_vertices = lon_vertices)
@@ -3053,7 +2166,7 @@ Index: cmor-2.8.3/Test/test_python_singleton_anywhere_in_table_def.py
myaxes[2] = grid_id
mapnm = 'lambert_conformal_conic'
-@@ -107,8 +107,8 @@
+@@ -107,8 +107,8 @@ myvars[0] = cmor.variable( table_entry =
ntimes=2
for i in range(ntimes):
data2d = read_2d_input_files(i, varin2d[0], lat,lon)*1.E-6
@@ -3064,10 +2177,10 @@ Index: cmor-2.8.3/Test/test_python_singleton_anywhere_in_table_def.py
- print 'wrote'
+ print('wrote')
cmor.close()
-Index: cmor-2.8.3/Test/test_python_singleton_string.py
+Index: cmor-3.2.0/Test/test_python_singleton_string.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_singleton_string.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_singleton_string.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_singleton_string.py
++++ cmor-3.2.0/Test/test_python_singleton_string.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-
@@ -3075,16 +2188,16 @@ Index: cmor-2.8.3/Test/test_python_singleton_string.py
from test_python_common import * # common subroutines
import cmor._cmor
-@@ -56,7 +56,7 @@
+@@ -39,7 +39,7 @@ ts='months'
tscl=3.5e-4
- tables.append(cmor.load_table("/git/cmip5-cmor-tables/Tables/%s" % t))
+ tables.append(cmor.load_table("Tables/%s" % t))
-print 'Tables ids:',tables
-+print('Tables ids:',tables)
++print ('Tables ids:',tables)
cmor.set_table(tables[0])
-@@ -76,7 +76,7 @@
+@@ -59,7 +59,7 @@ grid_id = cmor.grid(axis_ids = myaxes[:2
longitude = lon_coords,
latitude_vertices = lat_vertices,
longitude_vertices = lon_vertices)
@@ -3093,7 +2206,7 @@ Index: cmor-2.8.3/Test/test_python_singleton_string.py
myaxes[2] = grid_id
mapnm = 'lambert_conformal_conic'
-@@ -107,8 +107,8 @@
+@@ -90,8 +90,8 @@ myvars[0] = cmor.variable( table_entry =
ntimes=2
for i in range(ntimes):
data2d = read_2d_input_files(i, varin2d[0], lat,lon)*1.E-6
@@ -3105,17 +2218,17 @@ Index: cmor-2.8.3/Test/test_python_singleton_string.py
- print 'wrote'
+ print('wrote')
cmor.close()
-Index: cmor-2.8.3/Test/test_python_stephanie_6hrPlev_minutes.py
+Index: cmor-3.2.0/Test/test_python_stephanie_6hrPlev_minutes.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_stephanie_6hrPlev_minutes.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_stephanie_6hrPlev_minutes.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_stephanie_6hrPlev_minutes.py
++++ cmor-3.2.0/Test/test_python_stephanie_6hrPlev_minutes.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from __future__ import print_function
import cmor
import numpy
-@@ -37,7 +38,7 @@
+@@ -37,7 +38,7 @@ def main():
axis_ids = list()
for axis in axes:
@@ -3124,38 +2237,38 @@ Index: cmor-2.8.3/Test/test_python_stephanie_6hrPlev_minutes.py
axis_id = cmor.axis(**axis)
axis_ids.append(axis_id)
-Index: cmor-2.8.3/Test/test_python_user_interface_00.py
+Index: cmor-3.2.0/Test/test_python_user_interface_00.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_user_interface_00.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_user_interface_00.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_user_interface_00.py
++++ cmor-3.2.0/Test/test_python_user_interface_00.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
from test_python_common import * # common subroutines
import cmor._cmor
-@@ -40,18 +41,18 @@
- a = cmor.load_table(os.path.join(ipth,"../Tables/CMIP5_Omon"))
+@@ -22,18 +23,18 @@ tables=[]
+ a = cmor.load_table(os.path.join("CMIP6_Omon.json"))
tables.append(a)
- tables.append(cmor.load_table("Tables/CMIP5_Amon"))
+ tables.append(cmor.load_table("CMIP6_Amon.json"))
-print 'Tables ids:',tables
-+print('Tables ids:',tables)
++print ('Tables ids:',tables)
axes=[]
id="time"
units="months since 1980"
-print 'time bounds:',bnds_time
-+print('time bounds:',bnds_time)
++print ('time bounds:',bnds_time)
# ok we need to make the bounds 2D because the cmor module "undoes this"
bnds_time = numpy.reshape(bnds_time,(bnds_time.shape[0]/2,2))
bnds_lat = numpy.reshape(bnds_lat,(bnds_lat.shape[0]/2,2))
bnds_lon = numpy.reshape(bnds_lon,(bnds_lon.shape[0]/2,2))
myaxes[0] = cmor.axis(id,coord_vals=Time,units=units,cell_bounds=bnds_time,interval="1 month")
-print 'time bounds:',bnds_time
-+print('time bounds:',bnds_time)
++print ('time bounds:',bnds_time)
id='latitude'
units="degrees_north"
interval=""
-@@ -87,30 +88,30 @@
+@@ -69,30 +70,30 @@ myaxes2[1] = myaxes[3];
myaxes2[2] = myaxes[1];
myaxes2[3] = myaxes[2];
@@ -3194,7 +2307,7 @@ Index: cmor-2.8.3/Test/test_python_user_interface_00.py
# /* ok here we decalre a variable for region axis testing */
cmor.set_table(tables[0])
-@@ -125,7 +126,7 @@
+@@ -107,7 +108,7 @@ cmor.set_table(tables[1])
for i in range(ntimes):
data2d = read_2d_input_files(i, varin2d[0], lat,lon)
@@ -3203,25 +2316,25 @@ Index: cmor-2.8.3/Test/test_python_user_interface_00.py
cmor.write(myvars[0],data2d,1)
cmor.close()
-Index: cmor-2.8.3/Test/test_python_user_interface_01.py
+Index: cmor-3.2.0/Test/test_python_user_interface_01.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_user_interface_01.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_user_interface_01.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Test/test_python_user_interface_01.py
++++ cmor-3.2.0/Test/test_python_user_interface_01.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
from test_python_common import * # common subroutines
import cmor._cmor
-@@ -41,7 +42,7 @@
- a = cmor.load_table("Tables/CMIP5_grids")
+@@ -22,7 +23,7 @@ tables=[]
+ a = cmor.load_table("CMIP6_grids.json")
tables.append(a)
- tables.append(cmor.load_table("Tables/CMIP5_Amon"))
+ tables.append(cmor.load_table("CMIP6_Amon.json"))
-print 'Tables ids:',tables
-+print('Tables ids:',tables)
++print ('Tables ids:',tables)
cmor.set_table(tables[0])
-@@ -61,7 +62,7 @@
+@@ -42,7 +43,7 @@ grid_id = cmor.grid(axis_ids = myaxes[:2
longitude = lon_coords,
latitude_vertices = lat_vertices,
longitude_vertices = lon_vertices)
@@ -3230,36 +2343,35 @@ Index: cmor-2.8.3/Test/test_python_user_interface_01.py
myaxes[2] = grid_id
mapnm = 'lambert_conformal_conic'
-@@ -91,7 +92,7 @@
+@@ -72,7 +73,7 @@ myvars[0] = cmor.variable( table_entry =
)
for i in range(ntimes):
data2d = read_2d_input_files(i, varin2d[0], lat,lon)
-- print 'writing time: ',i,data2d.shape,data2d
+- print 'writing time: ',i,Time[i],data2d.shape,data2d
- print Time[i],bnds_time[2*i:2*i+2]
-+ print('writing time: ',i,data2d.shape,data2d)
-+ print(Time[i],bnds_time[2*i:2*i+2] )
++ print ('writing time: ',i,Time[i],data2d.shape,data2d)
++ print (Time[i],bnds_time[2*i:2*i+2])
cmor.write(myvars[0],data2d,1,time_vals=Time[i],time_bnds=bnds_time[2*i:2*i+2])
cmor.close()
-Index: cmor-2.8.3/Test/test_python_user_interface_03.py
+Index: cmor-3.2.0/Test/test_python_user_interface_03.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_user_interface_03.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_user_interface_03.py 2013-06-15 10:56:19.000000000 +0100
-@@ -1,11 +1,12 @@
-+from __future__ import print_function
- import numpy
- import cmor
+--- cmor-3.2.0.orig/Test/test_python_user_interface_03.py
++++ cmor-3.2.0/Test/test_python_user_interface_03.py
+@@ -3,11 +3,11 @@ import cmor
+ from time import localtime, strftime
+ today = strftime("%Y%m%d", localtime())
-print 'Done importing'
-+print('Done importing')
++print ('Done importing')
try:
import cdms2
except:
- print "This test code needs cdms2 interface for i/0"
-+ print("This test code needs cdms2 interface for i/0")
++ print ("This test code needs cdms2 interface for i/0")
import sys
sys.exit()
import os
-@@ -44,7 +45,7 @@
+@@ -40,7 +40,7 @@ def prep_var(data):
id=cmor.axis(table_entry='latitude',units=ax.units,coord_vals=ax[:],cell_bounds=ax.getBounds())
else:
id=cmor.axis(table_entry=str(ax.id),units=ax.units,coord_vals=ax[:],cell_bounds=ax.getBounds())
@@ -3268,7 +2380,7 @@ Index: cmor-2.8.3/Test/test_python_user_interface_03.py
axes.append(id)
var = cmor.variable(table_entry = data.id,
units = data.units,
-@@ -84,13 +85,13 @@
+@@ -63,13 +63,13 @@ def prep_cmor():
for var in ['tas',]:
@@ -3285,7 +2397,7 @@ Index: cmor-2.8.3/Test/test_python_user_interface_03.py
var_id = prep_var(data)
df = data.filled(data.missing_value)
cmor.write(var_id,df)
-@@ -100,8 +101,8 @@
+@@ -81,8 +81,8 @@ for var in ['tas',]:
if not numpy.allclose(s,data_ordered):
raise "Error reordering: %s"%o
else:
@@ -3297,21 +2409,21 @@ Index: cmor-2.8.3/Test/test_python_user_interface_03.py
#cmor.close()
-print 'Finito'
+print('Finito')
-Index: cmor-2.8.3/Lib/cmor_const.py
+Index: cmor-3.2.0/Lib/cmor_const.py
===================================================================
---- cmor-2.8.3.orig/Lib/cmor_const.py 2013-06-15 10:54:40.000000000 +0100
-+++ cmor-2.8.3/Lib/cmor_const.py 2013-06-15 10:54:40.000000000 +0100
+--- cmor-3.2.0.orig/Lib/cmor_const.py
++++ cmor-3.2.0/Lib/cmor_const.py
@@ -1,4 +1,4 @@
-import _cmor
+from . import _cmor
atts = """
CMOR_MAX_STRING
CMOR_MAX_ELEMENTS
-Index: cmor-2.8.3/Test/test_python_common.py
+Index: cmor-3.2.0/Test/test_python_common.py
===================================================================
---- cmor-2.8.3.orig/Test/test_python_common.py 2013-06-15 09:11:22.000000000 +0100
-+++ cmor-2.8.3/Test/test_python_common.py 2013-06-15 11:01:29.000000000 +0100
-@@ -105,7 +105,7 @@
+--- cmor-3.2.0.orig/Test/test_python_common.py
++++ cmor-3.2.0/Test/test_python_common.py
+@@ -105,7 +105,7 @@ def read_3d_input_files(it, varname, n0,
for k in range(n2):
for j in range(n1):
for i in range(n0):
@@ -3320,3 +2432,225 @@ Index: cmor-2.8.3/Test/test_python_common.py
return field
+Index: cmor-3.2.0/Lib/__init__.py
+===================================================================
+--- cmor-3.2.0.orig/Lib/__init__.py
++++ cmor-3.2.0/Lib/__init__.py
+@@ -1,12 +1,12 @@
+-import os
++mport os
+ import sys
+ xml_pth = os.path.join(sys.prefix,"share","udunits","udunits2.xml")
+ if os.path.exists(xml_pth):
+ os.environ["UDUNITS2_XML_PATH"] = xml_pth
+
+-from cmor_const import *
++from .cmor_const import *
+
+-from pywrapper import (
++from .pywrapper import (
+ CMORError, axis, variable, write, setup, load_table, set_table, zfactor,
+ close, grid, set_grid_mapping, time_varying_grid_coordinate, dataset_json,
+ set_cur_dataset_attribute, get_cur_dataset_attribute,
+@@ -14,6 +14,6 @@ from pywrapper import (
+ has_variable_attribute, get_final_filename, set_deflate)
+
+ try:
+- from check_CMOR_compliant import checkCMOR
++ from .check_CMOR_compliant import checkCMOR
+ except ImportError:
+ pass
+Index: cmor-3.2.0/Src/_cmormodule.c
+===================================================================
+--- cmor-3.2.0.orig/Src/_cmormodule.c
++++ cmor-3.2.0/Src/_cmormodule.c
+@@ -2,6 +2,23 @@
+ #include "numpy/arrayobject.h"
+ #include "cmor.h"
+
++#if PY_MAJOR_VERSION >= 3
++#define PyInt_AsLong PyLong_AsLong
++#define PyInt_FromLong PyLong_FromLong
++#define PyString_AsString PyUnicode_AsUTF8String
++#endif
++
++struct module_state {
++ PyObject *error;
++};
++
++#if PY_MAJOR_VERSION >= 3
++#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
++#else
++#define GETSTATE(m) (&_state)
++static struct module_state _state;
++#endif
++
+ static PyObject *CMORError;
+ volatile sig_atomic_t raise_exception = 0;
+ char *exception_message = "Problem with 'cmor.%s'. Please check the logfile "
+@@ -394,7 +411,11 @@ static PyObject *PyCMOR_axis( PyObject *
+ char *units;
+ char *interval;
+ int length;
+- char type;
++#if PY_MAJOR_VERSION >= 3
++ int type;
++#else
++ char type;
++#endif
+ void *coord_vals;
+ void *cell_bounds;
+ int cell_bounds_ndim;
+@@ -406,10 +427,12 @@ static PyObject *PyCMOR_axis( PyObject *
+ /* HUGE assumtion here is that the data is contiguous! */
+ /************************************************************************/
+
+- if( !PyArg_ParseTuple
+- ( args, "ssiOcOis", &name, &units, &length, &coords_obj, &type,
+- &bounds_obj, &cell_bounds_ndim, &interval ) )
+- return NULL;
++#if PY_MAJOR_VERSION >=3
++ if (!PyArg_ParseTuple(args,"ssiOCOis",&name,&units,&length,&coords_obj,&type,&bounds_obj,&cell_bounds_ndim,&interval))
++#else
++ if (!PyArg_ParseTuple(args,"ssiOcOis",&name,&units,&length,&coords_obj,&type,&bounds_obj,&cell_bounds_ndim,&interval))
++#endif
++ return NULL;
+
+ if( coords_obj == Py_None ) {
+ coord_vals = NULL;
+@@ -1030,10 +1053,59 @@ static PyMethodDef MyExtractMethods[] =
+ {NULL, NULL} /*sentinel */
+ };
+
+-PyMODINIT_FUNC init_cmor( void ) {
+- PyObject *cmor_module;
+- cmor_module = Py_InitModule("_cmor", MyExtractMethods);
++#if PY_MAJOR_VERSION >= 3
++
++ static int MyExtract_traverse(PyObject *m, visitproc visit, void *arg) {
++ Py_VISIT(GETSTATE(m)->error);
++ return 0;
++ }
++
++ static int MyExtract_clear(PyObject *m) {
++ Py_CLEAR(GETSTATE(m)->error);
++ return 0;
++ }
++
++ static struct PyModuleDef moduledef = {
++ PyModuleDef_HEAD_INIT,
++ "_cmor",
++ NULL,
++ sizeof(struct module_state),
++ MyExtractMethods,
++ NULL,
++ MyExtract_traverse,
++ MyExtract_clear,
++ NULL
++};
++
++
++#define INITERROR return NULL
++
++PyObject * PyInit__cmor(void)
++
++#else
++define INITERROR return
++
++void init_cmor(void)
++#endif
++{
++#if PY_MAJOR_VERSION >= 3
++ PyObject *module = PyModule_Create(&moduledef);
++#else
++ PyObject *module = Py_InitModule("_cmor", MyExtractMethods);
++#endif
+ import_array( );
+- CMORError = PyErr_NewException("_cmor.CMORError", NULL, NULL);
+- PyModule_AddObject(cmor_module, "CMORError", CMORError);
++
++ if (module == NULL)
++ INITERROR;
++ struct module_state *st = GETSTATE(module);
++
++ st->error = PyErr_NewException("_cmor.Error", NULL, NULL);
++ if (st->error == NULL) {
++ Py_DECREF(module);
++ INITERROR;
++ }
++
++#if PY_MAJOR_VERSION >= 3
++ return module;
++#endif
+ }
+Index: cmor-3.2.0/Test/cmor_speed_and_compression_01.py
+===================================================================
+--- cmor-3.2.0.orig/Test/cmor_speed_and_compression_01.py
++++ cmor-3.2.0/Test/cmor_speed_and_compression_01.py
+@@ -8,7 +8,7 @@ try:
+ cdms2.setNetcdfDeflateFlag(0)
+ cdms2.setNetcdfDeflateLevelFlag(0)
+ except:
+- print "This test code needs a recent cdms2 interface for i/0"
++ print ("This test code needs a recent cdms2 interface for i/0")
+ sys.exit()
+
+ if len(sys.argv) > 1:
+@@ -41,7 +41,7 @@ cmor.dataset_json("Test/common_user_inpu
+
+ tables = []
+ tables.append(cmor.load_table("mytable"))
+-print 'Tables ids:', tables
++print ('Tables ids:', tables)
+
+
+ ## read in data, just one slice
+@@ -87,10 +87,10 @@ mincdms=1000
+ c0=st
+ f=cdms2.open("Test/crap.nc","w")
+ #print 'Time:',i
+-print s.filled().shape
++print (s.filled().shape)
+ cmor.write(myvars[0],s.filled(),ntimes_passed=ntimes)
+ c=time.time()
+-print 'cmor write time:',c-c0
++print ('cmor write time:',c-c0)
+ totcmor+=c-c0
+ if maxcmor<c-c0:
+ maxcmor=c-c0
+@@ -99,7 +99,7 @@ if mincmor>c-c0:
+ c0=c
+ f.write(s,id=varout)
+ c=time.time()
+-print 'cdms time:',c-c0
++print ('cdms time:',c-c0)
+ totcdms+=c-c0
+ if maxcdms<c-c0:
+ maxcdms=c-c0
+@@ -113,12 +113,12 @@ import cdtime,os
+ ltime = cdtime.reltime(ntimes-1,'month since 1980').tocomp()
+ #lcmor = os.stat("CMIP6/CMIP/CSIRO-BOM/NICAM/piControl/r1i1p1f1/Amon/tas/gn/v%s/tas_Amon_piControl_NICAM_r1i1p1f1_gn_197901-197912.nc"%(today))[6]
+ lcmor = os.stat("CMIP6/ISMIP6/PCMDI/PCMDI-test-1-0/piControl-withism/r11i1p1f1/Amon/tas/gr/v%s/tas_Amon_piControl-withism_PCMDI-test-1-0_r11i1p1f1_gr_197901-197912.nc"%(today))[6]
+-print 'level:',level,"shuffle:",shuffle
+-print 'total cmor:',totcmor,mincmor,totcmor/ntimes,maxcmor,lcmor
++print ('level:',level,"shuffle:",shuffle)
++print ('total cmor:',totcmor,mincmor,totcmor/ntimes,maxcmor,lcmor)
+ lcdms = os.stat("Test/crap.nc")[6]
+-print 'total cdms:', totcdms, mincdms, totcdms / ntimes, maxcdms, lcdms
+-print 'Size diff:', float(lcmor) / float(lcdms)
+-print 'speed diff:', totcmor / totcdms
++print ('total cdms:', totcdms, mincdms, totcdms / ntimes, maxcdms, lcdms)
++print ('Size diff:', float(lcmor) / float(lcdms))
++print ('speed diff:', totcmor / totcdms)
+
+ if os.path.exists("summary.txt"):
+ f = open("summary.txt")
+@@ -133,7 +133,7 @@ dic[(level, shuffle)] = (float(lcmor) /
+ for i in range(10):
+ a = dic.get((i, 0), "N/A")
+ b = dic.get((i, 1), "N/A")
+- print 'Level: ', i, "no suffle:", a, "shuffle", b
++ print ('Level: ', i, "no suffle:", a, "shuffle", b)
+ f = open("summary.txt", "w")
+ f.write(repr(dic))
+ f.close()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/cmor.git
More information about the debian-science-commits
mailing list