Package diffpy :: Package pdfgui :: Package control :: Module fitting :: Class Fitting
[hide private]
[frames] | no frames]

Class Fitting

source code

               object --+        
                        |        
pdfcomponent.PDFComponent --+    
                            |    
          organizer.Organizer --+
                                |
                               Fitting

Fitting is the class to control a PdfFit process, which can be either 
running on a remote machine or locally. Fitting will start a thread to 
interact with the PdfFit server using ssh2 and XMLRPC protocol. 

rw:         fitness parameter
tolerancy:  accurancy requirement
step:       current refinement step
res:        fitting result string
parameters: parameter dictionary



Nested Classes [hide private]
  Worker
Worker is the daemon thread of fitting
Instance Methods [hide private]
 
__init__(self, name)
initialize...
source code
 
__changeStatus(self, fitStatus=None, jobStatus=None)
change current status of fitting...
source code
 
_release(self)
release resources
source code
 
_getStrId(self)
make a string identifier...
source code
 
copy(self, other=None)
copy self to other.
source code
 
load(self, z, subpath)
load data from a zipped project file...
source code
 
save(self, z, subpath)
save data from a zipped project file...
source code
 
stripped(self)
Make a copy stripped of all unpickleable data members.
source code
 
updateParameters(self)
Update parameters dictionary from active constraints.
source code
 
applyParameters(self)
Evaluate all constrained variables using current parameters.
source code
 
changeParameterIndex(self, oldidx, newidx)
Change a parameter index to a new value.
source code
 
queue(self, enter=True)
queue or dequeue self...
source code
 
getServer(self)
get a PDFfit2 instance either locally or remotely...
source code
 
configure(self)
configure fitting
source code
 
resetStatus(self)
reset status back to initialized
source code
 
run(self)
function to be run in daemon thread.
source code
 
_configureBondCalculation(self, struc)
Prepare server for bond angle or bond length calculation.
source code
 
outputBondAngle(self, struc, i, j, k)
Output bond angle defined by atoms i, j, k.
source code
 
outputBondLengthAtoms(self, struc, i, j)
Output shortest bond between atoms i, j.
source code
 
outputBondLengthTypes(self, struc, a1, a2, lb, ub)
Output all a1-a2 bond lenghts within specified range.
source code
 
pause(self, bPause=None)
pause ( self, bPause = None ) --> pause a fitting process bPause -- True to pause, False to restart.
source code
 
start(self)
start fitting
source code
 
stop(self)
stop the fitting
source code
 
isThreadRunning(self)
check if fitting thread is running...
source code
 
join(self)
wait for current fitting to finish
source code
 
close(self, force=False)
close up the fitting in order to exit...
source code
 
buildNameDict(self)
build up a data name dictionary, which will map data name to a unique index The private dataNameDict has such strcture: { 'd_data1':{'Gobs':12, 'Gcalc':11, ....}, 'd_data2':{'Gobs':10, 'Gcalc':9, ....}, ...
source code
 
appendStep(self, source)
after a refinement step is done, append all data from self to the ...
source code
 
refine_step(self)
Run a single step of the fit.
source code
 
getYNames(self)
get names of data item which can be plotted as y...
source code
 
getXNames(self)
get names of data item which can be plotted as x...
source code
 
getData(self, name, step=-1)
get self's data member...
source code
 
getMetaDataNames(self)
return all applicable meta data names...
source code
 
getMetaData(self, name)
get meta data value...
source code
 
_getData(self, id, name, step=-1)
get any data member from snapshots...
source code

Inherited from organizer.Organizer: add, getCalculation, getDataSet, getStructure, hasCalculations, hasDataSets, hasStructures, index, organization, remove, rename

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Variables [hide private]
  INITIALIZED = 1
  CONNECTED = 2
  CONFIGURED = 4
  DONE = 8
  VOID = 256
  QUEUED = 512
  RUNNING = 1024
  PAUSED = 2048
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, name)
(Constructor)

source code 
initialize

name -- name of this fitting

Overrides: organizer.Organizer.__init__

__changeStatus(self, fitStatus=None, jobStatus=None)

source code 
change current status of fitting

fitStatus -- new  fitting status
jobStatus -- new thread status

_getStrId(self)

source code 
make a string identifier

return value: string id

copy(self, other=None)

source code 
copy self to other. if other is None, create an instance

other -- ref to other object
return value: reference to copied object

Overrides: organizer.Organizer.copy

load(self, z, subpath)

source code 
load data from a zipped project file

z -- zipped project file
subpath -- path to its own storage within project file

returns a tree of internal hierachy

Overrides: organizer.Organizer.load

