Package diffpy :: Package pdfgui :: Package control :: Module fitstructure :: Class FitStructure
[hide private]
[frames] | no frames]

Class FitStructure

source code

                               object --+        
                                        |        
                pdfcomponent.PDFComponent --+    
                                            |    
                       object --+           |    
                                |           |    
                             list --+       |    
                                    |       |    
        Structure.structure.Structure --+   |    
                                        |   |    
Structure.pdffitstructure.PDFFitStructure --+    
                                            |    
                    pdfstructure.PDFStructure --+
                                                |
                                               FitStructure

FitStructure holds initial and refined structure and related fit
parameters.  Inherited from PDFStructure.

Class data members:
    symposeps   -- tolerance for recognizing site as symmetry position

Data members (in adition to those in PDFStructure):
    owner       -- instance of parent Fitting (set in Organizer.add())
    initial     -- initial structure, same as self
    refined     -- refined structure when available or None
    constraints -- dictionary of { refvar_string : Constraint_instance }
    selected_pairs -- string of selected pairs, by default "all-all".
                   Use setSelectedPairs() and getSelectedPairs() methods
                   to access its value.
    custom_spacegroup -- instance of SpaceGroup which has no equivalent
                   in diffpy.Structure.SpaceGroups module.  This can happen
                   after reading from a CIF file.  When equivalent space
                   group exists, custom_spacegroup is None.

Refinable variables:  pscale, spdiameter, delta1, delta2, sratio, lat(n),
    where n=1..6,  x(i), y(i), z(i), occ(i), u11(i), u22(i), u33(i),
    u12(i), u13(i), u23(i), where i=1..Natoms

Non-refinable variable:  rcut, stepcut



Instance Methods [hide private]
 
__init__(self, name, *args, **kwargs)
Initialize FitDataSet.
source code
 
_update_custom_spacegroup(self, parser)
Helper method for read() and readStr(), which takes care of setting custom_spacegroup after successful reading.
source code
 
read(self, filename, format='auto')
Load structure from a file, raise ControlFileError for invalid or unknown structure format.
source code
 
readStr(self, s, format='auto')
Same as PDFStructure.readStr, but handle the custom_spacegroup data.
source code
 
__getattr__(self, name)
Map self.initial to self.
source code
 
_getStrId(self)
make a string identifier...
source code
 
clearRefined(self)
Clear all refinement results.
source code
 
obtainRefined(self, server, iphase)
Upload refined phase from PdfFit server instance.
source code
 
findParameters(self)
Obtain dictionary of parameters used by self.constraints.
source code
 
applyParameters(self, parameters)
Evaluate constraint formulas and adjust initial PDFStructure.
source code
 
changeParameterIndex(self, oldidx, newidx)
Change a parameter index to a new value.
source code
 
_popAtomConstraints(self)
Take out atom-related items from the constraints dictionary.
source code
 
_restoreAtomConstraints(self, acd)
Restore self.constraints from atom constraints dictionary.
source code
 
insertAtoms(self, index, atomlist)
Insert list of atoms before index and adjust self.constraints.
source code
 
deleteAtoms(self, indices)
Removed atoms at given indices and adjust self.constraints.
source code
 
expandSuperCell(self, mno)
Perform supercell expansion for this structure and adjust constraints for positions and lattice parameters.
source code
 
isSpaceGroupPossible(self, spacegroup)
Check if space group is consistent with lattice parameters.
source code
 
getSpaceGroupList(self)
Return a list of SpaceGroup instances sorted by International Tables number.
source code
 
getSpaceGroup(self, sgname)
Find space group in getSpaceGroupList() by short_name or number.
source code
 
expandAsymmetricUnit(self, spacegroup, indices, sgoffset=[0, 0, 0])
Perform symmetry expansion for atoms at given indices.
source code
 
applySymmetryConstraints(self, spacegroup, indices, posflag, Uijflag, sgoffset=[0, 0, 0])
Generate symmetry constraints for positions and thermal factors.
source code
 
setSelectedPairs(self, s)
Set the value of selected_pairs to s, raise ControlValueError when s has invalid syntax.
source code
 
getSelectedPairs(self) source code
 
getPairSelectionFlags(self, s=None)
Translate string s to a list of allowed values for first and second pair index.
source code
 
