SDDSlib
Loading...
Searching...
No Matches
sdds.SDDS Class Reference

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
 

Detailed Description

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:

  • Each SDDS object must be initialized with a unique index ranging from 0 to 19. This index is required to manage the internal SDDS library resources and ensure no conflicts between multiple SDDS objects in the same program.
  • Ensure that the index is released (if necessary) before reusing it.

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).

Definition at line 17 of file sdds.py.

Constructor & Destructor Documentation

◆ __init__()

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.

84 def __init__(self, index):
85 """
86 Initializes a new SDDS object.
87
88 Args:
89 index (int): Integer index of the SDDS object. Must be between 0 and 19 inclusive.
90
91 The attributes are initialized to their default values.
92 """
93 if 0 <= index < 20:
94 self.index = index
95 else:
96 self.index = 0
97 # Initialize data storage variables
98 self.description = ["", ""]
99 self.parameterName = []
100 self.arrayName = []
101 self.columnName = []
102 self.parameterDefinition = []
103 self.arrayDefinition = []
104 self.arrayDimensions = []
105 self.columnDefinition = []
106 self.parameterData = []
107 self.arrayData = []
108 self.columnData = []
109 self.mode = self.SDDS_ASCII
110 self.loaded_pages = 0
111

Member Function Documentation

◆ defineArray()

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:

  • SDDS_SHORT: 16-bit signed integer.
  • SDDS_USHORT: 16-bit unsigned integer.
  • SDDS_LONG: 32-bit signed integer.
  • SDDS_ULONG: 32-bit unsigned integer.
  • SDDS_LONG64: 64-bit signed integer.
  • SDDS_ULONG64: 64-bit unsigned integer.
  • SDDS_FLOAT: Single-precision floating-point number.
  • SDDS_DOUBLE: Double-precision floating-point number.
  • SDDS_LONGDOUBLE: Long double-precision floating-point number.
  • SDDS_STRING: String (textual data).
  • SDDS_CHARACTER: Single character. fieldLength (int, optional): Field length for the array. dimensions (int, optional): Number of dimensions of the array. Defaults to 1

This method adds an array definition to the SDDS object.

Definition at line 558 of file sdds.py.

558 def defineArray(self, name, symbol="", units="", description="", formatString="", group_name="", type=SDDS_DOUBLE, fieldLength=0, dimensions=1):
559 """
560 Defines an array for the SDDS object.
561
562 Args:
563 name (str): Array name.
564 symbol (str, optional): Array symbol.
565 units (str, optional): Array units.
566 description (str, optional): Array description.
567 formatString (str, optional): Format string for the array.
568 group_name (str, optional): Group name for the array.
569 type (int, optional): Data type of the array. Defaults to SDDS_DOUBLE, Valid options include:
570 - SDDS_SHORT: 16-bit signed integer.
571 - SDDS_USHORT: 16-bit unsigned integer.
572 - SDDS_LONG: 32-bit signed integer.
573 - SDDS_ULONG: 32-bit unsigned integer.
574 - SDDS_LONG64: 64-bit signed integer.
575 - SDDS_ULONG64: 64-bit unsigned integer.
576 - SDDS_FLOAT: Single-precision floating-point number.
577 - SDDS_DOUBLE: Double-precision floating-point number.
578 - SDDS_LONGDOUBLE: Long double-precision floating-point number.
579 - SDDS_STRING: String (textual data).
580 - SDDS_CHARACTER: Single character.
581 fieldLength (int, optional): Field length for the array.
582 dimensions (int, optional): Number of dimensions of the array. Defaults to 1
583
584 This method adds an array definition to the SDDS object.
585 """
586 self.arrayName.append(name)
587 self.arrayDefinition.append(
588 [symbol, units, description, formatString, group_name, type, fieldLength, dimensions]
589 )
590 self.arrayData.append([])
591 self.arrayDimensions.append([])
592

◆ defineColumn()

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:

  • SDDS_SHORT: 16-bit signed integer.
  • SDDS_USHORT: 16-bit unsigned integer.
  • SDDS_LONG: 32-bit signed integer.
  • SDDS_ULONG: 32-bit unsigned integer.
  • SDDS_LONG64: 64-bit signed integer.
  • SDDS_ULONG64: 64-bit unsigned integer.
  • SDDS_FLOAT: Single-precision floating-point number.
  • SDDS_DOUBLE: Double-precision floating-point number.
  • SDDS_LONGDOUBLE: Long double-precision floating-point number.
  • SDDS_STRING: String (textual data).
  • SDDS_CHARACTER: Single character. fieldLength (int, optional): Field length for the column.

This method adds a column definition to the SDDS object.

Definition at line 620 of file sdds.py.

620 def defineColumn(self, name, symbol="", units="", description="", formatString="", type=SDDS_DOUBLE, fieldLength=0):
621 """
622 Defines a column for the SDDS object.
623
624 Args:
625 name (str): Column name.
626 symbol (str, optional): Column symbol.
627 units (str, optional): Column units.
628 description (str, optional): Column description.
629 formatString (str, optional): Format string for the column.
630 type (int, optional): Data type of the column. Defaults to SDDS_DOUBLE. Valid options include:
631 - SDDS_SHORT: 16-bit signed integer.
632 - SDDS_USHORT: 16-bit unsigned integer.
633 - SDDS_LONG: 32-bit signed integer.
634 - SDDS_ULONG: 32-bit unsigned integer.
635 - SDDS_LONG64: 64-bit signed integer.
636 - SDDS_ULONG64: 64-bit unsigned integer.
637 - SDDS_FLOAT: Single-precision floating-point number.
638 - SDDS_DOUBLE: Double-precision floating-point number.
639 - SDDS_LONGDOUBLE: Long double-precision floating-point number.
640 - SDDS_STRING: String (textual data).
641 - SDDS_CHARACTER: Single character.
642 fieldLength (int, optional): Field length for the column.
643
644 This method adds a column definition to the SDDS object.
645 """
646 self.columnName.append(name)
647 self.columnDefinition.append(
648 [symbol, units, description, formatString, type, fieldLength]
649 )
650 self.columnData.append([])
651

◆ defineParameter()

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:

  • SDDS_SHORT: 16-bit signed integer.
  • SDDS_USHORT: 16-bit unsigned integer.
  • SDDS_LONG: 32-bit signed integer.
  • SDDS_ULONG: 32-bit unsigned integer.
  • SDDS_LONG64: 64-bit signed integer.
  • SDDS_ULONG64: 64-bit unsigned integer.
  • SDDS_FLOAT: Single-precision floating-point number.
  • SDDS_DOUBLE: Double-precision floating-point number.
  • SDDS_LONGDOUBLE: Long double-precision floating-point number.
  • SDDS_STRING: String (textual data).
  • SDDS_CHARACTER: Single character. fixedValue (str, optional): Fixed value of the parameter.

This method adds a parameter definition to the SDDS object.

Definition at line 501 of file sdds.py.

