- Timestamp:
- Aug 11, 2017 12:16:08 PM (6 years ago)
- Location:
- branch/2frame
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branch/2frame/GSASIIpath.py
r2979 r2996 665 665 666 666 BinaryPathLoaded = False 667 def SetBinaryPath( ):667 def SetBinaryPath(printInfo=True): 668 668 ''' 669 669 Add location of GSAS-II shared libraries (binaries: .so or .pyd files) to path … … 710 710 if binpath: # were GSAS-II binaries found 711 711 sys.path.insert(0,binpath) 712 print('GSAS-II binary directory: {}'.format(binpath)) 712 if printInfo: 713 print('GSAS-II binary directory: {}'.format(binpath)) 713 714 BinaryPathLoaded = True 714 715 else: # try loading them 715 print('Attempting to download GSAS-II binary files...') 716 if printInfo: 717 print('Attempting to download GSAS-II binary files...') 716 718 try: 717 719 binpath = DownloadG2Binaries(g2home) 718 720 except AttributeError: # this happens when building in Read The Docs 719 print('Problem with download') 721 if printInfo: 722 print('Problem with download') 720 723 if binpath and TestSPG(binpath): 721 print('GSAS-II binary directory: {}'.format(binpath)) 724 if printInfo: 725 print('GSAS-II binary directory: {}'.format(binpath)) 722 726 sys.path.insert(0,binpath) 723 727 BinaryPathLoaded = True … … 754 758 if TestSPG(fpth): 755 759 sys.path.insert(0,binpath) 756 print('\n'+75*'*') 757 print(' Warning. Using an old-style GSAS-II binary library. This is unexpected') 758 print(' and will break in future GSAS-II versions. Please contact toby@anl.gov') 759 print(' so we can learn what is not working on your installation.') 760 print('GSAS-II binary directory: {}'.format(binpath)) 761 print(75*'*') 760 if printInfo: 761 print('\n'+75*'*') 762 print(' Warning. Using an old-style GSAS-II binary library. This is unexpected') 763 print(' and will break in future GSAS-II versions. Please contact toby@anl.gov') 764 print(' so we can learn what is not working on your installation.') 765 print('GSAS-II binary directory: {}'.format(binpath)) 766 print(75*'*') 762 767 break 763 768 else: … … 765 770 #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 766 771 #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 767 print(75*'*') 768 print('Use of GSAS-II binary directory {} failed!'.format(binpath)) 769 print(75*'*') 772 if printInfo: 773 print(75*'*') 774 print('Use of GSAS-II binary directory {} failed!'.format(binpath)) 775 print(75*'*') 770 776 raise Exception,"**** ERROR GSAS-II binary libraries not found, GSAS-II cannot run ****" 771 777 … … 783 789 import inspect 784 790 vals = [True for i in inspect.getmembers(config) if '__' not in i[0]] 785 print str(len(vals))+' values read from config file '+os.path.abspath(config.__file__) 791 if printInfo: 792 print str(len(vals))+' values read from config file '+os.path.abspath(config.__file__) 786 793 except ImportError: 787 794 configDict = {'Clip_on':True} 788 795 except Exception as err: 789 print("Error importing config.py file: "+str(err)) 796 if printInfo: 797 print("Error importing config.py file: "+str(err)) 790 798 configDict = {'Clip_on':True} 791 799 -
branch/2frame/GSASIIscriptable.py
r2984 r2996 34 34 35 35 import GSASIIpath 36 GSASIIpath.SetBinaryPath( ) # would rather have this in __name__ == '__main__' stanza36 GSASIIpath.SetBinaryPath(False) # would rather have this in __name__ == '__main__' stanza 37 37 import GSASIIIO as G2IO 38 38 import GSASIIfiles as G2fil … … 1162 1162 return self['data'][0]['ranId'] 1163 1163 1164 @property 1165 def residuals(self): 1166 data = self['data'][0] 1167 return {key: data[key] 1168 for key in ['R', 'Rb', 'wR', 'wRb', 'wRmin']} 1169 1164 1170 def fit_fixed_points(self): 1165 1171 """Attempts to apply a background fit to the fixed points currently specified.""" … … 1199 1205 1200 1206 # Some simple lookups 1207 controls = self.proj['Controls']['data'] 1201 1208 inst, inst2 = self['Instrument Parameters'] 1202 1209 pwddata = self['data'][1] … … 1215 1222 1216 1223 # Do the fit 1217 # TODO get controls from root1218 1224 data = np.array([xdata, ydata, W, Z, Z, Z]) 1219 1225 G2pwd.DoPeakFit('LSQ', [], bgrnd, limits, inst, inst2, data, 1220 bakVary, controls={})1226 prevVaryList=bakVary, controls=controls) 1221 1227 1222 1228 # Post-fit … … 1236 1242 return self['data'][1][3] 1237 1243 1238 def plot(self, Yobs=True, Ycalc=True, Background=True ):1244 def plot(self, Yobs=True, Ycalc=True, Background=True, Residual=True): 1239 1245 if plt: 1240 1246 data = self['data'][1] … … 1245 1251 if Background: 1246 1252 plt.plot(data[0], data[4], label='Background') 1253 if Residual: 1254 plt.plot(data[0], data[5], label="Residual") 1247 1255 1248 1256 def set_refinements(self, refs): … … 1310 1318 # are added 1311 1319 if do_fit_fixed_points: 1320 # Background won't be fit if refinement flag not set 1321 orig = self['Background'][0][1] 1322 self['Background'][0][1] = True 1312 1323 self.fit_fixed_points() 1324 # Restore the previous value 1325 self['Background'][0][1] = orig 1313 1326 1314 1327 def clear_refinements(self, refs): … … 1354 1367 def is_valid_refinement_key(key): 1355 1368 valid_keys = ["Cell", "Atoms", "LeBail"] 1369 return key in valid_keys 1370 1371 @staticmethod 1372 def is_valid_HAP_refinement_key(key): 1373 valid_keys = ["Babinet", "Extinction", "HStrain", "Mustrain", 1374 "Pref.Ori.", "Show", "Size", "Use", "Scale"] 1356 1375 return key in valid_keys 1357 1376
Note: See TracChangeset
for help on using the changeset viewer.