applyPairSelection(self, server, phaseidx)
Apply pair selection for calculations of partial PDF.
source code
 
copy(self, other=None)
copy self to other.
source code
 
load(self, z, subpath)
Load structure from a zipped project file.
source code
 
save(self, z, subpath)
Save structure to a zipped project file.
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

Inherited from pdfstructure.PDFStructure: getvar, setvar

Inherited from pdfcomponent.PDFComponent: close

Inherited from Structure.structure.Structure: __setitem__, __setslice__, __str__, addNewAtom, angle, append, distance, extend, getAtom, getLabels, getLastAtom, insert, placeInLattice, write, writeStr

Inherited from Structure.structure.Structure (private): _get_lattice, _set_lattice, _uncache, _update_labels

Inherited from list: __add__, __contains__, __delitem__, __delslice__, __eq__, __ge__, __getattribute__, __getitem__, __getslice__, __gt__, __hash__, __iadd__, __imul__, __iter__, __le__, __len__, __lt__, __mul__, __ne__, __new__, __repr__, __reversed__, __rmul__, count, index, pop, remove, reverse, sort

Inherited from object: __delattr__, __reduce__, __reduce_ex__, __setattr__

Class Variables [hide private]
  symposeps = 0.001
  sorted_standard_space_groups = []
Properties [hide private]

Inherited from Structure.structure.Structure: lattice

Inherited from object: __class__

Method Details [hide private]

__init__(self, name, *args, **kwargs)
(Constructor)

source code 
Initialize FitDataSet.

name         -- name of the data set.  The same name is used for
                self.initial and self.final.
args, kwargs -- optional arguments passed to parent PDFStructure

Overrides: pdfstructure.PDFStructure.__init__

_update_custom_spacegroup(self, parser)

source code 
Helper method for read() and readStr(), which takes care
of setting custom_spacegroup after successful reading.

parser -- instance of StructureParser used in reading.

No return value.

read(self, filename, format='auto')

source code 
Load structure from a file, raise ControlFileError for invalid
or unknown structure format.  Overloads PDFStructure.read()
to handle custom_spacegroup attribute.

filename -- file to be loaded
format   -- structure format such as 'pdffit', 'pdb', 'xyz'.  When
            'auto' all available formats are tried in a row.

Return instance of StructureParser used to load the data.
See Structure.read() for more info.

Overrides: pdfstructure.PDFStructure.read

readStr(self, s, format='auto')

source code 
Same as PDFStructure.readStr, but handle the
custom_spacegroup data.

Return instance of StructureParser used to load the data.
See Structure.readStr() for more info.

Overrides: Structure.pdffitstructure.PDFFitStructure.readStr

__getattr__(self, name)
(Qualification operator)

source code 
Map self.initial to self.
This is called only when normal attribute lookup fails.

_getStrId(self)

source code 
make a string identifier

return value: string id

obtainRefined(self, server, iphase)

source code 
Upload refined phase from PdfFit server instance.

server -- instance of PdfFit server
iphase -- index of this phase in server

findParameters(self)

source code 
Obtain dictionary of parameters used by self.constraints.
The keys of returned dictionary are integer parameter indices, and
the values are Parameter instances, with guessed initial values.

returns dictionary of indices and Parameter instances

applyParameters(self, parameters)

source code 
Evaluate constraint formulas and adjust initial PDFStructure.

parameters -- dictionary of parameter indices with Parameter
              instance values.  Values may also be float type.

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
this fit.

_popAtomConstraints(self)

source code 
Take out atom-related items from the constraints dictionary.

This is useful when atom indices are going to change due to
insertion or removal of atoms.  See also _restoreAtomConstraints().

Return a dictionary of atom instances vs dictionary of related
refinable variables (stripped of "(siteindex)") and Constraint
instances - for example {atom : {'u13' : constraint}}.

_restoreAtomConstraints(self, acd)

source code 
Restore self.constraints from atom constraints dictionary.  This
is useful for getting correct atom indices into refvar strings.
See also _popAtomConstraints()

acd -- dictionary obtained from _popAtomConstraints()

insertAtoms(self, index, atomlist)

source code 
Insert list of atoms before index and adjust self.constraints.