501 def defineParameter(self, name, symbol="", units="", description="", formatString="", type=SDDS_DOUBLE, fixedValue=""):
502 """
503 Defines a parameter for the SDDS object.
504
505 Args:
506 name (str): Parameter name.
507 symbol (str, optional): Parameter symbol.
508 units (str, optional): Parameter units.
509 description (str, optional): Parameter description.
510 formatString (str, optional): Format string for the parameter.
511 type (int, optional): Data type of the parameter. Defaults to SDDS_DOUBLE. Valid options include:
512 - SDDS_SHORT: 16-bit signed integer.
513 - SDDS_USHORT: 16-bit unsigned integer.
514 - SDDS_LONG: 32-bit signed integer.
515 - SDDS_ULONG: 32-bit unsigned integer.
516 - SDDS_LONG64: 64-bit signed integer.
517 - SDDS_ULONG64: 64-bit unsigned integer.
518 - SDDS_FLOAT: Single-precision floating-point number.
519 - SDDS_DOUBLE: Double-precision floating-point number.
520 - SDDS_LONGDOUBLE: Long double-precision floating-point number.
521 - SDDS_STRING: String (textual data).
522 - SDDS_CHARACTER: Single character.
523 fixedValue (str, optional): Fixed value of the parameter.
524
525 This method adds a parameter definition to the SDDS object.
526 """
527 self.parameterName.append(name)
528 self.parameterDefinition.append(
529 [symbol, units, description, formatString, type, fixedValue]
530 )
531 self.parameterData.append([])
532

◆ defineSimpleArray()

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:

  • SDDS_SHORT: 16-bit signed integer.
  • SDDS_USHORT: 16-bit unsigned integer.
  • SDDS_LONG: 32-bit signed integer.
  • SDDS_ULONG: 32-bit unsigned integer.
  • SDDS_LONG64: 64-bit signed integer.
  • SDDS_ULONG64: 64-bit unsigned integer.
  • SDDS_FLOAT: Single-precision floating-point number.
  • SDDS_DOUBLE: Double-precision floating-point number.
  • SDDS_LONGDOUBLE: Long double-precision floating-point number.
  • SDDS_STRING: String (textual data).
  • SDDS_CHARACTER: Single character. dimensions (int): Number of dimensions of the array.

This method adds an array definition with default attributes.

Definition at line 593 of file sdds.py.

593 def defineSimpleArray(self, name, type, dimensions):
594 """
595 Defines a simple array with minimal information.
596
597 Args:
598 name (str): Array name.
599 type (int): Data type of the array. Valid options include:
600 - SDDS_SHORT: 16-bit signed integer.
601 - SDDS_USHORT: 16-bit unsigned integer.
602 - SDDS_LONG: 32-bit signed integer.
603 - SDDS_ULONG: 32-bit unsigned integer.
604 - SDDS_LONG64: 64-bit signed integer.
605 - SDDS_ULONG64: 64-bit unsigned integer.
606 - SDDS_FLOAT: Single-precision floating-point number.
607 - SDDS_DOUBLE: Double-precision floating-point number.
608 - SDDS_LONGDOUBLE: Long double-precision floating-point number.
609 - SDDS_STRING: String (textual data).
610 - SDDS_CHARACTER: Single character.
611 dimensions (int): Number of dimensions of the array.
612
613 This method adds an array definition with default attributes.
614 """
615 self.arrayName.append(name)
616 self.arrayDefinition.append(["", "", "", "", "", type, 0, dimensions])
617 self.arrayData.append([])
618 self.arrayDimensions.append([])
619

◆ defineSimpleColumn()

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:

  • SDDS_SHORT: 16-bit signed integer.
  • SDDS_USHORT: 16-bit unsigned integer.
  • SDDS_LONG: 32-bit signed integer.
  • SDDS_ULONG: 32-bit unsigned integer.
  • SDDS_LONG64: 64-bit signed integer.
  • SDDS_ULONG64: 64-bit unsigned integer.
  • SDDS_FLOAT: Single-precision floating-point number.
  • SDDS_DOUBLE: Double-precision floating-point number.
  • SDDS_LONGDOUBLE: Long double-precision floating-point number.
  • SDDS_STRING: String (textual data).
  • SDDS_CHARACTER: Single character.

This method adds a column definition with default attributes.

Definition at line 652 of file sdds.py.

652 def defineSimpleColumn(self, name, type):
653 """
654 Defines a simple column with minimal information.
655
656 Args:
657 name (str): Column name.
658 type (int): Data type of the column. Valid options include:
659 - SDDS_SHORT: 16-bit signed integer.
660 - SDDS_USHORT: 16-bit unsigned integer.
661 - SDDS_LONG: 32-bit signed integer.
662 - SDDS_ULONG: 32-bit unsigned integer.
663 - SDDS_LONG64: 64-bit signed integer.
664 - SDDS_ULONG64: 64-bit unsigned integer.
665 - SDDS_FLOAT: Single-precision floating-point number.
666 - SDDS_DOUBLE: Double-precision floating-point number.
667 - SDDS_LONGDOUBLE: Long double-precision floating-point number.
668 - SDDS_STRING: String (textual data).
669 - SDDS_CHARACTER: Single character.
670
671 This method adds a column definition with default attributes.
672 """
673 self.columnName.append(name)
674 self.columnDefinition.append(["", "", "", "", type, 0])
675 self.columnData.append([])
676

◆ defineSimpleParameter()

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:

  • SDDS_SHORT: 16-bit signed integer.
  • SDDS_USHORT: 16-bit unsigned integer.
  • SDDS_LONG: 32-bit signed integer.
  • SDDS_ULONG: 32-bit unsigned integer.
  • SDDS_LONG64: 64-bit signed integer.
  • SDDS_ULONG64: 64-bit unsigned integer.
  • SDDS_FLOAT: Single-precision floating-point number.
  • SDDS_DOUBLE: Double-precision floating-point number.
  • SDDS_LONGDOUBLE: Long double-precision floating-point number.
  • SDDS_STRING: String (textual data).
  • SDDS_CHARACTER: Single character.

This method adds a parameter definition with default attributes.

Definition at line 533 of file sdds.py.

533 def defineSimpleParameter(self, name, type):
534 """
535 Defines a simple parameter with minimal information.
536
537 Args:
538 name (str): Parameter name.
539 type (int): Data type of the parameter. Valid options include:
540 - SDDS_SHORT: 16-bit signed integer.
541 - SDDS_USHORT: 16-bit unsigned integer.
542 - SDDS_LONG: 32-bit signed integer.
543 - SDDS_ULONG: 32-bit unsigned integer.
544 - SDDS_LONG64: 64-bit signed integer.
545 - SDDS_ULONG64: 64-bit unsigned integer.
546 - SDDS_FLOAT: Single-precision floating-point number.
547 - SDDS_DOUBLE: Double-precision floating-point number.
548 - SDDS_LONGDOUBLE: Long double-precision floating-point number.
549 - SDDS_STRING: String (textual data).
550 - SDDS_CHARACTER: Single character.
551
552 This method adds a parameter definition with default attributes.
553 """
554 self.parameterName.append(name)
555 self.parameterDefinition.append(["", "", "", "", type, ""])
556 self.parameterData.append([])
557

