@@ -147,7 +147,7 @@ def makePdabcDict(pdabcString):
147147
148148 #create empty lists to hold values
149149 d = []
150- ToF = []
150+ TOF = []
151151 alp = []
152152 bet = []
153153 sig = []
@@ -158,15 +158,15 @@ def makePdabcDict(pdabcString):
158158 if len (entry ) != 5 :
159159 raise Exception ("Error interpreting pdabc entry in .instprm file. Entries must have exactly 5 comma separated values" )
160160 d .append (float (entry [0 ]))
161- ToF .append (float (entry [1 ]))
161+ TOF .append (float (entry [1 ]))
162162 alp .append (float (entry [2 ]))
163163 bet .append (float (entry [3 ]))
164164 sig .append (float (entry [4 ]))
165165 nPdabc += 1
166166
167167 pdabcDict = {
168168 "d" :d ,
169- "TOF" :ToF ,
169+ "TOF" :TOF ,
170170 "alp" :alp ,
171171 "bet" :bet ,
172172 "sig" :sig
@@ -304,15 +304,15 @@ def SetPowderInstParms(Iparm, rd):
304304 key = Ipab + ' '
305305 print ("looking for key: " , key )
306306 Npab = int (Iparm [Ipab + ' ' ].strip ())
307- Inst2 ['Pdabc ' ] = []
307+ Inst2 ['pdabc ' ] = []
308308 for i in range (Npab ):
309309 k = Ipab + str (i + 1 ).rjust (2 )
310310 s = Iparm [k ].split ()
311- Inst2 ['Pdabc ' ].append ([float (t ) for t in s ])
312- Inst2 ['Pdabc ' ] = np .array (Inst2 ['Pdabc ' ])
313- Inst2 ['Pdabc ' ].T [3 ] += Inst2 ['Pdabc ' ].T [0 ]* Inst1 ['difC' ][0 ] #turn 3rd col into TOF
311+ Inst2 ['pdabc ' ].append ([float (t ) for t in s ])
312+ Inst2 ['pdabc ' ] = np .array (Inst2 ['pdabc ' ])
313+ Inst2 ['pdabc ' ].T [3 ] += Inst2 ['pdabc ' ].T [0 ]* Inst1 ['difC' ][0 ] #turn 3rd col into TOF
314314
315- print (f"loaded resolution data with { Inst2 ['Pdabc ' ].shape } shape" )
315+ print (f"loaded resolution data with { Inst2 ['pdabc ' ].shape } shape" )
316316 if 'INS 1I ITYP' in Iparm :
317317 s = Iparm ['INS 1I ITYP' ].split ()
318318 Ityp = int (s [0 ])
@@ -367,7 +367,8 @@ def ReadInstprm(instLines, bank, Sample={}):
367367 determined by instrument settings or information
368368 from the instprm file are placed here.
369369 :returns: bank,instdict where bank is the sample parameter set
370- number and instdict is the instrument parameter dict
370+ number and instdict is a list containing the regular instrument parameter dict
371+ and the "extended" dict, currently only containing pdabc entries (if they exist)
371372
372373 Note if 'Type' is set as Debye-Scherrer or Bragg-Brentano this will be used and
373374 will set defaults in the sample parameters. Otherwise, a single-wavelength file
@@ -484,12 +485,13 @@ def ReadInstprm(instLines, bank, Sample={}):
484485
485486 return bank ,[makeInstDict (newItems , newVals , len (newVals )* [False ]), iparm1 ]
486487
487- def WriteInstprm (fp , InstPrm , Sample = {}, bank = None ):
488+ def WriteInstprm (fp , InstPrm , InstPrm1 , Sample = {}, bank = None ):
488489 '''Write the contents of a GSAS-II (new) .instprm instrument parameter file
489490 ToDo: use this inside G2frame.OnSave and G2frame.OnSaveAll
490491
491492 :param file fp: Pointer to open file to be written.
492493 :param dict InstPrm: Instrument parameters
494+ :param dict InstPrm1: "extended" instrument parameters
493495 :param dict Sample: Sample parameters (optional)
494496 :param int bank: Bank number. If not None (default), this causes
495497 a "#Bank" heading to be placed in the file before the
@@ -510,6 +512,28 @@ def WriteInstprm(fp, InstPrm, Sample={}, bank=None):
510512 for item in ('Gonio. radius' ,'InstrName' ):
511513 if not Sample .get (item ): continue
512514 fp .write (f"{ indent } { item } :{ Sample [item ]} \n " )
515+
516+ #handle pdabc entries.
517+ if InstPrm1 :
518+ if "pdabc" in InstPrm1 :
519+
520+ #extract lists from InstPrm1["pdabc"] dictionary
521+ d = InstPrm1 ["pdabc" ]["d" ]
522+ tof = InstPrm1 ["pdabc" ]["TOF" ]
523+ alp = InstPrm1 ["pdabc" ]["alp" ]
524+ bet = InstPrm1 ["pdabc" ]["bet" ]
525+ sig = InstPrm1 ["pdabc" ]["sig" ]
526+
527+ #build output string
528+ i = 0
529+ resString = f"pdabc:\" \" \" { d [i ]:.4f} , { tof [i ]:8.1f} , { alp [i ]:8.6f} , { bet [i ]:8.6f} , { sig [i ]:8.6f} \n "
530+ for i in range (1 ,len (d )- 1 ):
531+ resString += f"{ d [i ]:7.4f} , { tof [i ]:8.1f} , { alp [i ]:8.6f} , { bet [i ]:8.6f} , { sig [i ]:8.6f} \n "
532+
533+ resString += f"{ d [- 1 ]:7.4f} , { tof [- 1 ]:8.1f} , { alp [- 1 ]:8.6f} , { bet [- 1 ]:8.6f} , { sig [- 1 ]:8.6f} \" \" \" \n "
534+
535+ #write output string
536+ fp .write (resString )
513537
514538def LoadImportRoutines (prefix , errprefix = None , traceback = False ):
515539 '''Routine to locate GSASII importers matching a prefix string.
0 commit comments