Input/output functions for files in the SKIRT stored table and stored column format. More...
Functions | |
def | arrayFromFile (fd, shape) |
This helper function reads a sequence of doubles from the specified (open) file to a numpy array with the given shape. More... | |
def | arrayToFile (fd, a) |
This helper function writes the specified numpy array to the given (open) file as a sequence of doubles in the required order (first index varies most rapidly). More... | |
def | intFromFile (fd) |
This helper function reads an 8-byte little-endian unsigned integer from the specified (open) file and returns the corresponding integer value. More... | |
def | intToFile (fd, n) |
This helper function writes the specified unsigned integer value to the given (open) file as a little-endian 8-byte sequence. More... | |
def | listStoredColumnsInfo (columnsFilePath) |
This function lists relevant metadata about the specified SKIRT stored columns file. More... | |
def | listStoredTableInfo (tableFilePath) |
This function lists relevant metadata about the specified SKIRT stored table file. More... | |
def | readStoredColumns (columnsFilePath) |
This function reads the specified SKIRT stored columns file and returns a dictionary with the following structure: More... | |
def | readStoredTable (tableFilePath) |
This function reads the specified SKIRT stored table file and returns a dictionary with the following structure: More... | |
def | stringFromFile (fd) |
This helper function reads an 8-byte name or unit string from the specified (open) file and returns the resulting variable-sized string after stripping trailing white space. More... | |
def | stringToFile (fd, s) |
This helper function writes the specified name or unit string to the given (open) file as an 8-byte sequence, after checking that the string adheres to the proper requirements. More... | |
def | writeStoredColumns (outFilePath, columnNames, columnUnits, values) |
This function writes the specified data and metadata to a disk file in SKIRT stored columns format. More... | |
def | writeStoredTable (outFilePath, axisNames, axisUnits, axisScales, axisGrids, quantityNames, quantityUnits, quantityScales, quantityValues) |
This function writes the specified data and metadata to a disk file in SKIRT stored table format. More... | |
Input/output functions for files in the SKIRT stored table and stored column format.
The functions in this module allow reading and writing data and metadata from and to a disk file in SKIRT stored table format or in SKIRT stored column format.
The SKIRT stored table file format is intended for tabulating one or more physical quantities as a function of on one or more independent variables. It has been designed for representing built-in SKIRT resources but it can be used for multi-dimensional tables in other contexts.
A SKIRT stored table file contains binary data with a straightforward layout. The file is essentially a sequence of 8-byte data items. A data item can have one of three types:
The overall layout is as follows:
The values are ordered so that the quantity values for a particular point are next to each other, the first axis index varies most rapidly, and the last axis index varies least rapidly.
The SKIRT stored columns file format stores a set of data columns and is intended as a faster replacement for large regular text column data files, without the benefit of being human readable. The format does not support non-leaf rows, so it cannot be used for adaptive mesh data.
A SKIRT stored columns file contains binary data with a straightforward layout. It can contain the same type of data items as described for stored tables above. The layout is similar but not identical to stored tables:
The values are ordered so that the column values for a particular row are next to each other.
def pts.storedtable.io.arrayFromFile | ( | fd, | |
shape | |||
) |
This helper function reads a sequence of doubles from the specified (open) file to a numpy array with the given shape.
The doubles should appear in the file in the required order (first index varies most rapidly).
def pts.storedtable.io.arrayToFile | ( | fd, | |
a | |||
) |
This helper function writes the specified numpy array to the given (open) file as a sequence of doubles in the required order (first index varies most rapidly).
def pts.storedtable.io.intFromFile | ( | fd | ) |
This helper function reads an 8-byte little-endian unsigned integer from the specified (open) file and returns the corresponding integer value.
def pts.storedtable.io.intToFile | ( | fd, | |
n | |||
) |
This helper function writes the specified unsigned integer value to the given (open) file as a little-endian 8-byte sequence.
def pts.storedtable.io.listStoredColumnsInfo | ( | columnsFilePath | ) |
This function lists relevant metadata about the specified SKIRT stored columns file.
The printed information includes the names and units and ranges for each of the columns and the number of rows. The stored columns file path is interpreted as described for the pts.utils.absPath() function.
def pts.storedtable.io.listStoredTableInfo | ( | tableFilePath | ) |
This function lists relevant metadata about the specified SKIRT stored table file.
The printed information includes the names, units and ranges for each of the axes, and the names and units for each of the quantities. The table file path is interpreted as described for the pts.utils.absPath() function.
def pts.storedtable.io.readStoredColumns | ( | columnsFilePath | ) |
This function reads the specified SKIRT stored columns file and returns a dictionary with the following structure:
def pts.storedtable.io.readStoredTable | ( | tableFilePath | ) |
This function reads the specified SKIRT stored table file and returns a dictionary with the following structure:
def pts.storedtable.io.stringFromFile | ( | fd | ) |
This helper function reads an 8-byte name or unit string from the specified (open) file and returns the resulting variable-sized string after stripping trailing white space.
def pts.storedtable.io.stringToFile | ( | fd, | |
s | |||
) |
This helper function writes the specified name or unit string to the given (open) file as an 8-byte sequence, after checking that the string adheres to the proper requirements.
def pts.storedtable.io.writeStoredColumns | ( | outFilePath, | |
columnNames, | |||
columnUnits, | |||
values | |||
) |
This function writes the specified data and metadata to a disk file in SKIRT stored columns format.
The function expects the following arguments:
A name or unit string must contain 1 to 8 printable and non-whitespace 7-bit ASCII characters. There must be at least one column; the number of rows may be zero. The output columns file path is interpreted as described for the pts.utils.absPath() function.
def pts.storedtable.io.writeStoredTable | ( | outFilePath, | |
axisNames, | |||
axisUnits, | |||
axisScales, | |||
axisGrids, | |||
quantityNames, | |||
quantityUnits, | |||
quantityScales, | |||
quantityValues | |||
) |
This function writes the specified data and metadata to a disk file in SKIRT stored table format.
The function expects the following arguments:
The sequences must be nonempty and have the same number of items within each group (axis and quantity). A name or unit string must contain 1 to 8 printable and non-whitespace 7-bit ASCII characters. The output table file path is interpreted as described for the pts.utils.absPath() function.