 Timestamp:
 May 3, 2021 10:46:42 PM (5 months ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/GSASIIscriptable.py
r4880 r4901 1272 1272 import GSASIIfiles as G2fil 1273 1273 import GSASIIimage as G2img 1274 import GSASIIlattice as G2lat 1274 1275 1275 1276 # Delay imports to not slow down small scripts that don't need them … … 1548 1549 """ 1549 1550 1550 import GSASIIlattice as G2lat1551 1551 if len(cell) != 6: 1552 1552 raise G2ScriptException("GenerateReflections: Invalid unit cell:" + str(cell)) … … 1710 1710 Iparm1, Iparm2 = load_iprms(instprm, reader, bank=bank) 1711 1711 G2fil.G2Print('Instrument parameters read:',reader.instmsg) 1712 1713 if 'T' in Iparm1['Type'][0]: 1714 if not reader.clockWd and reader.GSAS: 1715 reader.powderdata[0] *= 100. #put back the CW centideg correction 1716 cw = np.diff(reader.powderdata[0]) 1717 reader.powderdata[0] = reader.powderdata[0][:1]+cw/2. 1718 if reader.GSAS: #NB: old GSAS wanted intensities*CW even if normalized! 1719 npts = min(len(reader.powderdata[0]),len(reader.powderdata[1]),len(cw)) 1720 reader.powderdata[1] = reader.powderdata[1][:npts]/cw[:npts] 1721 reader.powderdata[2] = reader.powderdata[2][:npts]*cw[:npts]**2 #1/var=w at this point 1722 else: #NB: from topas/fullprof type files 1723 reader.powderdata[1] = reader.powderdata[1][:1] 1724 reader.powderdata[2] = reader.powderdata[2][:1] 1725 if 'Itype' in Iparm2: 1726 Ibeg = np.searchsorted(reader.powderdata[0],Iparm2['Tminmax'][0]) 1727 Ifin = np.searchsorted(reader.powderdata[0],Iparm2['Tminmax'][1]) 1728 reader.powderdata[0] = reader.powderdata[0][Ibeg:Ifin] 1729 YI,WYI = G2pwd.calcIncident(Iparm2,reader.powderdata[0]) 1730 reader.powderdata[1] = reader.powderdata[1][Ibeg:Ifin]/YI 1731 var = 1./reader.powderdata[2][Ibeg:Ifin] 1732 var += WYI*reader.powderdata[1]**2 1733 var /= YI**2 1734 reader.powderdata[2] = 1./var 1735 reader.powderdata[1] = np.where(np.isinf(reader.powderdata[1]),0.,reader.powderdata[1]) 1736 reader.powderdata[3] = np.zeros_like(reader.powderdata[0]) 1737 reader.powderdata[4] = np.zeros_like(reader.powderdata[0]) 1738 reader.powderdata[5] = np.zeros_like(reader.powderdata[0]) 1739 1712 1740 Ymin = np.min(reader.powderdata[1]) 1713 1741 Ymax = np.max(reader.powderdata[1]) … … 1718 1746 'refOffset': 0.1*Ymax, 'refDelt': 0.1*Ymax, 1719 1747 'Yminmax': [Ymin, Ymax]} 1748 # apply usersupplied corrections to powder data 1749 if 'CorrectionCode' in Iparm1: 1750 print('Applying corrections from instprm file') 1751 corr = Iparm1['CorrectionCode'][0] 1752 try: 1753 exec(corr) 1754 print('done') 1755 except Exception as err: 1756 print(u'error: {}'.format(err)) 1757 print('with commands ') 1758 print(corr) 1759 print('') 1760 finally: 1761 del Iparm1['CorrectionCode'] 1720 1762 reader.Sample['ranId'] = valuesdict['ranId'] 1721 if 'T' in Iparm1['Type'][0]:1722 if not reader.clockWd and reader.GSAS:1723 reader.powderdata[0] *= 100. #put back the CW centideg correction1724 1763 1725 1764 # Ending keys: … … 1736 1775 Tmin = np.min(reader.powderdata[0]) 1737 1776 Tmax = np.max(reader.powderdata[0]) 1777 Tmin1 = Tmin 1778 if 'NT' in Iparm1['Type'][0] and G2lat.Pos2dsp(Iparm1,Tmin) < 0.4: 1779 Tmin1 = G2lat.Dsp2pos(Iparm1,0.4) 1738 1780 1739 1781 default_background = [['chebyschev1', False, 3, 1.0, 0.0, 0.0], … … 1742 1784 1743 1785 output_dict = {u'Reflection Lists': {}, 1744 u'Limits': reader.pwdparms.get('Limits', [(Tmin, Tmax), [Tmin , Tmax]]),1786 u'Limits': reader.pwdparms.get('Limits', [(Tmin, Tmax), [Tmin1, Tmax]]), 1745 1787 u'data': [valuesdict, reader.powderdata, HistName], 1746 1788 u'Index Peak List': [[], []], … … 4457 4499 See :ref:`PeakRefine` for an example. 4458 4500 ''' 4459 import GSASIIlattice as G2lat4460 4501 import GSASIImath as G2mth 4461 4502 if (not dspace) + (not Q) + (not ttheta) != 2: … … 4587 4628 :returns: name of file that was written 4588 4629 ''' 4589 import GSASIIlattice as G2lat4590 4630 import math 4591 4631 nptand = lambda x: np.tan(x*math.pi/180.) … … 4953 4993 """ 4954 4994 # translated from GSASIIstrIO.ExportBaseclass.GetCell 4955 import GSASIIlattice as G2lat4956 4995 import GSASIImapvars as G2mv 4957 4996 try: … … 5779 5818 sv[1] = insChar 5780 5819 return ':'.join(sv) 5781 import GSASIIlattice as G2lat5782 5820 import GSASIIstrIO as G2stIO 5783 5821
Note: See TracChangeset
for help on using the changeset viewer.