◆ getArrayCount()

sdds.SDDS.getArrayCount ( self)

Retrieves the number of arrays.

Returns: int: The number of arrays.

Definition at line 1117 of file sdds.py.

1117 def getArrayCount(self):
1118 """
1119 Retrieves the number of arrays.
1120
1121 Returns:
1122 int: The number of arrays.
1123 """
1124 return(len(self.arrayName))
1125

◆ getArrayDatatype() [1/2]

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.

1178 def getArrayDatatype(self, name):
1179 """
1180 Retrieves the data type of a array.
1181
1182 Args:
1183 name (str): Array name.
1184
1185 Returns:
1186 int: Number representing the data type of the array.
1187 """
1188 if name in self.arrayName:
1189 return(self.arrayDefinition[self.arrayName.index(name)][5])
1190 else:
1191 msg = "Invalid array name " + name
1192 raise Exception(msg)
1193

◆ getArrayDatatype() [2/2]

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.

1226 def getArrayDatatype(self, name):
1227 """
1228 Retrieves the units of a array.
1229
1230 Args:
1231 name (str): Array name.
1232
1233 Returns:
1234 str: Units of the array.
1235 """
1236 if name in self.arrayName:
1237 return(self.arrayDefinition[self.arrayName.index(name)][1])
1238 else:
1239 msg = "Invalid array name " + name
1240 raise Exception(msg)
1241

◆ getArrayDimensionList()

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.

900 def getArrayDimensionList(self, name, page=1):
901 """
902 Gets a single array dimension at a specific page.
903
904 Args:
905 name (str): Array name.
906 page (int, optional): Page number (1-based index, defaults to 1).
907
908 Returns:
909 list: Array dimension.
910
911 Raises:
912 Exception: If the array name or page is invalid.
913 """
914 page = page - 1
915 numberOfArrays = len(self.arrayName)
916 if name in self.arrayName:
917 i = self.arrayName.index(name)
918 if len(self.arrayData[i]) == page:
919 return(self.arrayDimensions[i][page:])
920 elif len(self.arrayData[i]) < page or page < 0:
921 msg = "Invalid page " + str(page + 1)
922 raise Exception(msg)
923 else:
924 return(self.arrayDimensions[i][page])
925 else:
926 msg = "Invalid array name " + name
927 raise Exception(msg)
928

◆ getArrayDimensionLists()

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.

819 def getArrayDimensionLists(self, name):
820 """
821 Gets the nested list of array dimensions for a single array. This can be used to get dimensions for multiple pages at once.
822
823 Args:
824 name (str): Array name.
825
826 Returns:
827 list: Nested list of array dimensions.
828
829 Raises:
830 Exception: If the array name is invalid.
831 """
832 numberOfArrays = len(self.arrayName)
833 if name in self.arrayName:
834 return(self.arrayDimensions[self.arrayName.index(name)])
835 else:
836 msg = "Invalid array name " + name
837 raise Exception(msg)
838

◆ getArrayNames()

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.

1144 def getArrayNames(self):
1145 """
1146 Retrieves a list of all array names.
1147
1148 Returns:
1149 list: A list of array names as strings, or an empty list.
1150 """
1151 return(self.arrayName)
1152

◆ getArrayValueList()

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.

871 def getArrayValueList(self, name, page=1):
872 """
873 Gets a single array value at a specific page.
874
875 Args:
876 name (str): Array name.
877 page (int, optional): Page number (1-based index, defaults to 1).
878
879 Returns:
880 list: Array values.
881
882 Raises:
883 Exception: If the array name or page is invalid.
884 """
885 page = page - 1
886 numberOfArrays = len(self.arrayName)
887 if name in self.arrayName:
888 i = self.arrayName.index(name)
889 if len(self.arrayData[i]) == page:
890 return(self.arrayData[i][page:])
891 elif len(self.arrayData[i]) < page or page < 0:
892 msg = "Invalid page " + str(page + 1)
893 raise Exception(msg)
894 else:
895 return(self.arrayData[i][page])
896 else:
897 msg = "Invalid array name " + name
898 raise Exception(msg)
899

◆ getArrayValueLists()

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.

799 def getArrayValueLists(self, name):
800 """
801 Gets the nested list of array values for a single array. This can be used to get values for multiple pages at once.
802
803 Args:
804 name (str): Array name.
805
806 Returns:
807 list: Nested list of array values.
808
809 Raises:
810 Exception: If the array name is invalid.
811 """
812 numberOfArrays = len(self.arrayName)
813 if name in self.arrayName:
814 return(self.arrayData[self.arrayName.index(name)])
815 else:
816 msg = "Invalid array name " + name
817 raise Exception(msg)
818

◆ getColumnCount()

sdds.SDDS.getColumnCount ( self)

Retrieves the number of columns.

Returns: int: The number of columns.

Definition at line 1126 of file sdds.py.

1126 def getColumnCount(self):
1127 """
1128 Retrieves the number of columns.
1129
1130 Returns:
1131 int: The number of columns.
1132 """
1133 return(len(self.columnName))
1134

◆ getColumnDatatype() [1/2]

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.

1194 def getColumnDatatype(self, name):
1195 """
1196 Retrieves the data type of a column.
1197
1198 Args:
1199 name (str): Column name.
1200
1201 Returns:
1202 int: Number representing the data type of the column.
1203 """
1204 if name in self.columnName:
1205 return(self.columnDefinition[self.columnName.index(name)][4])
1206 else:
1207 msg = "Invalid column name " + name
1208 raise Exception(msg)
1209

◆ getColumnDatatype() [2/2]

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.

1242 def getColumnDatatype(self, name):
1243 """
1244 Retrieves the units of a column.
1245
1246 Args:
1247 name (str): Column name.
1248
1249 Returns:
1250 str: Units of the column.
1251 """
1252 if name in self.columnName:
1253 return(self.columnDefinition[self.columnName.index(name)][1])
1254 else:
1255 msg = "Invalid column name " + name
1256 raise Exception(msg)
1257

◆ getColumnNames()

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.

1153 def getColumnNames(self):
1154 """
1155 Retrieves a list of all column names.
1156
1157 Returns:
1158 list: A list of column names as strings, or an empty list.
1159 """
1160 return(self.columnName)
1161

◆ getColumnValue()

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.

