@@ -1615,42 +1615,43 @@ def GetDefaultParms(self,rd):
16151615 #1st priority: is there an instrument parameter file matching the current file
16161616 # with extension .instprm, .prm, .inst, or .ins? If so read it
16171617 basename = os .path .splitext (filename )[0 ]
1618- #-- look for an instrument file matching the name of the data file -------------
1619- print ('looking for default instrument parameter file named\n \t ' ,
1620- os .path .split (basename )[1 ],
1621- 'with extensions .prm, .inst, .ins or .instprm' )
1622- for ext in '.prm' ,'.inst' ,'.ins' ,'.instprm' :
1623- if self .zipfile :
1624- instfile = G2G .ExtractFileFromZip (self .zipfile ,
1625- selection = os .path .split (basename + ext )[1 ],parent = self )
1626- if instfile == None :
1627- continue
1628- print (f'created { instfile } from { self .zipfile } ' )
1629- self .cleanupList .append (instfile )
1630- else :
1631- instfile = basename + ext
1632- if not os .path .exists (instfile ):
1633- continue
1634- if 'instprm' in instfile :
1635- Lines = self .OpenPowderInstprm (instfile )
1636- instParmList = self .ReadPowderInstprm (Lines ,bank ,rd ) #this is [Inst1,Inst2] a pair of dicts
1637- if 'list' in str (type (instParmList )):
1638- rd .instfile = instfile
1639- rd .instmsg = 'GSAS-II file ' + instfile
1640- return instParmList
1618+ if basename :
1619+ #-- look for an instrument file matching the name of the data file -------------
1620+ print ('looking for default instrument parameter file named\n \t ' ,
1621+ os .path .split (basename )[1 ],
1622+ 'with extensions .prm, .inst, .ins or .instprm' )
1623+ for ext in '.prm' ,'.inst' ,'.ins' ,'.instprm' :
1624+ if self .zipfile :
1625+ instfile = G2G .ExtractFileFromZip (self .zipfile ,
1626+ selection = os .path .split (basename + ext )[1 ],parent = self )
1627+ if instfile == None :
1628+ continue
1629+ print (f'created { instfile } from { self .zipfile } ' )
1630+ self .cleanupList .append (instfile )
16411631 else :
1642- #print 'debug: open/read failed',instfile
1643- pass # fail silently
1644- else :
1645- Iparm = self .ReadPowderIparm (instfile ,bank ,numbanks ,rd )
1646- if Iparm :
1647- #print 'debug: success'
1648- rd .instfile = instfile
1649- rd .instmsg = instfile + ' bank ' + str (rd .instbank )
1650- return G2fil .SetPowderInstParms (Iparm ,rd )
1632+ instfile = basename + ext
1633+ if not os .path .exists (instfile ):
1634+ continue
1635+ if 'instprm' in instfile :
1636+ Lines = self .OpenPowderInstprm (instfile )
1637+ instParmList = self .ReadPowderInstprm (Lines ,bank ,rd ) #this is [Inst1,Inst2] a pair of dicts
1638+ if 'list' in str (type (instParmList )):
1639+ rd .instfile = instfile
1640+ rd .instmsg = 'GSAS-II file ' + instfile
1641+ return instParmList
1642+ else :
1643+ #print 'debug: open/read failed',instfile
1644+ pass # fail silently
16511645 else :
1652- #print 'debug: open/read failed',instfile
1653- pass # fail silently
1646+ Iparm = self .ReadPowderIparm (instfile ,bank ,numbanks ,rd )
1647+ if Iparm :
1648+ #print 'debug: success'
1649+ rd .instfile = instfile
1650+ rd .instmsg = instfile + ' bank ' + str (rd .instbank )
1651+ return G2fil .SetPowderInstParms (Iparm ,rd )
1652+ else :
1653+ #print 'debug: open/read failed',instfile
1654+ pass # fail silently
16541655
16551656 #-- look for an instrument file matching the name of the data file -------------
16561657 # 2nd choice: is there an instrument parameter file defined in the
@@ -2023,7 +2024,7 @@ def OnDummyPowder(self,event):
20232024 return
20242025 Iparm1 , Iparm2 = Iparm
20252026 if 'T' in Iparm1 ['Type' ][0 ]:
2026- rd .idstring = ' TOF neutron simulation'
2027+ rd .idstring = 'TOF neutron simulation'
20272028 simType = 'TOF'
20282029 else :
20292030 # need to get name, 2theta start, end, step
@@ -2044,28 +2045,25 @@ def OnDummyPowder(self,event):
20442045 N = 0
20452046 while (N < 3 ): # insist on a dataset with a few points
20462047 if 'TOF' in rd .idstring :
2047- names = ('dataset name' , 'start TOF (ms)' , 'end TOF (ms)' , 'DT/T' )
2048+ names = ('dataset name' , 'T start (ms)' , 'T end (ms)' , 'DT/T' )
20482049 inp = [rd .idstring , 10. ,80. ,0.0005 ] # see names for what's what
2049- dlg = G2G .ScrolledMultiEditor (
2050- self ,[inp ] * len (inp ),range (len (inp )),names ,
2051- header = 'Enter simulation name and range' ,
2052- minvals = (None ,.5 ,1.0 ,0.0001 ),
2053- maxvals = (None ,500. ,500. ,.01 ),
2054- sizevals = ((225 ,- 1 ),)
2055- )
2050+ minvals = (None ,.5 ,1.0 ,0.0001 )
2051+ maxvals = (None ,500. ,500. ,.01 )
20562052 else :
20572053 names = ('dataset name' , 'start angle' , 'end angle' , 'step size' )
20582054 if not wave or wave < 1.0 :
20592055 inp = [rd .idstring , 10. ,40. ,0.005 ] # see names for what's what
20602056 else :
20612057 inp = [rd .idstring , 10. ,80. ,0.01 ] # see names for what's what
2062- dlg = G2G .ScrolledMultiEditor (
2063- self ,[inp ] * len (inp ),range (len (inp )),names ,
2064- header = 'Enter simulation name and range' ,
2065- minvals = (None ,0.001 ,0.001 ,0.0001 ),
2066- maxvals = (None ,180. ,180. ,.1 ),
2067- sizevals = ((225 ,- 1 ),)
2068- )
2058+ minvals = (None ,0.001 ,0.001 ,0.0001 ),
2059+ maxvals = (None ,180. ,180. ,.1 ),
2060+ dlg = G2G .ScrolledMultiEditor (
2061+ self ,[inp ] * len (inp ),range (len (inp )),names ,
2062+ header = 'Enter ramnge for simulation and histogram name' ,
2063+ minvals = minvals ,
2064+ maxvals = maxvals ,
2065+ sizevals = ((250 ,- 1 ),None ,None ,None ),
2066+ size = (400 ,150 ))
20692067 dlg .CenterOnParent ()
20702068 if dlg .ShowModal () == wx .ID_OK :
20712069 if inp [1 ] > inp [2 ]:
@@ -2075,11 +2073,14 @@ def OnDummyPowder(self,event):
20752073 step = abs (step )
20762074 else :
20772075 return False
2076+ # TODO: compute if the range and see if the widths are all
2077+ # positive here. If OK continue, otherwise warn and reject the
2078+ # limits (as per issue #170)
20782079 if 'TOF' in rd .idstring :
20792080 N = (np .log (end )- np .log (start ))/ step
20802081 x = np .exp ((np .arange (0 ,N ))* step + np .log (start * 1000. ))
20812082 N = len (x )
2082- rd .Sample ['Scale' ][0 ] = 5000. # default is way too low for "counts"
2083+ rd .Sample ['Scale' ][0 ] = 5000. # default (1) is way too low for "counts"
20832084 else :
20842085 N = int ((end - start )/ step )+ 1
20852086 x = np .linspace (start ,end ,N ,True )
0 commit comments