def OnNewMenu(self, event): ElList = [] for Elem in self.Elems: ElList.append(Elem[0]) PE = G2elemGUI.PickElements(self, ElList) if PE.ShowModal() == wx.ID_OK: Elem = PE.Elem PE.Destroy() if Elem: for El in Elem: ElemSym = El.strip().upper() if ElemSym not in ElList: atomData = G2elem.GetAtomInfo(ElemSym.capitalize()) FormFactors = G2elem.GetFormFactorCoeff(ElemSym) for FormFac in FormFactors: FormSym = FormFac['Symbol'].strip() if FormSym == ElemSym: Z = FormFac['Z'] #At. No. N = 1. #no atoms / formula unit Orbs = G2elem.GetXsectionCoeff(ElemSym) Elem = [ElemSym, Z, N, FormFac, Orbs, atomData] self.Elems.append(Elem) self.Delete.Enable(True) self.panel.Destroy() self.DrawPanel() self.NewFPPlot = True self.SetWaveEnergy(self.Wave)
def OnPickElement(self, Parms): PE = G2elG.PickElement(self.testFFPanel, oneOnly=True) if PE.ShowModal() == wx.ID_OK: self.xrayFFs = G2el.GetFormFactorCoeff(PE.Elem) self.Elem = PE.Elem self.atmInfo = G2el.GetAtomInfo(PE.Elem) self.magFFs = G2el.GetMagFormFacCoeff(PE.Elem) PE.Destroy() self.MakePlot()
def CalcFPPS(self): """generate f" curves for selected elements does constant delta-lambda/lambda steps over defined range """ FPPS = [] if self.Elems: wx.BeginBusyCursor() Corr = self.Zcell * self.Radius * self.Pack / (10.0 * self.Volume) try: muT = [] for iE, Elem in enumerate(self.Elems): Els = Elem[0] Els = Els = Els.ljust(2).lower().capitalize() Wmin = self.Wmin Wmax = self.Wmax lWmin = math.log(Wmin) N = int(round( math.log(Wmax / Wmin) / self.Wres)) #number of constant delta-lam/lam steps I = range(N + 1) Ws = [] for i in I: Ws.append(math.exp(i * self.Wres + lWmin)) mus = [] Es = [] for j, W in enumerate(Ws): E = self.Kev / W DE = E * self.Eres #smear by defined source resolution res1 = G2elem.FPcalc(Elem[4], E + DE) res2 = G2elem.FPcalc(Elem[4], E - DE) muR = Corr * Elem[2] * (res1[2] + res2[2]) / 2.0 mus.append(muR) if iE: muT[j] += muR else: muT.append(muR) Es.append(E) if self.ifWave: Fpps = (Els, Ws, mus) else: Fpps = (Els, Es, mus) FPPS.append(Fpps) if self.ifWave: Fpps = ('Total', Ws, muT) else: Fpps = ('Total', Es, muT) FPPS.append(Fpps) finally: wx.EndBusyCursor() self.FPPS = FPPS
def test1(): fplot = self.plotNB.add('Neutron scattering lengths').gca() lams = np.linspace(0.3, 10.0, 1000, True) BLtable = {} El = self.Elem.capitalize() for isotope in self.atmInfo['Isotopes']: if 'Nat' in isotope: BLtable[isotope] = ['', atmdata.AtmBlens[El + '_']] else: BLtable[isotope] = [ '', atmdata.AtmBlens[El + '_' + isotope] ] for isotope in BLtable: if 'BW-LS' in BLtable[isotope][1]: b0 = np.ones_like(lams) * BLtable[isotope][1]['BW-LS'][0] else: b0 = np.ones_like(lams) * BLtable[isotope][1]['SL'][0] bp, bpp = G2el.BlenResTOF([ isotope, ], BLtable, lams) fplot.plot(lams, b0, label=isotope + El + ' b0') fplot.plot(lams, bp[0], label=isotope + El + " b'") fplot.plot(lams, bpp[0], label=isotope + El + ' b"') fplot.legend(loc='best') fplot.set_xlabel('wavelength, A') fplot.set_ylabel('b')
def CalcFPPS(self): """generate set of f' & f" curves for selected elements does constant delta-lambda/lambda steps over defined range """ FPPS = [] if self.Elems: wx.BeginBusyCursor() try: for Elem in self.Elems: Els = Elem[0] Els = Els = Els.ljust(2).lower().capitalize() Wmin = self.Wmin Wmax = self.Wmax Z = Elem[1] if Z > 78: Wmin = 0.16 #heavy element high energy failure of Cromer-Liberman if Z > 94: Wmax = 2.67 #heavy element low energy failure of Cromer-Liberman lWmin = math.log(Wmin) N = int(round( math.log(Wmax / Wmin) / self.Wres)) #number of constant delta-lam/lam steps I = range(N + 1) Ws = [] for i in I: Ws.append(math.exp(i * self.Wres + lWmin)) fps = [] fpps = [] Es = [] for W in Ws: E = self.Kev / W DE = E * self.Eres #smear by defined source resolution res1 = G2elem.FPcalc(Elem[3], E + DE) res2 = G2elem.FPcalc(Elem[3], E - DE) fps.append((res1[0] + res2[0]) / 2.0) fpps.append((res1[1] + res2[1]) / 2.0) Es.append(E) if self.ifWave: Fpps = (Els, Ws, fps, fpps) else: Fpps = (Els, Es, fps, fpps) FPPS.append(Fpps) finally: wx.EndBusyCursor() self.FPPS = FPPS
def test2(): fplot = self.plotNB.add('X-ray form factors').gca() sq = np.linspace(0, 2., 1000, True) for El in self.xrayFFs: F = G2el.ScatFac(El, sq**2) fplot.plot(sq, F, label=El['Symbol']) fplot.legend(loc='best') fplot.set_xlabel('sin-theta/lambda') fplot.set_ylabel('form factor')
def test3(): fplot = self.plotNB.add('magnetic form factors').gca() sq = np.linspace(0, 1., 1000, True) for El in self.magFFs: El['gfac'] = 2.0 F = G2el.MagScatFac(El, sq**2) fplot.plot(sq, F, label=El['Symbol']) fplot.legend(loc='best') fplot.set_xlabel('sin-theta/lambda') fplot.set_ylabel('form factor')
def OnFPRIMENewMenu(self, event): ElList = [] for Elem in self.Elems: ElList.append(Elem[0]) PE = G2elemGUI.PickElements(self,ElList) if PE.ShowModal() == wx.ID_OK: Elems = PE.Elem PE.Destroy() if Elems: for El in Elems: ElemSym = El.strip().upper() if ElemSym not in ElList: FormFactors = G2elem.GetFormFactorCoeff(ElemSym) for FormFac in FormFactors: FormSym = FormFac['Symbol'].strip() if FormSym == ElemSym: Z = FormFac['Z'] #At. No. Orbs = G2elem.GetXsectionCoeff(ElemSym) Elem = (ElemSym,Z,FormFac,Orbs) self.Elems.append(Elem) self.Delete.Enable(True) self.CalcFPPS() self.SetWaveEnergy(self.Wave)
def SetWaveEnergy(self, Wave): self.Wave = Wave self.Energy = self.Kev / self.Wave self.Energy = round(self.Energy, 4) E = self.Energy DE = E * self.Eres #smear by defined source resolution self.SpinText1.SetValue("%6.4f" % (self.Wave)) self.SpinText2.SetValue("%7.4f" % (self.Energy)) self.SpinText1.Update() self.SpinText2.Update() if self.ifWave: self.slider1.SetValue(int(1000. * self.Wave)) else: self.slider1.SetValue(int(1000. * self.Energy)) Text = '' for Elem in self.Elems: r1 = G2elem.FPcalc(Elem[3], E + DE) r2 = G2elem.FPcalc(Elem[3], E - DE) Els = Elem[0] Els = Els.ljust(2).lower().capitalize() if Elem[1] > 78 and self.Energy + DE > self.Kev / 0.16: Text += "%s\t%s%6s\t%s%6.3f \t%s%10.2f %s\n" % ( 'Element= ' + str(Els), " f'=", 'not valid', ' f"=', (r1[1] + r2[1]) / 2.0, ' ' + Gkmu + '=', (r1[2] + r2[2]) / 2.0, 'barns/atom') elif Elem[1] > 94 and self.Energy - DE < self.Kev / 2.67: Text += "%s\t%s%6s\t%s%6s\t%s%10s%s\n" % ( 'Element= ' + str(Els), " f'=", 'not valid', ' f"=', 'not valid', ' ' + Gkmu + '=', 'not valid') else: Text += "%s\t%s%6.3f \t%s%6.3f \t%s%10.2f %s\n" % ( 'Element= ' + str(Els), " f'=", (r1[0] + r2[0]) / 2.0, ' f"=', (r1[1] + r2[1]) / 2.0, ' ' + Gkmu + '=', (r1[2] + r2[2]) / 2.0, 'barns/atom') if len(self.Elems): self.Results.SetValue(Text) self.Results.Update() self.UpDateFPlot(Wave)
def SetWaveEnergy(self, Wave): self.Wave = Wave self.Energy = self.Kev / self.Wave self.Energy = round(self.Energy, 4) E = self.Energy DE = E * self.Eres #smear by defined source resolution self.SpinText1.SetValue("%.4f" % (self.Wave)) self.SpinText2.SetValue("%.4f" % (self.Energy)) self.SpinText1.Update() self.SpinText2.Update() if self.ifWave: self.slider1.SetValue(int(1000. * self.Wave)) else: self.slider1.SetValue(int(1000. * self.Energy)) Text = '' if not self.ifVol: self.Volume = 0 for Elem in self.Elems: self.Volume += 10. * Elem[2] muT = 0 Mass = 0 Fo = 0 Fop = 0 for Elem in self.Elems: Mass += self.Zcell * Elem[2] * Elem[5]['Mass'] r1 = G2elem.FPcalc(Elem[4], E + DE) r2 = G2elem.FPcalc(Elem[4], E - DE) Els = Elem[0] Els = Els.ljust(2).lower().capitalize() mu = 0 Fo += Elem[2] * Elem[1] if Elem[1] > 78 and self.Energy + DE > self.Kev / 0.16: mu = self.Zcell * Elem[2] * (r1[2] + r2[2]) / 2.0 Text += "%s\t%s%8.2f %s%6s %s%6.3f %s%10.2f %s\n" % ( 'Element= ' + str(Els), "N = ", Elem[2], " f'=", 'not valid', ' f"=', (r1[1] + r2[1]) / 2.0, ' ' + Gkmu + '=', mu, 'barns') elif Elem[1] > 94 and self.Energy - DE < self.Kev / 2.67: mu = 0 Text += "%s\t%s%8.2f %s%6s %s%6s %s%10s%s\n" % ( 'Element= ' + str(Els), "N = ", Elem[2], " f'=", 'not valid', ' f"=', 'not valid', ' ' + Gkmu + '=', 'not valid') else: mu = self.Zcell * Elem[2] * (r1[2] + r2[2]) / 2.0 Fop += Elem[2] * (Elem[1] + (r1[0] + r2[0]) / 2.0) Text += "%s\t%s%8.2f %s%6.3f %s%6.3f %s%10.2f %s\n" % ( 'Element= ' + str(Els), "N = ", Elem[2], " f'=", (r1[0] + r2[0]) / 2.0, ' f"=', (r1[1] + r2[1]) / 2.0, ' ' + Gkmu + '=', mu, 'barns') muT += mu if self.Volume: Text += "%s %s%10.2f %s" % ("Total", ' ' + Gkmu + '=', self.Pack * muT / self.Volume, 'cm' + Pwrm1 + ', ') Text += "%s%10.2f%s" % ('Total ' + Gkmu + 'R=', self.Radius * self.Pack * muT / (10.0 * self.Volume), ', ') Text += "%s%10.4f%s\n" % ('Transmission exp(-2'+Gkmu+'R)=', \ 100.0*math.exp(-2*self.Radius*self.Pack*muT/(10.0*self.Volume)),'%') self.Results.SetValue(Text) den = Mass / (0.602 * self.Volume) if self.ifVol: Text += '%s' % ('Theor. density=') else: Text += '%s' % ('Est. density=') Text += '%6.3f %s%.3f %s\n' % (den, 'g/cm' + Pwr3 + ', Powder density=', self.Pack * den, 'g/cm' + Pwr3) Text += '%s%10.2f%s\n' % ('X-ray small angle scattering contrast', (28.179 * Fo / self.Volume)** 2, '*10' + Pwr20 + '/cm' + Pwr4) if Fop: Text += '%s%10.2f%s\n' % ( 'Anomalous X-ray small angle scattering contrast', (28.179 * Fop / self.Volume)** 2, '*10' + Pwr20 + '/cm' + Pwr4) self.Results.SetValue(Text) self.Results.Update() self.SpinText3.SetValue("%.2f" % (self.Volume)) self.SpinText3.Update() self.SpinText4.SetValue("%d" % (self.Zcell)) self.SpinText4.Update() self.SpinText5.SetValue("%.2f" % (self.Radius)) self.SpinText5.Update() self.SpinText6.SetValue("%.2f" % (self.Pack)) self.SpinText6.Update() if len(self.Elems): self.CalcFPPS() self.UpDateAbsPlot(Wave, rePlot=True)
def UpDateFPlot(self,Wave,rePlot=True): """Plot f' & f" vs wavelength 0.05-3.0A""" "generate a set of form factor curves & plot them vs sin-theta/lambda or q or 2-theta" self.axylim = [] self.bxylim = [] try: if rePlot: self.axylim = self.ax.get_xlim(),self.ax.get_ylim() self.bxylim = self.bx.get_xlim(),self.bx.get_ylim() newPlot = False except: new,plotNum,self.Page,self.fplot,lim = self.parent.G2plotNB.FindPlotTab('Fprime','mpl') self.Page.canvas.mpl_connect('pick_event', self.OnPick) self.Page.canvas.mpl_connect('button_release_event', self.OnRelease) self.Page.canvas.mpl_connect('motion_notify_event', self.OnMotion) self.Page.canvas.mpl_connect('key_press_event', self.OnKeyPress) newPlot = True self.ax,self.bx = self.Page.figure.subplots(1,2) self.Page.Choice = (' key press','g: toggle grid',) self.Page.keyPress = self.OnKeyPress self.fplot.set_visible(False) self.ax.cla() self.bx.cla() self.ax.set_title('Resonant Scattering Factors',x=0,ha='left') self.ax.set_ylabel("f ',"+' f ", e-',fontsize=14) Ymin = 0.0 Ymax = 0.0 colors=['r','b','g','c','m','k'] if self.FPPS: for i,Fpps in enumerate(self.FPPS): Color = colors[i%6] Ymin = min(Ymin,min(Fpps[2]),min(Fpps[3])) Ymax = max(Ymax,max(Fpps[2]),max(Fpps[3])) fppsP1 = np.array(Fpps[1]) fppsP2 = np.array(Fpps[2]) fppsP3 = np.array(Fpps[3]) self.ax.plot(fppsP1,fppsP2,Color,label=Fpps[0]+" f '") self.ax.plot(fppsP1,fppsP3,Color,label=Fpps[0]+' f "') if self.ifWave: self.ax.set_xlabel(r'$\mathsf{\lambda, \AA}$',fontsize=14) self.ax.axvline(x=Wave,picker=3,color='black') else: self.ax.set_xlabel(r'$\mathsf{E, keV}$',fontsize=14) self.ax.set_xscale('log') self.ax.axvline(x=self.Kev/Wave,picker=3,color='black') self.ax.set_ylim(Ymin,Ymax) if self.FPPS: self.ax.legend(loc='best') self.Page.figure.subplots_adjust(hspace=0.25) if self.ifWave: self.bx.set_title('%s%s%6.4f%s'%('Form factors (',r'$\lambda=$',self.Wave,r'$\AA)$'),x=0,ha='left') else: self.bx.set_title('%s%6.2f%s'%('Form factors (E =',self.Energy,'keV)'),x=0,ha='left') if self.FFxaxis == 'S': self.bxlabel = 'sin('+Gktheta+')/'+Gklambda self.bx.set_xlabel(r'$\mathsf{sin(\theta)/\lambda}$',fontsize=14) elif self.FFxaxis == 'T': self.bxlabel = '2'+Gktheta self.bx.set_xlabel(r'$\mathsf{2\theta}$',fontsize=14) else: self.bxlabel = 'Q, '+Angstr+Pwrm1 self.bx.set_xlabel(r'$Q, \AA$',fontsize=14) self.bx.set_ylabel("f+f ', e-",fontsize=14) E = self.Energy DE = E*self.Eres #smear by defined source resolution StlMax = min(2.0,math.sin(80.0*math.pi/180.)/Wave) Stl = np.arange(0.,StlMax,.01) Ymax = 0.0 for i,Elem in enumerate(self.Elems): Els = Elem[0] Els = Els = Els.ljust(2).lower().capitalize() Ymax = max(Ymax,Elem[1]) res1 = G2elem.FPcalc(Elem[3],E+DE) res2 = G2elem.FPcalc(Elem[3],E-DE) res = (res1[0]+res2[0])/2.0 if Elem[1] > 78 and self.Energy > self.Kev/0.16: res = 0.0 if Elem[1] > 94 and self.Energy < self.Kev/2.67: res = 0.0 Els = Elem[0] Els = Els.ljust(2).lower().capitalize() X = [] ff = [] ffo = [] for S in Stl: ff.append(G2elem.ScatFac(Elem[2],S)+res) ffo.append(G2elem.ScatFac(Elem[2],S)) if self.FFxaxis == 'S': X.append(S) elif self.FFxaxis == 'T': X.append(360.0*math.asin(S*self.Wave)/math.pi) else: X.append(4.0*S*math.pi) Color = colors[i%6] Xp = np.array(X) ffop = np.array(ffo) ffp = np.array(ff) self.bx.plot(Xp,ffop,Color+'--',label=Els+" f") self.bx.plot(Xp,ffp,Color,label=Els+" f+f'") if self.Elems: self.bx.legend(loc='best') self.bx.set_ylim(0.0,Ymax+1.0) if newPlot: newPlot = False self.Page.canvas.draw() else: if rePlot: tb = self.Page.canvas.toolbar tb.push_current() self.ax.set_xlim(self.axylim[0]) self.ax.set_ylim(self.axylim[1]) self.axylim = [] tb.push_current() self.bx.set_xlim(self.bxylim[0]) self.bx.set_ylim(self.bxylim[1]) self.bxylim = [] tb.push_current() self.Page.canvas.draw()
def Reader(self,filename,filepointer, ParentFrame=None, usedRanIdList=[], **unused): self.isodistort_warnings = '' self.Phase = G2IO.SetNewPhase(Name='new phase',SGData=G2IO.P1SGData) # create a new empty phase dict # make sure the ranId is really unique! while self.Phase['ranId'] in usedRanIdList: self.Phase['ranId'] = ran.randint(0,sys.maxint) returnstat = False cellitems = ( '_cell_length_a','_cell_length_b','_cell_length_c', '_cell_angle_alpha','_cell_angle_beta','_cell_angle_gamma',) cellwaveitems = ( '_cell_wave_vector_seq_id', '_cell_wave_vector_x','_cell_wave_vector_y','_cell_wave_vector_z') reqitems = ( '_atom_site_fract_x', '_atom_site_fract_y', '_atom_site_fract_z', ) phasenamefields = ( '_chemical_name_common', '_pd_phase_name', '_chemical_formula_sum' ) try: self.ShowBusy() # this can take a while try: cf = G2IO.ReadCIF(filename) except Exception as detail: self.errors = "Parse or reading of file failed in pyCifRW; check syntax of file in enCIFer or CheckCIF" return False finally: self.DoneBusy() # scan blocks for structural info self.errors = 'Error during scan of blocks for datasets' str_blklist = [] for blk in cf.keys(): for r in reqitems+cellitems: if r not in cf[blk].keys(): break else: str_blklist.append(blk) if not str_blklist: selblk = None # no block to choose elif len(str_blklist) == 1: # only one choice selblk = 0 else: # choose from options choice = [] for blknm in str_blklist: choice.append('') # accumumlate some info about this phase choice[-1] += blknm + ': ' for i in phasenamefields: # get a name for the phase name = cf[blknm].get(i).strip() if name is None or name == '?' or name == '.': continue else: choice[-1] += name.strip()[:20] + ', ' break na = len(cf[blknm].get("_atom_site_fract_x")) if na == 1: choice[-1] += '1 atom' else: choice[-1] += ('%d' % nd) + ' atoms' choice[-1] += ', cell: ' fmt = "%.2f," for i,key in enumerate(cellitems): if i == 3: fmt = "%.f," if i == 5: fmt = "%.f" choice[-1] += fmt % cif.get_number_with_esd( cf[blknm].get(key))[0] sg = cf[blknm].get("_symmetry_space_group_name_H-M",'') if not sg: sg = cf[blknm].get("_space_group_name_H-M_alt",'') if sg: choice[-1] += ', (' + sg.strip() + ')' selblk = self.PhaseSelector( choice, ParentFrame=ParentFrame, title= 'Select a phase from one the CIF data_ blocks below', size=(600,100) ) self.errors = 'Error during reading of selected block' if selblk is None: returnstat = False # no block selected or available else: blknm = str_blklist[selblk] blk = cf[str_blklist[selblk]] E = True Super = False SpGrp = blk.get("_symmetry_space_group_name_H-M",'') if not SpGrp: SpGrp = blk.get("_space_group_name_H-M_alt",'') if not SpGrp: sspgrp = blk.get("_space_group_ssg_name",'').split('(') SpGrp = sspgrp[0] SuperSg = '('+sspgrp[1].replace('\\','') Super = True SuperVec = [[0,0,.1],False,4] # try normalizing the space group, to see if we can pick the space group out of a table SpGrpNorm = G2spc.StandardizeSpcName(SpGrp) if SpGrpNorm: E,SGData = G2spc.SpcGroup(SpGrpNorm) # nope, try the space group "out of the Box" if E and SpGrp: E,SGData = G2spc.SpcGroup(SpGrp) if E: if not SpGrp: self.warnings += 'No space group name was found in the CIF.' self.warnings += '\nThe space group has been set to "P 1". ' self.warnings += "Change this in phase's General tab." else: self.warnings += 'ERROR in space group symbol '+SpGrp self.warnings += '\nThe space group has been set to "P 1". ' self.warnings += "Change this in phase's General tab." self.warnings += '\nAre there spaces separating axial fields?\n\nError msg: ' self.warnings += G2spc.SGErrors(E) SGData = G2IO.SGData # P 1 self.Phase['General']['SGData'] = SGData # cell parameters cell = [] for lbl in cellitems: cell.append(cif.get_number_with_esd(blk[lbl])[0]) Volume = G2lat.calc_V(G2lat.cell2A(cell)) self.Phase['General']['Cell'] = [False,]+cell+[Volume,] # read in atoms self.errors = 'Error during reading of atoms' atomlbllist = [] # table to look up atom IDs atomloop = blk.GetLoop('_atom_site_label') atomkeys = [i.lower() for i in atomloop.keys()] if not blk.get('_atom_site_type_symbol'): self.isodistort_warnings += '\nlack of atom types prevents ISODISTORT processing' if blk.get('_atom_site_aniso_label'): anisoloop = blk.GetLoop('_atom_site_aniso_label') anisokeys = [i.lower() for i in anisoloop.keys()] else: anisoloop = None anisokeys = [] self.Phase['Atoms'] = [] G2AtomDict = { '_atom_site_type_symbol' : 1, '_atom_site_label' : 0, '_atom_site_fract_x' : 3, '_atom_site_fract_y' : 4, '_atom_site_fract_z' : 5, '_atom_site_occupancy' : 6, '_atom_site_aniso_u_11' : 11, '_atom_site_aniso_u_22' : 12, '_atom_site_aniso_u_33' : 13, '_atom_site_aniso_u_12' : 14, '_atom_site_aniso_u_13' : 15, '_atom_site_aniso_u_23' : 16, } ranIdlookup = {} for aitem in atomloop: atomlist = ['','','',0,0,0,1.0,'',0,'I',0.01,0,0,0,0,0,0,0] atomlist[-1] = ran.randint(0,sys.maxint) # add a random Id while atomlist[-1] in ranIdlookup: atomlist[-1] = ran.randint(0,sys.maxint) # make it unique for val,key in zip(aitem,atomkeys): col = G2AtomDict.get(key) if col >= 3: atomlist[col] = cif.get_number_with_esd(val)[0] elif col is not None: atomlist[col] = val elif key in ('_atom_site_thermal_displace_type', '_atom_site_adp_type'): #Iso or Aniso? if val.lower() == 'uani': atomlist[9] = 'A' elif key == '_atom_site_u_iso_or_equiv': atomlist[10] =cif.get_number_with_esd(val)[0] if not atomlist[1] and atomlist[0]: for i in range(2,0,-1): typ = atomlist[0].strip()[:i] if G2elem.CheckElement(typ): atomlist[1] = typ if not atomlist[1]: atomlist[1] = 'Xe' ulbl = '_atom_site_aniso_label' if atomlist[9] == 'A' and atomlist[0] in blk.get(ulbl): for val,key in zip(anisoloop.GetKeyedPacket(ulbl,atomlist[0]), anisokeys): col = G2AtomDict.get(key) if col: atomlist[col] = cif.get_number_with_esd(val)[0] atomlist[7],atomlist[8] = G2spc.SytSym(atomlist[3:6],SGData) atomlist[1] = G2elem.FixValence(atomlist[1]) self.Phase['Atoms'].append(atomlist) ranIdlookup[atomlist[0]] = atomlist[-1] if atomlist[0] in atomlbllist: self.warnings += ' ERROR: repeated atom label: '+atomlist[0] else: atomlbllist.append(atomlist[0]) if len(atomlbllist) != len(self.Phase['Atoms']): self.isodistort_warnings += '\nRepeated atom labels prevents ISODISTORT decode' for lbl in phasenamefields: # get a name for the phase name = blk.get(lbl) if name is None: continue name = name.strip() if name == '?' or name == '.': continue else: break else: # no name found, use block name for lack of a better choice name = blknm self.Phase['General']['Name'] = name.strip()[:20] self.Phase['General']['Super'] = Super if Super: self.Phase['General']['Type'] = 'modulated' self.Phase['General']['SuperVec'] = SuperVec self.Phase['General']['SuperSg'] = SuperSg self.Phase['General']['SSGData'] = G2spc.SSpcGroup(SGData,SuperSg)[1] if not self.isodistort_warnings: if blk.get('_iso_displacivemode_label') or blk.get('_iso_occupancymode_label'): self.errors = "Error while processing ISODISTORT constraints" self.ISODISTORT_proc(blk,atomlbllist,ranIdlookup) else: self.warnings += self.isodistort_warnings returnstat = True except Exception as detail: self.errors += '\n '+str(detail) print 'CIF error:',detail # for testing print sys.exc_info()[0] # for testing import traceback print traceback.format_exc() returnstat = False return returnstat