fabio.cbfimage.CIF

Package fabio :: Module cbfimage :: Class CIF |
[hide private]
[frames] | no frames]

# Class CIF

source code

    object --+
             |
          dict --+
                 |
                CIF

This is the CIF class, it represents the CIF dictionary; and as a a python dictionary thus inherits from the dict built in class.

Instance Methods | [hide private]
    new empty dictionary
__init__(self, _strFilename=None) Constructor of the class. | source code
__setitem__(self, key, value) x[i]=y | source code
v, remove specified key and return the corresponding value |
pop(self, key) If key is not found, d is returned if given, otherwise KeyError is raised | source code
(k, v), remove and return some (key, value) pair as a |
popitem(self, key) 2-tuple; but raise KeyError if D is empty. | source code
loadCIF(self, _strFilename, _bKeepComment=False) Load the CIF file and populates the CIF dictionary into the object | source code
readCIF(self, _strFilename, _bKeepComment=False) Load the CIF file and populates the CIF dictionary into the object | source code
None |
_parseCIF(self, sText) Parses the text of a CIF file | source code
saveCIF(self, _strFilename=`'``test.cif``'`, linesep=`'``\n``'`, binary=False) Transforms the CIF object in string then write it into the given file | source code
tostring(self, _strFilename=None, linesep=`'``\n``'`) Converts a cif dictionnary to a string according to the CIF syntax | source code
boolean |
exists(self, sKey) Check if the key exists in the CIF and is non empty. | source code
boolean |
existsInLoop(self, sKey) Check if the key exists in the CIF dictionary. | source code
dictionary |
loadCHIPLOT(self, _strFilename) Load the powder diffraction CHIPLOT file and returns the pd_CIF dictionary in the object | source code
Inherited from `dict`: `__cmp__`, `__contains__`, `__delitem__`, `__eq__`, `__ge__`, `__getattribute__`, `__getitem__`, `__gt__`, `__iter__`, `__le__`, `__len__`, `__lt__`, `__ne__`, `__new__`, `__repr__`, `__sizeof__`, `clear`, `copy`, `fromkeys`, `get`, `has_key`, `items`, `iteritems`, `iterkeys`, `itervalues`, `keys`, `setdefault`, `update`, `values` Inherited from `object`: `__delattr__`, `__format__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__str__`, `__subclasshook__`

Static Methods | [hide private]
boolean |
isAscii(_strIn) Check if all characters in a string are ascii, | source code
string |
_readCIF(_instream) Check if the filename containing the CIF data exists | source code
list |
_splitCIF(sText) Separate the text in fields as defined in the CIF | source code
tuple |
_analyseOneLoop(lFields, iStart) Processes one loop in the data extraction of the CIF file | source code
LoopHasKey(loop, key) Returns True if the key (string) exist in the array called loop | source code

Class Variables | [hide private]
| EOL = ``[``'``\r``'``,` `'``\n``'``,` `'``\r\n``'``,` `'``\n\r``'``]``
| BLANK = ``[``'``` `'``,` `'``\t``'``,` `'``\r``'``,` `'``\n``'``,` `'``\r\n``'``,` `'``\n\r``'``]``
| START_COMMENT = ``[``'``"``'``,` `'``\'``'``]``
| BINARY_MARKER = ``'``--CIF-BINARY-FORMAT-SECTION--``'``
Inherited from `dict`: `__hash__`

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, _strFilename=None) (Constructor) | source code
Constructor of the class. Parameters: `_strFilename` (filename (str) or file object) - the name of the file to open Returns:
    new empty dictionary
Overrides: object.__init__

### __setitem__(self, key, value) (Index assignment operator) | source code
x[i]=y Overrides: dict.__setitem__ (inherited documentation)

### pop(self, key) | source code
If key is not found, d is returned if given, otherwise KeyError is raised Returns: v, remove specified key and return the corresponding value Overrides: dict.pop (inherited documentation)

### popitem(self, key) | source code
2-tuple; but raise KeyError if D is empty. Returns: (k, v), remove and return some (key, value) pair as a Overrides: dict.popitem (inherited documentation)

### loadCIF(self, _strFilename, _bKeepComment=False) | source code
Load the CIF file and populates the CIF dictionary into the object Parameters: `_strFilename` (string) - the name of the file to open `_strFilename` (string) - the name of the file to open Returns: None

### readCIF(self, _strFilename, _bKeepComment=False) | source code
Load the CIF file and populates the CIF dictionary into the object Parameters: `_strFilename` (string) - the name of the file to open `_strFilename` (string) - the name of the file to open Returns: None

### isAscii(_strIn) Static Method | source code
Check if all characters in a string are ascii, Parameters: `_strIn` (python string) - input string Returns: boolean boolean

### _readCIF(_instream) Static Method | source code
Check if the filename containing the CIF data exists read the cif file removes the comments Parameters: `_instream` (open file in read mode) - the file containing the CIF data Returns: string a string containing the raw data

### _parseCIF(self, sText) | source code
Parses the text of a CIF file Cut it in fields Find all the loops and process Find all the keys and values Parameters: `sText` (string) - the content of the CIF - file Returns: None Nothing, the data are incorporated at the CIF object dictionary

### _splitCIF(sText) Static Method | source code
Separate the text in fields as defined in the CIF Parameters: `sText` (string) - the content of the CIF - file Returns: list list of all the fields of the CIF

### _analyseOneLoop(lFields, iStart) Static Method | source code
Processes one loop in the data extraction of the CIF file Parameters: `lFields` (list) - list of all the words contained in the cif file `iStart` (integer) - the starting index corresponding to the "loop_" key Returns: tuple the list of loop dictionaries, the length of the data extracted from the lFields and the list of all the keys of the loop.

### saveCIF(self, _strFilename=`'``test.cif``'`, linesep=`'``\n``'`, binary=False) | source code
Transforms the CIF object in string then write it into the given file Parameters: `_strFilename` - the of the file to be written `linesep` - line separation used (to force compatibility with windows/unix) `binary` - Shall we write the data as binary (True only for imageCIF/CBF) `param` (string)

### tostring(self, _strFilename=None, linesep=`'``\n``'`) | source code
Converts a cif dictionnary to a string according to the CIF syntax Parameters: `_strFilename` (string) - the name of the filename to be appended in the header of the CIF file Returns: a sting that corresponds to the content of the CIF - file.

### exists(self, sKey) | source code
Check if the key exists in the CIF and is non empty. Parameters: `sKey` (string) - CIF key `cif` - CIF dictionary Returns: boolean True if the key exists in the CIF dictionary and is non empty

### existsInLoop(self, sKey) | source code
Check if the key exists in the CIF dictionary. Parameters: `sKey` (string) - CIF key `cif` - CIF dictionary Returns: boolean True if the key exists in the CIF dictionary and is non empty

### loadCHIPLOT(self, _strFilename) | source code
Load the powder diffraction CHIPLOT file and returns the pd_CIF dictionary in the object Parameters: `_strFilename` (string) - the name of the file to open Returns: dictionary the CIF object corresponding to the powder diffraction