#print spaceGroup atomList = H.readInfo(infoFile)[2] wavelength = 2.07750 ttMin = 3.0 ttMax = 166.3 ttStep = 0.05 exclusions = [[52, 54], [60.5, 62.5], [92.5, 95], [115.0, 117], [125.0, 126]] tt, observed = H.readData(observedFile, kind="y", skiplines=3, start=ttMin, stop=ttMax, step=ttStep, exclusions=exclusions, colstep=2) backg = H.LinSpline(backgFile) #print >> sys.stderr, tt.shape, observed.shape basisSymmetry = copy(symmetry) if (basisSymmetry.centerType() == 2): # change to acentric basisSymmetry.setCenterType(1) basisSymmetry.setNumIrreps(1) # Number of the basis from BasIreps (1-6) basisIndex = 2 for magAtom in magAtomList: magAtom.setNumkVectors(1) magAtom.setIrrepNum_ind(0, 1)
import os, sys sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import numpy as np import fswig_hklgen as H import hkl_model as Mod np.seterr(divide="ignore", invalid="ignore") DATAPATH = os.path.dirname(os.path.abspath(__file__)) backgFile = os.path.join(DATAPATH, "ncaf_3t2.bac") observedFile = os.path.join(DATAPATH, "ncaf_3t2.dat") infoFile = os.path.join(DATAPATH, "ncaf_3t2.pcr") (spaceGroup, crystalCell, atoms) = H.readInfo(infoFile) wavelength = 1.225300 backg = H.LinSpline(None) ttMin = 0.0 ttMax = 125.450004578 ttStep = 0.049980081505 exclusions = [[0, 5], [125, 180]] tt, observed = H.readIllData(observedFile, "D1A", backgFile) def fit(): # PYTHONPATH=. bumps Al2O3.py --fit=dream --store=M1 --burn=100 --steps=500 cell = Mod.makeCell(crystalCell, spaceGroup.xtalSystem()) cell.a.pm(0.5) m = Mod.Model(tt, observed, backg, 0, 0,
def diffPattern(infoFile=None, backgroundFile=None, wavelength=1.5403, ttMin=0, ttMax=180, ttStep=0.05, exclusions=None, spaceGroup=None, cell=None, atomList=None, symmetry=None, basisSymmetry=None, magAtomList=None, uvw=[0, 0, 1], scale=1, magnetic=False, info=False, plot=False, saveFile=None, observedData=(None, None), labels=None, base=0, residuals=False, error=None, muR=None): background = H.LinSpline(backgroundFile) sMin, sMax = H.getS(ttMin, wavelength), H.getS(ttMax, wavelength) if magnetic: if (infoFile != None): infofile = H.readMagInfo(infoFile) if (spaceGroup == None): spaceGroup = infofile[0] if (cell == None): cell = infofile[1] if (magAtomList == None): magAtomList = infofile[2] if (symmetry == None): symmetry = infofile[3] if (basisSymmetry == None): basisSymmetry = symmetry ## magnetic peaks # convert magnetic symmetry to space group latt = H.getMagsymmK_latt(basisSymmetry) if basisSymmetry.get_magsymm_k_mcentred() == 1: latt += " -1" else: latt += " 1" spg = _SpaceGroup() FortFuncs().set_spacegroup(latt, spg) refList = H.hklGen(spaceGroup, cell, sMin, sMax, True, xtal=False) refList2 = H.hklGen(spg, cell, sMin, np.sin(179.5 / 2) / wavelength, True, xtal=True) magRefList = H.satelliteGen( cell, symmetry, sMax, hkls=refList2) #satelliteGen_python(cell, sMax, None)# print "length of reflection list " + str(len(magRefList)) magIntensities = H.calcIntensity(magRefList, magAtomList, basisSymmetry, wavelength, cell, True, muR=muR) # add in structural peaks if (atomList == None): atomList = H.readInfo(infoFile)[2] #refList = hklGen(spaceGroup, cell, sMin, sMax, True, xtal=xtal) intensities = H.calcIntensity(refList, atomList, spaceGroup, wavelength, muR=muR) reflections = magRefList[:] + refList[:] intensities = np.append(magIntensities, intensities) else: if (infoFile != None): infofile = H.readInfo(infoFile) if (spaceGroup == None): spaceGroup = infofile[0] if (cell == None): cell = infofile[1] if (atomList == None): atomList = infofile[2] print "length of atom list is", len(atomList) print(spaceGroup.number) refList = H.hklGen(spaceGroup, cell, sMin, sMax, True, xtal=False) reflections = refList[:] intensities = H.calcIntensity(refList, atomList, spaceGroup, wavelength, muR=muR) peaks = H.makePeaks(reflections, uvw, intensities, scale, wavelength, base=base) numPoints = int(floor((ttMax - ttMin) / ttStep)) + 1 tt = np.linspace(ttMin, ttMax, numPoints) intensity = H.getIntensity(peaks, background, tt, base=base) if info: if magnetic: H.printInfo(cell, spaceGroup, (atomList, magAtomList), (refList, magRefList), wavelength, basisSymmetry, muR=muR) else: H.printInfo(cell, spaceGroup, atomList, refList, wavelength, muR=muR) if plot: H.plotPattern(peaks, background, observedData[0], observedData[1], ttMin, ttMax, ttStep, exclusions, labels=labels, base=base, residuals=residuals, error=error) H.pylab.show() H.pylab.savefig(os.path.join('/tmp/bland', str('plot.jpg')), dpi=2000) if saveFile: np.savetxt(saveFile, (tt, intensity), delimiter=" ") tt1 = ["%.3f" % H.twoTheta(ref.s, wavelength) for ref in refList] for atom in atomList: print atom.label(), "element:", atom.element(), "iso:", atom.BIso( ), "multip:", atom.multip(), "coords:", atom.coords( ), "occupancy:", atom.occupancy() h, k, l = tuple([str(ref.hkl[i]) for ref in refList] for i in xrange(3)) return (tt1, tt, intensities, [h, k, l], peaks, background)