Changeset 3216
- Timestamp:
- Jan 7, 2018 9:06:19 PM (6 years ago)
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
Binaries/win_32_p2.7_n1.13/BuildNotes.txt
r3214 r3216 20 20 (files libgcc_s_dw2-1.dll, libgmp-10.dll, libquadmath-0.dll, 21 21 libgfortran-3.dll, libgmpxx-4.dll, libwinpthread-1.dll) 22 23 Note: see https://anaconda.org/msys2/m2w64-ntldd-git for a utility 24 that can find dependencies. -
Binaries/win_32_p3.6_n1.13/BuildNotes.txt
r3214 r3216 20 20 (files libgcc_s_dw2-1.dll, libgmp-10.dll, libquadmath-0.dll, 21 21 libgfortran-3.dll, libgmpxx-4.dll & libwinpthread-1.dll) 22 23 Note: see https://anaconda.org/msys2/m2w64-ntldd-git for a utility 24 that can find dependencies. -
trunk/GSASIIIO.py
r3196 r3216 1264 1264 file without invoking any GUI objects. 1265 1265 ''' 1266 # TODO: review exporters producing exceptions where .Writer can't be used where G2frame is None (see CIF) 1267 # TODO: review conflicting uses of .Writer with mode (SeqRef) & elsewhere 1268 # TODO: move this class to G2fil 1266 1269 def __init__(self,G2frame,formatName,extension,longFormatName=None,): 1267 1270 self.G2frame = G2frame … … 1795 1798 self.sigDict[i] = sig 1796 1799 #GSASIIpath.IPyBreak() 1797 1800 1801 def SetFromArray(self,hist,histname): 1802 '''Load a histogram into the exporter in preparation for use of the .Writer 1803 rather than the main tree. This is used in GSASIIscriptable when wx 1804 is not present. 1805 ''' 1806 self.Histograms[histname] = {} 1807 self.Histograms[histname]['Data'] = hist['data'][1] 1808 self.Histograms[histname]['Instrument Parameters'] = hist['Instrument Parameters'] 1809 self.Histograms[histname]['Sample Parameters'] = hist['Sample Parameters'] 1810 1798 1811 # Tools to pull information out of the data arrays 1799 1812 def GetCell(self,phasenam): -
trunk/GSASIIdataGUI.py
r3212 r3216 2407 2407 # find all the exporter files 2408 2408 if not self.exporterlist: # this only needs to be done once 2409 pathlist = sys.path 2410 filelist = [] 2411 for path in pathlist: 2412 for filename in glob.iglob(os.path.join(path,"G2export*.py")): 2413 filelist.append(filename) 2414 filelist = sorted(list(set(filelist))) # remove duplicates 2415 # go through the routines and import them, saving objects that 2416 # have export routines (method Exporter) 2417 for filename in filelist: 2418 path,rootname = os.path.split(filename) 2419 pkg = os.path.splitext(rootname)[0] 2420 # try: 2421 fp = None 2422 fp, fppath,desc = imp.find_module(pkg,[path,]) 2423 pkg = imp.load_module(pkg,fp,fppath,desc) 2424 for clss in inspect.getmembers(pkg): # find classes defined in package 2425 if clss[0].startswith('_'): continue 2426 if inspect.isclass(clss[1]): 2427 # check if we have the required methods 2428 for m in 'Exporter','loadParmDict': 2429 if not hasattr(clss[1],m): break 2430 if not callable(getattr(clss[1],m)): break 2431 else: 2432 exporter = clss[1](self) # create an export instance 2433 self.exporterlist.append(exporter) 2434 # except AttributeError: 2435 # print 'Import_'+errprefix+': Attribute Error'+str(filename) 2436 # pass 2437 # except ImportError: 2438 # print 'Import_'+errprefix+': Error importing file'+str(filename) 2439 # pass 2440 if fp: fp.close() 2409 self.exporterlist = G2fil.LoadExportRoutines(self) 2410 2441 2411 # Add submenu item(s) for each Exporter by its self-declared type (can be more than one) 2442 2412 for obj in self.exporterlist: -
trunk/GSASIIfiles.py
r3207 r3216 369 369 return readerlist 370 370 371 def LoadExportRoutines( ):372 ''' Placeholder that will someday retrieve the exporters371 def LoadExportRoutines(parent, traceback=False): 372 '''Routine to locate GSASII exporters 373 373 ''' 374 pass 374 exporterlist = [] 375 pathlist = sys.path 376 filelist = [] 377 for path in pathlist: 378 for filename in glob.iglob(os.path.join(path,"G2export*.py")): 379 filelist.append(filename) 380 filelist = sorted(list(set(filelist))) # remove duplicates 381 # go through the routines and import them, saving objects that 382 # have export routines (method Exporter) 383 for filename in filelist: 384 path,rootname = os.path.split(filename) 385 pkg = os.path.splitext(rootname)[0] 386 try: 387 fp = None 388 fp, fppath,desc = imp.find_module(pkg,[path,]) 389 pkg = imp.load_module(pkg,fp,fppath,desc) 390 for clss in inspect.getmembers(pkg): # find classes defined in package 391 if clss[0].startswith('_'): continue 392 if not inspect.isclass(clss[1]): continue 393 # check if we have the required methods 394 if not hasattr(clss[1],'Exporter'): continue 395 if not callable(getattr(clss[1],'Exporter')): continue 396 if parent is None: 397 if not hasattr(clss[1],'Writer'): continue 398 else: 399 if not hasattr(clss[1],'loadParmDict'): continue 400 if not callable(getattr(clss[1],'loadParmDict')): continue 401 try: 402 exporter = clss[1](parent) # create an export instance 403 except AttributeError: 404 pass 405 except Exception as exc: 406 print ('\nExport init: Error substantiating class ' + clss[0]) 407 print (u'Error message: {}\n'.format(exc)) 408 if traceback: 409 traceback.print_exc(file=sys.stdout) 410 continue 411 exporterlist.append(exporter) 412 except AttributeError: 413 print ('Export Attribute Error ' + filename) 414 if traceback: 415 traceback.print_exc(file=sys.stdout) 416 except Exception as exc: 417 print ('\nExport init: Error importing file ' + filename) 418 print (u'Error message: {}\n'.format(exc)) 419 if traceback: 420 traceback.print_exc(file=sys.stdout) 421 finally: 422 if fp: 423 fp.close() 424 return exporterlist -
trunk/GSASIIscriptable.py
r3213 r3216 9 9 ########### SVN repository information ################### 10 10 # 11 # TODO: Export patterns12 11 # TODO: integrate 2d data based on a model 13 # TODO: export entire project as a JSON file?14 12 # 15 13 """ … … 463 461 PwdrDataReaders = [] 464 462 PhaseReaders = [] 463 exportersByExtension = {} 464 '''Specifies the list of extensions that are supported for Powder data export''' 465 465 466 466 def LoadG2fil(): 467 467 """Delay importing this module, it is slow""" 468 468 global G2fil 469 global PwdrDataReaders470 global PhaseReaders471 469 if G2fil is None: 472 470 import GSASIIfiles 473 471 G2fil = GSASIIfiles 472 global PwdrDataReaders 473 global PhaseReaders 474 474 PwdrDataReaders = G2fil.LoadImportRoutines("pwd", "Powder_Data") 475 475 PhaseReaders = G2fil.LoadImportRoutines("phase", "Phase") 476 476 AllExporters = G2fil.LoadExportRoutines(None) 477 global exportersByExtension 478 exportersByExtension = {} 479 for obj in AllExporters: 480 try: 481 obj.Writer 482 except AttributeError: 483 continue 484 for typ in obj.exporttype: 485 if typ not in exportersByExtension: 486 exportersByExtension[typ] = {obj.extension:obj} 487 else: 488 exportersByExtension[typ][obj.extension] = obj 477 489 478 490 def LoadDictFromProjFile(ProjFile): … … 1905 1917 @property 1906 1918 def residuals(self): 1919 '''Provides a dictionary with with the R-factors for this histogram. 1920 Includes the weighted and unweighted profile terms (R, Rb, wR, wRb, wRmin) 1921 as well as the Bragg R-values for each phase (ph:H:Rf and ph:H:Rf^2). 1922 ''' 1907 1923 data = self.data['data'][0] 1908 return {key: data[key] 1909 for key in ['R', 'Rb', 'wR', 'wRb', 'wRmin']} 1910 1924 return {key: data[key] for key in data 1925 if key in ['R', 'Rb', 'wR', 'wRb', 'wRmin'] 1926 or ':' in key} 1927 1928 @property 1929 def InstrumentParameters(self): 1930 '''Provides a dictionary with with the Instrument Parameters 1931 for this histogram. 1932 ''' 1933 return self.data['Instrument Parameters'][0] 1934 1935 @property 1936 def SampleParameters(self): 1937 '''Provides a dictionary with with the Sample Parameters 1938 for this histogram. 1939 ''' 1940 return self.data['Sample Parameters'] 1941 1911 1942 @property 1912 1943 def id(self): … … 1988 2019 self.proj.save() 1989 2020 2021 def getdata(self,datatype): 2022 '''Provides access to the histogram data of the selected data type 2023 2024 :param str datatype: must be one of the following values (case is ignored) 2025 2026 * 'X': the 2theta or TOF values for the pattern 2027 * 'Yobs': the observed intensity values 2028 * 'Yweight': the weights for each data point (1/sigma**2) 2029 * 'Ycalc': the computed intensity values 2030 * 'Background': the computed background values 2031 * 'Residual': the difference between Yobs and Ycalc (obs-calc) 2032 2033 :returns: an numpy MaskedArray with data values of the requested type 2034 2035 ''' 2036 enums = ['x', 'yobs', 'yweight', 'ycalc', 'background', 'residual'] 2037 if datatype.lower() not in enums: 2038 raise G2ScriptException("Invalid datatype = "+datatype+" must be one of "+enums) 2039 return self.data['data'][1][enums.index(datatype.lower())] 2040 1990 2041 def y_calc(self): 1991 2042 return self.data['data'][1][3] 1992 2043 2044 def Export(self,fileroot,extension): 2045 '''Write the histogram into a file. The path is specified by fileroot and 2046 extension. 2047 2048 :param str fileroot: name of the file, optionally with a path (extension is 2049 ignored) 2050 :param str extension: includes '.', must match an extension in global 2051 exportersByExtension['powder'] or a Exception is raised. 2052 :returns: name of file that was written 2053 ''' 2054 if extension not in exportersByExtension.get('powder',[]): 2055 raise G2ScriptException('No Writer for file type = "'+extension+'"') 2056 fil = os.path.abspath(os.path.splitext(fileroot)[0]+extension) 2057 obj = exportersByExtension['powder'][extension] 2058 obj.SetFromArray(hist=self.data,histname=self.name) 2059 obj.Writer(self.name,fil) 2060 1993 2061 def plot(self, Yobs=True, Ycalc=True, Background=True, Residual=True): 1994 2062 try: … … 2522 2590 print(u'Unknown HAP key: '+key) 2523 2591 2592 def getHAPvalues(self, histname): 2593 """Returns a dict with HAP values for the selected histogram 2594 2595 :param histogram: is a histogram object (:class:`G2PwdrData`) or 2596 a histogram name or the index number of the histogram 2597 2598 :returns: HAP value dict 2599 """ 2600 if isinstance(histname, G2PwdrData): 2601 histname = histname.name 2602 elif histname in self.data['Histograms']: 2603 pass 2604 elif type(histname) is int: 2605 histname = self.proj.histograms()[histname].name 2606 else: 2607 raise G2ScriptException("Invalid histogram reference: "+str(histname)) 2608 return self.data['Histograms'][histname] 2609 2524 2610 def clear_HAP_refinements(self, refs, histograms='all'): 2525 2611 """Clears the given HAP refinement parameters between this phase and -
trunk/exports/G2export_CIF.py
r3200 r3216 1962 1962 # +'\n'+FormatPhaseProfile(phasenam)) 1963 1963 if hist.startswith("PWDR"): 1964 histblk = self.Histograms[hist]["Sample Parameters"]1965 1964 WritePowderData(hist) 1966 1965 elif hist.startswith("HKLF"): … … 2382 2381 longFormatName = 'Export data as CIF' 2383 2382 ) 2383 if G2frame is None: raise AttributeError('CIF export requires data tree') # prevent use from Scriptable 2384 2384 self.exporttype = ['powder'] 2385 2385 # CIF-specific items
Note: See TracChangeset
for help on using the changeset viewer.