1067 def getColumnValue(self, name, page=1, row=1):
1068 """
1069 Gets a single column value at a specific page and row.
1070
1071 Args:
1072 name (str): Column name.
1073 page (int, optional): Page number (1-based index, defaults to 1).
1074 row (int, optional): Row number (1-based index, defaults to 1).
1075
1076 Returns:
1077 value: Column value.
1078
1079 Raises:
1080 Exception: If the column name, page, or row is invalid.
1081 """
1082 page = page - 1
1083 row = row - 1
1084 numberOfColumns = len(self.columnName)
1085 if name in self.columnName:
1086 i = self.columnName.index(name)
1087 if len(self.columnData[i]) == page:
1088 if row == 0:
1089 return(self.columnData[i][page:])
1090 else:
1091 msg = "Invalid row " + str(row + 1)
1092 raise Exception(msg)
1093 elif len(self.columnData[i]) < page or page < 0:
1094 msg = "Invalid page " + str(page + 1)
1095 raise Exception(msg)
1096 else:
1097 if len(self.columnData[i][page]) == row:
1098 return(self.columnData[i][page][row:])
1099 elif len(self.columnData[i][page]) < row or row < 0:
1100 msg = "Invalid row " + str(row + 1)
1101 raise Exception(msg)
1102 else:
1103 return(self.columnData[i][page][row])
1104 else:
1105 msg = "Invalid column name " + name
1106 raise Exception(msg)
1107

◆ getColumnValueList()

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.

997 def getColumnValueList(self, name, page=1):
998 """
999 Gets a single column value list at a specific page.
1000
1001 Args:
1002 name (str): Column name.
1003 page (int, optional): Page number (1-based index, defaults to 1).
1004
1005 Returns:
1006 list: Column values.
1007
1008 Raises:
1009 Exception: If the column name or page is invalid.
1010 """
1011 page = page - 1
1012 numberOfColumns = len(self.columnName)
1013 if name in self.columnName:
1014 i = self.columnName.index(name)
1015 if len(self.columnData[i]) == page:
1016 return(self.columnData[i][page:])
1017 elif len(self.columnData[i]) < page or page < 0:
1018 msg = "Invalid page " + str(page + 1)
1019 raise Exception(msg)
1020 else:
1021 return(self.columnData[i][page])
1022 else:
1023 msg = "Invalid column name " + name
1024 raise Exception(msg)
1025

◆ getColumnValueLists()

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.

949 def getColumnValueLists(self, name):
950 """
951 Gets the nested list of column values for a single column. This can be used to get values for multiple pages at once.
952
953 Args:
954 name (str): Column name.
955
956 Returns:
957 list: Nested list of column values.
958
959 Raises:
960 Exception: If the column name is invalid.
961 """
962 numberOfColumns = len(self.columnName)
963 if name in self.columnName:
964 return(self.columnData[self.columnName.index(name)])
965 else:
966 msg = "Invalid column name " + name
967 raise Exception(msg)
968

◆ getParameterCount()

sdds.SDDS.getParameterCount ( self)

Retrieves the number of parameters.

Returns: int: The number of parameters.

Definition at line 1108 of file sdds.py.

1108 def getParameterCount(self):
1109 """
1110 Retrieves the number of parameters.
1111
1112 Returns:
1113 int: The number of parameters.
1114 """
1115 return(len(self.parameterName))
1116

◆ getParameterDatatype()

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.

1162 def getParameterDatatype(self, name):
1163 """
1164 Retrieves the data type of a parameter.
1165
1166 Args:
1167 name (str): Parameter name.
1168
1169 Returns:
1170 int: Number representing the data type of the parameter.
1171 """
1172 if name in self.parameterName:
1173 return(self.parameterDefinition[self.parameterName.index(name)][4])
1174 else:
1175 msg = "Invalid parameter name " + name
1176 raise Exception(msg)
1177

◆ getParameterNames()

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.

1135 def getParameterNames(self):
1136 """
1137 Retrieves a list of all parameter names.
1138
1139 Returns:
1140 list: A list of parameter names as strings, or an empty list.
1141 """
1142 return(self.parameterName)
1143

◆ getParameterUnits()

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.

1210 def getParameterUnits(self, name):
1211 """
1212 Retrieves the units of a parameter.
1213
1214 Args:
1215 name (str): Parameter name.
1216
1217 Returns:
1218 str: Units of the parameter.
1219 """
1220 if name in self.parameterName:
1221 return(self.parameterDefinition[self.parameterName.index(name)][1])
1222 else:
1223 msg = "Invalid parameter name " + name
1224 raise Exception(msg)
1225

◆ getParameterValue()

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.

747 def getParameterValue(self, name, page=1):
748 """
749 Gets a single parameter value at a specific page.
750
751 Args:
752 name (str): Parameter name.
753 page (int, optional): Page number (1-based index, defaults to 1).
754
755 Returns:
756 value: Parameter value.
757
758 Raises:
759 Exception: If the parameter name or page is invalid.
760 """
761 page = page - 1
762 numberOfParameters = len(self.parameterName)
763 if name in self.parameterName:
764 i = self.parameterName.index(name)
765 if len(self.parameterData[i]) == page:
766 return(self.parameterData[i][page:])
767 elif len(self.parameterData[i]) < page or page < 0:
768 msg = "Invalid page " + str(page + 1)
769 raise Exception(msg)
770 else:
771 return(self.parameterData[i][page])
772 else:
773 msg = "Invalid parameter name " + name
774 raise Exception(msg)
775

◆ getParameterValueList()

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.

697 def getParameterValueList(self, name):
698 """
699 Gets the list of parameter values for a parameter. This can be used to get values for multiple pages at once.
700
701 Args:
702 name (str): Parameter name.
703
704 Returns:
705 list: List of values for the parameter.
706
707 Raises:
708 Exception: If the parameter name is invalid.
709
710 """
711 numberOfParameters = len(self.parameterName)
712 if name in self.parameterName:
713 return(self.parameterData[self.parameterName.index(name)])
714 else:
715 msg = "Invalid parameter name " + name
716 raise Exception(msg)
717

◆ load()

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.

