SDDSlib
|
A class to represent and manipulate SDDS datasets. More...
Public Member Functions | |
__init__ (self, index) | |
Initializes a new SDDS object. | |
load (self, input) | |
Loads an SDDS file into the SDDS object. | |
loadSparse (self, input, interval, offset) | |
Loads an SDDS file into the SDDS object with sparse data reading. | |
loadLastRows (self, input, lastrows) | |
Loads an SDDS file into the SDDS object, reading only the last few rows. | |
save (self, output) | |
Saves the SDDS object's data to an SDDS file. | |
setDescription (self, text, contents) | |
Sets the description for the SDDS object. | |
defineParameter (self, name, symbol="", units="", description="", formatString="", type=SDDS_DOUBLE, fixedValue="") | |
Defines a parameter for the SDDS object. | |
defineSimpleParameter (self, name, type) | |
Defines a simple parameter with minimal information. | |
defineArray (self, name, symbol="", units="", description="", formatString="", group_name="", type=SDDS_DOUBLE, fieldLength=0, dimensions=1) | |
Defines an array for the SDDS object. | |
defineSimpleArray (self, name, type, dimensions) | |
Defines a simple array with minimal information. | |
defineColumn (self, name, symbol="", units="", description="", formatString="", type=SDDS_DOUBLE, fieldLength=0) | |
Defines a column for the SDDS object. | |
defineSimpleColumn (self, name, type) | |
Defines a simple column with minimal information. | |
setParameterValueList (self, name, valueList) | |
Sets the list of parameter values for a parameter. | |
getParameterValueList (self, name) | |
Gets the list of parameter values for a parameter. | |
setParameterValue (self, name, value, page=1) | |
Sets a single parameter value at a specific page. | |
getParameterValue (self, name, page=1) | |
Gets a single parameter value at a specific page. | |
setArrayValueLists (self, name, valueList, dimensionList) | |
Sets the nested list of array values and dimensions for a single array. | |
getArrayValueLists (self, name) | |
Gets the nested list of array values for a single array. | |
getArrayDimensionLists (self, name) | |
Gets the nested list of array dimensions for a single array. | |
setArrayValueList (self, name, valueList, dimensionList, page=1) | |
Sets a single array value and dimension at a specific page. | |
getArrayValueList (self, name, page=1) | |
Gets a single array value at a specific page. | |
getArrayDimensionList (self, name, page=1) | |
Gets a single array dimension at a specific page. | |
setColumnValueLists (self, name, valueList) | |
Sets the nested list of column values for a single column. | |
getColumnValueLists (self, name) | |
Gets the nested list of column values for a single column. | |
setColumnValueList (self, name, valueList, page=1) | |
Sets a single column value list at a specific page. | |
getColumnValueList (self, name, page=1) | |
Gets a single column value list at a specific page. | |
setColumnValue (self, name, value, page=1, row=1) | |
Sets a single column value at a specific page and row. | |
getColumnValue (self, name, page=1, row=1) | |
Gets a single column value at a specific page and row. | |
getParameterCount (self) | |
Retrieves the number of parameters. | |
getArrayCount (self) | |
Retrieves the number of arrays. | |
getColumnCount (self) | |
Retrieves the number of columns. | |
getParameterNames (self) | |
Retrieves a list of all parameter names. | |
getArrayNames (self) | |
Retrieves a list of all array names. | |
getColumnNames (self) | |
Retrieves a list of all column names. | |
getParameterDatatype (self, name) | |
Retrieves the data type of a parameter. | |
getArrayDatatype (self, name) | |
Retrieves the data type of a array. | |
getColumnDatatype (self, name) | |
Retrieves the data type of a column. | |
getParameterUnits (self, name) | |
Retrieves the units of a parameter. | |
getArrayDatatype (self, name) | |
Retrieves the units of a array. | |
getColumnDatatype (self, name) | |
Retrieves the units of a column. | |
pageCount (self) | |
Retrieves the number or loaded pages. | |
Public Attributes | |
int | index = index |
list | description = ["", ""] |
list | parameterName = [] |
list | arrayName = [] |
list | columnName = [] |
list | parameterDefinition = [] |
list | arrayDefinition = [] |
list | arrayDimensions = [] |
list | columnDefinition = [] |
list | parameterData = [] |
list | arrayData = [] |
list | columnData = [] |
int | mode = self.SDDS_ASCII |
int | loaded_pages = 0 |
str | parameterName = "Invalid parameter name " + name |
str | arrayName = "Invalid array name " + name |
str | columnName = "Invalid column name " + name |
Static Public Attributes | |
int | SDDS_VERBOSE_PrintErrors = 1 |
int | SDDS_EXIT_PrintErrors = 2 |
int | SDDS_CHECK_OKAY = 0 |
int | SDDS_CHECK_NONEXISTENT = 1 |
int | SDDS_CHECK_WRONGTYPE = 2 |
int | SDDS_CHECK_WRONGUNITS = 3 |
int | SDDS_LONGDOUBLE = 1 |
int | SDDS_DOUBLE = 2 |
int | SDDS_REAL64 = 2 |
int | SDDS_FLOAT = 3 |
int | SDDS_REAL32 = 3 |
int | SDDS_LONG64 = 4 |
int | SDDS_INT64 = 4 |
int | SDDS_ULONG64 = 5 |
int | SDDS_UINT64 = 5 |
int | SDDS_LONG = 6 |
int | SDDS_INT32 = 6 |
int | SDDS_ULONG = 7 |
int | SDDS_UINT32 = 7 |
int | SDDS_SHORT = 8 |
int | SDDS_INT16 = 8 |
int | SDDS_USHORT = 9 |
int | SDDS_UINT16 = 9 |
int | SDDS_STRING = 10 |
int | SDDS_CHARACTER = 11 |
int | SDDS_NUM_TYPES = 11 |
int | SDDS_BINARY = 1 |
int | SDDS_ASCII = 2 |
int | SDDS_FLUSH_TABLE = 1 |
A class to represent and manipulate SDDS datasets.
This class provides methods to load, manipulate, and save SDDS data. It supports ASCII and binary formats and facilitates operations on parameters, arrays, and columns.
Important:
Attributes: index (int): The index of the SDDS dataset (integer from 0 to 19). description (list): List containing the description text and contents of the SDDS file. parameterName (list): List of parameter names. arrayName (list): List of array names. columnName (list): List of column names. parameterDefinition (list): List of parameter definitions. arrayDefinition (list): List of array definitions. arrayDimensions (list): List of array dimensions. columnDefinition (list): List of column definitions. parameterData (list): List of parameter data values. arrayData (list): List of array data values. columnData (list): List of column data values. mode (int): The data storage mode (SDDS_ASCII
or SDDS_BINARY
).
sdds.SDDS.__init__ | ( | self, | |
index ) |
Initializes a new SDDS object.
Args: index (int): Integer index of the SDDS object. Must be between 0 and 19 inclusive.
The attributes are initialized to their default values.
Definition at line 84 of file sdds.py.
sdds.SDDS.defineArray | ( | self, | |
name, | |||
symbol = "", | |||
units = "", | |||
description = "", | |||
formatString = "", | |||
group_name = "", | |||
type = SDDS_DOUBLE, | |||
fieldLength = 0, | |||
dimensions = 1 ) |
Defines an array for the SDDS object.
Args: name (str): Array name. symbol (str, optional): Array symbol. units (str, optional): Array units. description (str, optional): Array description. formatString (str, optional): Format string for the array. group_name (str, optional): Group name for the array. type (int, optional): Data type of the array. Defaults to SDDS_DOUBLE, Valid options include:
This method adds an array definition to the SDDS object.
Definition at line 558 of file sdds.py.
sdds.SDDS.defineColumn | ( | self, | |
name, | |||
symbol = "", | |||
units = "", | |||
description = "", | |||
formatString = "", | |||
type = SDDS_DOUBLE, | |||
fieldLength = 0 ) |
Defines a column for the SDDS object.
Args: name (str): Column name. symbol (str, optional): Column symbol. units (str, optional): Column units. description (str, optional): Column description. formatString (str, optional): Format string for the column. type (int, optional): Data type of the column. Defaults to SDDS_DOUBLE. Valid options include:
This method adds a column definition to the SDDS object.
Definition at line 620 of file sdds.py.
sdds.SDDS.defineParameter | ( | self, | |
name, | |||
symbol = "", | |||
units = "", | |||
description = "", | |||
formatString = "", | |||
type = SDDS_DOUBLE, | |||
fixedValue = "" ) |
Defines a parameter for the SDDS object.
Args: name (str): Parameter name. symbol (str, optional): Parameter symbol. units (str, optional): Parameter units. description (str, optional): Parameter description. formatString (str, optional): Format string for the parameter. type (int, optional): Data type of the parameter. Defaults to SDDS_DOUBLE. Valid options include:
This method adds a parameter definition to the SDDS object.
Definition at line 501 of file sdds.py.
sdds.SDDS.defineSimpleArray | ( | self, | |
name, | |||
type, | |||
dimensions ) |
Defines a simple array with minimal information.
Args: name (str): Array name. type (int): Data type of the array. Valid options include:
This method adds an array definition with default attributes.
Definition at line 593 of file sdds.py.
sdds.SDDS.defineSimpleColumn | ( | self, | |
name, | |||
type ) |
Defines a simple column with minimal information.
Args: name (str): Column name. type (int): Data type of the column. Valid options include:
This method adds a column definition with default attributes.
Definition at line 652 of file sdds.py.
sdds.SDDS.defineSimpleParameter | ( | self, | |
name, | |||
type ) |
Defines a simple parameter with minimal information.
Args: name (str): Parameter name. type (int): Data type of the parameter. Valid options include:
This method adds a parameter definition with default attributes.
Definition at line 533 of file sdds.py.
sdds.SDDS.getArrayCount | ( | self | ) |
sdds.SDDS.getArrayDatatype | ( | self, | |
name ) |
Retrieves the data type of a array.
Args: name (str): Array name.
Returns: int: Number representing the data type of the array.
Definition at line 1178 of file sdds.py.
sdds.SDDS.getArrayDatatype | ( | self, | |
name ) |
Retrieves the units of a array.
Args: name (str): Array name.
Returns: str: Units of the array.
Definition at line 1226 of file sdds.py.
sdds.SDDS.getArrayDimensionList | ( | self, | |
name, | |||
page = 1 ) |
Gets a single array dimension at a specific page.
Args: name (str): Array name. page (int, optional): Page number (1-based index, defaults to 1).
Returns: list: Array dimension.
Raises: Exception: If the array name or page is invalid.
Definition at line 900 of file sdds.py.
sdds.SDDS.getArrayDimensionLists | ( | self, | |
name ) |
Gets the nested list of array dimensions for a single array.
This can be used to get dimensions for multiple pages at once.
Args: name (str): Array name.
Returns: list: Nested list of array dimensions.
Raises: Exception: If the array name is invalid.
Definition at line 819 of file sdds.py.
sdds.SDDS.getArrayNames | ( | self | ) |
Retrieves a list of all array names.
Returns: list: A list of array names as strings, or an empty list.
Definition at line 1144 of file sdds.py.
sdds.SDDS.getArrayValueList | ( | self, | |
name, | |||
page = 1 ) |
Gets a single array value at a specific page.
Args: name (str): Array name. page (int, optional): Page number (1-based index, defaults to 1).
Returns: list: Array values.
Raises: Exception: If the array name or page is invalid.
Definition at line 871 of file sdds.py.
sdds.SDDS.getArrayValueLists | ( | self, | |
name ) |
Gets the nested list of array values for a single array.
This can be used to get values for multiple pages at once.
Args: name (str): Array name.
Returns: list: Nested list of array values.
Raises: Exception: If the array name is invalid.
Definition at line 799 of file sdds.py.
sdds.SDDS.getColumnCount | ( | self | ) |
sdds.SDDS.getColumnDatatype | ( | self, | |
name ) |
Retrieves the data type of a column.
Args: name (str): Column name.
Returns: int: Number representing the data type of the column.
Definition at line 1194 of file sdds.py.
sdds.SDDS.getColumnDatatype | ( | self, | |
name ) |
Retrieves the units of a column.
Args: name (str): Column name.
Returns: str: Units of the column.
Definition at line 1242 of file sdds.py.
sdds.SDDS.getColumnNames | ( | self | ) |
Retrieves a list of all column names.
Returns: list: A list of column names as strings, or an empty list.
Definition at line 1153 of file sdds.py.
sdds.SDDS.getColumnValue | ( | self, | |
name, | |||
page = 1, | |||
row = 1 ) |
Gets a single column value at a specific page and row.
Args: name (str): Column name. page (int, optional): Page number (1-based index, defaults to 1). row (int, optional): Row number (1-based index, defaults to 1).
Returns: value: Column value.
Raises: Exception: If the column name, page, or row is invalid.
Definition at line 1067 of file sdds.py.
sdds.SDDS.getColumnValueList | ( | self, | |
name, | |||
page = 1 ) |
Gets a single column value list at a specific page.
Args: name (str): Column name. page (int, optional): Page number (1-based index, defaults to 1).
Returns: list: Column values.
Raises: Exception: If the column name or page is invalid.
Definition at line 997 of file sdds.py.
sdds.SDDS.getColumnValueLists | ( | self, | |
name ) |
Gets the nested list of column values for a single column.
This can be used to get values for multiple pages at once.
Args: name (str): Column name.
Returns: list: Nested list of column values.
Raises: Exception: If the column name is invalid.
Definition at line 949 of file sdds.py.
sdds.SDDS.getParameterCount | ( | self | ) |
Retrieves the number of parameters.
Returns: int: The number of parameters.
Definition at line 1108 of file sdds.py.
sdds.SDDS.getParameterDatatype | ( | self, | |
name ) |
Retrieves the data type of a parameter.
Args: name (str): Parameter name.
Returns: int: Number representing the data type of the parameter.
Definition at line 1162 of file sdds.py.
sdds.SDDS.getParameterNames | ( | self | ) |
Retrieves a list of all parameter names.
Returns: list: A list of parameter names as strings, or an empty list.
Definition at line 1135 of file sdds.py.
sdds.SDDS.getParameterUnits | ( | self, | |
name ) |
Retrieves the units of a parameter.
Args: name (str): Parameter name.
Returns: str: Units of the parameter.
Definition at line 1210 of file sdds.py.
sdds.SDDS.getParameterValue | ( | self, | |
name, | |||
page = 1 ) |
Gets a single parameter value at a specific page.
Args: name (str): Parameter name. page (int, optional): Page number (1-based index, defaults to 1).
Returns: value: Parameter value.
Raises: Exception: If the parameter name or page is invalid.
Definition at line 747 of file sdds.py.
sdds.SDDS.getParameterValueList | ( | self, | |
name ) |
Gets the list of parameter values for a parameter.
This can be used to get values for multiple pages at once.
Args: name (str): Parameter name.
Returns: list: List of values for the parameter.
Raises: Exception: If the parameter name is invalid.
Definition at line 697 of file sdds.py.
sdds.SDDS.load | ( | self, | |
input ) |
Loads an SDDS file into the SDDS object.
Args: input (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 112 of file sdds.py.
sdds.SDDS.loadLastRows | ( | self, | |
input, | |||
lastrows ) |
Loads an SDDS file into the SDDS object, reading only the last few rows.
Args: input (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 274 of file sdds.py.
sdds.SDDS.loadSparse | ( | self, | |
input, | |||
interval, | |||
offset ) |
Loads an SDDS file into the SDDS object with sparse data reading.
Args: input (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 193 of file sdds.py.
sdds.SDDS.pageCount | ( | self | ) |
Retrieves the number or loaded pages.
Returns: int: Number or loaded pages
Definition at line 1258 of file sdds.py.
sdds.SDDS.save | ( | self, | |
output ) |
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 354 of file sdds.py.
sdds.SDDS.setArrayValueList | ( | self, | |
name, | |||
valueList, | |||
dimensionList, | |||
page = 1 ) |
Sets a single array value and dimension at a specific page.
Args: name (str): Array name. valueList (list): Array values. dimensionList (list): Array dimensions. page (int, optional): Page number (1-based index, defaults to 1).
Raises: Exception: If the array name or page is invalid.
This method sets the array values and dimensions at the specified page.
Definition at line 839 of file sdds.py.
sdds.SDDS.setArrayValueLists | ( | self, | |
name, | |||
valueList, | |||
dimensionList ) |
Sets the nested list of array values and dimensions for a single array.
This can be used to set values for multiple pages at once.
Args: name (str): Array name. valueList (list): Nested list of array values. dimensionList (list): Nested list of array dimensions.
Raises: Exception: If the array name is invalid.
This method assigns values and dimensions to an array across pages.
Definition at line 776 of file sdds.py.
sdds.SDDS.setColumnValue | ( | self, | |
name, | |||
value, | |||
page = 1, | |||
row = 1 ) |
Sets a single column value at a specific page and row.
Args: name (str): Column name. value: Column value. page (int, optional): Page number (1-based index, defaults to 1). row (int, optional): Row number (1-based index, defaults to 1).
Raises: Exception: If the column name, page, or row is invalid.
This method sets the column value at the specified page and row.
Definition at line 1026 of file sdds.py.
sdds.SDDS.setColumnValueList | ( | self, | |
name, | |||
valueList, | |||
page = 1 ) |
Sets a single column value list at a specific page.
Args: name (str): Column name. valueList (list): Column values. page (int, optional): Page number (1-based index, defaults to 1).
Raises: Exception: If the column name or page is invalid.
This method sets the column values at the specified page.
Definition at line 969 of file sdds.py.
sdds.SDDS.setColumnValueLists | ( | self, | |
name, | |||
valueList ) |
Sets the nested list of column values for a single column.
This can be used to set values for multiple pages at once.
Args: name (str): Column name. valueList (list): Nested list of column values.
Raises: Exception: If the column name is invalid.
This method assigns a list of values to a column across pages.
Definition at line 929 of file sdds.py.
sdds.SDDS.setDescription | ( | self, | |
text, | |||
contents ) |
Sets the description for the SDDS object.
Args: text (str): Description text. contents (str): Description contents.
Definition at line 491 of file sdds.py.
sdds.SDDS.setParameterValue | ( | self, | |
name, | |||
value, | |||
page = 1 ) |
Sets a single parameter value at a specific page.
Args: name (str): Parameter name. value: Parameter value. page (int, optional): Page number (1-based index, defaults to 1).
Raises: Exception: If the parameter name or page is invalid.
This method sets the parameter value at the specified page.
Definition at line 718 of file sdds.py.
sdds.SDDS.setParameterValueList | ( | self, | |
name, | |||
valueList ) |
Sets the list of parameter values for a parameter.
This can be used to set values for multiple pages at once.
Args: name (str): Parameter name. valueList (list): List of values for the parameter.
Raises: Exception: If the parameter name is invalid.
This method assigns a list of values to a parameter across pages.
Definition at line 677 of file sdds.py.
str sdds.SDDS.parameterName = "Invalid parameter name " + name |