index    -- position in the initial structure, atoms are appended
            when larger than len(self.initial).
atomlist -- list of atom instances.

deleteAtoms(self, indices)

source code 
Removed atoms at given indices and adjust self.constraints.

indices -- list of integer indices of atoms to be deleted

expandSuperCell(self, mno)

source code 
Perform supercell expansion for this structure and adjust
constraints for positions and lattice parameters.  New lattice
parameters are multiplied and fractional coordinates divided by
corresponding multiplier.  New atoms are grouped with their source
in the original cell.

mno -- tuple or list of three positive integer cell multipliers along
the a, b, c axis

isSpaceGroupPossible(self, spacegroup)

source code 
Check if space group is consistent with lattice parameters.

spacegroup -- instance of SpaceGroup

Return bool.

getSpaceGroupList(self)

source code 
Return a list of SpaceGroup instances sorted by International
Tables number.  When custom_spacegroup is defined, the list starts
with custom_spacegroup.

getSpaceGroup(self, sgname)

source code 
Find space group in getSpaceGroupList() by short_name or number.
Use P1 when nothing else matches.

Return instance of SpaceGroup.
Raise ValueError if sgname cannot be found or when it is not present
in getSpaceGroupList().

expandAsymmetricUnit(self, spacegroup, indices, sgoffset=[0, 0, 0])

source code 
Perform symmetry expansion for atoms at given indices.
Temperature factors may be corrected to reflect the symmetry.
All constraints for expanded atoms are erased with the exception
of the occupancy("occ".  Constraints of unaffected atoms are adjusted
for new positions self.initial.

spacegroup  -- instance of Structure.SpaceGroup
indices     -- list of integer indices of atoms to be expanded
sgoffset    -- optional offset of space group origin [0,0,0]

applySymmetryConstraints(self, spacegroup, indices, posflag, Uijflag, sgoffset=[0, 0, 0])

source code 
Generate symmetry constraints for positions and thermal factors.
Both positions and thermal factors may get corrected to reflect
space group symmetry.  Old positional and thermal constraints get
erased.  New parameter indices start at fist decade after the last
used parameter.

spacegroup  -- instance of Structure.SpaceGroup
indices     -- list of integer indices of atoms to be expanded
posflag     -- required bool flag for constraining positions
Uijflag     -- required bool flag for Uij constrainment
sgoffset    -- optional offset of space group origin [0,0,0]

setSelectedPairs(self, s)

source code 
Set the value of selected_pairs to s, raise ControlValueError when
s has invalid syntax.  The selected_pairs is a comma separated list of
words formatted as

    [!]{element|indexOrRange|all}-[!]{element|indexOrRange|all}

where '!' excludes the given atoms from first or second pair.

Examples:

    all-all              all possible pairs
    Na-Na                only Na-Na pairs
    all-all, !Na-        all pairs except Na-Na (first index skips Na)
    all-all, -!Na        same as previous (second index skips Na)
    Na-1:4               pairs of Na and first 4 atoms
    all-all, !Cl-!Cl     exclude any pairs containing Cl
    all-all, !Cl-, -!Cl  same as previous
    1-all                only pairs including the first atom

Use getPairSelectionFlags() method to get a list of included values
for first and second pair index.

getPairSelectionFlags(self, s=None)

source code 
Translate string s to a list of allowed values for first and second
pair index.  Raise ControlValueError for invalid syntax of s.  See
setSelectedPairs() docstring for a definition of pair selection syntax.

s -- string describing selected pairs (default: self.selected_pairs)

Return a dictionary with following keys:

firstflags  -- list of selection flags for first indices
secondflags -- list of selection flags for second indices
fixed_pair_string -- argument corrected to standard syntax

applyPairSelection(self, server, phaseidx)

source code 
Apply pair selection for calculations of partial PDF.

server   -- instance of PdfFit engine
phaseidx -- phase index in PdfFit engine starting from 1

copy(self, other=None)

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

other -- reference to other object

returns reference to copied object

Overrides: pdfstructure.PDFStructure.copy

load(self, z, subpath)

source code 
Load structure from a zipped project file.

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

save(self, z, subpath)

source code 
Save structure to a zipped project file.

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

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