112 def load(self, input):
113 """
114 Loads an SDDS file into the SDDS object.
115
116 Args:
117 input (str): The input SDDS filename to load.
118
119 Raises:
120 Exception: If unable to read the SDDS data.
121
122 This method reads the SDDS file specified by `input`, and populates the object's data structures
123 with the parameters, arrays, columns, and their respective data.
124 """
125 try:
126 # Open SDDS file
127 if sddsdata.InitializeInput(self.index, input) != 1:
128 time.sleep(1)
129 if sddsdata.InitializeInput(self.index, input) != 1:
130 raise ValueError("Failed to initialize SDDS input.")
131
132 # Get data storage mode (SDDS_ASCII or SDDS_BINARY)
133 self.mode = sddsdata.GetMode(self.index)
134
135 # Get description text and contents
136 self.description = sddsdata.GetDescription(self.index)
137
138 # Get parameter names
139 self.parameterName = sddsdata.GetParameterNames(self.index)
140 numberOfParameters = len(self.parameterName)
141
142 # Get array names
143 self.arrayName = sddsdata.GetArrayNames(self.index)
144 numberOfArrays = len(self.arrayName)
145
146 # Get column names
147 self.columnName = sddsdata.GetColumnNames(self.index)
148 numberOfColumns = len(self.columnName)
149
150 # Get parameter definitions
151 self.parameterDefinition = [sddsdata.GetParameterDefinition(self.index, name) for name in self.parameterName]
152
153 # Get array definitions
154 self.arrayDefinition = [sddsdata.GetArrayDefinition(self.index, name) for name in self.arrayName]
155
156 # Get column definitions
157 self.columnDefinition = [sddsdata.GetColumnDefinition(self.index, name) for name in self.columnName]
158
159 # Initialize parameter, array, and column data
160 self.parameterData = [[] for _ in range(numberOfParameters)]
161 self.arrayData = [[] for _ in range(numberOfArrays)]
162 self.columnData = [[] for _ in range(numberOfColumns)]
163 self.arrayDimensions = [[] for _ in range(numberOfArrays)]
164
165 # Read in SDDS data
166 page = sddsdata.ReadPage(self.index)
167 if page != 1:
168 raise Exception("Unable to read SDDS data for the first page")
169 while page > 0:
170 self.loaded_pages += 1
171 for i in range(numberOfParameters):
172 self.parameterData[i].append(sddsdata.GetParameter(self.index, i))
173 for i in range(numberOfArrays):
174 self.arrayData[i].append(sddsdata.GetArray(self.index, i))
175 self.arrayDimensions[i].append(sddsdata.GetArrayDimensions(self.index, i))
176 rows = sddsdata.RowCount(self.index)
177 if rows > 0:
178 for i in range(numberOfColumns):
179 self.columnData[i].append(sddsdata.GetColumn(self.index, i))
180 else:
181 for i in range(numberOfColumns):
182 self.columnData[i].append([])
183 page = sddsdata.ReadPage(self.index)
184
185 # Close SDDS file
186 if sddsdata.Terminate(self.index) != 1:
187 raise ValueError("Failed to terminate SDDS input.")
188
189 except:
190 sddsdata.PrintErrors(self.SDDS_VERBOSE_PrintErrors)
191 raise
192

◆ loadLastRows()

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.

274 def loadLastRows(self, input, lastrows):
275 """
276 Loads an SDDS file into the SDDS object, reading only the last few rows.
277
278 Args:
279 input (str): The input SDDS filename to load.
280 lastrows (int): Number of last rows to read.
281
282 Raises:
283 Exception: If unable to read the SDDS data.
284
285 This method reads only the last `lastrows` rows from each page of the SDDS file.
286 """
287 try:
288 # Open SDDS file
289 if sddsdata.InitializeInput(self.index, input) != 1:
290 time.sleep(1)
291 if sddsdata.InitializeInput(self.index, input) != 1:
292 raise ValueError("Failed to initialize SDDS input.")
293
294 # Get data storage mode (SDDS_ASCII or SDDS_BINARY)
295 self.mode = sddsdata.GetMode(self.index)
296
297 # Get description text and contents
298 self.description = sddsdata.GetDescription(self.index)
299
300 # Get parameter names
301 self.parameterName = sddsdata.GetParameterNames(self.index)
302 numberOfParameters = len(self.parameterName)
303
304 # Get array names
305 self.arrayName = sddsdata.GetArrayNames(self.index)
306 numberOfArrays = len(self.arrayName)
307
308 # Get column names
309 self.columnName = sddsdata.GetColumnNames(self.index)
310 numberOfColumns = len(self.columnName)
311
312 # Get parameter definitions
313 self.parameterDefinition = [sddsdata.GetParameterDefinition(self.index, name) for name in self.parameterName]
314
315 # Get array definitions
316 self.arrayDefinition = [sddsdata.GetArrayDefinition(self.index, name) for name in self.arrayName]
317
318 # Get column definitions
319 self.columnDefinition = [sddsdata.GetColumnDefinition(self.index, name) for name in self.columnName]
320
321 # Initialize parameter, array, and column data
322 self.parameterData = [[] for _ in range(numberOfParameters)]
323 self.arrayData = [[] for _ in range(numberOfArrays)]
324 self.columnData = [[] for _ in range(numberOfColumns)]
325 self.arrayDimensions = [[] for _ in range(numberOfArrays)]
326
327 # Read in SDDS data (last rows)
328 page = sddsdata.ReadPageLastRows(self.index, lastrows)
329 if page != 1:
330 raise Exception("Unable to read SDDS data for the first page")
331 while page > 0:
332 for i in range(numberOfParameters):
333 self.parameterData[i].append(sddsdata.GetParameter(self.index, i))
334 for i in range(numberOfArrays):
335 self.arrayData[i].append(sddsdata.GetArray(self.index, i))
336 self.arrayDimensions[i].append(sddsdata.GetArrayDimensions(self.index, i))
337 rows = sddsdata.RowCount(self.index)
338 if rows > 0:
339 for i in range(numberOfColumns):
340 self.columnData[i].append(sddsdata.GetColumn(self.index, i))
341 else:
342 for i in range(numberOfColumns):
343 self.columnData[i].append([])
344 page = sddsdata.ReadPageLastRows(self.index, lastrows)
345
346 # Close SDDS file
347 if sddsdata.Terminate(self.index) != 1:
348 raise ValueError("Failed to terminate SDDS input.")
349
350 except:
351 sddsdata.PrintErrors(self.SDDS_VERBOSE_PrintErrors)
352 raise
353

◆ loadSparse()

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.

