Package diffpy :: Package Structure :: Module structure :: Class Structure
[hide private]
[frames] | no frames]

Class Structure

source code

object --+    
         |    
      list --+
             |
            Structure
Known Subclasses:
bratomsstructure.BRAtomsStructure, pdffitstructure.PDFFitStructure

Structure --> group of atoms

Structure class is inherited from Python list.  It contains
a list of Atom instances.  Structure overloads setitem and setslice
methods so that the lattice attribute of atoms get set to lattice.

Data members:
    title   -- structure description
    lattice -- coordinate system (instance of Lattice)



Instance Methods [hide private]
 
__init__(self, atoms=[], lattice=None, title='', filename=None)
define group of atoms in a specified lattice.
source code
 
__setitem__(self, idx, a, copy=True)
Set idx-th atom to a.
source code
 
__setslice__(self, lo, hi, atoms, copy=True)
Set Structure slice from lo to hi-1 to the sequence of atoms.
source code
 
__str__(self)
simple string representation
source code
 
_get_lattice(self) source code
 
_set_lattice(self, value) source code
 
_uncache(self, *args)
Reset cached flag for a list of internal attributes.
source code
 
_update_labels(self)
Update the _labels dictionary of unique string labels of atoms.
source code
 
addNewAtom(self, *args, **kwargs)
Add new Atom instance to the end of this Structure.
source code
 
angle(self, a0, a1, a2)
angle at atom a1 in degrees
source code
 
append(self, a, copy=True)
Append atom to a structure and update its lattice attribute.
source code
 
distance(self, id0, id1)
Distance between 2 atoms, no periodic boundary conditions.
source code
 
extend(self, atoms, copy=True)
Extend Structure by appending copies from a list of atoms.
source code
 
getAtom(self, id)
Reference to internal Atom specified by the identifier.
source code
 
getLabels(self)
List of unique string labels for all atoms in this structure.
source code
 
getLastAtom(self)
Return Reference to the last Atom in this structure.
source code
 
insert(self, idx, a, copy=True)
Insert atom a before position idx in this Structure.
source code
 
placeInLattice(self, new_lattice)
place structure into new_lattice coordinate system...
source code
 
read(self, filename, format='auto')
Load structure from a file, any original data become lost.
source code
 
readStr(self, s, format='auto')
Load structure from a string, any original data become lost.
source code
 
write(self, filename, format)
Save structure to file in the specified format No return value.
source code
 
writeStr(self, format)
return string representation of the structure in specified format...
source code

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__

Properties [hide private]
  lattice
Coordinate system for this Structure.

Inherited from object: __class__

Method Details [hide private]

__init__(self, atoms=[], lattice=None, title='', filename=None)
(Constructor)

source code 
define group of atoms in a specified lattice.

atoms    -- list of Atom instances to be included in this Structure.
            When atoms argument is an existing Structure instance,
            the new Structure is its copy.
lattice  -- instance of Lattice defining coordinate systems, property.
title    -- string description of the structure
filename -- optional, name of a file to load the structure from.
            Overrides atoms argument when specified.

Structure(stru)     create a copy of Structure instance stru.

Because Structure is inherited from a list it can use list expansions,
for example:
    oxygen_atoms = [ for a in stru if a.element == "O" ]
    oxygen_stru = Structure(oxygen_atoms, lattice=stru.lattice)

Returns:
new list

Overrides: list.__init__

__setitem__(self, idx, a, copy=True)
(Index assignment operator)

source code 
Set idx-th atom to a.

idx  -- index of atom in this Structure
a    -- instance of Atom
copy -- flag for setting to a copy of a.
        When False, set to a and update a.lattice.

No return value.

Overrides: list.__setitem__

__setslice__(self, lo, hi, atoms, copy=True)
(Slice assignment operator)

source code 
Set Structure slice from lo to hi-1 to the sequence of atoms.

lo    -- low index for the slice
hi    -- high index of the slice
atoms -- sequence of Atom instances
copy  -- flag for using copies of Atom instances.  When False, set
         to existing instances and update their lattice attributes.

No return value.

Overrides: list.__setslice__

__str__(self)
(Informal representation operator)

source code 
simple string representation

Overrides: object.__str__

_uncache(self, *args)

source code 
Reset cached flag for a list of internal attributes.

*args -- list of strings, currently supported are "labels"

No return value.
Raise AttributeError for any invalid args.

_update_labels(self)

source code 
Update the _labels dictionary of unique string labels of atoms.

No return value.

addNewAtom(self, *args, **kwargs)

source code 
Add new Atom instance to the end of this Structure.

All arguments are forwarded to Atom constructor.

No return value.

append(self, a, copy=True)

source code 
Append atom to a structure and update its lattice attribute.

a    -- instance of Atom
copy -- flag for appending a copy of a.
        When False, append a and update a.owner.

No return value.

Overrides: list.append

distance(self, id0, id1)

source code 
Distance between 2 atoms, no periodic boundary conditions.

id0 -- zero based index of the first atom or a string label
       such as "Na1"
id1 -- zero based index or string label of the second atom.

Return float.
Raise ValueError for invalid arguments.

extend(self, atoms, copy=True)

source code 
Extend Structure by appending copies from a list of atoms.

atoms -- list of Atom instances
copy  -- flag for extending with copies of Atom instances.
         When False extend with atoms and update their lattice
         attributes.

No return value.

Overrides: list.extend

getAtom(self, id)

source code 
Reference to internal Atom specified by the identifier.

id  -- zero based index or a string label formatted as
       "%(element)s%(order)i", for example "Na1", "Cl1"

Return Atom instance.
Raise ValueError for invalid id.

See also getLabels().

getLabels(self)

source code 
List of unique string labels for all atoms in this structure.

Return a list.

insert(self, idx, a, copy=True)

source code 
Insert atom a before position idx in this Structure.

idx  -- position in atom list
a    -- instance of Atom
copy -- flag for inserting a copy of a.
        When False, append a and update a.lattice.

No return value.

Overrides: list.insert

placeInLattice(self, new_lattice)

source code 
place structure into new_lattice coordinate system

sets lattice to new_lattice and recalculate fractional coordinates
of all atoms so their absolute positions remain the same

return self

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

source code 
Load structure from a file, any original data become lost.

filename -- file to be loaded
format   -- all structure formats are defined in Parsers submodule,
            when format == 'auto' all Parsers are tried one by one

Return instance of data Parser used to process file.  This
can be inspected for information related to particular format.

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

source code 
Load structure from a string, any original data become lost.

s        -- string with structure definition
format   -- all structure formats are defined in Parsers submodule,
            when format == 'auto' all Parsers are tried one by one

Return instance of data Parser used to process input string.  This
can be inspected for information related to particular format.

write(self, filename, format)

source code 
Save structure to file in the specified format

No return value.

Note: available structure formats can be obtained by:
    from Parsers import formats

writeStr(self, format)

source code 
return string representation of the structure in specified format

Note: available structure formats can be obtained by:
    from Parsers import formats


Property Details [hide private]

lattice

Coordinate system for this Structure.

Get Method:
diffpy.Structure.structure.Structure._get_lattice(self)
Set Method:
diffpy.Structure.structure.Structure._set_lattice(self, value)