armi.nuclearDataIO.cccc.cccc module
Defines containers for the reading and writing standard interface files for reactor physics codes.
- armi.nuclearDataIO.cccc.cccc.IMPLICIT_INT = 'IJKLMN'
Letters that trigger implicit integer types in old FORTRAN 77 codes
- class armi.nuclearDataIO.cccc.cccc.IORecord(stream, hasRecordBoundaries=True)[source]
Bases:
objectA single CCCC record.
Reads or writes information to or from a stream.
- Parameters:
stream – A collection of data to be read or written
hasRecordBoundaries (bool) – A True value means the fortran file was written using access=’sequential’ and contains a 4 byte int count at the beginning and end of each record. Otherwise, if False the fortran file was written using access=’direct’.
Notes
The methods in this object often have rw prefixes, meaning the same method can be used for both reading and writing. We consider this a significant achievement that enforces consistency between the code for reading and writing CCCC records. The tradeoff is that it’s a bit challenging to comprehend at first.
- maxsize = 10
- count = 885
- rwInt(val)[source]
Abstract method for reading or writing an integer.
Notes
The method has a seemingly odd signature, because it is used for both reading and writing. When writing, the
valshould have value, but when the record is being read,valcan beNoneor anything else; it is ignored.
- rwFloat(val)[source]
Abstract method for reading or writing a floating point (single precision) value.
Notes
The method has a seemingly odd signature, because it is used for both reading and writing. When writing, the
valshould have value, but when the record is being read,valcan beNoneor anything else; it is ignored.
- rwDouble(val)[source]
Abstract method for reading or writing a floating point (double precision) value.
Notes
The method has a seemingly odd signature, because it is used for both reading and writing. When writing, the
valshould have value, but when the record is being read,valcan beNoneor anything else; it is ignored.
- rwString(val, length)[source]
Abstract method for reading or writing a string.
Notes
The method has a seemingly odd signature, because it is used for both reading and writing. When writing, the
valshould have value, but when the record is being read,valcan beNoneor anything else; it is ignored.
- rwList(contents, containedType, length, strLength=0)[source]
A method for reading and writing a (array) of items of a specific type.
Notes
The method has a seemingly odd signature, because it is used for both reading and writing. When writing, the
contentsshould have value, but when the record is being read,contentscan beNoneor anything else; it is ignored.Warning
If a
contentsevaluates toTrue, the array must be the same size aslength.
- rwMatrix(contents, *shape)[source]
A method for reading and writing a matrix of floating point values.
Notes
The method has a seemingly odd signature, because it is used for both reading and writing. When writing, the
contentsshould have value, but when the record is being read,contentscan beNoneor anything else; it is ignored.Warning
If a
contentsis notNone, the array must be the same shape as*shape.
- rwDoubleMatrix(contents, *shape)[source]
Read or write a matrix of floating point values.
Notes
The method has a seemingly odd signature, because it is used for both reading and writing. When writing, the
contentsshould have value, but when the record is being read,contentscan beNoneor anything else; it is ignored.Warning
If a
contentsis notNone, the array must be the same shape as*shape.
- class armi.nuclearDataIO.cccc.cccc.BinaryRecordReader(stream, hasRecordBoundaries=True)[source]
Bases:
IORecordWrites a single CCCC record in binary format.
Notes
This class reads a single CCCC record in binary format. A CCCC record consists of a leading and ending integer indicating how many bytes the record is. The data contained within the record may be integer, float, double, or string.
- open()[source]
Open the record by reading the number of bytes in the record, this value will be used to ensure the entire record was read.
- class armi.nuclearDataIO.cccc.cccc.BinaryRecordWriter(stream, hasRecordBoundaries=True)[source]
Bases:
IORecorda single record from a CCCC file.
Reads binary information sequentially.
- class armi.nuclearDataIO.cccc.cccc.AsciiRecordReader(stream, hasRecordBoundaries=True)[source]
Bases:
BinaryRecordReaderReads a single CCCC record in ASCII format.
See also
- class armi.nuclearDataIO.cccc.cccc.AsciiRecordWriter(stream, hasRecordBoundaries=True)[source]
Bases:
IORecordWrites a single CCCC record in ASCII format.
Since there is no specific format of an ASCII CCCC record, the format is roughly the same as the
BinaryRecordWriter, except that theAsciiRecordReaderputs a space in front of all values (ints, floats, and strings), and puts a newline character\nat the end of all records.
- class armi.nuclearDataIO.cccc.cccc.DataContainer[source]
Bases:
objectData representation that can be read/written to/from with a cccc.Stream.
This is an optional convenience class expected to be used in concert with
StreamWithDataStructure.
- class armi.nuclearDataIO.cccc.cccc.Stream(fileName, fileMode)[source]
Bases:
objectAn abstract CCCC IO stream.
Warning
This is more of a stream Parser/Serializer than an actual stream.
Notes
A concrete instance of this class should implement the
readWrite()method.Create an instance of a
Stream.- Parameters:
- readWrite()[source]
This method should be implemented on any sub-classes to specify the order of records.
- classmethod writeBinary(data: DataContainer, fileName: str)[source]
Write the contents of a data container to a binary file.
- classmethod writeAscii(data: DataContainer, fileName: str)[source]
Write the contents of a data container to an ASCII file.
- class armi.nuclearDataIO.cccc.cccc.StreamWithDataContainer(data: DataContainer, fileName: str, fileMode: str)[source]
Bases:
StreamA cccc.Stream that reads/writes to a specialized data container.
This is a relatively common pattern so some of the boilerplate is handled here.
Warning
This is more of a stream Parser/Serializer than an actual stream.
Notes
It should be possible to fully merge this with
Stream, which may make this a little less confusing.
- armi.nuclearDataIO.cccc.cccc.getBlockBandwidth(m, nintj, nblok)[source]
Return block bandwidth JL, JU from CCCC interface files.
It is common for CCCC files to block data in various records with a description along the lines of:
WITH M AS THE BLOCK INDEX, JL=(M-1)*((NINTJ-1)/NBLOK +1)+1 AND JU=MIN0(NINTJ,JUP) WHERE JUP=M*((NINTJ-1)/NBLOK +1)
This function computes JL and JU for these purposes. It also converts JL and JU to zero based indices rather than 1 based ones, as is almost always wanted when dealing with python/numpy matrices.
The term bandwidth refers to a kind of sparse matrix representation. Some rows only have columns JL to JH in them rather than 0 to JMAX. The non-zero band from JL to JH is what we’re talking about here.