193 def loadSparse(self, input, interval, offset):
194 """
195 Loads an SDDS file into the SDDS object with sparse data reading.
196
197 Args:
198 input (str): The input SDDS filename to load.
199 interval (int): Interval between pages to read.
200 offset (int): Offset to start reading from.
201
202 Raises:
203 Exception: If unable to read the SDDS data.
204
205 This method reads every `interval` pages from the SDDS file, starting from the page at `offset`.
206 """
207 try:
208 # Open SDDS file
209 if sddsdata.InitializeInput(self.index, input) != 1:
210 time.sleep(1)
211 if sddsdata.InitializeInput(self.index, input) != 1:
212 raise ValueError("Failed to initialize SDDS input.")
213
214 # Get data storage mode (SDDS_ASCII or SDDS_BINARY)
215 self.mode = sddsdata.GetMode(self.index)
216
217 # Get description text and contents
218 self.description = sddsdata.GetDescription(self.index)
219
220 # Get parameter names
221 self.parameterName = sddsdata.GetParameterNames(self.index)
222 numberOfParameters = len(self.parameterName)
223
224 # Get array names
225 self.arrayName = sddsdata.GetArrayNames(self.index)
226 numberOfArrays = len(self.arrayName)
227
228 # Get column names
229 self.columnName = sddsdata.GetColumnNames(self.index)
230 numberOfColumns = len(self.columnName)
231
232 # Get parameter definitions
233 self.parameterDefinition = [sddsdata.GetParameterDefinition(self.index, name) for name in self.parameterName]
234
235 # Get array definitions
236 self.arrayDefinition = [sddsdata.GetArrayDefinition(self.index, name) for name in self.arrayName]
237
238 # Get column definitions
239 self.columnDefinition = [sddsdata.GetColumnDefinition(self.index, name) for name in self.columnName]
240
241 # Initialize parameter, array, and column data
242 self.parameterData = [[] for _ in range(numberOfParameters)]
243 self.arrayData = [[] for _ in range(numberOfArrays)]
244 self.columnData = [[] for _ in range(numberOfColumns)]
245 self.arrayDimensions = [[] for _ in range(numberOfArrays)]
246
247 # Read in SDDS data sparsely
248 page = sddsdata.ReadPageSparse(self.index, interval, offset)
249 if page != 1:
250 raise Exception("Unable to read SDDS data for the first page")
251 while page > 0:
252 for i in range(numberOfParameters):
253 self.parameterData[i].append(sddsdata.GetParameter(self.index, i))
254 for i in range(numberOfArrays):
255 self.arrayData[i].append(sddsdata.GetArray(self.index, i))
256 self.arrayDimensions[i].append(sddsdata.GetArrayDimensions(self.index, i))
257 rows = sddsdata.RowCount(self.index)
258 if rows > 0:
259 for i in range(numberOfColumns):
260 self.columnData[i].append(sddsdata.GetColumn(self.index, i))
261 else:
262 for i in range(numberOfColumns):
263 self.columnData[i].append([])
264 page = sddsdata.ReadPageSparse(self.index, interval, offset)
265
266 # Close SDDS file
267 if sddsdata.Terminate(self.index) != 1:
268 raise ValueError("Failed to terminate SDDS input.")
269
270 except:
271 sddsdata.PrintErrors(self.SDDS_VERBOSE_PrintErrors)
272 raise
273

◆ pageCount()

sdds.SDDS.pageCount ( self)

Retrieves the number or loaded pages.

Returns: int: Number or loaded pages

Definition at line 1258 of file sdds.py.

1258 def pageCount(self):
1259 """
1260 Retrieves the number or loaded pages
1261
1262 Returns:
1263 int: Number or loaded pages
1264 """
1265 return(self.loaded_pages)
1266
1267
1268
1269# Expose constants to the module-level namespace

◆ save()

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.

354 def save(self, output):
355 """
356 Saves the SDDS object's data to an SDDS file.
357
358 Args:
359 output (str): The output SDDS filename to save the data.
360
361 Raises:
362 Exception: If unable to write the SDDS data.
363
364 This method writes the data stored in the SDDS object to the specified file, including the
365 parameters, arrays, columns, and their data.
366 """
367 try:
368 # Check for invalid SDDS data
369 numberOfParameters = len(self.parameterName)
370 numberOfArrays = len(self.arrayName)
371 numberOfColumns = len(self.columnName)
372 pages = 0
373
374 if numberOfParameters != len(self.parameterData):
375 raise Exception("Unmatched parameterName and parameterData")
376 if numberOfArrays != len(self.arrayData):
377 raise Exception("Unmatched arrayName and arrayData")
378 if numberOfColumns != len(self.columnData):
379 raise Exception("Unmatched columnName and columnData")
380 if numberOfParameters != len(self.parameterDefinition):
381 raise Exception("Unmatched parameterName and parameterDefinition")
382 if numberOfArrays != len(self.arrayDefinition):
383 raise Exception("Unmatched arrayName and arrayDefinition")
384 if numberOfColumns != len(self.columnDefinition):
385 raise Exception("Unmatched columnName and columnDefinition")
386
387 if numberOfParameters > 0:
388 pages = len(self.parameterData[0])
389 elif numberOfColumns > 0:
390 pages = len(self.columnData[0])
391 elif numberOfArrays > 0:
392 pages = len(self.arrayData[0])
393
394 for i in range(numberOfParameters):
395 if pages != len(self.parameterData[i]):
396 raise Exception("Unequal number of pages in parameter data")
397 for i in range(numberOfArrays):
398 if pages != len(self.arrayData[i]):
399 raise Exception("Unequal number of pages in array data")
400 if pages != len(self.arrayDimensions[i]):
401 raise Exception("Unequal number of pages in array dimension data")
402 for i in range(numberOfColumns):
403 if pages != len(self.columnData[i]):
404 raise Exception("Unequal number of pages in column data")
405 for page in range(pages):
406 rows = 0
407 if numberOfColumns > 0:
408 rows = len(self.columnData[0][page])
409 for i in range(numberOfColumns):
410 if rows != len(self.columnData[i][page]):
411 raise Exception("Unequal number of rows in column data")
412
413 # Open SDDS output file
414 if sddsdata.InitializeOutput(self.index, self.mode, 1, self.description[0], self.description[1], output) != 1:
415 raise ValueError("Failed to initialize SDDS output.")
416
417 # Define parameters, arrays, and columns
418 for i in range(numberOfParameters):
419 if sddsdata.DefineParameter(
420 self.index,
421 self.parameterName[i],
422 self.parameterDefinition[i][0],
423 self.parameterDefinition[i][1],
424 self.parameterDefinition[i][2],
425 self.parameterDefinition[i][3],
426 self.parameterDefinition[i][4],
427 self.parameterDefinition[i][5],
428 ) == -1:
429 raise ValueError("Failed to define parameter.")
430
431 for i in range(numberOfArrays):
432 if sddsdata.DefineArray(
433 self.index,
434 self.arrayName[i],
435 self.arrayDefinition[i][0],
436 self.arrayDefinition[i][1],
437 self.arrayDefinition[i][2],
438 self.arrayDefinition[i][3],
439 self.arrayDefinition[i][4],
440 self.arrayDefinition[i][5],
441 self.arrayDefinition[i][6],
442 self.arrayDefinition[i][7],
443 ) == -1:
444 raise ValueError("Failed to define array.")
445
446 for i in range(numberOfColumns):
447 if sddsdata.DefineColumn(
448 self.index,
449 self.columnName[i],
450 self.columnDefinition[i][0],
451 self.columnDefinition[i][1],
452 self.columnDefinition[i][2],
453 self.columnDefinition[i][3],
454 self.columnDefinition[i][4],
455 self.columnDefinition[i][5],
456 ) == -1:
457 raise ValueError("Failed to define column.")
458
459 # Write SDDS header
460 if sddsdata.WriteLayout(self.index) != 1:
461 raise ValueError("Failed to write SDDS layout.")
462
463 # Write SDDS data
464 for page in range(pages):
465 rows = 0
466 if numberOfColumns > 0:
467 rows = len(self.columnData[0][page])
468 if sddsdata.StartPage(self.index, rows) != 1:
469 raise ValueError("Failed to start SDDS page.")
470 for i in range(numberOfParameters):
471 if sddsdata.SetParameter(self.index, i, self.parameterData[i][page]) != 1:
472 raise ValueError("Failed to set parameter value.")
473 for i in range(numberOfArrays):
474 if sddsdata.SetArray(
475 self.index, i, self.arrayData[i][page], self.arrayDimensions[i][page]
476 ) != 1:
477 raise ValueError("Failed to set array value.")
478 for i in range(numberOfColumns):
479 if sddsdata.SetColumn(self.index, i, self.columnData[i][page]) != 1:
480 raise ValueError("Failed to set column value.")
481 if sddsdata.WritePage(self.index) != 1:
482 raise ValueError("Failed to write SDDS page.")
483
484 # Close SDDS output file
485 if sddsdata.Terminate(self.index) != 1:
486 raise ValueError("Failed to terminate SDDS output.")
487 except:
488 sddsdata.PrintErrors(self.SDDS_VERBOSE_PrintErrors)
489 raise
490

