From 0c3db48472601d6d5ae170fd57b312812166638c Mon Sep 17 00:00:00 2001 From: Jon Wright Date: Fri, 29 Sep 2017 13:10:39 +0200 Subject: [PATCH] 2to3 --- .gitignore | 2 +- sandbox/diffracCl/diffracCl.py | 38 +++++++++++------------ sandbox/ev78/integrate_them.py | 56 +++++++++++++++++----------------- sandbox/ev78/makevols.py | 10 +++--- sandbox/ev78/rad.py | 8 ++--- sandbox/ev78/watch_direcs.py | 14 ++++----- sandbox/fittrans.py | 18 ++++++----- sandbox/map/gridgrain.py | 12 +++++--- sandbox/map/gridmap.py | 10 +++--- sandbox/map/grids.py | 4 ++- sandbox/map/mp.py | 8 +++-- sandbox/map/plot_gmap.py | 4 ++- sandbox/map/uniqify_ubi.py | 24 ++++++++------- sandbox/teo.py | 35 +++++++++++---------- 14 files changed, 130 insertions(+), 113 deletions(-) diff --git a/.gitignore b/.gitignore index 69a3559a..d12d3c9b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,7 @@ __pycache__/ # 2to3 remains -*.bak +*.bak* # C extensions *.so diff --git a/sandbox/diffracCl/diffracCl.py b/sandbox/diffracCl/diffracCl.py index 345b73fc..94526f01 100644 --- a/sandbox/diffracCl/diffracCl.py +++ b/sandbox/diffracCl/diffracCl.py @@ -8,22 +8,22 @@ if "win" in sys.platform: timer = time.clock dll = ctypes.CDLL("diffracCl.dll") - print "# time.clock", sys.platform, sys.version + print("# time.clock", sys.platform, sys.version) else: timer = time.time dll = ctypes.CDLL("./diffracCl.so") - print "# time.time", sys.platform, sys.version + print("# time.time", sys.platform, sys.version) import pyopencl.version -print "# pyopencl:",pyopencl.version.VERSION +print("# pyopencl:",pyopencl.version.VERSION) class myCL: def __init__(self, npx): self.ctx = cl.create_some_context() for d in self.ctx.devices: - print "#",d.platform.name - print "#",d.vendor - print "#",d.name + print("#",d.platform.name) + print("#",d.vendor) + print("#",d.name) self.npx = npx self.queue = cl.CommandQueue(self.ctx) self.pars = numpy.zeros(14, dtype=numpy.float32) @@ -155,7 +155,7 @@ def make_pars( parfile ): example.popCorn() pars = make_pars(sys.argv[1]) example.setpars( pars ) - print "# Init", timer()-start + print("# Init", timer()-start) times = [] # Warmup tth, eta = example.execute() @@ -164,12 +164,12 @@ def make_pars( parfile ): tth, eta = example.execute() times.append(timer()-start) times = numpy.array(times) - print "# mean min max std" - print "%.4f %.4f %.4f %.4f"%( times.mean(), times.min(), - times.max(), times.std()) + print("# mean min max std") + print("%.4f %.4f %.4f %.4f"%( times.mean(), times.min(), + times.max(), times.std())) t = numpy.median(times) - print "%.1f ms, %.1f fps,"%(1e3*t,1.0/t), - print tth.max(),tth.min() + print("%.1f ms, %.1f fps,"%(1e3*t,1.0/t), end=' ') + print(tth.max(),tth.min()) eta_cl = eta.copy() eta_ct = eta.copy() tth_cl = tth.copy() @@ -177,18 +177,18 @@ def make_pars( parfile ): o = ctp( npx ) times = numpy.array( o.compute( tth_ct, eta_ct, pars ) ) - print "# ctypes module, hopefully with openmp" - print "# mean min max std" - print "%.4f %.4f %.4f %.4f"%( times.mean(), times.min(), - times.max(), times.std()) + print("# ctypes module, hopefully with openmp") + print("# mean min max std") + print("%.4f %.4f %.4f %.4f"%( times.mean(), times.min(), + times.max(), times.std())) t = numpy.median(times) - print "%.1f ms, %.1f fps,"%(1e3*t,1.0/t), - print tth.max(),tth.min() + print("%.1f ms, %.1f fps,"%(1e3*t,1.0/t), end=' ') + print(tth.max(),tth.min()) # Check same ness eta_err = (abs(eta_cl - eta_ct)).mean() tth_err = (abs(tth_cl - tth_ct)).mean() - print "Mean diff tth,eta",tth_err,eta_err + print("Mean diff tth,eta",tth_err,eta_err) if len(sys.argv)>2: from matplotlib.pylab import imshow, figure, show, colorbar, title figure(1) diff --git a/sandbox/ev78/integrate_them.py b/sandbox/ev78/integrate_them.py index e06d00e4..e965fbad 100755 --- a/sandbox/ev78/integrate_them.py +++ b/sandbox/ev78/integrate_them.py @@ -5,7 +5,7 @@ import os, time, fabio, numpy import pyFAI -print pyFAI.__file__ +print(pyFAI.__file__) SOLID_ANGLE = True #print "PATH:", sys.path @@ -19,12 +19,12 @@ class darkflood(object): """ def __init__(self, darkfile=None, floodfile=None): if darkfile is None: - print "Warning: no dark supplied" + print("Warning: no dark supplied") self.darkobj = None else: self.darkobj = fabio.open(darkfile) if floodfile is None: - print "Warning: no flood supplied" + print("Warning: no flood supplied") self.floodmult = None else: self.floodobj = fabio.open(floodfile) @@ -57,7 +57,7 @@ def edffilenameseries(stem, first=None, last=None, glob=False, extn=".edf"): yield fname num += 1 if first is not None and last is None: - print "Starting with image",first,"then incrementing" + print("Starting with image",first,"then incrementing") num = first while 1: fname = "%s%04d%s"%( stem, num, extn ) @@ -73,9 +73,9 @@ def calcfrom1d( integrator, tth, I, shape): Computes a 2D image from a 1D integrated profile """ ttha = integrator.twoThetaArray(shape) - print ttha.ravel().shape - print tth.shape - print I.shape + print(ttha.ravel().shape) + print(tth.shape) + print(I.shape) calcimage = numpy.interp( ttha.ravel(), tth*numpy.pi/180, I ) @@ -97,7 +97,7 @@ def determineparfile( fname ): return "pyfai" if bytes.find("X-BEAM CENTRE") != -1: return "fit2d" - print bytes + print(bytes) raise Exception("Parameters not recognised in file: %s"%(fname)) class fit2dcakepars: @@ -153,7 +153,7 @@ def __init__(self, fname ): key, value = line.split(" = ") value = value.rstrip() # get rid of trailing \n except: - print "$$$%s$$$"% (line) + print("$$$%s$$$"% (line)) raise if value == "None": value = None @@ -163,7 +163,7 @@ def setparameter( self, key, value ): if key in self.option_names: self.options[key] = value else: - print "Failure to set {%s}=%s"%( key, value) + print("Failure to set {%s}=%s"%( key, value)) def __getitem__(self, key): return self.options[key] def __setitem__(self, key, value): @@ -179,7 +179,7 @@ def display(tth, I, img): imshow(img,vmin=-.21,vmax=.21) colorbar() show() - raw_input("continue?") + input("continue?") def integrate_them( o ): """ @@ -200,9 +200,9 @@ def integrate_them( o ): if ptype == "pyfai": integrator.load( o.parfile ) if o.dark is not None: - print "Using dark from command line",o.dark + print("Using dark from command line",o.dark) if o.flood is not None: - print "Using dark from command line",o.flood + print("Using dark from command line",o.flood) elif ptype == "fit2d": f2d = fit2dcakepars( o.parfile ) if f2d["SPATIAL DIS."][0] not in ["Y","y"]: @@ -220,20 +220,20 @@ def integrate_them( o ): ) integrator.rot3=0 integrator.reset() - print integrator.param, integrator.detector.pixel1 + print(integrator.param, integrator.detector.pixel1) # First choice is command line. Then from pars if supplied if o.dark is None: if f2d["DARK CURRENT"][0] in ["Y","y"]: o.dark = f2d["DC FILE"] - print "Using dark from fit2d parameter file",o.dark + print("Using dark from fit2d parameter file",o.dark) else: - print "Using dark from command line",o.dark + print("Using dark from command line",o.dark) if o.flood is None: if f2d["FLAT-FIELD"][0] in ["Y","y"]: o.flood = f2d["FF FILE"] - print "Using flood from fit2d parameter file",o.flood + print("Using flood from fit2d parameter file",o.flood) else: - print "Using flood from command line",o.flood + print("Using flood from command line",o.flood) # Should be in fabio utilities df = darkflood( o.dark, o.flood ) # Should be in fabio @@ -242,19 +242,19 @@ def integrate_them( o ): # Command line is first priority for make if o.mask is not None: mask = fabio.open( o.mask ).data - print "Using mask", o.mask + print("Using mask", o.mask) # assume poni file deals with this independently? elif ptype == "fit2d": # try in fit2d parfile if f2d["USE MASK"][0] in ['y','Y']: mask = fabio.open( f2d["MASK FILE"] ).data - print "Using mask",f2d["MASK FILE"] + print("Using mask",f2d["MASK FILE"]) else: mask = None if mask is not None: - print "mask mean:",mask.mean() + print("mask mean:",mask.mean()) integrator.write(os.path.splitext(o.parfile)[0]+".poni") for f in fs: - print "Processing",f, + print("Processing",f, end=' ') try: fo = df.correct( fabio.open(f) ) except: @@ -288,7 +288,7 @@ def integrate_them( o ): #delta_dummy=delta_dummy # precision of dummy ) - print "wrote",outFile + print("wrote",outFile) if o.backcalc: calcimage = calcfrom1d( integrator, tth, I, fo.data.shape ) * integrator._polarization err = (calcimage - fo.data) * (1-mask)/(calcimage+mask) @@ -325,10 +325,10 @@ def fitcen( data, cim , mask=None ): try: imat = numpy.linalg.inv( [ [ mxx, mxy], [mxy, myy] ] ) shft = numpy.dot( imat, [rx, ry] ) - print "Image offset estimate (pixels)", shft - print "Intensity mean, min, max errors", (diff*diff).mean(), diff.min(), diff.max() + print("Image offset estimate (pixels)", shft) + print("Intensity mean, min, max errors", (diff*diff).mean(), diff.min(), diff.max()) except: - print "Cannot estimate beam centre error" + print("Cannot estimate beam centre error") def get_options(parser): @@ -402,13 +402,13 @@ def polstuff(): except: if o is not None: o.print_help() - print "\nHere is the problem:\n" + print("\nHere is the problem:\n") raise integrate_them( options ) # calcimage = calcfrom1d( integrator, tth, I, data.shape, mask) - print pyFAI.__file__ + print(pyFAI.__file__) diff --git a/sandbox/ev78/makevols.py b/sandbox/ev78/makevols.py index 481701e8..b4903926 100644 --- a/sandbox/ev78/makevols.py +++ b/sandbox/ev78/makevols.py @@ -14,7 +14,7 @@ def readtxt(fname): ctrs = "diffty pico3 notsrcu".split() h["pico3"]=1 h["notsrcu"]=1 - for line in open(fname).xreadlines(): + for line in open(fname): if line[0] == "#": if cnext is not None: h[cnext] = float(line.split()[cindex]) @@ -45,8 +45,8 @@ def decidegrid(vals): if y!=y0: break blocksize = i if len(vals) % blocksize != 0: - print "Blocksize seems to be",blocksize, - print "you have",len(vals),"images. Problem." + print("Blocksize seems to be",blocksize, end=' ') + print("you have",len(vals),"images. Problem.") vals.shape = vals.shape[0]/blocksize,blocksize,vals.shape[1] # Find the best angular grid mapping onto this a0=vals[0,:,1] @@ -103,13 +103,13 @@ def writehdf(fname, blob, tth, vp): HOME = "/data/visitor/ev78/id11" os.chdir(HOME) stem = sys.argv[1] - print stem + print(stem) txtfile = "%s/%s.txt"%(stem,stem) # file with motor positions and image filenames vals = readtxt(txtfile) # figure array dimensions vals, offset = decidegrid(vals) - print vals.shape + print(vals.shape) # Read 1D integrated data (pyFAI was already run on it) xaxis, blob = readdat( "%s/%s"%(stem,stem), vals) diff --git a/sandbox/ev78/rad.py b/sandbox/ev78/rad.py index 1f0f961d..bd60950d 100644 --- a/sandbox/ev78/rad.py +++ b/sandbox/ev78/rad.py @@ -28,7 +28,7 @@ def make_indices(self): arshape = self.dims[0]/2+1, self.dims[1] nv = (arshape[0]-1)*2 nh = arshape[0] - print "NV,NH",nv,nh + print("NV,NH",nv,nh) self.ftimshape = (nv, nh) self.ftimlen = nv*nh n1 = (self.dims[0]/2+1)*self.dims[1] @@ -110,7 +110,7 @@ def find_offset(a1, a2): pylab.plot(a1) pylab.plot(a2[::-1]) pylab.show() - print numpy.argmax(c)/2.0 + print(numpy.argmax(c)/2.0) 1/0 return numpy.argmax(c)/2.0 @@ -136,7 +136,7 @@ def difftomo(N=256): ipk = s[s.shape[0]/2,s.shape[1]/2].argmax() offset = find_offset( s[:,0,ipk], s[:,-1,ipk] ) ioff = int(numpy.round(offset)) - print "Offset (centre pixel) seems to be",offset,ioff + print("Offset (centre pixel) seems to be",offset,ioff) recon = numpy.zeros((N,N,s.shape[2]),numpy.float32) i0 = numpy.zeros(s.shape[2],numpy.float32) for i in range(s.shape[2]): @@ -157,7 +157,7 @@ def difftomo(N=256): pylab.subplot(122) pylab.imshow(s[:,:,i] - i0[i]) pylab.colorbar() - raw_input("next?") + input("next?") grp = h["DiffTomo/NXdata"] savearray( i0, "recon_bg", grp ) savearray( recon, "recon", grp) diff --git a/sandbox/ev78/watch_direcs.py b/sandbox/ev78/watch_direcs.py index e551eb79..3aa82482 100644 --- a/sandbox/ev78/watch_direcs.py +++ b/sandbox/ev78/watch_direcs.py @@ -20,13 +20,13 @@ def process(stem): - print "Checking",stem, + print("Checking",stem, end=' ') sys.stdout.flush() os.chdir(os.path.join(HOME, stem)) fl = glob.glob("*") - edfs = filter(lambda s:s.endswith("edf"), fl) - dats = filter(lambda s:s.endswith("dat"), fl) - print len(edfs) + edfs = [s for s in fl if s.endswith("edf")] + dats = [s for s in fl if s.endswith("dat")] + print(len(edfs)) if len(edfs)!=len(dats): os.system("../process2x2.sh %s"%(stem)) @@ -40,12 +40,12 @@ def process(stem): try: num = int(num) except: - print "dirname does not start with a number",dirname + print("dirname does not start with a number",dirname) continue stem = dirname.replace("_edna","") process(stem) - lastone = checked.keys() + lastone = list(checked.keys()) lastone.sort() - print "sleeping" + print("sleeping") time.sleep(10) diff --git a/sandbox/fittrans.py b/sandbox/fittrans.py index be1db968..3787b4e2 100644 --- a/sandbox/fittrans.py +++ b/sandbox/fittrans.py @@ -1,4 +1,6 @@ +from __future__ import print_function + from ImageD11.columnfile import columnfile from ImageD11 import transform, parameters, unitcell, grain, gv_general @@ -82,7 +84,7 @@ def test_XL_to_gv(): T = np.array( [0,0,0] ) gnew = XL_to_gv( omega, wedge, chi, XL, wavelength, T[0],T[1],T[2]) gold = XL_to_gv_old( omega, wedge, chi, XL, wavelength, T[0],T[1],T[2]) - print gnew-gold + print(gnew-gold) #test_XL_to_gv() @@ -149,7 +151,7 @@ def __init__(self, fname, parfile): self.ds_tol = 0.005 self.bins=np.arange(0,0.5,0.005) - print "Setting up" + print("Setting up") self.compute_XLYLZL() self.computegv() @@ -293,7 +295,7 @@ def ringassign(self, ds=None): vol = np.sqrt(np.linalg.det(self.cell.g)) rscp = pow(vol, 1.0/3.0) pylab.hist( diffs*rscp, bins = np.arange(0,0.5,0.005) ) - print (diffs*rscp < 0.05).sum() + print((diffs*rscp < 0.05).sum()) return ra, diffs def find_triplets(self, peak): @@ -316,7 +318,7 @@ def find_triplets(self, peak): ng = 0 # Take old peak assignments: if 1: - print "Using existing peak assignments" + print("Using existing peak assignments") inds = np.arange(o.colfile.nrows,dtype=np.int) for i,gref in enumerate(gl): gref.pks = np.compress( o.colfile.labels == i, inds ) @@ -334,10 +336,10 @@ def find_triplets(self, peak): # gref = o.refine( gref, tol=0.0075) gfl.append( gref ) ng += 1 - print ng,ng*100.0/len(gl), "%.2f "%(time.time()-start), gref.npks, - print (3*"%.4f ")%tuple(gref.translation), - print (6*"%.6f ")%ubitocellpars(gref.ubi) - print time.time()-start + print(ng,ng*100.0/len(gl), "%.2f "%(time.time()-start), gref.npks, end=' ') + print((3*"%.4f ")%tuple(gref.translation), end=' ') + print((6*"%.6f ")%ubitocellpars(gref.ubi)) + print(time.time()-start) grain.write_grain_file(sys.argv[4], gfl) # 1/0 # for i in range(2): diff --git a/sandbox/map/gridgrain.py b/sandbox/map/gridgrain.py index bb9a6909..0d82745e 100644 --- a/sandbox/map/gridgrain.py +++ b/sandbox/map/gridgrain.py @@ -1,4 +1,6 @@ +from __future__ import print_function + # from ImageD11 import transform, transformer, indexing, parameters @@ -39,19 +41,19 @@ def gridgrains( ul, flt, pars, peaks_xyz, omega, **pars) - if pars.has_key('omegasign'): + if 'omegasign' in pars: om_sgn = float(pars["omegasign"]) else: om_sgn = 1.0 gv = transform.compute_g_vectors( tth, eta, omega*om_sgn, **pars) - print tx, ty, + print(tx, ty, end=' ') for ubi in ul: ns = score( ubi, gv.T, tol ) - print ns, + print(ns, end=' ') n += ns - print + print() return n @@ -76,7 +78,7 @@ def gridgrains( ul, flt, pars, pars["y_center"] = yc for zc in [zcen-1, zcen, zcen +1 ]: pars["z_center"] = zc - print "\n\n# %f %f %f"%(dist, yc, zc) + print("\n\n# %f %f %f"%(dist, yc, zc)) npk = gridgrains( ul, flt, pars ) f.write("%f %f %f %d\n"%( dist, yc, zc, npk)) f.flush() diff --git a/sandbox/map/gridmap.py b/sandbox/map/gridmap.py index a9e59cc7..4b6f0ff9 100644 --- a/sandbox/map/gridmap.py +++ b/sandbox/map/gridmap.py @@ -1,4 +1,6 @@ +from __future__ import print_function + # from ImageD11 import transform, transformer, indexing, parameters @@ -40,19 +42,19 @@ def gridgrains( ul, flt, pars, peaks_xyz, omega, **pars) - if pars.has_key('omegasign'): + if 'omegasign' in pars: om_sgn = float(pars["omegasign"]) else: om_sgn = 1.0 gv = transform.compute_g_vectors( tth, eta, omega*om_sgn, **pars) - print tx, ty, + print(tx, ty, end=' ') for ubi in ul: ns = score( ubi, gv.T, tol ) - print ns, + print(ns, end=' ') n += ns - print + print() return n diff --git a/sandbox/map/grids.py b/sandbox/map/grids.py index 88e88918..6c9c1daa 100644 --- a/sandbox/map/grids.py +++ b/sandbox/map/grids.py @@ -1,3 +1,5 @@ + +from __future__ import print_function # Create objects to manipulate - they hold your data # import numpy as np @@ -59,7 +61,7 @@ def grids( flt, tol, npk ): myindexer.gvflat = np.reshape(np.fromstring( myindexer.gv.tostring(),np.float), myindexer.gv.shape) # ds for rings - print gv.shape + print(gv.shape) myindexer.ds = np.sqrt( gv[:,0]*gv[:,0] + gv[:,1]*gv[:,1] + gv[:,2]*gv[:,2] ) diff --git a/sandbox/map/mp.py b/sandbox/map/mp.py index 7accae2a..a7c6e50f 100644 --- a/sandbox/map/mp.py +++ b/sandbox/map/mp.py @@ -1,4 +1,6 @@ +from __future__ import print_function + from ImageD11 import sym_u from ImageD11.grain import read_grain_file @@ -16,10 +18,10 @@ for g in gl: ubi = sym_u.find_uniq_u( g.ubi, c ) g.set_ubi( ubi ) - print x, y , + print(x, y, end=' ') for i in range(3): for j in range(3): - print g.u[i][j], - print + print(g.u[i][j], end=' ') + print() diff --git a/sandbox/map/plot_gmap.py b/sandbox/map/plot_gmap.py index c0623667..d6b72ca5 100644 --- a/sandbox/map/plot_gmap.py +++ b/sandbox/map/plot_gmap.py @@ -1,4 +1,6 @@ +from __future__ import print_function + import sys from matplotlib.pylab import * @@ -10,4 +12,4 @@ x, y = float(vals[0]), float(vals[1]) npks = [ int(v) for v in vals[2:] ] best = argmax(npks) - print x,y,best+1,npks[best] + print(x,y,best+1,npks[best]) diff --git a/sandbox/map/uniqify_ubi.py b/sandbox/map/uniqify_ubi.py index 0cd56fd9..b3b52ccd 100644 --- a/sandbox/map/uniqify_ubi.py +++ b/sandbox/map/uniqify_ubi.py @@ -1,3 +1,5 @@ + +from __future__ import print_function import glob, sys, os import numpy as np @@ -59,12 +61,12 @@ hkl = np.array(pks,np.float).T uniq_ubis = [] -names = ubi_all.keys() +names = list(ubi_all.keys()) tol = 0.25 for name in names: this_list = ubi_all[name] - for ubi, i in zip(this_list,range(len(this_list))): + for ubi, i in zip(this_list,list(range(len(this_list)))): gv = np.dot(np.linalg.inv(ubi), hkl) seen = 0 for j in range(len(uniq_ubis)): @@ -82,9 +84,9 @@ if seen == 0: uniq_ubis.append([ubi,[(name,i)], [ubi] ]) if seen > 1: - print "uniq seen more than once",ubi,i,name + print("uniq seen more than once",ubi,i,name) -print "# Found",len(uniq_ubis),"unique ubi matrices" +print("# Found",len(uniq_ubis),"unique ubi matrices") dsu = [ (len(uo[1]),(uo[1],uo[0])) for uo in uniq_ubis] dsu.sort() @@ -99,19 +101,19 @@ usum = usum + ubi_all[name][i] j += 1 u = usum/j - print "%f %f %f\n" %(u[0,0],u[0,1],u[0,2]), - print "%f %f %f\n" %(u[1,0],u[1,1],u[1,2]), - print "%f %f %f\n\n"%(u[2,0],u[2,1],u[2,2]), + print("%f %f %f\n" %(u[0,0],u[0,1],u[0,2]), end=' ') + print("%f %f %f\n" %(u[1,0],u[1,1],u[1,2]), end=' ') + print("%f %f %f\n\n"%(u[2,0],u[2,1],u[2,2]), end=' ') j = 0 for l, uo in dsu[::-1]: - print "# ", uo[1][0] - print "# ", uo[1][1] - print "# ", uo[1][2] + print("# ", uo[1][0]) + print("# ", uo[1][1]) + print("# ", uo[1][2]) j += 1 for name, i in uo[0]: n = os.path.split(name)[1] x = int(n.split("_")[0][1:]) y = int(n.split("_")[1].split(".")[0][1:]) - print "%d %d %d"%(x,y,j) + print("%d %d %d"%(x,y,j)) diff --git a/sandbox/teo.py b/sandbox/teo.py index 3b27f0d3..bdb3ebea 100644 --- a/sandbox/teo.py +++ b/sandbox/teo.py @@ -1,4 +1,7 @@ +from __future__ import print_function + +from six.moves import input # Try fitting using theta/eta/omega instead of x/y/omega or gx/gy/gz @@ -54,12 +57,12 @@ def Dcalc( UB, hkls, wedge, chi, wavelength, etao, omega): g = np.dot( UB , hkls ) assert g.dtype == np.float if 0: - print g.shape - print hkls.shape + print(g.shape) + print(hkls.shape) for i in range(10): - print g[:,i], - print hkls[:,i], - print np.dot(np.linalg.inv( UB ), g[:,i] ) + print(g[:,i], end=' ') + print(hkls[:,i], end=' ') + print(np.dot(np.linalg.inv( UB ), g[:,i] )) # wedge/chi matrix for axis orientation wc = gv_general.wedgechi( wedge=wedge, chi=chi ) @@ -99,8 +102,8 @@ def Dcalc( UB, hkls, wedge, chi, wavelength, etao, omega): for i in range(len(err)): if err[i] < 1: continue - print i, eta_one[i], eta_two[i], omega1[i], omega2[i] - print "\t", etao[i], omega[i], etac[i], omegac[i] + print(i, eta_one[i], eta_two[i], omega1[i], omega2[i]) + print("\t", etao[i], omega[i], etac[i], omegac[i]) # Two theta angles mod_g = np.sqrt((g*g).sum(axis=0)) @@ -204,7 +207,7 @@ def solve( self ): try: U, s, V = np.linalg.svd( A, full_matrices = False, compute_uv = True ) except np.linalg.LinAlgError: - print "SVD failure!!!" + print("SVD failure!!!") raise # Clip out small singular values: invS = np.where( s > s.max()*1e-9, 1/s, 0 ) @@ -219,9 +222,9 @@ def solve( self ): if TESTING > 0: lsqmat = np.dot( A, A.T ) errmat = np.linalg.inv( lsqmat ) - print solution - print errmat - print svderrmat + print(solution) + print(errmat) + print(svderrmat) assert np.allclose( self.errmat, errmat ) self.esds = np.sqrt( np.diag( self.errmat ) ) self.condition = s.max() / s.min() # sqrt ? @@ -260,7 +263,7 @@ def fitone( UB, t, sc, fc, omega, hkls, pars): pl.subplot(313) pl.plot(etac, erreta, "+") pl.show() - raw_input() + input() s = 1e-7 @@ -343,10 +346,10 @@ def refit_makemap( colf, pars, grains ): if S.sh_esd.max() < 1e-10: break if TESTING: - print "translation",t - print "Cell",indexing.ubitocellpars(np.linalg.inv(UB)) - print "Translation %.5f %.5f %.5f"%tuple(t) - print "Cell %.7f %.7f %.7f %.8f %.8f %.8f"%(indexing.ubitocellpars(np.linalg.inv(UB))) + print("translation",t) + print("Cell",indexing.ubitocellpars(np.linalg.inv(UB))) + print("Translation %.5f %.5f %.5f"%tuple(t)) + print("Cell %.7f %.7f %.7f %.8f %.8f %.8f"%(indexing.ubitocellpars(np.linalg.inv(UB)))) g.translation = t g.set_ubi(np.linalg.inv( UB )) return grains