ChiantiPy.fortranformat package

Submodules

ChiantiPy.fortranformat.FortranRecordReader module

class ChiantiPy.fortranformat.FortranRecordReader.FortranRecordReader(format)

Bases: object

Generate a reader object for FORTRAN format strings

Typical use case …

>>> header_line = FortranRecordReader('(A15, A15, A15)')
>>> header_line.read('              x              y              z')
['              x', '              y', '              z']
>>> line = FortranRecordReader('(3F15.3)')
>>> line.read('          1.000          0.000          0.500')
[1.0, 0.0, 0.5]
>>> line.read('          1.100          0.100          0.600')
[1.1, 0.1, 0.6]

Note: it is best to create a new object for each format, changing the format causes the parser to reevalute the format string which is costly in terms of performance

property format
get_format()
match(record)
read(record)

Pass a string representing a FORTRAN record to obtain the relevent values

set_format(format)

ChiantiPy.fortranformat.FortranRecordWriter module

class ChiantiPy.fortranformat.FortranRecordWriter.FortranRecordWriter(format)

Bases: object

Generate a writer object for FORTRAN format strings

Typical use case …

>>> header_line = FortranRecordWriter('(A15, A15, A15)')
>>> header_line.write(['x', 'y', 'z'])
'              x              y              z'
>>> line = FortranRecordWriter('(3F15.3)')
>>> line.write([1.0, 0.0, 0.5])
'          1.000          0.000          0.500'
>>> line.write([1.1, 0.1, 0.6])
'          1.100          0.100          0.600'

Note: it is best to create a new object for each format, changing the format causes the parser to reevalute the format string which is costly in terms of performance

property format
get_format()
set_format(format)
write(values)

Pass a list of values correspoding to the FORTRAN format specified to generate a string

ChiantiPy.fortranformat.config module

ChiantiPy.fortranformat.config.reset()

Module contents