◆ setArrayValueList()

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.

839 def setArrayValueList(self, name, valueList, dimensionList, page=1):
840 """
841 Sets a single array value and dimension at a specific page.
842
843 Args:
844 name (str): Array name.
845 valueList (list): Array values.
846 dimensionList (list): Array dimensions.
847 page (int, optional): Page number (1-based index, defaults to 1).
848
849 Raises:
850 Exception: If the array name or page is invalid.
851
852 This method sets the array values and dimensions at the specified page.
853 """
854 page = page - 1
855 numberOfArrays = len(self.arrayName)
856 if name in self.arrayName:
857 i = self.arrayName.index(name)
858 if len(self.arrayData[i]) == page:
859 self.arrayData[i][page:] = [valueList]
860 self.arrayDimensions[i][page:] = [dimensionList]
861 elif len(self.arrayData[i]) < page or page < 0:
862 msg = "Invalid page " + str(page + 1)
863 raise Exception(msg)
864 else:
865 self.arrayData[i][page] = valueList
866 self.arrayDimensions[i][page] = dimensionList
867 else:
868 msg = "Invalid array name " + name
869 raise Exception(msg)
870

◆ setArrayValueLists()

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.

776 def setArrayValueLists(self, name, valueList, dimensionList):
777 """
778 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.
779
780 Args:
781 name (str): Array name.
782 valueList (list): Nested list of array values.
783 dimensionList (list): Nested list of array dimensions.
784
785 Raises:
786 Exception: If the array name is invalid.
787
788 This method assigns values and dimensions to an array across pages.
789 """
790 numberOfArrays = len(self.arrayName)
791 if name in self.arrayName:
792 i = self.arrayName.index(name)
793 self.arrayDimensions[i] = dimensionList
794 self.arrayData[i] = valueList
795 else:
796 msg = "Invalid array name " + name
797 raise Exception(msg)
798

◆ setColumnValue()

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.

1026 def setColumnValue(self, name, value, page=1, row=1):
1027 """
1028 Sets a single column value at a specific page and row.
1029
1030 Args:
1031 name (str): Column name.
1032 value: Column value.
1033 page (int, optional): Page number (1-based index, defaults to 1).
1034 row (int, optional): Row number (1-based index, defaults to 1).
1035
1036 Raises:
1037 Exception: If the column name, page, or row is invalid.
1038
1039 This method sets the column value at the specified page and row.
1040 """
1041 page = page - 1
1042 row = row - 1
1043 numberOfColumns = len(self.columnName)
1044 if name in self.columnName:
1045 i = self.columnName.index(name)
1046 if len(self.columnData[i]) == page:
1047 if row == 0:
1048 self.columnData[i][page:] = [[value]]
1049 else:
1050 msg = "Invalid row " + str(row + 1)
1051 raise Exception(msg)
1052 elif len(self.columnData[i]) < page or page < 0:
1053 msg = "Invalid page " + str(page + 1)
1054 raise Exception(msg)
1055 else:
1056 if len(self.columnData[i][page]) == row:
1057 self.columnData[i][page][row:] = [value]
1058 elif len(self.columnData[i][page]) < row or row < 0:
1059 msg = "Invalid row " + str(row + 1)
1060 raise Exception(msg)
1061 else:
1062 self.columnData[i][page][row] = value
1063 else:
1064 msg = "Invalid column name " + name
1065 raise Exception(msg)
1066

◆ setColumnValueList()

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.

969 def setColumnValueList(self, name, valueList, page=1):
970 """
971 Sets a single column value list at a specific page.
972
973 Args:
974 name (str): Column name.
975 valueList (list): Column values.
976 page (int, optional): Page number (1-based index, defaults to 1).
977
978 Raises:
979 Exception: If the column name or page is invalid.
980
981 This method sets the column values at the specified page.
982 """
983 page = page - 1
984 if name in self.columnName:
985 i = self.columnName.index(name)
986 if len(self.columnData[i]) == page:
987 self.columnData[i][page:] = [valueList]
988 elif len(self.columnData[i]) < page or page < 0:
989 msg = "Invalid page " + str(page + 1)
990 raise Exception(msg)
991 else:
992 self.columnData[i][page] = valueList
993 else:
994 msg = "Invalid column name " + name
995 raise Exception(msg)
996

◆ setColumnValueLists()

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.

929 def setColumnValueLists(self, name, valueList):
930 """
931 Sets the nested list of column values for a single column. This can be used to set values for multiple pages at once.
932
933 Args:
934 name (str): Column name.
935 valueList (list): Nested list of column values.
936
937 Raises:
938 Exception: If the column name is invalid.
939
940 This method assigns a list of values to a column across pages.
941 """
942 numberOfColumns = len(self.columnName)
943 if name in self.columnName:
944 self.columnData[self.columnName.index(name)] = valueList
945 else:
946 msg = "Invalid column name " + name
947 raise Exception(msg)
948

◆ setDescription()

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.

491 def setDescription(self, text, contents):
492 """
493 Sets the description for the SDDS object.
494
495 Args:
496 text (str): Description text.
497 contents (str): Description contents.
498 """
499 self.description = [text, contents]
500

◆ setParameterValue()

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.

718 def setParameterValue(self, name, value, page=1):
719 """
720 Sets a single parameter value at a specific page.
721
722 Args:
723 name (str): Parameter name.
724 value: Parameter value.
725 page (int, optional): Page number (1-based index, defaults to 1).
726
727 Raises:
728 Exception: If the parameter name or page is invalid.
729
730 This method sets the parameter value at the specified page.
731 """
732 page = page - 1
733 numberOfParameters = len(self.parameterName)
734 if name in self.parameterName:
735 i = self.parameterName.index(name)
736 if len(self.parameterData[i]) == page:
737 self.parameterData[i][page:] = [value]
738 elif len(self.parameterData[i]) < page or page < 0:
739 msg = "Invalid page " + str(page + 1)
740 raise Exception(msg)
741 else:
742 self.parameterData[i][page] = value
743 else:
744 msg = "Invalid parameter name " + name
745 raise Exception(msg)
746

◆ setParameterValueList()

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.

