Changeset 3415 for trunk/testDeriv.py


Ignore:
Timestamp:
May 31, 2018 3:47:44 PM (3 years ago)
Author:
vondreele
Message:

change testDeriv.py so it can be run in a bat file.
mag moment derivatives now close to correct & are workable

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/testDeriv.py

    r3369 r3415  
    2222
    2323import sys
     24import os
    2425import platform
    2526if '2' in platform.python_version_tuple()[0]:
     
    6970        self.testDerivPanel = wx.ScrolledWindow(self)       
    7071        self.plotNB = plot.PlotNotebook()
     72        self.testFile = ''
     73        arg = sys.argv
     74        if len(arg) > 1 and arg[1]:
     75            try:
     76                self.testFile = os.path.splitext(arg[1])[0]+u'.testDeriv'
     77            except:
     78                self.testFile = os.path.splitext(arg[1])[0]+'.testDeriv'
     79            self.TestRead()
     80            self.UpdateControls(None)
    7181       
    7282    def __init__(self, parent):
     
    94104            if dlg.ShowModal() == wx.ID_OK:
    95105                self.dirname = dlg.GetDirectory()
    96                 testFile = dlg.GetPath()
    97                 file = open(testFile,'rb')
    98                 if '2' in platform.python_version_tuple()[0]:
    99                     self.values = cPickle.load(file)
    100                     self.HistoPhases = cPickle.load(file)
    101                     (self.constrDict,self.fixedList,self.depVarList) = cPickle.load(file)
    102                     self.parmDict = cPickle.load(file)
    103                     self.varylist = cPickle.load(file)
    104                     self.calcControls = cPickle.load(file)
    105                     self.pawleyLookup = cPickle.load(file)
    106                 else:
    107                     self.values = cPickle.load(file,encoding='Latin-1')
    108                     self.HistoPhases = cPickle.load(file,encoding='Latin-1')
    109                     (self.constrDict,self.fixedList,self.depVarList) = cPickle.load(file,encoding='Latin-1')
    110                     self.parmDict = cPickle.load(file,encoding='Latin-1')
    111                     self.varylist = cPickle.load(file,encoding='Latin-1')
    112                     self.calcControls = cPickle.load(file,encoding='Latin-1')
    113                     self.pawleyLookup = cPickle.load(file,encoding='Latin-1')
    114                 self.use = [False for i in range(len(self.varylist+self.depVarList))]
    115                 self.delt = [max(abs(self.parmDict[name])*0.0001,1e-6) for name in self.varylist+self.depVarList]
    116                 file.close()
    117                 groups,parmlist = G2mv.GroupConstraints(self.constrDict)
    118                 G2mv.GenerateConstraints(groups,parmlist,self.varylist,self.constrDict,self.fixedList,self.parmDict)
     106                self.testFile = dlg.GetPath()
     107                self.TestRead()
    119108                self.UpdateControls(event)
    120                 print(G2mv.VarRemapShow(self.varylist))
    121                 print('Dependent Vary List:',self.depVarList)
    122109        finally:
    123110            dlg.Destroy()
     111           
     112    def TestRead(self):
     113        file = open(self.testFile,'rb')
     114        if '2' in platform.python_version_tuple()[0]:
     115            self.values = cPickle.load(file)
     116            self.HistoPhases = cPickle.load(file)
     117            (self.constrDict,self.fixedList,self.depVarList) = cPickle.load(file)
     118            self.parmDict = cPickle.load(file)
     119            self.varylist = cPickle.load(file)
     120            self.calcControls = cPickle.load(file)
     121            self.pawleyLookup = cPickle.load(file)
     122        else:
     123            self.values = cPickle.load(file,encoding='Latin-1')
     124            self.HistoPhases = cPickle.load(file,encoding='Latin-1')
     125            (self.constrDict,self.fixedList,self.depVarList) = cPickle.load(file,encoding='Latin-1')
     126            self.parmDict = cPickle.load(file,encoding='Latin-1')
     127            self.varylist = cPickle.load(file,encoding='Latin-1')
     128            self.calcControls = cPickle.load(file,encoding='Latin-1')
     129            self.pawleyLookup = cPickle.load(file,encoding='Latin-1')
     130        self.use = [False for i in range(len(self.varylist+self.depVarList))]
     131        self.delt = [max(abs(self.parmDict[name])*0.0001,1e-6) for name in self.varylist+self.depVarList]
     132        file.close()
     133        groups,parmlist = G2mv.GroupConstraints(self.constrDict)
     134        G2mv.GenerateConstraints(groups,parmlist,self.varylist,self.constrDict,self.fixedList,self.parmDict)
     135        print(G2mv.VarRemapShow(self.varylist))
     136        print('Dependent Vary List:',self.depVarList)
    124137           
    125138    def UpdateControls(self,event):
Note: See TracChangeset for help on using the changeset viewer.