serpentTools.next.DetectorReader¶
-
class
serpentTools.next.DetectorReader(names=None)¶ Class for reading Serpent detector files
Creating one of these manually may not always be necessary. However, it can be useful if repeated files are to be read, as a fresh reader is created for each call to
DetectorFile.fromSerpent().-
names¶ Names of detectors that, if found when reading, should be processed. Any other detectors will not be processed and stored
- Type
set of str
-
read(source, sourcename=None, postcheck=True, strict=True)¶ Process detectors from a Serpent output file
- Parameters
source (str or pathlib.Path or io.IOBase) – Filenames can be provided as strings or
pathlib.Pathand will be opened accordingly. Otherwise read directly from this argumentsourcename (str, optional) – Additional descriptor of the data source. If not provided, and
sourceis a string orpathlib.Path, use the name of the filepostcheck (bool, optional) – Check if any detectors have been found after reading. Default: True
strict (bool, optional) – Raise errors if no detectors are found during post-read check. Otherwise warn if none are found. Default : True
- Returns
Mapping of detector names and their corresponding instances.
- Return type
- Raises
SerpentToolsException – If
postcheckandstrictand no detectors were found- Warns
UserWarning – if
postcheckand notstrictand no detectors were found
-
readTextStream(stream, sourcename=None, postcheck=True, strict=True)¶ Process detectors from a stream of text data
Differs from
read()as this method only handles readableio.TextIOBaseinstances, like opened files.read()relies on this method for processing of the file data, but handles more input types.- Parameters
source (io.TextIOBase) –
readable()buffer of text data corresponding to a Serpent output file.sourcename (str, optional) – Additional descriptor of the data source. If not provided, and
sourceis a string orpathlib.Path, use the name of the filepostcheck (bool, optional) – Check if any detectors have been found after reading. Default: True
strict (bool, optional) – Raise errors if no detectors are found during post-read check. Otherwise warn if none are found. Default : True
- Returns
Mapping of detector names and their corresponding instances.
- Return type
- Raises
SerpentToolsException – If
postcheckandstrictand no detectors were found- Warns
UserWarning – if
postcheckand notstrictand no detectors were found
-