677 def setParameterValueList(self, name, valueList):
678 """
679 Sets the list of parameter values for a parameter. This can be used to set values for multiple pages at once.
680
681 Args:
682 name (str): Parameter name.
683 valueList (list): List of values for the parameter.
684
685 Raises:
686 Exception: If the parameter name is invalid.
687
688 This method assigns a list of values to a parameter across pages.
689 """
690 numberOfParameters = len(self.parameterName)
691 if name in self.parameterName:
692 self.parameterData[self.parameterName.index(name)] = valueList
693 else:
694 msg = "Invalid parameter name " + name
695 raise Exception(msg)
696

Member Data Documentation

◆ arrayData

list sdds.SDDS.arrayData = []

Definition at line 107 of file sdds.py.

◆ arrayDefinition

list sdds.SDDS.arrayDefinition = []

Definition at line 103 of file sdds.py.

◆ arrayDimensions

list sdds.SDDS.arrayDimensions = []

Definition at line 104 of file sdds.py.

◆ arrayName [1/2]

str sdds.SDDS.arrayName = []

Definition at line 100 of file sdds.py.

◆ arrayName [2/2]

str sdds.SDDS.arrayName = "Invalid array name " + name

Definition at line 813 of file sdds.py.

◆ columnData

list sdds.SDDS.columnData = []

Definition at line 108 of file sdds.py.

◆ columnDefinition

list sdds.SDDS.columnDefinition = []

Definition at line 105 of file sdds.py.

◆ columnName [1/2]

str sdds.SDDS.columnName = []

Definition at line 101 of file sdds.py.

◆ columnName [2/2]

str sdds.SDDS.columnName = "Invalid column name " + name

Definition at line 963 of file sdds.py.

◆ description

list sdds.SDDS.description = ["", ""]

Definition at line 98 of file sdds.py.

◆ index

sdds.SDDS.index = index

Definition at line 94 of file sdds.py.

◆ loaded_pages

sdds.SDDS.loaded_pages = 0

Definition at line 110 of file sdds.py.

◆ mode

sdds.SDDS.mode = self.SDDS_ASCII

Definition at line 109 of file sdds.py.

◆ parameterData

list sdds.SDDS.parameterData = []

Definition at line 106 of file sdds.py.

◆ parameterDefinition

list sdds.SDDS.parameterDefinition = []

Definition at line 102 of file sdds.py.

◆ parameterName [1/2]

str sdds.SDDS.parameterName = []

Definition at line 99 of file sdds.py.

◆ parameterName [2/2]

str sdds.SDDS.parameterName = "Invalid parameter name " + name

Definition at line 712 of file sdds.py.

◆ SDDS_ASCII

int sdds.SDDS.SDDS_ASCII = 2
static

Definition at line 81 of file sdds.py.

◆ SDDS_BINARY

int sdds.SDDS.SDDS_BINARY = 1
static

Definition at line 80 of file sdds.py.

◆ SDDS_CHARACTER

int sdds.SDDS.SDDS_CHARACTER = 11
static

Definition at line 76 of file sdds.py.

◆ SDDS_CHECK_NONEXISTENT

int sdds.SDDS.SDDS_CHECK_NONEXISTENT = 1
static

Definition at line 53 of file sdds.py.

◆ SDDS_CHECK_OKAY

int sdds.SDDS.SDDS_CHECK_OKAY = 0
static

Definition at line 52 of file sdds.py.

◆ SDDS_CHECK_WRONGTYPE

int sdds.SDDS.SDDS_CHECK_WRONGTYPE = 2
static

Definition at line 54 of file sdds.py.

◆ SDDS_CHECK_WRONGUNITS

int sdds.SDDS.SDDS_CHECK_WRONGUNITS = 3
static

Definition at line 55 of file sdds.py.

◆ SDDS_DOUBLE

int sdds.SDDS.SDDS_DOUBLE = 2
static

Definition at line 59 of file sdds.py.

◆ SDDS_EXIT_PrintErrors

int sdds.SDDS.SDDS_EXIT_PrintErrors = 2
static

Definition at line 49 of file sdds.py.

◆ SDDS_FLOAT

int sdds.SDDS.SDDS_FLOAT = 3
static

Definition at line 61 of file sdds.py.

◆ SDDS_FLUSH_TABLE

int sdds.SDDS.SDDS_FLUSH_TABLE = 1
static

Definition at line 82 of file sdds.py.

◆ SDDS_INT16

int sdds.SDDS.SDDS_INT16 = 8
static

Definition at line 72 of file sdds.py.

◆ SDDS_INT32

int sdds.SDDS.SDDS_INT32 = 6
static

Definition at line 68 of file sdds.py.

◆ SDDS_INT64

int sdds.SDDS.SDDS_INT64 = 4
static

Definition at line 64 of file sdds.py.

◆ SDDS_LONG

int sdds.SDDS.SDDS_LONG = 6
static

Definition at line 67 of file sdds.py.

◆ SDDS_LONG64

int sdds.SDDS.SDDS_LONG64 = 4
static

Definition at line 63 of file sdds.py.

◆ SDDS_LONGDOUBLE

int sdds.SDDS.SDDS_LONGDOUBLE = 1
static

Definition at line 58 of file sdds.py.

◆ SDDS_NUM_TYPES

int sdds.SDDS.SDDS_NUM_TYPES = 11
static

Definition at line 77 of file sdds.py.

◆ SDDS_REAL32

int sdds.SDDS.SDDS_REAL32 = 3
static

Definition at line 62 of file sdds.py.

◆ SDDS_REAL64

int sdds.SDDS.SDDS_REAL64 = 2
static

Definition at line 60 of file sdds.py.

◆ SDDS_SHORT

int sdds.SDDS.SDDS_SHORT = 8
static

Definition at line 71 of file sdds.py.

◆ SDDS_STRING

int sdds.SDDS.SDDS_STRING = 10
static

Definition at line 75 of file sdds.py.

◆ SDDS_UINT16

int sdds.SDDS.SDDS_UINT16 = 9
static

Definition at line 74 of file sdds.py.

◆ SDDS_UINT32

int sdds.SDDS.SDDS_UINT32 = 7
static

Definition at line 70 of file sdds.py.

◆ SDDS_UINT64

int sdds.SDDS.SDDS_UINT64 = 5
static

Definition at line 66 of file sdds.py.

◆ SDDS_ULONG

int sdds.SDDS.SDDS_ULONG = 7
static

Definition at line 69 of file sdds.py.

◆ SDDS_ULONG64

int sdds.SDDS.SDDS_ULONG64 = 5
static

Definition at line 65 of file sdds.py.

◆ SDDS_USHORT

int sdds.SDDS.SDDS_USHORT = 9
static

Definition at line 73 of file sdds.py.

◆ SDDS_VERBOSE_PrintErrors

sdds.SDDS.SDDS_VERBOSE_PrintErrors = 1
static

Definition at line 48 of file sdds.py.


The documentation for this class was generated from the following file: