spectre.Visualization.ReadH5¶
Functions
|
List all subfiles with the given 'extension' in the 'h5files'. |
|
Returns all observations in the 'volfiles' and their times |
|
Select an observation in the 'volfiles' |
|
Convert a '.dat' subfile to a Pandas DataFrame |
- spectre.Visualization.ReadH5.available_subfiles(h5files: str | Path | File | Iterable[str] | Iterable[Path] | Iterable[File], extension: str) List[str] ¶
List all subfiles with the given ‘extension’ in the ‘h5files’.
- Parameters:
h5files (Path(s) or open h5py file(s). Can be a single file or path, a list) – of files or paths, or an iterable that opens and closes each file on demand.
extension (str)
- Return type:
List of paths in the ‘h5files’ that end with the ‘extension’
- spectre.Visualization.ReadH5.list_observations(volfiles: spectre.IO.H5.H5Vol | Iterable[spectre.IO.H5.H5Vol]) Tuple[List[int], List[float]] ¶
Returns all observations in the ‘volfiles’ and their times
- spectre.Visualization.ReadH5.select_observation(volfiles: spectre.IO.H5.H5Vol | Iterable[spectre.IO.H5.H5Vol], step: int = None, time: float = None) Tuple[int, float] ¶
Select an observation in the ‘volfiles’
- Parameters:
volfiles – Open spectre H5 volume files. Can be a single volfile or a list, but can also be an iterator that opens and closes the files on demand. The volfiles are assumed to be ordered in time, meaning that later volfiles contain the same or later observation IDs than earlier volfiles. This assumption should hold for volfiles from multiple nodes in segments like ‘Segment*/VolumeData*.h5’ and exists to avoid opening all volfiles from all segments. See ‘step’ and ‘time’ below for details.
step – Select the observation with this step number, counting unique observation IDs from the start of the first volfile. Mutually exclusive with ‘time’.
time – Select the observation closest to this time. The search is stopped once a volfile’s closest time is further away than the previous.
Returns: Tuple of (observation ID, time).
- spectre.Visualization.ReadH5.to_dataframe(open_subfile: Dataset | spectre.IO.H5.H5Dat, slice=None) pandas.DataFrame ¶
Convert a ‘.dat’ subfile to a Pandas DataFrame
This function isn’t particularly complex, but it allows to convert a subfile to a DataFrame in a single statement like this:
to_dataframe(open_h5_file[“Norms.dat”])
Without this function, you would have to store the subfile in an extra variable to access its “Legend” attribute.
You can optionally pass a slice object which will slice the data for you so the entire dataset isn’t read in
- Parameters:
open_subfile – An open h5py subfile representing a SpECTRE dat file, or a spectre.IO.H5.H5Dat subfile, typically from a reductions file.
slice – A numpy slice object to choose specific rows. Defaults to None. If you try to slice columns, an error will occur.
- Returns: Pandas DataFrame with column names read from the “Legend”
attribute of the dat file.