Changeset 3190
- Timestamp:
- Dec 12, 2017 12:31:12 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIIO.py
r3189 r3190 694 694 name = name.replace('IMG ',data['type']+' ') 695 695 Comments = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,Id, 'Comments')) 696 Controls = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,G2frame.root, 'Controls')) 696 697 if 'PWDR' in name: 697 698 names = ['Type','Lam','Zero','Polariz.','U','V','W','X','Y','Z','SH/L','Azimuth'] … … 744 745 except: 745 746 polariz = 0.99 747 for key in ('Temperature','Pressure','Time','FreePrm1','FreePrm2','FreePrm3','Omega', 748 'Chi','Phi'): 749 if key.lower() in item.lower(): 750 try: 751 Sample[key] = float(item.split('=')[1]) 752 except: 753 pass 754 if 'label_prm' in item.lower(): 755 for num in ('1','2','3'): 756 if 'label_prm'+num in item.lower(): 757 Controls['FreePrm'+num] = item.split('=')[1].strip() 746 758 if 'PWDR' in Aname: 747 759 parms = ['PXC',data['wavelength'],0.0,polariz,1.0,-0.10,0.4,0.30,1.0,0.0,0.0001,Azms[i]] … … 2167 2179 pixelSize:lambda x: [74.8, 74.8]|0 2168 2180 ISOlikeDate: lambda dow,m,d,t,y:"{}-{}-{}T{} ({})".format(y,m,d,t,dow)|0,1,2,3,4 2181 Temperature: float|53 2182 FreePrm2: int | 34 | Free Parm2 Label 2169 2183 # define other variables 2170 2184 0:day … … 2180 2194 to determine values that are used for image interpretation (see table, 2181 2195 below). Any others are copied to the Comments subsection of the Image 2182 tree item. 2196 tree item. 2183 2197 * Column labels are defined with a column number (integer) followed by 2184 2198 a colon (:) and a label to be assigned to that column. All labeled … … 2192 2206 The parameter name is followed by a colon. After the colon, specify 2193 2207 Python code that defines or specifies a function that will be called to 2194 generate a value for that parameter. After that code, supply a vertical 2195 bar (|) and then a list of one more more columns that will be supplied 2196 as arguments to that function. The examples above are discussed below: 2208 generate a value for that parameter. 2209 2210 Note that several keywords, if defined in the Comments, will be found and 2211 placed in the appropriate section of the powder histogram(s)'s Sample 2212 Parameters after an integration: 'Temperature','Pressure','Time', 2213 'FreePrm1','FreePrm2','FreePrm3','Omega','Chi', and 'Phi'. 2214 2215 After the Python code, supply a vertical bar (|) and then a list of one 2216 more more columns that will be supplied as arguments to that function. 2217 2218 Note that the labels for the three FreePrm items can be changed by 2219 including that label as a third item with an additional vertical bar. Labels 2220 will be ignored for any other named parameters. 2221 2222 The examples above are discussed here: 2197 2223 2198 2224 ``filename:lambda x,y: "{}_{:0>6}".format(x,y)|33,34`` … … 2219 2245 value is not used in the expression. 2220 2246 2221 2247 ``ISOlikeDate: lambda dow,m,d,t,y:"{}-{}-{}T{} ({})".format(y,m,d,t,dow)|0,1,2,3,4`` 2222 2248 This example defines a parameter that takes items in the first five columns 2223 2249 and formats them in a different way. This parameter is not one of the pre-defined 2224 2250 parameter names below. Some external code could be used to change the month string 2225 (argument ``m``) to a integer from 1 to 12. 2251 (argument ``m``) to a integer from 1 to 12. 2252 2253 ``FreePrm2: int | 34 | Free Parm2 Label`` 2254 In this example, the contents of column 34 will be converted to an integer and 2255 placed as the second free-named parameter in the Sample Parameters after an 2256 integration. The label for this parameter will be changed to "Free Parm2 Label". 2226 2257 2227 2258 **Pre-defined parameter names** … … 2265 2296 keyExp = {} 2266 2297 keyCols = {} 2298 labels = {} 2267 2299 for line in fp: # read label definitions 2268 2300 items = line.strip().split(':') … … 2282 2314 print(msg) 2283 2315 keyCols[key] = [int(i) for i in items[1].strip().split(',')] 2316 if key.lower().startswith('freeprm') and len(items) > 2: 2317 labels[key] = items[2] 2284 2318 continue 2285 2319 if len(items) == 2: # simple column definition … … 2295 2329 name = keyExp['filename'](*[items[j] for j in keyCols['filename']]) 2296 2330 if name == imageName: # got our match, parse the line and finish 2297 metadata = {lbldict[ i]:items[i] for iin lbldict}2331 metadata = {lbldict[j]:items[j] for j in lbldict} 2298 2332 metadata.update( 2299 2333 {key:keyExp[key](*[items[j] for j in keyCols[key]]) for key in keyExp}) 2300 2334 metadata['par file'] = parFil 2301 2335 metadata['lbls file'] = lblFil 2302 print("Metadata read from {}".format(parFil)) 2336 for lbl in labels: 2337 metadata['label_'+lbl[4:].lower()] = labels[lbl] 2338 print("Metadata read from {} line {}".format(parFil,i+1)) 2303 2339 return metadata 2304 2340 else: -
trunk/docs/source/index.rst
r3187 r3190 22 22 GSASIIscriptable.rst 23 23 GSASIIscripts.rst 24 imports.rst 24 25 exports.rst 25 imports.rst26 26 27 27 *Required packages*
Note: See TracChangeset
for help on using the changeset viewer.