Changeset 824
- Timestamp:
- Jan 10, 2013 3:22:25 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r823 r824 1182 1182 dlg = wx.FileDialog( 1183 1183 self, 'Choose image files', '.', '', 1184 'Any image file (*.tif;*.tiff;*.mar*;*.avg;*.sum;*.img;*.G2img)|' 1185 '*.tif;*.tiff;*.mar*;*.avg;*.sum;*.img;*.G2img;*.zip|' 1184 'Any image file (*.edf;*.tif;*.tiff;*.mar*;*.avg;*.sum;*.img;*.G2img)|' 1185 '*.edf;*.tif;*.tiff;*.mar*;*.avg;*.sum;*.img;*.G2img;*.zip|' 1186 'European detector file (*.edf)|*.edf|' 1186 1187 'Any detector tif (*.tif;*.tiff)|*.tif;*.tiff|' 1187 1188 'MAR file (*.mar*)|*.mar*|' -
trunk/GSASIIIO.py
r798 r824 94 94 if not ospath.exists(imagefile): 95 95 dlg = wx.FileDialog(G2frame, 'Bad image file name; choose name', '.', '',\ 96 'Any image file (*.tif;*.tiff;*.mar*;*.avg;*.sum;*.img)\ 97 |*.tif;*.tiff;*.mar*;*.avg;*.sum;*.img|\ 96 'Any image file (*.edf;*.tif;*.tiff;*.mar*;*.avg;*.sum;*.img)\ 97 |*.edf;*.tif;*.tiff;*.mar*;*.avg;*.sum;*.img|\ 98 European detector file (*.edf)|*.edf|\ 98 99 Any detector tif (*.tif;*.tiff)|*.tif;*.tiff|\ 99 100 MAR file (*.mar*)|*.mar*|\ … … 116 117 if ext == '.tif' or ext == '.tiff': 117 118 Comments,Data,Npix,Image = GetTifData(imagefile) 119 elif ext == '.edf': 120 Comments,Data,Npix,Image = GetEdfData(imagefile) 118 121 elif ext == '.img': 119 122 Comments,Data,Npix,Image = GetImgData(imagefile) … … 142 145 return Comments,Data,Npix,image 143 146 147 def GetEdfData(filename,imageOnly=False): 148 import struct as st 149 import array as ar 150 if not imageOnly: 151 print 'Read European detector data edf file: ',filename 152 File = open(filename,'rb') 153 head = File.read(3072) 154 lines = head.split('\n') 155 sizexy = [0,0] 156 pixSize = [0,0] 157 cent = [0,0] 158 head = ['European detector data',] 159 for line in lines: 160 fields = line.split() 161 if 'Dim_1' in line: 162 sizexy[0] = int(fields[2]) 163 elif 'Dim_2' in line: 164 sizexy[1] = int(fields[2]) 165 elif 'DataType' in line: 166 dType = fields[2] 167 elif 'refined_wavelength' in line: 168 wave = float(fields[2]) 169 elif 'Size' in line: 170 imSize = int(fields[2]) 171 elif 'DataType' in lines: 172 dType = fields[2] 173 elif 'pixel_size_x' in line: 174 pixSize[0] = float(fields[2]) 175 elif 'pixel_size_y' in line: 176 pixSize[1] = float(fields[2]) 177 elif 'beam_center_x' in line: 178 cent[0] = float(fields[2]) 179 elif 'beam_center_y' in line: 180 cent[1] = float(fields[2]) 181 elif 'refined_distance' in line: 182 dist = float(fields[2]) 183 if line: 184 head.append(line) 185 if dType == 'UnsignedShort': 186 image = np.array(ar.array('H',File.read(imSize)),dtype=np.int32) 187 image = np.reshape(image,(sizexy[1],sizexy[0])) 188 data = {'pixelSize':pixSize,'wavelength':wave,'distance':dist,'center':cent,'size':sizexy} 189 Npix = sizexy[0]*sizexy[1] 190 File.close() 191 if imageOnly: 192 return image 193 else: 194 return head,data,Npix,image 195 144 196 def GetGEsumData(filename,imageOnly=False): 145 197 import struct as st … … 285 337 else: 286 338 return head,data,Npix,image.T 287 339 288 340 def GetTifData(filename,imageOnly=False): 289 341 import struct as st -
trunk/GSASIImath.py
r823 r824 368 368 def getRestPolefig(ODFln,SamSym,Grid): 369 369 X,Y = np.meshgrid(np.linspace(1.,-1.,Grid),np.linspace(-1.,1.,Grid)) 370 R,P = np.sqrt(X**2+Y**2).flatten(),atan2d( X,Y).flatten()370 R,P = np.sqrt(X**2+Y**2).flatten(),atan2d(Y,X).flatten() 371 371 R = np.where(R <= 1.,2.*atand(R),0.0) 372 372 Z = np.zeros_like(R) -
trunk/GSASIIstruct.py
r823 r824 2103 2103 ODFln = G2lat.Flnh(False,SHCoef,phi,beta,SGData) 2104 2104 R,P,Z = G2mth.getRestPolefig(ODFln,SamSym[textureData['Model']],grid) 2105 Z = ma.masked_greater(Z,0.0) 2106 raise Exception 2105 Z1 = -ma.masked_greater(Z,0.0) 2106 IndZ1 = np.array(ma.nonzero(Z1)) 2107 for ind in IndZ1.T: 2108 pNames.append('%d:%s:%d:%.2f:%.2f'%(pId,name,i,R[ind[0],ind[1]],P[ind[0],ind[1]])) 2109 pVals.append(Z1[ind[0]][ind[1]]) 2110 pWt.append(wt/esd1**2) 2111 if ifesd2: 2112 Z2 = 1.-Z 2113 for ind in np.ndindex(grid,grid): 2114 pNames.append('%d:%s:%d:%.2f:%.2f'%(pId,name+'-unit',i,R[ind[0],ind[1]],P[ind[0],ind[1]])) 2115 pVals.append(Z1[ind[0]][ind[1]]) 2116 pWt.append(wt/esd2**2) 2107 2117 2108 2118 for item in varyList: … … 2127 2137 SGData = General['SGData'] 2128 2138 AtLookup = G2mth.FillAtomLookUp(Phases[phase]['Atoms']) 2129 Amat,Bmat = G2lat.cell2AB(General['Cell'][1:7]) 2139 cell = General['Cell'][1:7] 2140 Amat,Bmat = G2lat.cell2AB(cell) 2141 textureData = General['SH Texture'] 2142 2143 SHCoef = textureData['SH Coeff'][1] 2144 shModels = ['cylindrical','none','shear - 2/m','rolling - mmm'] 2145 SamSym = dict(zip(shModels,['0','-1','2/m','mmm'])) 2130 2146 phaseRest = restraintDict[phase] 2131 2147 names = {'Bond':'Bonds','Angle':'Angles','Plane':'Planes', 2132 2148 'Chiral':'Volumes','Torsion':'Torsions','Rama':'Ramas', 2133 2149 'ChemComp':'Sites','Texture':'HKLs'} 2150 lasthkl = np.array([0,0,0]) 2134 2151 for ip,pName in enumerate(pNames): 2135 2152 pnames = pName.split(':') … … 2170 2187 mul = np.array(G2mth.GetAtomItemsById(Atoms,AtLookUp,indx,cs+1)) 2171 2188 deriv = mul*factors 2172 elif name == 'Texture': 2189 elif 'Texture' in name: 2190 hkl,grid,esd1,ifesd2,esd2 = itemRest[names[name]][id] 2191 if np.any(lasthkl-hkl): 2192 PH = np.array(hkl) 2193 phi,beta = G2lat.CrsAng(np.array(hkl),cell,SGData) 2194 ODFln = G2lat.Flnh(False,SHCoef,phi,beta,SGData) 2195 # R,P,Z = G2mth.getRestPolefig(ODFln,SamSym[textureData['Model']],grid) 2196 lasthkl = copy.copy(hkl) 2197 if 'unit' in name: 2198 pass 2199 else: 2200 gam = float(pnames[3]) 2201 phi = float(pnames[4]) 2202 pass 2203 2173 2204 raise Exception 2174 2205 for dName,drv in zip(dNames,deriv):
Note: See TracChangeset
for help on using the changeset viewer.