save(self, z, subpath)

source code 
save data from a zipped project file

z       -- zipped project file
subpath -- path to its own storage within project file

Overrides: organizer.Organizer.save

stripped(self)

source code 
Make a copy stripped of all unpickleable data members.
The copy should be suitable for pickling and has the
following data members removed:
    controlCenter, lock, pauseEvent, thread

returns reference to stripped copy

updateParameters(self)

source code 
Update parameters dictionary from active constraints.

returns self.parameters

changeParameterIndex(self, oldidx, newidx)

source code 
Change a parameter index to a new value.

This will replace all instances of one parameter name with another in
the containing fit.

queue(self, enter=True)

source code 
queue or dequeue self

enter -- True to queue, False to dequeue

getServer(self)

source code 
get a PDFfit2 instance either locally or remotely
        

_configureBondCalculation(self, struc)

source code 
Prepare server for bond angle or bond length calculation.

struc   -- instance of PDFStructure

No return value.

outputBondAngle(self, struc, i, j, k)

source code 
Output bond angle defined by atoms i, j, k.
The angle is calculated using the shortest lengths ji and jk with
respect to periodic boundary conditions.

struc   -- instance of PDFStructure
i, j, k -- atom indices starting at 1

No return value.  The result should be automatically added to
the Output Window, because all server output is sent there.

Raise ControlValueError for invalid indices i, j, k.

outputBondLengthAtoms(self, struc, i, j)

source code 
Output shortest bond between atoms i, j.
Periodic boundary conditions are applied to find the shortest bond.

struc   -- instance of PDFStructure
i, j    -- atom indices starting at 1

No return value.  The result should be automatically added to
the Output Window, because all server output is sent there.

Raise ControlValueError for invalid indices i, j.

outputBondLengthTypes(self, struc, a1, a2, lb, ub)

source code 
Output all a1-a2 bond lenghts within specified range.

struc  -- instance of PDFStructure
a1     -- symbol of the first element in pair or "ALL"
a2     -- symbol of the second element in pair or "ALL"
lb     -- lower bond length boundary
ub     -- upper bond length boundary

No return value.  The result should be automatically added to
the Output Window, because all server output is sent there.

Raise ControlValueError for invalid element symbols.

pause(self, bPause=None)

source code 
pause ( self, bPause = None ) --> pause a fitting process

bPause -- True to pause, False to restart. If None, it will figure out 
        by itself.

isThreadRunning(self)

source code 
check if fitting thread is running

return: True if running, False otherwise

close(self, force=False)

source code 
close up the fitting in order to exit

force -- if force to exit

Overrides: pdfcomponent.PDFComponent.close

buildNameDict(self)

source code 
build up a data name dictionary, which will map data name to a
unique index

The private dataNameDict has such strcture:
{ 'd_data1':{'Gobs':12, 'Gcalc':11, ....},
  'd_data2':{'Gobs':10, 'Gcalc':9, ....},
  ...
  'p_ph1':{'lat(1)':1,'lat(2)':2, .....},
  'p_ph1':{'lat(1)':3,'lat(2)':4, .....},
  ...
  'f_fit':{'rw':100, 1:101, 2:102}
}

The value of each sub-dict is the corresponding index of this data
item in the snapshot.
The prefix d_ p_ f_ make dataset,struc,fitname unique within the 
shared name space of dictionary

appendStep(self, source)

source code 
after a refinement step is done, append all data from self to the 
historical storage, i.e., self.snapshots        

source -- where to get the fitted data, in deed it's a PdfFit2 instance

refine_step(self)

source code 
Run a single step of the fit.

return value: True if refinement is finished, otherwise False 

getYNames(self)

source code 
get names of data item which can be plotted as y

returns a name str list

getXNames(self)

source code 
get names of data item which can be plotted as x

returns a name str list

getData(self, name, step=-1)

source code 
get self's data member

name -- data item name
step -- step info, it can be:
        (1) a number ( -1 means latest step ): for single step
        (2) a list of numbers: for multiple steps
        (3) None: for all steps

returns data object, be it a single number, a list, or a list of list

getMetaDataNames(self)

source code 
return all applicable meta data names
        

getMetaData(self, name)

source code 
get meta data value

name -- meta data name
returns meta data value

_getData(self, id, name, step=-1)

source code 
get any data member from snapshots

id   -- reference to a Fitting/Calculation/Phase/DataSet object
name -- data item name
step -- step info, it can be:
        (1) a number ( -1 means latest step ): for single step
        (2) a list of numbers: for multiple steps
        (3) None: for all steps

returns data object, be it a single number, a list, or a list of list