Changeset 1145
- Timestamp:
- Nov 12, 2013 3:52:13 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r1143 r1145 1613 1613 if not G2gd.GetPatternTreeItemId(self,self.root,'Controls'): 1614 1614 sub = self.PatternTree.AppendItem(parent=self.root,text='Controls') 1615 self.PatternTree.SetItemPyData(sub,copy.copy(G2 gd.DefaultControls))1615 self.PatternTree.SetItemPyData(sub,copy.copy(G2obj.DefaultControls)) 1616 1616 if not G2gd.GetPatternTreeItemId(self,self.root,'Covariance'): 1617 1617 sub = self.PatternTree.AppendItem(parent=self.root,text='Covariance') -
trunk/GSASIIgrid.py
r1143 r1145 41 41 import GSASIIrestrGUI as G2restG 42 42 import GSASIIpy3 as G2py3 43 import GSASIIobj as G2obj 43 44 44 45 # trig functions in degrees … … 141 142 142 143 VERY_LIGHT_GREY = wx.Colour(235,235,235) 143 DefaultControls = {144 'deriv type':'analytic Hessian', #default controls145 'min dM/M':0.0001,'shift factor':1.,'max cyc':3,'F**2':True,146 'minF/sig':0,147 'Author':'no name',148 'FreeVar1':'Sample humidity (%)',149 'FreeVar2':'Sample voltage (V)',150 'FreeVar3':'Applied load (MN)',151 }152 144 ################################################################################ 153 145 #### GSAS-II class definitions … … 3551 3543 data = G2frame.PatternTree.GetItemPyData(item) 3552 3544 if not data: #fill in defaults 3553 data = copy.copy( DefaultControls) #least squares controls3545 data = copy.copy(G2obj.DefaultControls) #least squares controls 3554 3546 G2frame.PatternTree.SetItemPyData(item,data) 3555 3547 for i in G2frame.Refine: i.Enable(True) -
trunk/GSASIIobj.py
r1141 r1145 1 # TODO: change this to assemble the look-up tables of atoms, phases and hists from the tree 2 # and then save/unsave those values in __init__ & __str__, etc. 1 # -*- coding: utf-8 -*- 2 #GSASIIobj - data objects for GSAS-II 3 ########### SVN repository information ################### 4 # $Date$ 5 # $Author$ 6 # $Revision$ 7 # $URL$ 8 # $Id$ 9 ########### SVN repository information ################### 3 10 4 11 ''' … … 679 686 680 687 GSASIIpath.SetVersionNumber("$Revision$") 688 689 DefaultControls = { 690 'deriv type':'analytic Hessian', #default controls 691 'min dM/M':0.0001,'shift factor':1.,'max cyc':3,'F**2':True, 692 'minF/sig':0, 693 'Author':'no name', 694 'FreeVar1':'Sample humidity (%)', 695 'FreeVar2':'Sample voltage (V)', 696 'FreeVar3':'Applied load (MN)', 697 } 698 '''Values to be used as defaults for the initial contents of the ``Controls`` 699 data tree item. 700 ''' 701 702 681 703 PhaseIdLookup = {} 682 704 '''dict listing phase name and random Id keyed by sequential phase index as a str; -
trunk/GSASIIstrIO.py
r1144 r1145 49 49 :return: dictionary of control items 50 50 ''' 51 Controls = copy.copy(G2 gd.DefaultControls)51 Controls = copy.copy(G2obj.DefaultControls) 52 52 fl = open(GPXfile,'rb') 53 53 while True: -
trunk/imports/G2sfact_CIF.py
r1123 r1145 51 51 return True 52 52 def Reader(self,filename,filepointer, ParentFrame=None, **kwarg): 53 hklitems = ('_refln_index_h','_refln_index_k','_refln_index_l') 54 cellitems = ( 55 '_cell_length_a','_cell_length_b','_cell_length_c', 56 '_cell_angle_alpha','_cell_angle_beta','_cell_angle_gamma',) 53 hklitems = [('_refln_index_h','_refln_index_k','_refln_index_l'), 54 ('_refln.index_h','_refln.index_k','_refln.index_l')] 55 cellitems = [ 56 ('_cell_length_a','_cell_length_b','_cell_length_c', 57 '_cell_angle_alpha','_cell_angle_beta','_cell_angle_gamma',), 58 ('_cell.length_a','_cell.length_b','_cell.length_c', 59 '_cell.angle_alpha','_cell.angle_beta','_cell.angle_gamma',),] 60 61 Fdatanames = ('_refln_f_meas','_refln.f_meas','_refln.f_meas_au', 62 ) 63 64 F2datanames = ('_refln_f_squared_meas','_refln.f_squared_meas', 65 ) 66 67 Idatanames = ('_refln_intensity_meas','_refln.intensity_meas', 68 ) # not used yet 69 70 Isignames = ('_refln_intensity_meas_sigma','_refln.intensity_meas_sigma', 71 ) # not used yet 72 73 Fcalcnames = ('_refln_f_calc','_refln.f_calc','_refln.f_calc_au', 74 ) 75 76 F2calcnames = ('_refln_f_squared_calc','_refln.f_squared_calc', 77 ) 78 79 Fsignames = ('_refln_f_meas_sigma','_refln.f_meas_sigma','_refln.f_meas_sigma_au', 80 ) 81 82 F2signames = ('_refln_f_squared_meas_sigma','_refln.f_squared_meas_sigma', 83 ) 84 85 phasenames = ('_refln_phase_calc','_refln.phase_calc', 86 ) 87 88 89 SGdataname = ('_symmetry_space_group_name_H-M', '_symmetry.space_group_name_H-M') 90 57 91 phasenamefields = ( 58 92 '_chemical_name_common', … … 65 99 if self.repeat and rdbuffer is not None: 66 100 cf = rdbuffer.get('lastcif') 67 print 'Reus epreviously parsed CIF'101 print 'Reusing previously parsed CIF' 68 102 if cf is None: 69 103 self.ShowBusy() # this can take a while … … 72 106 # scan blocks for reflections 73 107 blklist = [] 74 blktype = []75 for blk in cf.keys():108 for blk in cf.keys(): # scan for reflections, F or F2 values and cell lengths. 109 # Ignore blocks that do not have structure factors and a cell 76 110 blkkeys = [k.lower() for k in cf[blk].keys()] 77 gotFo = True 78 gotFo2 = True 79 for r in hklitems: 80 if r not in blkkeys: 81 gotFo = False 82 gotFo2 = False 83 if '_refln_f_squared_meas' not in blkkeys: 84 gotFo = False 85 if '_refln_f_squared_meas' not in blkkeys: 86 gotFo2 = False 87 if gotFo or gotFo2: 88 blklist.append(blk) 89 blktype.append(gotFo2) 111 gotFo = False 112 gotFo2 = False 113 for i in range(2): 114 if hklitems[i][0] in blkkeys and hklitems[i][1] in blkkeys and hklitems[i][2] in blkkeys: 115 dnIndex = i 116 break 117 else: 118 break # no reflections 119 for dn in Fdatanames: 120 if dn in blkkeys: 121 blklist.append(blk) 122 gotFo = True 123 break 124 if gotFo: break 125 for dn in F2datanames: 126 if dn in blkkeys: 127 blklist.append(blk) 128 break 129 else: 130 break 90 131 if not blklist: 91 132 selblk = None # no block to choose … … 107 148 s = '' 108 149 fmt = "%.2f," 109 for i,key in enumerate(cellitems ):150 for i,key in enumerate(cellitems[dnIndex]): 110 151 if i == 3: fmt = "%.f," 111 152 if i == 5: fmt = "%.f" … … 114 155 s += fmt % cif.get_number_with_esd(val)[0] 115 156 if s: choice[-1] += ', cell: ' + s 116 sg = cf[blknm].get("_symmetry_space_group_name_H-M") 117 if sg: choice[-1] += ', (' + sg.strip() + ')' 157 for dn in SGdataname: 158 sg = cf[blknm].get(dn) 159 if sg: 160 choice[-1] += ', (' + sg.strip() + ')' 161 break 118 162 choice.append('Import all of the above') 119 163 if self.repeat: # we were called to repeat the read … … 140 184 self.objname = os.path.basename(filename)+':'+str(blknm) 141 185 # read in reflections 142 refloop = blk.GetLoop('_refln_index_h') 186 try: 187 refloop = blk.GetLoop(hklitems[0][0]) 188 dnIndex = 0 189 except KeyError: 190 try: 191 refloop = blk.GetLoop(hklitems[1][0]) 192 dnIndex = 1 193 except KeyError: 194 raise Exception, "Unexpected: index_h not found!" 143 195 itemkeys = {} 144 196 # prepare an index to the CIF reflection loop 145 197 for i,key in enumerate(refloop.keys()): 146 198 itemkeys[key.lower()] = i 147 if '_refln_f_squared_calc' in itemkeys: 148 FcalcPresent = True 149 elif '_refln_f_calc' in itemkeys: 150 FcalcPresent = True 199 200 # scan for data names: 201 F2dn = None 202 Fdn = None 203 F2cdn = None 204 Fcdn = None 205 F2sdn = None 206 Fsdn = None 207 Phdn = None 208 FcalcPresent = False 209 for dn in F2datanames: 210 if dn in itemkeys: 211 F2dn = dn 212 for dn in F2calcnames: 213 if dn in itemkeys: 214 F2cdn = dn 215 FcalcPresent = True 216 break 217 for dn in F2signames: 218 if dn in itemkeys: 219 F2sdn = dn 220 break 221 break 151 222 else: 152 FcalcPresent = False 223 for dn in Fdatanames: 224 if dn in itemkeys: 225 Fdn = dn 226 for dn in Fcalcnames: 227 if dn in itemkeys: 228 Fcdn = dn 229 FcalcPresent = True 230 break 231 for dn in Fsignames: 232 if dn in itemkeys: 233 Fsdn = dn 234 break 235 break 236 else: 237 raise Exception, "no F or F2 value" 238 for dn in phasenames: 239 if dn in itemkeys: 240 Phdn = dn 241 break 242 243 # loop over all reflections 153 244 for item in refloop: 245 F2c = 0.0 246 sigF2 = 0.0 154 247 HKL = [] 155 for i in hklitems: # ('_refln_index_h','_refln_index_k','_refln_index_l') 156 num = itemkeys.get(i) 157 try: 158 HKL.append(int(item[num])) 159 except: 160 HKL.append('.') 161 #h,k,l,m,dsp,Fo2,sig,Fc2,Fot2,Fct2,phase,... 162 ref = HKL+[0,0,0,0,0, 0,0,0,0,0, 0] 163 if '_refln_f_squared_meas' in itemkeys: 164 try: 165 Fsq = float(item[itemkeys['_refln_f_squared_meas']]) 166 ref[8] = Fsq 167 ref[5] = Fsq 168 except: 248 try: 249 for i in hklitems[dnIndex]: # '_refln[._]index_[hkl]' 250 num = itemkeys.get(i) 169 251 try: 170 Fsq,Esd = item[itemkeys['_refln_f_squared_meas']].split('(') 171 Fsq = float(Fsq) 172 ref[8] = Fsq 173 ref[5] = Fsq 174 ref[6] = float(Esd[:-1]) 252 HKL.append(int(item[num])) 253 except: 254 HKL.append('.') 255 #h,k,l,m,dsp,Fo2,sig,Fc2,Fot2,Fct2,phase,... 256 ref = HKL+[0,0,0,0,0, 0,0,0,0,0, 0] 257 if F2dn: 258 F2 = item[itemkeys[F2dn]] 259 if '(' in F2: 260 F2, sigF2 = cif.get_number_with_esd(F2) 261 F2 = float(F2) 262 sigF2 = float(sigF2) 263 elif F2sdn: 264 F2 = float(F2) 265 sigF2 = float(item[itemkeys[F2sdn]]) 266 else: 267 F2 = float(F2) 268 try: 269 if F2cdn: 270 F2c = float(item[itemkeys[F2cdn]]) 175 271 except: 176 272 pass 177 if '_refln_f_squared_sigma' in itemkeys: 273 else: 274 F = item[itemkeys[Fdn]] 275 if '(' in F: 276 F, sig = cif.get_number_with_esd(F) 277 elif Fsdn: 278 F = float(F) 279 sig = float(item[itemkeys[Fsdn]]) 280 else: 281 F = float(F) 282 sig = 0.0 283 F2 = F**2 284 sigF2 = 2.0*F*sig 178 285 try: 179 ref[6] = float(item[itemkeys['_refln_f_squared_sigma']]) 286 if Fcdn: 287 Fc = float(item[itemkeys[Fcdn]]) 288 F2c = Fc*Fc 180 289 except: 181 pass 182 elif '_refln_f_meas' in itemkeys: 290 pass 291 292 ref[8] = F2 293 ref[5] = F2 294 ref[6] = sigF2 295 ref[9] = F2c 296 ref[7] = F2c 183 297 try: 184 Fsq = float(item[itemkeys['_refln_f_meas']])**2 185 ref[8] = Fsq 186 ref[5] = Fsq 298 if Phdn: 299 ref[10] = float(item[itemkeys[Phdn]]) 187 300 except: 188 try: 189 Fsq,Esd = item[itemkeys['_refln_f_squared_meas']].split('(') 190 Fsq = float(Fsq)**2 191 ref[8] = Fsq 192 ref[5] = Fsq 193 ref[6] = 2.0*sqrt(Fsq)*float(Esd[:-1]) 194 except: 195 pass 196 if '_refln_f_sigma' in itemkeys: 197 try: 198 ref[6] = 2.*sqrt(ref[8])*float(item[itemkeys['_refln_f_sigma']]) 199 except: 200 pass 201 if '_refln_f_squared_calc' in itemkeys: 202 try: 203 Fsq = float(item[itemkeys['_refln_f_squared_calc']]) 204 ref[9] = Fsq 205 ref[7] = Fsq 206 except: 207 pass 208 elif '_refln_f_calc' in itemkeys: 209 try: 210 Fsq = float(item[itemkeys['_refln_f_calc']])**2 211 ref[9] = Fsq 212 ref[7] = Fsq 213 except: 214 pass 215 if '_refln_phase_calc' in itemkeys: 216 try: 217 ref[10] = float(item[itemkeys['_refln_phase_calc']]) 218 except: 219 pass 301 pass 302 except: 303 continue # skip over incompletely parsed reflections 220 304 self.RefDict['RefList'].append(ref) 221 305 self.RefDict['FF'].append({}) … … 225 309 if blk['_diffrn_radiation_probe'] == 'neutron': 226 310 type = 'SNC' 311 elif blk.get('_diffrn_radiation.probe'): 312 if blk['_diffrn_radiation.probe'] == 'neutron': 313 type = 'SNC' 227 314 else: 228 315 type = 'SXC' 229 316 if blk.get('_diffrn_radiation_wavelength'): 230 317 wave = float(blk['_diffrn_radiation_wavelength']) 318 elif blk.get('_diffrn_radiation.wavelength'): 319 wave = float(blk['_diffrn_radiation.wavelength']) 231 320 else: 232 321 wave = None
Note: See TracChangeset
for help on using the changeset viewer.