output¶
Read, write and convert self-describing analysis tables.
Summary¶
Exceptions:
Raised when an analysis table cannot be read, written or converted. |
Classes:
Base writer that preserves native formatting and adds table exports. |
|
Supported analysis-table output formats. |
|
A validated numerical table with scientific column metadata. |
|
Write an |
Functions:
Convert one analysis table or energy file to one or more outputs. |
|
Infer a requested output format from a recognized filename suffix. |
|
Read native, CSV, TSV or XVG analysis data by content. |
|
Read a PQ or QMCFC energy file as an analysis table. |
|
Write an analysis table to an open text stream. |
__all__: AnalysisColumn, AnalysisDataWriter, AnalysisOutputError, AnalysisOutputFormat, AnalysisPlotPreset, AnalysisSchema, AnalysisTable, AnalysisTableWriter, BROADENED_SPECTRUM_SCHEMA, EnergyFileOptions, MOMENTUM_SCHEMA, MSD_SCHEMA, RDF_SCHEMA, VACF_SCHEMA, VACF_SPECTRUM_SCHEMA, VACF_WINDOWED_SCHEMA, VIBRATIONAL_IR_SCHEMA, VIBRATIONAL_SCHEMA, convert_analysis_output, infer_output_format, normal_mode_schema, read_analysis_table, read_energy_table, write_analysis_table
Reference¶
- exception AnalysisOutputError[source]¶
Bases:
PQExceptionRaised when an analysis table cannot be read, written or converted.
- class AnalysisDataWriter(
- filename: str | None,
- mode: str | FileWritingMode = 'w',
- export_files: Sequence[str] | None = None,
Bases:
BaseWriterBase writer that preserves native formatting and adds table exports.
- Parameters:
filename (str | None) – Primary output path, or None for native text on stdout.
mode (str | FileWritingMode, optional) – Output writing mode, by default
w.export_files (Sequence[str] | None, optional) – Additional distinct output paths, by default None.
- write_table(
- table: AnalysisTable,
- native_writer: Callable[[TextIO | StringIO], None],
Write the primary file and all requested additional exports.
- schema: AnalysisSchema¶
- class AnalysisOutputFormat(*values)[source]¶
Bases:
str,EnumSupported analysis-table output formats.
- CSV = 'csv'¶
- NATIVE = 'native'¶
- TSV = 'tsv'¶
- XVG = 'xvg'¶
- class AnalysisTable(
- schema: AnalysisSchema,
- data: ndarray,
Bases:
objectA validated numerical table with scientific column metadata.
- classmethod from_columns(
- schema: AnalysisSchema,
- columns: Sequence[Sequence[Real] | ndarray],
Build a table from equally sized one-dimensional columns.
- data: ndarray¶
- schema: AnalysisSchema¶
- class AnalysisTableWriter(
- filename: str,
- mode: str | FileWritingMode = 'w',
Bases:
BaseWriterWrite an
AnalysisTableusing a suffix-selected format.- Parameters:
filename (str) – Output path whose suffix selects the format.
mode (str | FileWritingMode, optional) – Output writing mode, by default
w. Append mode is only valid for native text.
- write(
- table: AnalysisTable,
- x_field: str | None = None,
- y_fields: Sequence[str] | None = None,
Write a table and close the output stream.
- convert_analysis_output(
- input_file: str,
- output_files: Sequence[str],
- x_field: str | None = None,
- y_fields: Sequence[str] | None = None,
- mode: str | FileWritingMode = 'w',
- *,
- energy: EnergyFileOptions | None = None,
Convert one analysis table or energy file to one or more outputs.
- Parameters:
input_file (str) – Native, CSV, TSV or PQAnalysis XVG input table, or a PQ/QMCFC
.enenergy file.output_files (Sequence[str]) – Distinct output paths. Each suffix selects its format.
x_field (str | None, optional) – XVG x-axis field override, by default None.
y_fields (Sequence[str] | None, optional) – XVG y-axis fields, by default None.
mode (str | FileWritingMode, optional) – Output writing mode, by default
w.energy (EnergyFileOptions | None, optional) – Energy-file reading options. Inputs ending in
.enare read as energy files, others only withas_energy_file=True.
- infer_output_format(
- filename: str | None,
Infer a requested output format from a recognized filename suffix.
Unrecognized suffixes and stdout retain the native PQAnalysis format.
- Parameters:
filename (str | None) – Requested output filename, or None for stdout.
- Returns:
Format selected from the case-insensitive suffix.
- Return type:
- read_analysis_table(
- filename: str,
Read native, CSV, TSV or XVG analysis data by content.
- Parameters:
filename (str) – Input table. Its extension is not used for format detection.
- Returns:
Numeric data and reconstructed scientific schema.
- Return type:
- Raises:
AnalysisOutputError – If metadata, headers or numeric rows are malformed.
- read_energy_table(
- filename: str,
- options: EnergyFileOptions | None = None,
Read a PQ or QMCFC energy file as an analysis table.
Names and units come from
EnergyFileReaderand appear asNAME [unit]in CSV/TSV headers. The default plot stacks one XVG graph per non-zero energy over the simulation time.- Parameters:
filename (str) – Energy file.
options (EnergyFileOptions | None, optional) – Info file, engine and timestep, by default
EnergyFileOptions().
- Returns:
One table column per energy-file column.
- Return type:
- write_analysis_table(
- table: AnalysisTable,
- file: TextIO | StringIO,
- output_format: AnalysisOutputFormat,
- x_field: str | None = None,
- y_fields: Sequence[str] | None = None,
Write an analysis table to an open text stream.
- Parameters:
table (AnalysisTable) – Validated data and scientific schema.
file (TextIO) – Open UTF-8 text stream.
output_format (AnalysisOutputFormat) – Format to write.
x_field (str | None, optional) – XVG x-axis field override, by default None.
y_fields (Sequence[str] | None, optional) – XVG y-axis fields, by default None.