Changeset 3995


Ignore:
Timestamp:
May 24, 2019 2:11:36 PM (3 years ago)
Author:
vondreele
Message:

Add save of indexed peaks to csv file
fix neutron bugs in MEM Dysnomia code

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIdataGUI.py

    r3990 r3995  
    52735273       
    52745274        # PDR / Index Peak List
    5275         G2G.Define_wxId('wxID_INDXRELOAD',)
     5275        G2G.Define_wxId('wxID_INDXRELOAD','wxID_INDEXSAVE',)
    52765276        self.IndPeaksMenu = wx.MenuBar()
    52775277        self.PrefillDataMenu(self.IndPeaksMenu)
    52785278        self.IndPeaksEdit = wx.Menu(title='')
    52795279        self.IndPeaksMenu.Append(menu=self.IndPeaksEdit,title='Operations')
    5280         self.IndPeaksEdit.Append(G2G.wxID_INDXRELOAD,'Load/Reload','Load/Reload index peaks from peak list')
     5280        self.IndPeaksEdit.Append(G2G.wxID_INDXRELOAD,'Load/Reload','Load/Reload index peaks from peak list')
     5281        self.IndPeaksEdit.Append(G2G.wxID_INDEXSAVE,'Save','Save index peaks to CSV file')
    52815282        self.PostfillDataMenu()
    52825283       
  • trunk/GSASIIphsGUI.py

    r3994 r3995  
    42134213    def OnRunDysnomia(event):
    42144214       
     4215        path2GSAS2 = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
     4216        DYSNOMIA = os.path.join(path2GSAS2,'Dysnomia','Dysnomia64.exe')
     4217       
     4218        if not os.path.exists(DYSNOMIA):
     4219            wx.MessageBox(''' Dysnomia is not installed. Please download it from
     4220    https://jp-minerals.org/dysnomia/en/
     4221    and install it at.'''+DYSNOMIA,
     4222                caption='Dysnomia not installed',style=wx.ICON_ERROR)
     4223            return
     4224
    42154225        generalData = data['General']
    42164226        Map = generalData['Map']
     
    42324242            for el in generalData['Isotope']:
    42334243                isotope = generalData['Isotope'][el]
     4244                if el not in generalData['Isotopes']:
     4245                    continue
    42344246                if generalData['Isotopes'][el][isotope]['SL'][0] < 0.:
    42354247                    MEMtype = 1
    42364248        prfName = str(G2pwd.makePRFfile(data,MEMtype))
    4237         if not G2pwd.makeMEMfile(data,reflData,MEMtype):
     4249        if not G2pwd.makeMEMfile(data,reflData,MEMtype,DYSNOMIA):
    42384250            SpGrp = generalData['SGData']['SpGrp']
    42394251            wx.MessageBox('Non standard space group '+SpGrp+' not permitted in Dysnomia','Dysnomia Error',
     
    42414253            return
    42424254
    4243         path2GSAS2 = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
    4244         DYSNOMIA = os.path.join(path2GSAS2,'Dysnomia','Dysnomia64.exe')
    4245        
    4246         if not os.path.exists(DYSNOMIA):
    4247             wx.MessageBox(''' Dysnomia is not installed. Please download it from
    4248     https://jp-minerals.org/dysnomia/en/
    4249     and install it at.'''+DYSNOMIA,
    4250                 caption='Dysnomia not installed',style=wx.ICON_ERROR)
    4251             return
    42524255
    42534256        wx.MessageBox(''' For use of Dysnomia, please cite:
     
    42584261       
    42594262        print('Run '+DYSNOMIA)       
    4260         subp.run([DYSNOMIA,prfName],startupinfo=subp.CREATE_NEW_PROCESS_GROUP)
     4263        subp.call([DYSNOMIA,prfName],startupinfo=subp.CREATE_NEW_PROCESS_GROUP)
    42614264       
    42624265        if G2pwd.MEMupdateReflData(prfName,reflData):
  • trunk/GSASIIpwd.py

    r3994 r3995  
    28642864    return prfName
    28652865
    2866 def makeMEMfile(data,reflData,MEMtype):
     2866def makeMEMfile(data,reflData,MEMtype,DYSNOMIA):
    28672867    ''' make Dysnomia .mem file of reflection data, etc.
    28682868    ;param dict data: GSAS-II phase data
     
    28702870    :param int MEMtype: 1 for neutron data with negative scattering lengths
    28712871                        0 otherwise
     2872    :param str:DYSNOMIA path to dysnomia.exe
    28722873    '''
    28732874   
     
    29122913        mem.write('%10.3f%10.3f 0.001\n'%(sumpos,sumneg))
    29132914    else:
    2914         mem.write('%10.3 0.001\n'%sumpos)
     2915        mem.write('%10.3f 0.001\n'%sumpos)
    29152916       
    29162917    refs = []
     
    29622963        Fobs = np.sqrt(ref[6])
    29632964        mem.write('%5d%5d%5d%10.3f%10.3f%10.3f\n'%(h,k,l,Fobs*npcosd(ref[7]),Fobs*npsind(ref[7]),max(0.01*Fobs,0.1)))
     2965    while True:
     2966        if not len(refs2[-1]):
     2967            del refs2[-1]
     2968        else:
     2969            break
    29642970    mem.write('%5d\n'%len(refs2))
    2965     for ref2 in refs2:
    2966         if not len(ref2):
    2967             break
     2971    for iref2,ref2 in enumerate(refs2):
     2972        mem.write('#%5d\n'%iref2)
    29682973        mem.write('%5d\n'%len(ref2))
    29692974        Gsum = 0.
  • trunk/GSASIIpwdGUI.py

    r3981 r3995  
    29022902        UpdateIndexPeaksGrid(G2frame,data)
    29032903       
     2904    def OnSave(event):
     2905        pth = G2G.GetExportPath(G2frame)
     2906        dlg = wx.FileDialog(G2frame, 'Choose Index peaks csv file', pth, '',
     2907            'indexing peaks file (*.csv)|*.csv',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT)
     2908        try:
     2909            if dlg.ShowModal() == wx.ID_OK:
     2910                filename = dlg.GetPath()
     2911                filename = os.path.splitext(filename)[0]+'.csv'
     2912                File = open(filename,'w')
     2913                names = 'h,k,l,position,intensity,d-Obs,d-calc\n'
     2914                File.write(names)
     2915                fmt = '%d,%d,%d,%.4f,%.1f,%.5f,%.5f\n'
     2916                for refl in data[0]:
     2917                    if refl[3]:
     2918                        File.write(fmt%(refl[4],refl[5],refl[6],refl[0],refl[1],refl[7],refl[8]))
     2919                File.close()
     2920        finally:
     2921            dlg.Destroy()
     2922       
    29042923    def KeyEditPickGrid(event):
    29052924        colList = G2frame.indxPeaks.GetSelectedCols()
     
    29262945        G2gd.SetDataMenuBar(G2frame,G2frame.dataWindow.IndPeaksMenu)
    29272946        G2frame.Bind(wx.EVT_MENU, OnReload, id=G2G.wxID_INDXRELOAD)
     2947        G2frame.Bind(wx.EVT_MENU, OnSave, id=G2G.wxID_INDEXSAVE)
    29282948    G2frame.dataWindow.IndexPeaks.Enable(False)
    29292949    G2frame.IndexPeaksTable = []
Note: See TracChangeset for help on using the changeset viewer.