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
 
readCIF(self, _strFilename)
Just call loadCIF: Load the CIF file and sets the CIF dictionnary into the object
source code
 
loadCIF(self, _strFilename, _bKeepComment=False)
Load the CIF file and returns the CIF dictionnary into the object
source code
dictionary
_parseCIF(self, sText)
-Parses the text of a CIF file -Cut it in fields -Find all the loops and process -Find all the keys and values
source code
 
saveCIF(self, _strFilename='test.cif')
Transforms the CIF object in string then write it into the given file
source code
string
_cif2str(self, _strFilename)
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__, __setitem__, __sizeof__, clear, copy, fromkeys, get, has_key, items, iteritems, iterkeys, itervalues, keys, pop, popitem, setdefault, update, values, viewitems, viewkeys, viewvalues

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 -read the cif file -removes the comments
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__

readCIF(self, _strFilename)

source code 

Just call loadCIF: Load the CIF file and sets the CIF dictionnary into the object

Parameters:
  • _strFilename (string) - the name of the file to open

loadCIF(self, _strFilename, _bKeepComment=False)

source code 

Load the CIF file and returns the CIF dictionnary into the object

Parameters:
  • _strFilename (string) - the name of the file to open
  • _bKeepComment (boolean) - shall we remove comments
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: dictionary
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')

source code 

Transforms the CIF object in string then write it into the given file

Parameters:
  • _strFilename (string) - the of the file to be written

_cif2str(self, _strFilename)

source code 

converts a cif dictionnary to a string according to the CIF syntax

Parameters:
  • _strFilename (string @return : a sting that corresponds to the content of the CIF-file.) - the name of the filename to be appended in the header of the CIF file
Returns: string

exists(self, sKey)

source code 

Check if the key exists in the CIF and is non empty.

Parameters:
  • sKey (string) - CIF key
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
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