SDDS ToolKit Programs and Libraries for C and Python
|
Python script providing the SDDS Python module.
This module provides the SDDS
class and associated methods to load, manipulate, and save SDDS files. It supports both ASCII and binary SDDS formats and provides functionality to read, write, and manipulate SDDS data.
Dependencies: sddsdata module
Definition in file sdds.py.
Go to the source code of this file.
Functions | |
SDDS | sdds.load (input_file) |
Loads an SDDS file into the SDDS object. | |
SDDS | sdds.loadSparse (input_file, interval, offset) |
Loads an SDDS file into the SDDS object with sparse data reading. | |
SDDS | sdds.loadLastRows (input_file, lastrows) |
Loads an SDDS file into the SDDS object, reading only the last few rows. | |
sdds.save (SDDS sdds_obj, output_file) | |
Saves the SDDS object's data to an SDDS file. | |
sdds.sdds_data_type_to_string (data_type_code) | |
Converts a numeric SDDS data type code to its string representation. | |
sdds.sdds_data_type_to_short_string (data_type_code) | |
Converts a numeric SDDS data type code to its short string representation. | |
sdds.sdds_short_string_to_data_type (data_type_code) | |
Converts a numeric SDDS data type code to its short string representation. | |
sdds.demo1 (output) | |
Demonstrates how to save a demo SDDS file using the SDDS class. | |
sdds.demo2 (output) | |
Demonstrates how to save a demo SDDS file using the SDDS class with simplified definitions. | |
sdds.demo3 (output) | |
Demonstrates how to save a demo SDDS file using sddsdata commands directly. | |
sdds.demo4 (output) | |
Demonstrates how to save a demo SDDS file using sddsdata commands and writing one row at a time. | |
sdds.demo5 (output) | |
Demonstrates how to open an existing SDDS file and add rows to the last page without loading the whole file into memory. | |
sdds.demo6 (output) | |
Demonstrates how to open an existing SDDS file and add a new page. | |
SddsFile | sdds.read (input_file) |
Mostly backward compatible with the PyLHC sdds module read() function. | |
sdds.write (SddsFile sdds_file, output_file) | |
Mostly backward compatible with the PyLHC sdds module write() function. | |
sdds.demo1 | ( | output | ) |
Demonstrates how to save a demo SDDS file using the SDDS class.
Args: output (str): The output SDDS filename to save the demo data.
This function creates an SDDS object, populates it with sample data, and saves it to the specified output file.
Definition at line 1494 of file sdds.py.
sdds.demo2 | ( | output | ) |
Demonstrates how to save a demo SDDS file using the SDDS class with simplified definitions.
Args: output (str): The output SDDS filename to save the demo data.
This function shows how to use simplified methods to define parameters, arrays, and columns.
Definition at line 1565 of file sdds.py.
sdds.demo3 | ( | output | ) |
Demonstrates how to save a demo SDDS file using sddsdata
commands directly.
Args: output (str): The output SDDS filename to save the demo data.
This function shows how to use sddsdata
module functions directly to create and save an SDDS file.
Definition at line 1621 of file sdds.py.
sdds.demo4 | ( | output | ) |
Demonstrates how to save a demo SDDS file using sddsdata
commands and writing one row at a time.
Args: output (str): The output SDDS filename to save the demo data.
This function shows how to write data to an SDDS file one row at a time, useful for logging applications.
Definition at line 1682 of file sdds.py.
sdds.demo5 | ( | output | ) |
Demonstrates how to open an existing SDDS file and add rows to the last page without loading the whole file into memory.
Args: output (str): The output SDDS filename to append data.
This function shows how to append data to an existing SDDS file efficiently.
Definition at line 1750 of file sdds.py.
sdds.demo6 | ( | output | ) |
Demonstrates how to open an existing SDDS file and add a new page.
Args: output (str): The output SDDS filename to append data.
This function shows how to append a new page to an existing SDDS file.
Definition at line 1785 of file sdds.py.
SDDS sdds.load | ( | input_file | ) |
Loads an SDDS file into the SDDS object.
Args: input_file (str): The input SDDS filename to load.
Raises: Exception: If unable to read the SDDS data.
This method reads the SDDS file specified by input
, and populates the object's data structures with the parameters, arrays, columns, and their respective data.
Definition at line 1323 of file sdds.py.
SDDS sdds.loadLastRows | ( | input_file, | |
lastrows ) |
Loads an SDDS file into the SDDS object, reading only the last few rows.
Args: input_file (str): The input SDDS filename to load. lastrows (int): Number of last rows to read.
Raises: Exception: If unable to read the SDDS data.
This method reads only the last lastrows
rows from each page of the SDDS file.
Definition at line 1373 of file sdds.py.
SDDS sdds.loadSparse | ( | input_file, | |
interval, | |||
offset ) |
Loads an SDDS file into the SDDS object with sparse data reading.
Args: input_file (str): The input SDDS filename to load. interval (int): Interval between pages to read. offset (int): Offset to start reading from.
Raises: Exception: If unable to read the SDDS data.
This method reads every interval
pages from the SDDS file, starting from the page at offset
.
Definition at line 1348 of file sdds.py.
SddsFile sdds.read | ( | input_file | ) |
Mostly backward compatible with the PyLHC sdds module read() function.
Unlike the PyLHC version, this function reads all the SDDS pages and works with column data. The data is returned in a structured dictionary.
Args: input_file (str): The input SDDS file to be read.
Returns: dict: A dictionary with parameters, arrays, and columns data. Example structure: { pages = {integer}, binary = {boolean}, "definitions": {name: {"type:" string, "units": string, "description": string}, "values": {parameter_name: {[Page1Value, Page2Value, ...]}, {array_name: {[Page1List, Page2List, ...]}, {column_name: {[Page1List, Page2List, ...]}, "values": {array_name: {[page1DimList, Page2DimList, ...]} }
Definition at line 1870 of file sdds.py.
sdds.save | ( | SDDS | sdds_obj, |
output_file ) |
Saves the SDDS object's data to an SDDS file.
Args: output (str): The output SDDS filename to save the data.
Raises: Exception: If unable to write the SDDS data.
This method writes the data stored in the SDDS object to the specified file, including the parameters, arrays, columns, and their data.
Definition at line 1397 of file sdds.py.
sdds.sdds_data_type_to_short_string | ( | data_type_code | ) |
Converts a numeric SDDS data type code to its short string representation.
Args: data_type_code (int): Numeric code of the SDDS data type.
Returns: str: String representation of the SDDS data type.
Definition at line 1442 of file sdds.py.
sdds.sdds_data_type_to_string | ( | data_type_code | ) |
Converts a numeric SDDS data type code to its string representation.
Args: data_type_code (int): Numeric code of the SDDS data type.
Returns: str: String representation of the SDDS data type.
Definition at line 1416 of file sdds.py.
sdds.sdds_short_string_to_data_type | ( | data_type_code | ) |
Converts a numeric SDDS data type code to its short string representation.
Args: data_type_code (string): String representation of the SDDS data type.
Returns: int: Numeric code of the SDDS data type.
Definition at line 1468 of file sdds.py.
sdds.write | ( | SddsFile | sdds_file, |
output_file ) |
Mostly backward compatible with the PyLHC sdds module write() function.
Unlike the PyLHC version, this function writes all the SDDS pages and works with column data. The data is expected to be in a structured dictionary like that returned from the read() function.
Args: output_file (str): The output SDDS file to be written to.
Definition at line 1967 of file sdds.py.