SDDS ToolKit Programs and Libraries for C and Python
All Classes Files Functions Variables Macros Pages
sddsdatamodule.c File Reference

Detailed Description

Python C extension module (sddsdata) for interfacing with the C language SDDS library.

This file provides a set of Python bindings to the SDDS library for handling scientific data in the Self-Describing Data Sets (SDDS) format.

Definition in file sddsdatamodule.c.

#include <Python.h>
#include "SDDS.h"

Go to the source code of this file.

Functions

static PyObject * sddsdata_InitializeInput (PyObject *self, PyObject *args)
 Initializes an SDDS dataset for input from a file.
 
static PyObject * sddsdata_InitializeAppend (PyObject *self, PyObject *args)
 Initializes an SDDS dataset for appending data to a file.
 
static PyObject * sddsdata_InitializeAppendToPage (PyObject *self, PyObject *args)
 Initializes appending data to an existing SDDS page in a file.
 
static PyObject * sddsdata_InitializeOutput (PyObject *self, PyObject *args)
 Initializes an SDDS dataset for output to a file.
 
static PyObject * sddsdata_SetColumnMajorOrder (PyObject *self, PyObject *args)
 Sets the data order for the SDDS dataset to column-major.
 
static PyObject * sddsdata_SetFixedRowCountMode (PyObject *self, PyObject *args)
 Sets the row count mode for an SDDS dataset to fixed row count mode.
 
static PyObject * sddsdata_SetRowMajorOrder (PyObject *self, PyObject *args)
 Sets the data order for the SDDS dataset to row-major.
 
static PyObject * sddsdata_EnableFSync (PyObject *self, PyObject *args)
 Enables filesystem synchronization (fsync) for an SDDS dataset.
 
static PyObject * sddsdata_DisableFSync (PyObject *self, PyObject *args)
 Disables filesystem synchronization (fsync) for an SDDS dataset.
 
static PyObject * sddsdata_Terminate (PyObject *self, PyObject *args)
 Terminates an SDDS dataset, releasing any associated resources.
 
static PyObject * sddsdata_SetTerminateMode (PyObject *self, PyObject *args)
 Sets the termination mode for SDDS to avoid freeing strings in arrays and tables.
 
static PyObject * sddsdata_DefineParameter (PyObject *self, PyObject *args)
 Defines a parameter in an SDDS dataset.
 
static PyObject * sddsdata_DefineArray (PyObject *self, PyObject *args)
 Defines an array in an SDDS dataset.
 
static PyObject * sddsdata_DefineColumn (PyObject *self, PyObject *args)
 Defines a column in an SDDS dataset.
 
static PyObject * sddsdata_IsValidName (PyObject *self, PyObject *args)
 Validates a name for SDDS compatibility.
 
static PyObject * sddsdata_SetNameValidityFlags (PyObject *self, PyObject *args)
 Sets name validity flags to allow any name.
 
static PyObject * sddsdata_DefineSimpleColumn (PyObject *self, PyObject *args)
 Defines a simple column in an SDDS dataset.
 
static PyObject * sddsdata_DefineSimpleArray (PyObject *self, PyObject *args)
 Defines a simple array in an SDDS dataset.
 
static PyObject * sddsdata_DefineSimpleParameter (PyObject *self, PyObject *args)
 Defines a simple parameter in an SDDS dataset.
 
static PyObject * sddsdata_WriteLayout (PyObject *self, PyObject *args)
 Writes the layout of an SDDS dataset.
 
static PyObject * sddsdata_EraseData (PyObject *self, PyObject *args)
 Erases data from an SDDS dataset.
 
static PyObject * sddsdata_ProcessColumnString (PyObject *self, PyObject *args)
 Processes a column definition string.
 
static PyObject * sddsdata_ProcessArrayString (PyObject *self, PyObject *args)
 Processes an array definition string.
 
static PyObject * sddsdata_ProcessParameterString (PyObject *self, PyObject *args)
 Processes a parameter definition string.
 
static PyObject * sddsdata_InitializeCopy (PyObject *self, PyObject *args)
 Initializes a copy from one SDDS dataset to another.
 
static PyObject * sddsdata_CopyLayout (PyObject *self, PyObject *args)
 Copies the layout from one SDDS dataset to another.
 
static PyObject * sddsdata_AppendLayout (PyObject *self, PyObject *args)
 Appends the layout of one SDDS dataset to another.
 
static PyObject * sddsdata_CopyPage (PyObject *self, PyObject *args)
 Copies a page from one SDDS dataset to another.
 
static PyObject * sddsdata_CopyParameters (PyObject *self, PyObject *args)
 Copies parameters from one SDDS dataset to another.
 
static PyObject * sddsdata_CopyArrays (PyObject *self, PyObject *args)
 Copies arrays from one SDDS dataset to another.
 
static PyObject * sddsdata_CopyColumns (PyObject *self, PyObject *args)
 Copies columns from one SDDS dataset to another.
 
static PyObject * sddsdata_CopyRow (PyObject *self, PyObject *args)
 Copies a row from one SDDS dataset to another.
 
static PyObject * sddsdata_CopyRowDirect (PyObject *self, PyObject *args)
 Directly copies a row from one SDDS dataset to another.
 
static PyObject * sddsdata_CopyAdditionalRows (PyObject *self, PyObject *args)
 Copies additional rows from one SDDS dataset to another.
 
static PyObject * sddsdata_DeferSavingLayout (PyObject *self, PyObject *args)
 Defers saving the layout of an SDDS dataset.
 
static PyObject * sddsdata_SaveLayout (PyObject *self, PyObject *args)
 Saves the layout of an SDDS dataset.
 
static PyObject * sddsdata_RestoreLayout (PyObject *self, PyObject *args)
 Restores the layout of an SDDS dataset.
 
static PyObject * sddsdata_StartPage (PyObject *self, PyObject *args)
 Starts a page in an SDDS dataset.
 
static PyObject * sddsdata_ClearPage (PyObject *self, PyObject *args)
 Clears the current page in an SDDS dataset.
 
static PyObject * sddsdata_LengthenTable (PyObject *self, PyObject *args)
 Lengthens the table by adding additional rows.
 
static PyObject * sddsdata_WritePage (PyObject *self, PyObject *args)
 Writes the current page of the dataset to the file.
 
static PyObject * sddsdata_UpdatePage (PyObject *self, PyObject *args)
 Updates the page based on the specified mode.
 
static PyObject * sddsdata_InitHeaderlessInput (PyObject *self, PyObject *args)
 Initializes a headerless input for a dataset file.
 
static PyObject * sddsdata_ReadPage (PyObject *self, PyObject *args)
 Reads the current page from the dataset file.
 
static PyObject * sddsdata_ReadPageSparse (PyObject *self, PyObject *args)
 Reads a sparse page from the dataset file.
 
static PyObject * sddsdata_ReadPageLastRows (PyObject *self, PyObject *args)
 Reads the last rows of the current page from the dataset file.
 
static PyObject * sddsdata_RowCount (PyObject *self, PyObject *args)
 Gets the number of rows in the dataset.
 
static PyObject * sddsdata_SetColumnFlags (PyObject *self, PyObject *args)
 Sets the column flags for the dataset.
 
static PyObject * sddsdata_SetRowFlags (PyObject *self, PyObject *args)
 Sets the row flags for the dataset.
 
static PyObject * sddsdata_GetRowFlag (PyObject *self, PyObject *args)
 Gets the flag value for a specific row in the dataset.
 
static PyObject * sddsdata_DeleteColumn (PyObject *self, PyObject *args)
 Deletes a column from the dataset.
 
static PyObject * sddsdata_DeleteParameter (PyObject *self, PyObject *args)
 Deletes a parameter from the dataset.
 
static PyObject * sddsdata_DeleteUnsetColumns (PyObject *self, PyObject *args)
 Deletes all unset columns in the dataset.
 
static PyObject * sddsdata_DeleteUnsetRows (PyObject *self, PyObject *args)
 Deletes all unset rows in the dataset.
 
static PyObject * sddsdata_ColumnCount (PyObject *self, PyObject *args)
 Gets the count of columns in the dataset.
 
static PyObject * sddsdata_ArrayCount (PyObject *self, PyObject *args)
 Gets the count of arrays in the dataset.
 
static PyObject * sddsdata_ParameterCount (PyObject *self, PyObject *args)
 Gets the count of parameters in the dataset.
 
static PyObject * sddsdata_GetDescription (PyObject *self, PyObject *args)
 Gets the description (text and contents) of the dataset.
 
static PyObject * sddsdata_GetDescriptionText (PyObject *self, PyObject *args)
 Retrieves the description text for a dataset.
 
static PyObject * sddsdata_GetDescriptionContents (PyObject *self, PyObject *args)
 Retrieves the description contents for a dataset.
 
static PyObject * sddsdata_NumberOfErrors (PyObject *self, PyObject *args)
 Returns the number of errors recorded.
 
static PyObject * sddsdata_ClearErrors (PyObject *self, PyObject *args)
 Clears all recorded errors.
 
static PyObject * sddsdata_SetError (PyObject *self, PyObject *args)
 Sets an error description.
 
static PyObject * sddsdata_Bomb (PyObject *self, PyObject *args)
 Displays a message on stderr and exits the program.
 
static PyObject * sddsdata_Warning (PyObject *self, PyObject *args)
 Displays a warning message on stderr.
 
static PyObject * sddsdata_RegisterProgramName (PyObject *self, PyObject *args)
 Registers a program name for use in error messages.
 
static PyObject * sddsdata_PrintErrors (PyObject *self, PyObject *args)
 Prints error messages based on the provided mode.
 
static PyObject * sddsdata_TransferColumnDefinition (PyObject *self, PyObject *args)
 Transfers a column definition from one dataset to another.
 
static PyObject * sddsdata_TransferArrayDefinition (PyObject *self, PyObject *args)
 Transfers an array definition from one dataset to another.
 
static PyObject * sddsdata_TransferParameterDefinition (PyObject *self, PyObject *args)
 Transfers a parameter definition from one dataset to another.
 
static PyObject * sddsdata_DefineColumnLikeParameter (PyObject *self, PyObject *args)
 Defines a column in one dataset based on a parameter in another dataset.
 
static PyObject * sddsdata_DefineParameterLikeColumn (PyObject *self, PyObject *args)
 Defines a parameter in one dataset based on a column in another dataset.
 
static PyObject * sddsdata_TransferAllColumnDefinitions (PyObject *self, PyObject *args)
 Transfers all column definitions from one dataset to another.
 
static PyObject * sddsdata_TransferAllArrayDefinitions (PyObject *self, PyObject *args)
 Transfers all array definitions from one dataset to another.
 
static PyObject * sddsdata_TransferAllParameterDefinitions (PyObject *self, PyObject *args)
 Transfers all parameter definitions from one dataset to another.
 
static PyObject * sddsdata_GetColumnIndex (PyObject *self, PyObject *args)
 Retrieves the index of a column in a dataset.
 
static PyObject * sddsdata_GetArrayIndex (PyObject *self, PyObject *args)
 Retrieves the index of an array in a dataset.
 
static PyObject * sddsdata_GetParameterIndex (PyObject *self, PyObject *args)
 Retrieves the index of a parameter in a dataset.
 
static PyObject * sddsdata_GetColumnType (PyObject *self, PyObject *args)
 Retrieves the type of a column in a dataset.
 
static PyObject * sddsdata_GetArrayType (PyObject *self, PyObject *args)
 Retrieves the type of an array in a dataset.
 
static PyObject * sddsdata_GetNamedColumnType (PyObject *self, PyObject *args)
 Retrieves the type of a column by name in a dataset.
 
static PyObject * sddsdata_GetNamedArrayType (PyObject *self, PyObject *args)
 Retrieves the type of an array by name in a dataset.
 
static PyObject * sddsdata_GetColumnDefinition (PyObject *self, PyObject *args)
 Retrieves the definition of a column in a dataset.
 
static PyObject * sddsdata_GetArrayDefinition (PyObject *self, PyObject *args)
 Retrieves the definition of an array in a dataset.
 
static PyObject * sddsdata_GetParameterType (PyObject *self, PyObject *args)
 Retrieves the type of a parameter in a dataset.
 
static PyObject * sddsdata_GetNamedParameterType (PyObject *self, PyObject *args)
 Retrieves the type of a parameter by name in a dataset.
 
static PyObject * sddsdata_GetParameterDefinition (PyObject *self, PyObject *args)
 Retrieves the definition of a parameter in a dataset.
 
static PyObject * sddsdata_GetTypeSize (PyObject *self, PyObject *args)
 Retrieves the size of a given SDDS data type.
 
static PyObject * sddsdata_GetTypeName (PyObject *self, PyObject *args)
 Retrieves the name of a given SDDS data type.
 
static PyObject * sddsdata_IdentifyType (PyObject *self, PyObject *args)
 Identifies the SDDS data type for a given type name.
 
static PyObject * sddsdata_CheckColumn (PyObject *self, PyObject *args)
 Verifies the existence and type of a column in a dataset.
 
static PyObject * sddsdata_CheckArray (PyObject *self, PyObject *args)
 Verifies the existence and type of an array in a dataset.
 
static PyObject * sddsdata_CheckParameter (PyObject *self, PyObject *args)
 Verifies the existence and type of a parameter in a dataset.
 
static PyObject * sddsdata_HasWhitespace (PyObject *self, PyObject *args)
 Determines if a string contains whitespace.
 
static PyObject * sddsdata_StringIsBlank (PyObject *self, PyObject *args)
 Checks if a string is blank.
 
static PyObject * sddsdata_ApplyFactorToParameter (PyObject *self, PyObject *args)
 Applies a scaling factor to a parameter in a dataset.
 
static PyObject * sddsdata_ApplyFactorToColumn (PyObject *self, PyObject *args)
 Applies a scaling factor to a column in a dataset.
 
static PyObject * sddsdata_DeleteParameterFixedValues (PyObject *self, PyObject *args)
 Deletes fixed parameter values for a given dataset.
 
static PyObject * sddsdata_SetDataMode (PyObject *self, PyObject *args)
 Sets the data mode for a given dataset.
 
static PyObject * sddsdata_CheckDataset (PyObject *self, PyObject *args)
 Checks the validity of a dataset.
 
static PyObject * sddsdata_SetAutoCheckMode (PyObject *self, PyObject *args)
 Sets the auto-check mode for datasets.
 
static PyObject * sddsdata_GetColumnNameFromIndex (PyObject *self, PyObject *args)
 Retrieves a column name by its index from a dataset.
 
static PyObject * sddsdata_GetColumnNames (PyObject *self, PyObject *args)
 Retrieves all column names from a dataset.
 
static PyObject * sddsdata_GetArrayNameFromIndex (PyObject *self, PyObject *args)
 Retrieves an array name by its index from a dataset.
 
static PyObject * sddsdata_GetArrayNames (PyObject *self, PyObject *args)
 Retrieves all array names from a dataset.
 
static PyObject * sddsdata_GetParameterNameFromIndex (PyObject *self, PyObject *args)
 Retrieves a parameter name by its index from a dataset.
 
static PyObject * sddsdata_GetParameterNames (PyObject *self, PyObject *args)
 Retrieves all parameter names from a dataset.
 
static PyObject * sddsdata_SetParameter (PyObject *self, PyObject *args)
 Sets a parameter value in a dataset by index or name.
 
static PyObject * sddsdata_SetArray (PyObject *self, PyObject *args)
 Sets an array value in a dataset.
 
static PyObject * sddsdata_SetColumn (PyObject *self, PyObject *args)
 Sets a column value in a dataset.
 
static PyObject * sddsdata_SetRowValues (PyObject *self, PyObject *args)
 Sets values for a specific row in a dataset.
 
static PyObject * sddsdata_GetColumn (PyObject *self, PyObject *args)
 Retrieves a column's data from a dataset.
 
static PyObject * sddsdata_GetArray (PyObject *self, PyObject *args)
 Retrieves an array's data from a dataset.
 
static PyObject * sddsdata_GetArrayDimensions (PyObject *self, PyObject *args)
 Retrieves the dimensions of an array in a dataset.
 
static PyObject * sddsdata_GetParameter (PyObject *self, PyObject *args)
 Retrieves the value of a parameter from a dataset.
 
static PyObject * sddsdata_GetMode (PyObject *self, PyObject *args)
 Retrieves the data mode of a dataset.
 
void initsddsdata (void)
 

Function Documentation

◆ initsddsdata()

void initsddsdata ( void )

Definition at line 3731 of file sddsdatamodule.c.

3733{
3734 struct module_state *st;
3735#if PY_MAJOR_VERSION >= 3
3736 PyObject *module = PyModule_Create(&moduledef);
3737#else
3738 PyObject *module = Py_InitModule( "sddsdata", sddsdata_methods );
3739#endif
3740 if (module == NULL)
3741 INITERROR;
3742
3743 st = GETSTATE(module);
3744
3745 st->error = PyErr_NewException("sddsedir.Error", NULL, NULL);
3746 if (st->error == NULL) {
3747 Py_DECREF(module);
3748 INITERROR;
3749 }
3750
3751#if PY_MAJOR_VERSION >= 3
3752 return module;
3753#endif
3754
3755}

◆ sddsdata_AppendLayout()

static PyObject * sddsdata_AppendLayout ( PyObject * self,
PyObject * args )
static

Appends the layout of one SDDS dataset to another.

Parameters
selfUnused.
argsA tuple containing:
  • fileIndexTarget (long): Index of the target dataset.
  • fileIndexSource (long): Index of the source dataset.
Returns
PyObject* A Python integer (1 on success, 0 on error).

Definition at line 751 of file sddsdatamodule.c.

752{
753 long fileIndexTarget;
754 long fileIndexSource;
755 if (!PyArg_ParseTuple(args, "ll", &fileIndexTarget, &fileIndexSource)) {
756 return 0;
757 }
758 return PyLong_FromLong(SDDS_AppendLayout(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource], 0));
759}
int32_t SDDS_AppendLayout(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source, uint32_t mode)
Definition SDDS_copy.c:158
SDDS_DATASET dataset_f[20]
Array of SDDS dataset structures.

◆ sddsdata_ApplyFactorToColumn()

static PyObject * sddsdata_ApplyFactorToColumn ( PyObject * self,
PyObject * args )
static

Applies a scaling factor to a column in a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex (long): Dataset index.
  • name (char*): Column name.
  • factor (double): Scaling factor.
Returns
Python integer (1 on success, 0 on error).

Definition at line 2253 of file sddsdatamodule.c.

2254{
2255 long fileIndex;
2256 char *name;
2257 double factor;
2258 if (!PyArg_ParseTuple(args, "lsd", &fileIndex, &name, &factor)) {
2259 return 0;
2260 }
2261 return PyLong_FromLong(SDDS_ApplyFactorToColumn(&dataset_f[fileIndex], name, factor));
2262}
int32_t SDDS_ApplyFactorToColumn(SDDS_DATASET *SDDS_dataset, char *name, double factor)
Applies a scaling factor to all elements of a specific column in the SDDS dataset.

◆ sddsdata_ApplyFactorToParameter()

static PyObject * sddsdata_ApplyFactorToParameter ( PyObject * self,
PyObject * args )
static

Applies a scaling factor to a parameter in a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex (long): Dataset index.
  • name (char*): Parameter name.
  • factor (double): Scaling factor.
Returns
Python integer (1 on success, 0 on error).

Definition at line 2232 of file sddsdatamodule.c.

2233{
2234 long fileIndex;
2235 char *name;
2236 double factor;
2237 if (!PyArg_ParseTuple(args, "lsd", &fileIndex, &name, &factor)) {
2238 return 0;
2239 }
2240 return PyLong_FromLong(SDDS_ApplyFactorToParameter(&dataset_f[fileIndex], name, factor));
2241}
int32_t SDDS_ApplyFactorToParameter(SDDS_DATASET *SDDS_dataset, char *name, double factor)
Applies a scaling factor to a specific parameter in the SDDS dataset.

◆ sddsdata_ArrayCount()

static PyObject * sddsdata_ArrayCount ( PyObject * self,
PyObject * args )
static

Gets the count of arrays in the dataset.

Parameters
selfPython object (unused).
argsPython arguments tuple containing:
  • fileIndex (long): Index of the dataset file.
Returns
PyObject*: Number of arrays as PyLong.

Definition at line 1331 of file sddsdatamodule.c.

1332{
1333 long fileIndex;
1334 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
1335 return 0;
1336 }
1337 return PyLong_FromLong(SDDS_ArrayCount(&dataset_f[fileIndex]));
1338}
int32_t SDDS_ArrayCount(SDDS_DATASET *page)
Retrieves the number of arrays in the SDDS dataset.

◆ sddsdata_Bomb()

static PyObject * sddsdata_Bomb ( PyObject * self,
PyObject * args )
static

Displays a message on stderr and exits the program.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • message (char*): Message to display.
Returns
Python None, or NULL on error.

Definition at line 1495 of file sddsdatamodule.c.

1496{
1497 char *message;
1498 if (!PyArg_ParseTuple(args, "s", &message)) {
1499 return NULL;
1500 }
1501 SDDS_Bomb(message);
1502 Py_INCREF(Py_None);
1503 return Py_None;
1504}
void SDDS_Bomb(char *message)
Terminates the program after printing an error message and recorded errors.
Definition SDDS_utils.c:342

◆ sddsdata_CheckArray()

static PyObject * sddsdata_CheckArray ( PyObject * self,
PyObject * args )
static

Verifies the existence and type of an array in a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex (long): Dataset index.
  • name (char*): Array name.
  • units (char*): Expected units.
  • type (long): Expected type.
Returns
Python integer indicating the check status.

Definition at line 2153 of file sddsdatamodule.c.

2154{
2155 long fileIndex;
2156 char *name;
2157 char *units;
2158 long type;
2159 if (!PyArg_ParseTuple(args, "lssl", &fileIndex, &name, &units, &type)) {
2160 return PyLong_FromLong(SDDS_CHECK_WRONGTYPE);
2161 }
2162 return PyLong_FromLong(SDDS_CheckArray(&dataset_f[fileIndex], name, units, type, stderr));
2163}
int32_t SDDS_CheckArray(SDDS_DATASET *SDDS_dataset, char *name, char *units, int32_t type, FILE *fp_message)
Checks if an array exists in the SDDS dataset with the specified name, units, and type.

◆ sddsdata_CheckColumn()

static PyObject * sddsdata_CheckColumn ( PyObject * self,
PyObject * args )
static

Verifies the existence and type of a column in a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex (long): Dataset index.
  • name (char*): Column name.
  • units (char*): Expected units.
  • type (long): Expected type.
Returns
Python integer indicating the check status.

Definition at line 2130 of file sddsdatamodule.c.

2131{
2132 long fileIndex;
2133 char *name;
2134 char *units;
2135 long type;
2136 if (!PyArg_ParseTuple(args, "lssl", &fileIndex, &name, &units, &type)) {
2137 return PyLong_FromLong(SDDS_CHECK_WRONGTYPE);
2138 }
2139 return PyLong_FromLong(SDDS_CheckColumn(&dataset_f[fileIndex], name, units, type, stderr));
2140}
int32_t SDDS_CheckColumn(SDDS_DATASET *SDDS_dataset, char *name, char *units, int32_t type, FILE *fp_message)
Checks if a column exists in the SDDS dataset with the specified name, units, and type.

◆ sddsdata_CheckDataset()

static PyObject * sddsdata_CheckDataset ( PyObject * self,
PyObject * args )
static

Checks the validity of a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex: Index of the dataset file.
  • caller: Caller information string.
Returns
PyObject*:
  • 0 on error.
  • 1 on success.

Definition at line 2318 of file sddsdatamodule.c.

2319{
2320 long fileIndex;
2321 char *caller;
2322 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &caller)) {
2323 return 0;
2324 }
2325 return PyLong_FromLong(SDDS_CheckDataset(&dataset_f[fileIndex], caller));
2326}
int32_t SDDS_CheckDataset(SDDS_DATASET *SDDS_dataset, const char *caller)
Validates the SDDS dataset pointer.
Definition SDDS_utils.c:552

◆ sddsdata_CheckParameter()

static PyObject * sddsdata_CheckParameter ( PyObject * self,
PyObject * args )
static

Verifies the existence and type of a parameter in a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex (long): Dataset index.
  • name (char*): Parameter name.
  • units (char*): Expected units.
  • type (long): Expected type.
Returns
Python integer indicating the check status.

Definition at line 2176 of file sddsdatamodule.c.

2177{
2178 long fileIndex;
2179 char *name;
2180 char *units;
2181 long type;
2182 if (!PyArg_ParseTuple(args, "lssl", &fileIndex, &name, &units, &type)) {
2183 return PyLong_FromLong(SDDS_CHECK_WRONGTYPE);
2184 }
2185 return PyLong_FromLong(SDDS_CheckParameter(&dataset_f[fileIndex], name, units, type, stderr));
2186}
int32_t SDDS_CheckParameter(SDDS_DATASET *SDDS_dataset, char *name, char *units, int32_t type, FILE *fp_message)
Checks if a parameter exists in the SDDS dataset with the specified name, units, and type.

◆ sddsdata_ClearErrors()

static PyObject * sddsdata_ClearErrors ( PyObject * self,
PyObject * args )
static

Clears all recorded errors.

Parameters
selfPython object (unused).
argsPython tuple (unused).
Returns
Python None.

Definition at line 1461 of file sddsdatamodule.c.

1462{
1464 Py_INCREF(Py_None);
1465 return Py_None;
1466}
void SDDS_ClearErrors()
Clears all recorded error messages from the SDDS error stack.
Definition SDDS_utils.c:318

◆ sddsdata_ClearPage()

static PyObject * sddsdata_ClearPage ( PyObject * self,
PyObject * args )
static

Clears the current page in an SDDS dataset.

Parameters
selfUnused.
argsA tuple containing:
  • fileIndex (long): Index of the dataset.
Returns
PyObject* A Python integer (1 on success, 0 on error).

Definition at line 995 of file sddsdatamodule.c.

996{
997 long fileIndex;
998 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
999 return 0;
1000 }
1001 return PyLong_FromLong(SDDS_ClearPage(&dataset_f[fileIndex]));
1002}
int32_t SDDS_ClearPage(SDDS_DATASET *SDDS_dataset)

◆ sddsdata_ColumnCount()

static PyObject * sddsdata_ColumnCount ( PyObject * self,
PyObject * args )
static

Gets the count of columns in the dataset.

Parameters
selfPython object (unused).
argsPython arguments tuple containing:
  • fileIndex (long): Index of the dataset file.
Returns
PyObject*: Number of columns as PyLong.

Definition at line 1315 of file sddsdatamodule.c.

1316{
1317 long fileIndex;
1318 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
1319 return 0;
1320 }
1321 return PyLong_FromLong(SDDS_ColumnCount(&dataset_f[fileIndex]));
1322}
int32_t SDDS_ColumnCount(SDDS_DATASET *page)
Retrieves the number of columns in the SDDS dataset.

◆ sddsdata_CopyAdditionalRows()

static PyObject * sddsdata_CopyAdditionalRows ( PyObject * self,
PyObject * args )
static

Copies additional rows from one SDDS dataset to another.

Parameters
selfUnused.
argsA tuple containing:
  • fileIndexTarget (long): Index of the target dataset.
  • fileIndexSource (long): Index of the source dataset.
Returns
PyObject* A Python integer (1 on success, 0 on error).

Definition at line 899 of file sddsdatamodule.c.

900{
901 long fileIndexTarget;
902 long fileIndexSource;
903 if (!PyArg_ParseTuple(args, "ll", &fileIndexTarget, &fileIndexSource)) {
904 return 0;
905 }
906 return PyLong_FromLong(SDDS_CopyAdditionalRows(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource]));
907}
int32_t SDDS_CopyAdditionalRows(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source)
Definition SDDS_copy.c:519

◆ sddsdata_CopyArrays()

static PyObject * sddsdata_CopyArrays ( PyObject * self,
PyObject * args )
static

Copies arrays from one SDDS dataset to another.

Parameters
selfUnused.
argsA tuple containing:
  • fileIndexTarget (long): Index of the target dataset.
  • fileIndexSource (long): Index of the source dataset.
Returns
PyObject* A Python integer (1 on success, 0 on error).

Definition at line 811 of file sddsdatamodule.c.

812{
813 long fileIndexTarget;
814 long fileIndexSource;
815 if (!PyArg_ParseTuple(args, "ll", &fileIndexTarget, &fileIndexSource)) {
816 return 0;
817 }
818 return PyLong_FromLong(SDDS_CopyArrays(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource]));
819}
int32_t SDDS_CopyArrays(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source)
Definition SDDS_copy.c:334

◆ sddsdata_CopyColumns()

static PyObject * sddsdata_CopyColumns ( PyObject * self,
PyObject * args )
static

Copies columns from one SDDS dataset to another.

Parameters
selfUnused.
argsA tuple containing:
  • fileIndexTarget (long): Index of the target dataset.
  • fileIndexSource (long): Index of the source dataset.
Returns
PyObject* A Python integer (1 on success, 0 on error).

Definition at line 831 of file sddsdatamodule.c.

832{
833 long fileIndexTarget;
834 long fileIndexSource;
835 if (!PyArg_ParseTuple(args, "ll", &fileIndexTarget, &fileIndexSource)) {
836 return 0;
837 }
838 return PyLong_FromLong(SDDS_CopyColumns(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource]));
839}
int32_t SDDS_CopyColumns(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source)
Definition SDDS_copy.c:387

◆ sddsdata_CopyLayout()

static PyObject * sddsdata_CopyLayout ( PyObject * self,
PyObject * args )
static

Copies the layout from one SDDS dataset to another.

Parameters
selfUnused.
argsA tuple containing:
  • fileIndexTarget (long): Index of the target dataset.
  • fileIndexSource (long): Index of the source dataset.
Returns
PyObject* A Python integer (1 on success, 0 on error).

Definition at line 731 of file sddsdatamodule.c.

732{
733 long fileIndexTarget;
734 long fileIndexSource;
735 if (!PyArg_ParseTuple(args, "ll", &fileIndexTarget, &fileIndexSource)) {
736 return 0;
737 }
738 return PyLong_FromLong(SDDS_CopyLayout(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource]));
739}
int32_t SDDS_CopyLayout(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source)
Definition SDDS_copy.c:222

◆ sddsdata_CopyPage()

static PyObject * sddsdata_CopyPage ( PyObject * self,
PyObject * args )
static

Copies a page from one SDDS dataset to another.

Parameters
selfUnused.
argsA tuple containing:
  • fileIndexTarget (long): Index of the target dataset.
  • fileIndexSource (long): Index of the source dataset.
Returns
PyObject* A Python integer (1 on success, 0 on error).

Definition at line 771 of file sddsdatamodule.c.

772{
773 long fileIndexTarget;
774 long fileIndexSource;
775 if (!PyArg_ParseTuple(args, "ll", &fileIndexTarget, &fileIndexSource)) {
776 return 0;
777 }
778 return PyLong_FromLong(SDDS_CopyPage(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource]));
779}
int32_t SDDS_CopyPage(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source)
Definition SDDS_copy.c:578

◆ sddsdata_CopyParameters()

static PyObject * sddsdata_CopyParameters ( PyObject * self,
PyObject * args )
static

Copies parameters from one SDDS dataset to another.

Parameters
selfUnused.
argsA tuple containing:
  • fileIndexTarget (long): Index of the target dataset.
  • fileIndexSource (long): Index of the source dataset.
Returns
PyObject* A Python integer (1 on success, 0 on error).

Definition at line 791 of file sddsdatamodule.c.

792{
793 long fileIndexTarget;
794 long fileIndexSource;
795 if (!PyArg_ParseTuple(args, "ll", &fileIndexTarget, &fileIndexSource)) {
796 return 0;
797 }
798 return PyLong_FromLong(SDDS_CopyParameters(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource]));
799}
int32_t SDDS_CopyParameters(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source)
Definition SDDS_copy.c:286

◆ sddsdata_CopyRow()

static PyObject * sddsdata_CopyRow ( PyObject * self,
PyObject * args )
static

Copies a row from one SDDS dataset to another.

Parameters
selfUnused.
argsA tuple containing:
  • fileIndexTarget (long): Index of the target dataset.
  • target_row (long): Row number in the target dataset.
  • fileIndexSource (long): Index of the source dataset.
  • source_row (long): Row number in the source dataset.
Returns
PyObject* A Python integer (1 on success, 0 on error).

Definition at line 853 of file sddsdatamodule.c.

854{
855 long fileIndexTarget;
856 long target_row;
857 long fileIndexSource;
858 long source_row;
859 if (!PyArg_ParseTuple(args, "llll", &fileIndexTarget, &target_row, &fileIndexSource, &source_row)) {
860 return 0;
861 }
862 return PyLong_FromLong(SDDS_CopyRow(&dataset_f[fileIndexTarget], target_row, &dataset_f[fileIndexSource], source_row));
863}
int32_t SDDS_CopyRow(SDDS_DATASET *SDDS_target, int64_t target_row, SDDS_DATASET *SDDS_source, int64_t source_srow)
Definition SDDS_copy.c:778

◆ sddsdata_CopyRowDirect()

static PyObject * sddsdata_CopyRowDirect ( PyObject * self,
PyObject * args )
static

Directly copies a row from one SDDS dataset to another.

Parameters
selfUnused.
argsA tuple containing:
  • fileIndexTarget (long): Index of the target dataset.
  • target_row (long): Row number in the target dataset.
  • fileIndexSource (long): Index of the source dataset.
  • source_row (long): Row number in the source dataset.
Returns
PyObject* A Python integer (1 on success, 0 on error).

Definition at line 877 of file sddsdatamodule.c.

878{
879 long fileIndexTarget;
880 long target_row;
881 long fileIndexSource;
882 long source_row;
883 if (!PyArg_ParseTuple(args, "llll", &fileIndexTarget, &target_row, &fileIndexSource, &source_row)) {
884 return 0;
885 }
886 return PyLong_FromLong(SDDS_CopyRowDirect(&dataset_f[fileIndexTarget], target_row, &dataset_f[fileIndexSource], source_row));
887}
int32_t SDDS_CopyRowDirect(SDDS_DATASET *SDDS_target, int64_t target_row, SDDS_DATASET *SDDS_source, int64_t source_row)
Definition SDDS_copy.c:834

◆ sddsdata_DeferSavingLayout()

static PyObject * sddsdata_DeferSavingLayout ( PyObject * self,
PyObject * args )
static

Defers saving the layout of an SDDS dataset.

Parameters
selfUnused.
argsA tuple containing:
  • fileIndex (long): Index of the dataset.
  • mode (long): Mode for deferring (0 for False, 1 for True).
Returns
PyObject* None.

Definition at line 919 of file sddsdatamodule.c.

920{
921 long fileIndex, mode;
922 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &mode)) {
923 return Py_None;
924 }
925 SDDS_DeferSavingLayout(&dataset_f[fileIndex],mode);
926 Py_INCREF(Py_None);
927 return Py_None;
928}
void SDDS_DeferSavingLayout(SDDS_DATASET *SDDS_dataset, int32_t mode)
Definition SDDS_copy.c:603

◆ sddsdata_DefineArray()

static PyObject * sddsdata_DefineArray ( PyObject * self,
PyObject * args )
static

Defines an array in an SDDS dataset.

Parameters
selfUnused.
argsA tuple containing:
  • fileIndex (long): Index of the dataset.
  • name (char*): Name of the array.
  • symbol (char*): Symbol for the array.
  • units (char*): Units of the array.
  • description (char*): Description of the array.
  • format_string (char*): Format string for the array.
  • type (long): Data type of the array.
  • field_length (long): Length of the fields in the array.
  • dimensions (long): Number of dimensions in the array.
  • group_name (char*): Name of the group to which the array belongs.
Returns
PyObject*
  • Index of the defined array on success.
  • -1 on error.

Definition at line 393 of file sddsdatamodule.c.

394{
395 long fileIndex;
396 char *name;
397 char *symbol;
398 char *units;
399 char *description;
400 char *format_string;
401 long type;
402 long field_length;
403 long dimensions;
404 char *group_name;
405 if (!PyArg_ParseTuple(args, "lsssssslll", &fileIndex, &name , &symbol, &units, &description, &format_string, &group_name, &type, &field_length, &dimensions)) {
406 return PyLong_FromLong(-1);
407 }
408 if (symbol)
409 if (strlen(symbol) == 0)
410 symbol = NULL;
411 if (units)
412 if (strlen(units) == 0)
413 units = NULL;
414 if (description)
415 if (strlen(description) == 0)
416 description = NULL;
417 if (format_string)
418 if (strlen(format_string) == 0)
419 format_string = NULL;
420 if (group_name)
421 if (strlen(group_name) == 0)
422 group_name = NULL;
423 return PyLong_FromLong(SDDS_DefineArray(&dataset_f[fileIndex], name, symbol, units, description, format_string, type, field_length, dimensions, group_name));
424}
int32_t SDDS_DefineArray(SDDS_DATASET *SDDS_dataset, const char *name, const char *symbol, const char *units, const char *description, const char *format_string, int32_t type, int32_t field_length, int32_t dimensions, const char *group_name)
Defines a data array within the SDDS dataset.

◆ sddsdata_DefineColumn()

static PyObject * sddsdata_DefineColumn ( PyObject * self,
PyObject * args )
static

Defines a column in an SDDS dataset.

Parameters
selfUnused.
argsA tuple containing:
  • fileIndex (long): Index of the dataset.
  • name (char*): Name of the column.
  • symbol (char*): Symbol for the column.
  • units (char*): Units of the column.
  • description (char*): Description of the column.
  • format_string (char*): Format string for the column.
  • type (long): Data type of the column.
  • field_length (long): Length of the fields in the column.
Returns
PyObject*
  • Index of the defined column on success.
  • -1 on error.

Definition at line 444 of file sddsdatamodule.c.

445{
446 long fileIndex;
447 char *name;
448 char *symbol;
449 char *units;
450 char *description;
451 char *format_string;
452 long type;
453 long field_length;
454 if (!PyArg_ParseTuple(args, "lsssssll", &fileIndex, &name , &symbol, &units, &description, &format_string, &type, &field_length)) {
455 return PyLong_FromLong(-1);
456 }
457 if (symbol)
458 if (strlen(symbol) == 0)
459 symbol = NULL;
460 if (units)
461 if (strlen(units) == 0)
462 units = NULL;
463 if (description)
464 if (strlen(description) == 0)
465 description = NULL;
466 if (format_string)
467 if (strlen(format_string) == 0)
468 format_string = NULL;
469 return PyLong_FromLong(SDDS_DefineColumn(&dataset_f[fileIndex], name, symbol, units, description, format_string, type, field_length));
470}
int32_t SDDS_DefineColumn(SDDS_DATASET *SDDS_dataset, const char *name, const char *symbol, const char *units, const char *description, const char *format_string, int32_t type, int32_t field_length)
Defines a data column within the SDDS dataset.

◆ sddsdata_DefineColumnLikeParameter()

static PyObject * sddsdata_DefineColumnLikeParameter ( PyObject * self,
PyObject * args )
static

Defines a column in one dataset based on a parameter in another dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndexTarget (long): Target dataset index.
  • fileIndexSource (long): Source dataset index.
  • name (char*): Name of the parameter to base the column on.
  • newName (char*): New name for the column (optional).
Returns
Python integer (1 on success, 0 on error).

Definition at line 1643 of file sddsdatamodule.c.

1644{
1645 long fileIndexTarget;
1646 long fileIndexSource;
1647 char *name;
1648 char *newName;
1649 if (!PyArg_ParseTuple(args, "llss", &fileIndexTarget, &fileIndexSource, &name, &newName)) {
1650 return 0;
1651 }
1652 return PyLong_FromLong(SDDS_DefineColumnLikeParameter(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource], name, newName));
1653}
int32_t SDDS_DefineColumnLikeParameter(SDDS_DATASET *target, SDDS_DATASET *source, char *name, char *newName)
Defines a column in the target dataset based on a parameter definition from the source dataset.

◆ sddsdata_DefineParameter()

static PyObject * sddsdata_DefineParameter ( PyObject * self,
PyObject * args )
static

Defines a parameter in an SDDS dataset.

Parameters
selfUnused pointer to the module object.
argsPython tuple containing:
  • fileIndex (long): Index of the dataset in the array.
  • name (char*): Name of the parameter.
  • symbol (char*): Symbol for the parameter (optional).
  • units (char*): Units of the parameter (optional).
  • description (char*): Description of the parameter (optional).
  • format_string (char*): Format string for displaying the parameter (optional).
  • type (long): Data type of the parameter (e.g., SDDS_LONG, SDDS_DOUBLE).
  • fixed_value (PyObject*): Fixed value for the parameter.
Returns
PyObject*
  • Index of the defined parameter on success.
  • -1 on error.

Definition at line 302 of file sddsdatamodule.c.

303{
304 long fileIndex;
305 char *name;
306 char *symbol;
307 char *units;
308 char *description;
309 char *format_string;
310 long type;
311 PyObject *fixed_value;
312 char *fixedStringValue;
313 int32_t fixedLongValue;
314 double fixedDoubleValue;
315 char buffer[SDDS_MAXLINE];
316 if (!PyArg_ParseTuple(args, "lssssslO", &fileIndex, &name , &symbol , &units , &description , &format_string , &type , &fixed_value)) {
317 return PyLong_FromLong(-1);
318 }
319 if (symbol)
320 if (strlen(symbol) == 0)
321 symbol = NULL;
322 if (units)
323 if (strlen(units) == 0)
324 units = NULL;
325 if (description)
326 if (strlen(description) == 0)
327 description = NULL;
328 if (format_string)
329 if (strlen(format_string) == 0)
330 format_string = NULL;
331
332 if (PyString_Check(fixed_value)) {
333 fixedStringValue = (char*)PyString_AsString(fixed_value);
334 if (fixedStringValue)
335 if (strlen(fixedStringValue) == 0)
336 fixedStringValue = NULL;
337 return PyLong_FromLong(SDDS_DefineParameter(&dataset_f[fileIndex],
338 name, symbol, units,
339 description, format_string,
340 type, fixedStringValue));
341 } else {
342 if (PyNumber_Check(fixed_value)) {
343 if (PyLong_Check(fixed_value)) {
344 fixedLongValue = (int32_t)PyLong_AsLong(fixed_value);
345 SDDS_SprintTypedValue(&fixedLongValue, 0, SDDS_LONG , format_string, buffer, 0);
346 return PyLong_FromLong(SDDS_DefineParameter(&dataset_f[fileIndex],
347 name, symbol, units,
348 description, format_string,
349 type, buffer));
350 } else if (PyInt_Check(fixed_value)) {
351 fixedLongValue = (int32_t)PyInt_AsLong(fixed_value);
352 SDDS_SprintTypedValue(&fixedLongValue, 0, SDDS_LONG , format_string, buffer, 0);
353 return PyLong_FromLong(SDDS_DefineParameter(&dataset_f[fileIndex],
354 name, symbol, units,
355 description, format_string,
356 type, buffer));
357 } else if (PyFloat_Check(fixed_value)) {
358 fixedDoubleValue = PyFloat_AsDouble(fixed_value);
359 SDDS_SprintTypedValue(&fixedDoubleValue, 0, SDDS_DOUBLE , format_string, buffer, 0);
360 return PyLong_FromLong(SDDS_DefineParameter(&dataset_f[fileIndex],
361 name, symbol, units,
362 description, format_string,
363 type, buffer));
364 }
365 }
366 return PyLong_FromLong(SDDS_DefineParameter1(&dataset_f[fileIndex],
367 name, symbol, units,
368 description, format_string,
369 type, NULL));
370 }
371}
int32_t SDDS_DefineParameter1(SDDS_DATASET *SDDS_dataset, const char *name, const char *symbol, const char *units, const char *description, const char *format_string, int32_t type, void *fixed_value)
Defines a data parameter with a fixed numerical value.
int32_t SDDS_DefineParameter(SDDS_DATASET *SDDS_dataset, const char *name, const char *symbol, const char *units, const char *description, const char *format_string, int32_t type, char *fixed_value)
Defines a data parameter with a fixed string value.
int32_t SDDS_SprintTypedValue(void *data, int64_t index, int32_t type, const char *format, char *buffer, uint32_t mode)
Formats a data value of a specified type into a string buffer using an optional printf format string.
Definition SDDS_utils.c:151
#define SDDS_LONG
Identifier for the signed 32-bit integer data type.
Definition SDDStypes.h:61
#define SDDS_DOUBLE
Identifier for the double data type.
Definition SDDStypes.h:37

◆ sddsdata_DefineParameterLikeColumn()

static PyObject * sddsdata_DefineParameterLikeColumn ( PyObject * self,
PyObject * args )
static

Defines a parameter in one dataset based on a column in another dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndexTarget (long): Target dataset index.
  • fileIndexSource (long): Source dataset index.
  • name (char*): Name of the column to base the parameter on.
  • newName (char*): New name for the parameter (optional).
Returns
Python integer (1 on success, 0 on error).

Definition at line 1666 of file sddsdatamodule.c.

1667{
1668 long fileIndexTarget;
1669 long fileIndexSource;
1670 char *name;
1671 char *newName;
1672 if (!PyArg_ParseTuple(args, "llss", &fileIndexTarget, &fileIndexSource, &name, &newName)) {
1673 return 0;
1674 }
1675 return PyLong_FromLong(SDDS_DefineParameterLikeColumn(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource], name, newName));
1676}
int32_t SDDS_DefineParameterLikeColumn(SDDS_DATASET *target, SDDS_DATASET *source, char *name, char *newName)
Defines a parameter in the target dataset based on a column definition from the source dataset.

◆ sddsdata_DefineSimpleArray()

static PyObject * sddsdata_DefineSimpleArray ( PyObject * self,
PyObject * args )
static

Defines a simple array in an SDDS dataset.

Parameters
selfUnused.
argsA tuple containing:
  • fileIndex (long): Index of the dataset.
  • name (char*): Name of the array.
  • units (char*): Units of the array.
  • type (long): Data type of the array.
  • dimensions (long): Number of dimensions in the array.
Returns
PyObject* A Python integer (1 on success, 0 on error).

Definition at line 543 of file sddsdatamodule.c.

544{
545 long fileIndex;
546 char *name;
547 char *units;
548 long type;
549 long dimensions;
550 long results;
551 if (!PyArg_ParseTuple(args, "lssll", &fileIndex, &name, &units, &type, &dimensions)) {
552 return 0;
553 }
554 if (units)
555 if (strlen(units) == 0)
556 units = NULL;
557 results = SDDS_DefineArray(&dataset_f[fileIndex], name, NULL, units, NULL, NULL, type, 0, dimensions, NULL);
558 if (results == -1) {
559 results = 0;
560 } else {
561 results = 1;
562 }
563 return PyLong_FromLong(results);
564}

◆ sddsdata_DefineSimpleColumn()

static PyObject * sddsdata_DefineSimpleColumn ( PyObject * self,
PyObject * args )
static

Defines a simple column in an SDDS dataset.

Parameters
selfUnused.
argsA tuple containing:
  • fileIndex (long): Index of the dataset.
  • name (char*): Name of the column.
  • units (char*): Units of the column.
  • type (long): Data type of the column.
Returns
PyObject* A Python integer (1 on success, 0 on error).

Definition at line 515 of file sddsdatamodule.c.

516{
517 long fileIndex;
518 char *name;
519 char *units;
520 long type;
521 if (!PyArg_ParseTuple(args, "lssl", &fileIndex, &name, &units, &type)) {
522 return 0;
523 }
524 if (units)
525 if (strlen(units) == 0)
526 units = NULL;
527 return PyLong_FromLong(SDDS_DefineSimpleColumn(&dataset_f[fileIndex], name, units, type));
528}
int32_t SDDS_DefineSimpleColumn(SDDS_DATASET *SDDS_dataset, const char *name, const char *unit, int32_t type)
Defines a simple data column within the SDDS dataset.

◆ sddsdata_DefineSimpleParameter()

static PyObject * sddsdata_DefineSimpleParameter ( PyObject * self,
PyObject * args )
static

Defines a simple parameter in an SDDS dataset.

Parameters
selfUnused.
argsA tuple containing:
  • fileIndex (long): Index of the dataset.
  • name (char*): Name of the parameter.
  • units (char*): Units of the parameter.
  • type (long): Data type of the parameter.
Returns
PyObject* A Python integer (1 on success, 0 on error).

Definition at line 578 of file sddsdatamodule.c.

579{
580 long fileIndex;
581 char *name;
582 char *units;
583 long type;
584 if (!PyArg_ParseTuple(args, "lssl", &fileIndex, &name, &units, &type)) {
585 return 0;
586 }
587 if (units)
588 if (strlen(units) == 0)
589 units = NULL;
590 return PyLong_FromLong(SDDS_DefineSimpleParameter(&dataset_f[fileIndex], name, units, type));
591}
int32_t SDDS_DefineSimpleParameter(SDDS_DATASET *SDDS_dataset, const char *name, const char *unit, int32_t type)
Defines a simple data parameter within the SDDS dataset.

◆ sddsdata_DeleteColumn()

static PyObject * sddsdata_DeleteColumn ( PyObject * self,
PyObject * args )
static

Deletes a column from the dataset.

Parameters
selfPython object (unused).
argsPython arguments tuple containing:
  • fileIndex (long): Index of the dataset file.
  • column_name (char*): Name of the column to delete.
Returns
PyObject*:
  • PyLong(0) on error.
  • PyLong(1) on success.

Definition at line 1242 of file sddsdatamodule.c.

1243{
1244 long fileIndex;
1245 char *column_name;
1246 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &column_name)) {
1247 return 0;
1248 }
1249 return PyLong_FromLong(SDDS_DeleteColumn(&dataset_f[fileIndex], column_name));
1250}
int32_t SDDS_DeleteColumn(SDDS_DATASET *SDDS_dataset, char *column_name)
Deletes a specified column from an SDDS dataset.

◆ sddsdata_DeleteParameter()

static PyObject * sddsdata_DeleteParameter ( PyObject * self,
PyObject * args )
static

Deletes a parameter from the dataset.

Parameters
selfPython object (unused).
argsPython arguments tuple containing:
  • fileIndex (long): Index of the dataset file.
  • parameter_name (char*): Name of the parameter to delete.
Returns
PyObject*:
  • PyLong(0) on error.
  • PyLong(1) on success.

Definition at line 1262 of file sddsdatamodule.c.

1263{
1264 long fileIndex;
1265 char *parameter_name;
1266 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &parameter_name)) {
1267 return 0;
1268 }
1269 return PyLong_FromLong(SDDS_DeleteParameter(&dataset_f[fileIndex], parameter_name));
1270}
int32_t SDDS_DeleteParameter(SDDS_DATASET *SDDS_dataset, char *parameter_name)
Deletes a specified parameter from an SDDS dataset.

◆ sddsdata_DeleteParameterFixedValues()

static PyObject * sddsdata_DeleteParameterFixedValues ( PyObject * self,
PyObject * args )
static

Deletes fixed parameter values for a given dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex: Index of the dataset file.
Returns
PyObject*:
  • 0 on error.
  • 1 on success.

Definition at line 2275 of file sddsdatamodule.c.

2276{
2277 long fileIndex;
2278 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
2279 return 0;
2280 }
2281 return PyLong_FromLong(SDDS_DeleteParameterFixedValues(&dataset_f[fileIndex]));
2282}
int32_t SDDS_DeleteParameterFixedValues(SDDS_DATASET *SDDS_dataset)
Deletes fixed values from all parameters in the SDDS dataset.

◆ sddsdata_DeleteUnsetColumns()

static PyObject * sddsdata_DeleteUnsetColumns ( PyObject * self,
PyObject * args )
static

Deletes all unset columns in the dataset.

Parameters
selfPython object (unused).
argsPython arguments tuple containing:
  • fileIndex (long): Index of the dataset file.
Returns
PyObject*:
  • PyLong(0) on error.
  • PyLong(1) on success.

Definition at line 1281 of file sddsdatamodule.c.

1282{
1283 long fileIndex;
1284 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
1285 return 0;
1286 }
1287 return PyLong_FromLong(SDDS_DeleteUnsetColumns(&dataset_f[fileIndex]));
1288}
int32_t SDDS_DeleteUnsetColumns(SDDS_DATASET *SDDS_dataset)
Deletes all columns from an SDDS dataset that are not marked as "of interest".

◆ sddsdata_DeleteUnsetRows()

static PyObject * sddsdata_DeleteUnsetRows ( PyObject * self,
PyObject * args )
static

Deletes all unset rows in the dataset.

Parameters
selfPython object (unused).
argsPython arguments tuple containing:
  • fileIndex (long): Index of the dataset file.
Returns
PyObject*:
  • PyLong(0) on error.
  • PyLong(1) on success.

Definition at line 1299 of file sddsdatamodule.c.

1300{
1301 long fileIndex;
1302 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
1303 return 0;
1304 }
1305 return PyLong_FromLong(SDDS_DeleteUnsetRows(&dataset_f[fileIndex]));
1306}
int32_t SDDS_DeleteUnsetRows(SDDS_DATASET *SDDS_dataset)
Deletes rows from an SDDS dataset that are not marked as "of interest".

◆ sddsdata_DisableFSync()

static PyObject * sddsdata_DisableFSync ( PyObject * self,
PyObject * args )
static

Disables filesystem synchronization (fsync) for an SDDS dataset.

Parameters
selfUnused pointer to the module object.
argsPython tuple containing:
  • fileIndex (long): Index of the dataset in the array.
Returns
PyObject*
  • Py_None (Python's None).

Definition at line 235 of file sddsdatamodule.c.

236{
237 long fileIndex;
238 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
239 return Py_None;
240 }
241 dataset_f[fileIndex].layout.data_mode.fsync_data = 0;
242 return Py_None;
243}

◆ sddsdata_EnableFSync()

static PyObject * sddsdata_EnableFSync ( PyObject * self,
PyObject * args )
static

Enables filesystem synchronization (fsync) for an SDDS dataset.

Parameters
selfUnused pointer to the module object.
argsPython tuple containing:
  • fileIndex (long): Index of the dataset in the array.
Returns
PyObject*
  • Py_None (Python's None).

Definition at line 215 of file sddsdatamodule.c.

216{
217 long fileIndex;
218 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
219 return Py_None;
220 }
221 dataset_f[fileIndex].layout.data_mode.fsync_data = 1;
222 return Py_None;
223}

◆ sddsdata_EraseData()

static PyObject * sddsdata_EraseData ( PyObject * self,
PyObject * args )
static

Erases data from an SDDS dataset.

Parameters
selfUnused.
argsA tuple containing:
  • fileIndex (long): Index of the dataset.
Returns
PyObject* A Python integer (1 on success, 0 on error).

Definition at line 620 of file sddsdatamodule.c.

621{
622 long fileIndex;
623 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
624 return 0;
625 }
626 return PyLong_FromLong(SDDS_EraseData(&dataset_f[fileIndex]));
627}
int32_t SDDS_EraseData(SDDS_DATASET *SDDS_dataset)
Erases all data entries in the SDDS dataset.

◆ sddsdata_GetArray()

static PyObject * sddsdata_GetArray ( PyObject * self,
PyObject * args )
static

Retrieves an array's data from a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex: Index of the dataset file.
  • indexOrName: Index or name of the array to retrieve.
Returns
PyObject*:
  • NULL on error.
  • List of values from the array on success.

Definition at line 3246 of file sddsdatamodule.c.

3247{
3248 long fileIndex;
3249 PyObject *indexOrName;
3250 long originalType, i, elements;
3251 SDDS_ARRAY *arrayValue=NULL;
3252 char *name;
3253 char **data;
3254 int32_t number;
3255 char buffer[40];
3256 long index;
3257 PyObject *v;
3258 if (!PyArg_ParseTuple(args, "lO", &fileIndex, &indexOrName)) {
3259 return NULL;
3260 }
3261 if (PyString_Check(indexOrName)) {
3262 index = SDDS_GetArrayIndex(&dataset_f[fileIndex], (char*)PyString_AsString(indexOrName));
3263 } else if (PyNumber_Check(indexOrName)) {
3264 if (PyInt_Check(indexOrName))
3265 index = PyInt_AsLong(indexOrName);
3266 else if (PyLong_Check(indexOrName))
3267 index = PyLong_AsLong(indexOrName);
3268 else
3269 return NULL;
3270 } else
3271 return NULL;
3272
3273 data = SDDS_GetArrayNames(&dataset_f[fileIndex], &number);
3274 if (!(data))
3275 return NULL;
3276 if ((index >= 0) && (index < number)) {
3277 name = data[index];
3278 } else {
3279 return NULL;
3280 }
3281
3282 arrayValue = SDDS_GetArray(&(dataset_f[fileIndex]), name, NULL);
3283
3284 for (i=0;i<number;i++)
3285 free(data[i]);
3286 free(data);
3287
3288 originalType = arrayValue->definition->type;
3289
3290 if (!(arrayValue))
3291 return NULL;
3292
3293 elements = arrayValue->elements;
3294
3295 /*
3296 if (!(v = PyList_New(arrayValue->definition->dimensions)))
3297 return NULL;
3298 for (i=0;i<arrayValue>dimensions;i++) {
3299 if (!(v[i] = PyList_New(arrayValue->dimension[i])))
3300 return NULL;
3301 }
3302 */
3303 if (!(v = PyList_New(arrayValue->elements)))
3304 return NULL;
3305
3306 switch (originalType) {
3307 case SDDS_SHORT:
3308 for (i=0;i < elements;i++) {
3309 PyList_SetItem(v, i, PyLong_FromLong((long)(((short*)arrayValue->data)[i])));
3310 }
3311 break;
3312 case SDDS_USHORT:
3313 for (i=0;i < elements;i++) {
3314 PyList_SetItem(v, i, PyLong_FromLong((long)(((unsigned short*)arrayValue->data)[i])));
3315 }
3316 break;
3317 case SDDS_LONG:
3318 for (i=0;i < elements;i++) {
3319 PyList_SetItem(v, i, PyLong_FromLong((long)(((int32_t*)arrayValue->data)[i])));
3320 }
3321 break;
3322 case SDDS_ULONG:
3323 for (i=0;i < elements;i++) {
3324 PyList_SetItem(v, i, PyLong_FromUnsignedLong((unsigned long)(((uint32_t*)arrayValue->data)[i])));
3325 }
3326 break;
3327 case SDDS_LONG64:
3328 for (i=0;i < elements;i++) {
3329 PyList_SetItem(v, i, PyLong_FromLongLong((long long)(((int64_t*)arrayValue->data)[i])));
3330 }
3331 break;
3332 case SDDS_ULONG64:
3333 for (i=0;i < elements;i++) {
3334 PyList_SetItem(v, i, PyLong_FromUnsignedLongLong((unsigned long long)(((uint64_t*)arrayValue->data)[i])));
3335 }
3336 break;
3337 case SDDS_FLOAT:
3338 for (i=0;i < elements;i++) {
3339 sprintf(buffer, "%.6E", ((float*)arrayValue->data)[i]);
3340 PyList_SetItem(v, i, PyFloat_FromDouble(atof(buffer)));
3341 }
3342 break;
3343 case SDDS_DOUBLE:
3344 for (i=0;i < elements;i++) {
3345 PyList_SetItem(v, i, PyFloat_FromDouble(((double*)arrayValue->data)[i]));
3346 }
3347 break;
3348 case SDDS_CHARACTER:
3349 for (i=0;i < elements;i++) {
3350 sprintf(buffer, "%c", ((char*)arrayValue->data)[i]);
3351 PyList_SetItem(v, i, PyString_FromString(buffer));
3352 }
3353 break;
3354 case SDDS_STRING:
3355 for (i=0;i < elements;i++) {
3356 PyList_SetItem(v, i, PyString_FromString(((char**)arrayValue->data)[i]));
3357 }
3358 break;
3359 default:
3360 return NULL;
3361 }
3362 SDDS_FreeArray(arrayValue);
3363 return v;
3364}
SDDS_ARRAY * SDDS_GetArray(SDDS_DATASET *SDDS_dataset, char *array_name, SDDS_ARRAY *memory)
Retrieves an array from the current data table of an SDDS dataset.
void SDDS_FreeArray(SDDS_ARRAY *array)
Frees memory allocated for an SDDS array structure.
int32_t SDDS_GetArrayIndex(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the index of a named array in the SDDS dataset.
char ** SDDS_GetArrayNames(SDDS_DATASET *SDDS_dataset, int32_t *number)
Retrieves the names of all arrays in the SDDS dataset.
#define SDDS_ULONG
Identifier for the unsigned 32-bit integer data type.
Definition SDDStypes.h:67
#define SDDS_FLOAT
Identifier for the float data type.
Definition SDDStypes.h:43
#define SDDS_STRING
Identifier for the string data type.
Definition SDDStypes.h:85
#define SDDS_ULONG64
Identifier for the unsigned 64-bit integer data type.
Definition SDDStypes.h:55
#define SDDS_SHORT
Identifier for the signed short integer data type.
Definition SDDStypes.h:73
#define SDDS_CHARACTER
Identifier for the character data type.
Definition SDDStypes.h:91
#define SDDS_USHORT
Identifier for the unsigned short integer data type.
Definition SDDStypes.h:79
#define SDDS_LONG64
Identifier for the signed 64-bit integer data type.
Definition SDDStypes.h:49

◆ sddsdata_GetArrayDefinition()

static PyObject * sddsdata_GetArrayDefinition ( PyObject * self,
PyObject * args )
static

Retrieves the definition of an array in a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex (long): Dataset index.
  • name (char*): Name of the array.
Returns
Python list containing array attributes on success, NULL on error.

Definition at line 1930 of file sddsdatamodule.c.

1931{
1932 long fileIndex;
1933 char *name;
1934 ARRAY_DEFINITION *pardef;
1935 PyObject *v;
1936 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &name)) {
1937 return NULL;
1938 }
1939 if ((pardef = SDDS_GetArrayDefinition(&dataset_f[fileIndex], name)) == NULL)
1940 return NULL;
1941 if (!(v = PyList_New(8)))
1942 return NULL;
1943
1944 if (pardef->symbol)
1945 PyList_SetItem(v, 0, PyString_FromString(pardef->symbol));
1946 else
1947 PyList_SetItem(v, 0, PyString_FromString(""));
1948 if (pardef->units)
1949 PyList_SetItem(v, 1, PyString_FromString(pardef->units));
1950 else
1951 PyList_SetItem(v, 1, PyString_FromString(""));
1952 if (pardef->description)
1953 PyList_SetItem(v, 2, PyString_FromString(pardef->description));
1954 else
1955 PyList_SetItem(v, 2, PyString_FromString(""));
1956 if (pardef->format_string)
1957 PyList_SetItem(v, 3, PyString_FromString(pardef->format_string));
1958 else
1959 PyList_SetItem(v, 3, PyString_FromString(""));
1960 if (pardef->group_name)
1961 PyList_SetItem(v, 4, PyString_FromString(pardef->group_name));
1962 else
1963 PyList_SetItem(v, 4, PyString_FromString(""));
1964 PyList_SetItem(v, 5, PyLong_FromLong(pardef->type));
1965 PyList_SetItem(v, 6, PyLong_FromLong(pardef->field_length));
1966 PyList_SetItem(v, 7, PyLong_FromLong(pardef->dimensions));
1967
1969
1970 return v;
1971}
ARRAY_DEFINITION * SDDS_GetArrayDefinition(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the definition of a specified array from the SDDS dataset.
int32_t SDDS_FreeArrayDefinition(ARRAY_DEFINITION *source)
Frees memory allocated for an array definition.

◆ sddsdata_GetArrayDimensions()

static PyObject * sddsdata_GetArrayDimensions ( PyObject * self,
PyObject * args )
static

Retrieves the dimensions of an array in a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex: Index of the dataset file.
  • indexOrName: Index or name of the array.
Returns
PyObject*:
  • NULL on error.
  • List of dimensions of the array on success.

Definition at line 3378 of file sddsdatamodule.c.

3379{
3380 long fileIndex;
3381 PyObject *indexOrName;
3382 long i;
3383 SDDS_ARRAY *arrayValue=NULL;
3384 char *name;
3385 char **data;
3386 int32_t number;
3387 long index;
3388 PyObject *v;
3389 if (!PyArg_ParseTuple(args, "lO", &fileIndex, &indexOrName)) {
3390 return NULL;
3391 }
3392 if (PyString_Check(indexOrName)) {
3393 index = SDDS_GetArrayIndex(&dataset_f[fileIndex], (char*)PyString_AsString(indexOrName));
3394 } else if (PyNumber_Check(indexOrName)) {
3395 if (PyInt_Check(indexOrName))
3396 index = PyInt_AsLong(indexOrName);
3397 else if (PyLong_Check(indexOrName))
3398 index = PyLong_AsLong(indexOrName);
3399 else
3400 return NULL;
3401 } else
3402 return NULL;
3403
3404 data = SDDS_GetArrayNames(&dataset_f[fileIndex], &number);
3405 if (!(data))
3406 return NULL;
3407 if ((index >= 0) && (index < number)) {
3408 name = data[index];
3409 } else {
3410 return NULL;
3411 }
3412
3413 arrayValue = SDDS_GetArray(&(dataset_f[fileIndex]), name, NULL);
3414
3415 for (i=0;i<number;i++)
3416 free(data[i]);
3417 free(data);
3418
3419 if (!(arrayValue))
3420 return NULL;
3421
3422 if (!(v = PyList_New(arrayValue->definition->dimensions)))
3423 return NULL;
3424 for (i=0;i<arrayValue->definition->dimensions;i++) {
3425 PyList_SetItem(v, i, PyLong_FromLong(arrayValue->dimension[i]));
3426 }
3427 SDDS_FreeArray(arrayValue);
3428 return v;
3429}

◆ sddsdata_GetArrayIndex()

static PyObject * sddsdata_GetArrayIndex ( PyObject * self,
PyObject * args )
static

Retrieves the index of an array in a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex (long): Dataset index.
  • name (char*): Name of the array.
Returns
Python integer (index on success, -1 on error).

Definition at line 1769 of file sddsdatamodule.c.

1770{
1771 long fileIndex;
1772 char *name;
1773 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &name)) {
1774 return PyLong_FromLong(-1);
1775 }
1776 return PyLong_FromLong(SDDS_GetArrayIndex(&dataset_f[fileIndex], name));
1777}

◆ sddsdata_GetArrayNameFromIndex()

static PyObject * sddsdata_GetArrayNameFromIndex ( PyObject * self,
PyObject * args )
static

Retrieves an array name by its index from a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex: Index of the dataset file.
  • index: Index of the array.
Returns
PyObject*:
  • NULL on error.
  • Array name string on success.

Definition at line 2432 of file sddsdatamodule.c.

2433{
2434 long fileIndex;
2435 long index;
2436 char **data;
2437 int32_t number;
2438 PyObject *v;
2439 long i;
2440 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &index)) {
2441 return NULL;
2442 }
2443 data = SDDS_GetArrayNames(&dataset_f[fileIndex], &number);
2444 if (!(data))
2445 return NULL;
2446 if ((index >= 0) && (index < number)) {
2447 v = PyString_FromString(data[index]);
2448 for (i=0;i<number;i++)
2449 free(data[i]);
2450 free(data);
2451 return v;
2452 }
2453 for (i=0;i<number;i++)
2454 free(data[i]);
2455 free(data);
2456 return NULL;
2457}

◆ sddsdata_GetArrayNames()

static PyObject * sddsdata_GetArrayNames ( PyObject * self,
PyObject * args )
static

Retrieves all array names from a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex: Index of the dataset file.
Returns
PyObject*:
  • NULL on error.
  • List of array names on success.

Definition at line 2470 of file sddsdatamodule.c.

2471{
2472 long fileIndex;
2473 long index;
2474 char **data;
2475 int32_t number;
2476 PyObject *v;
2477 long i;
2478 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
2479 return NULL;
2480 }
2481 data = SDDS_GetArrayNames(&dataset_f[fileIndex], &number);
2482 if (!(data))
2483 return NULL;
2484 if (!(v = PyList_New(number)))
2485 return NULL;
2486 for (index = 0; index < number; index++)
2487 PyList_SetItem(v, index, PyString_FromString(data[index]));
2488 for (i=0;i<number;i++)
2489 free(data[i]);
2490 free(data);
2491 return v;
2492}

◆ sddsdata_GetArrayType()

static PyObject * sddsdata_GetArrayType ( PyObject * self,
PyObject * args )
static

Retrieves the type of an array in a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex (long): Dataset index.
  • index (long): Array index.
Returns
Python integer (type on success, 0 on error).

Definition at line 1826 of file sddsdatamodule.c.

1827{
1828 long fileIndex;
1829 long index;
1830 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &index)) {
1831 return 0;
1832 }
1833 return PyLong_FromLong(SDDS_GetArrayType(&dataset_f[fileIndex], index));
1834}
int32_t SDDS_GetArrayType(SDDS_DATASET *SDDS_dataset, int32_t index)
Retrieves the data type of an array in the SDDS dataset by its index.

◆ sddsdata_GetColumn()

static PyObject * sddsdata_GetColumn ( PyObject * self,
PyObject * args )
static

Retrieves a column's data from a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex: Index of the dataset file.
  • indexOrName: Index or name of the column to retrieve.
Returns
PyObject*:
  • NULL on error.
  • List of values from the column on success.

Definition at line 3106 of file sddsdatamodule.c.

3107{
3108 long fileIndex;
3109 PyObject *indexOrName;
3110 long originalType;
3111 int64_t rows, i;
3112 void *columnValue;
3113 char *name;
3114 char **data;
3115 int32_t number;
3116 char buffer[40];
3117 long index;
3118 PyObject *v;
3119 if (!PyArg_ParseTuple(args, "lO", &fileIndex, &indexOrName)) {
3120 return NULL;
3121 }
3122 if (PyString_Check(indexOrName)) {
3123 index = SDDS_GetColumnIndex(&dataset_f[fileIndex], (char*)PyString_AsString(indexOrName));
3124 } else if (PyNumber_Check(indexOrName)) {
3125 if (PyInt_Check(indexOrName))
3126 index = PyInt_AsLong(indexOrName);
3127 else if (PyLong_Check(indexOrName))
3128 index = PyLong_AsLong(indexOrName);
3129 else
3130 return NULL;
3131 } else
3132 return NULL;
3133
3134 data = SDDS_GetColumnNames(&dataset_f[fileIndex], &number);
3135 if (!(data))
3136 return NULL;
3137 if ((index >= 0) && (index < number)) {
3138 name = data[index];
3139 } else {
3140 return NULL;
3141 }
3142
3143 rows = SDDS_RowCount(&(dataset_f[fileIndex]));
3144 if (rows < 0) {
3145 Py_INCREF(Py_None);
3146 return Py_None;
3147 }
3148
3149 originalType = SDDS_GetColumnType(&(dataset_f[fileIndex]), index);
3150
3151 columnValue = SDDS_GetColumn(&(dataset_f[fileIndex]), name);
3152
3153 for (i=0;i<number;i++)
3154 free(data[i]);
3155 free(data);
3156
3157 if (!(columnValue))
3158 return NULL;
3159
3160 if (!(v = PyList_New(rows)))
3161 return NULL;
3162
3163 switch (originalType) {
3164 case SDDS_SHORT:
3165 for (i=0;i < rows;i++) {
3166 PyList_SetItem(v, i, PyLong_FromLong((long)(((short*)columnValue)[i])));
3167 }
3168 free((short*)columnValue);
3169 break;
3170 case SDDS_USHORT:
3171 for (i=0;i < rows;i++) {
3172 PyList_SetItem(v, i, PyLong_FromLong((long)(((unsigned short*)columnValue)[i])));
3173 }
3174 free((unsigned short*)columnValue);
3175 break;
3176 case SDDS_LONG:
3177 for (i=0;i < rows;i++) {
3178 PyList_SetItem(v, i, PyLong_FromLong((long)(((int32_t*)columnValue)[i])));
3179 }
3180 free((int32_t*)columnValue);
3181 break;
3182 case SDDS_ULONG:
3183 for (i=0;i < rows;i++) {
3184 PyList_SetItem(v, i, PyLong_FromUnsignedLong((unsigned long)(((uint32_t*)columnValue)[i])));
3185 }
3186 free((uint32_t*)columnValue);
3187 break;
3188 case SDDS_LONG64:
3189 for (i=0;i < rows;i++) {
3190 PyList_SetItem(v, i, PyLong_FromLongLong((long long)(((int64_t*)columnValue)[i])));
3191 }
3192 free((int64_t*)columnValue);
3193 break;
3194 case SDDS_ULONG64:
3195 for (i=0;i < rows;i++) {
3196 PyList_SetItem(v, i, PyLong_FromUnsignedLongLong((unsigned long long)(((uint64_t*)columnValue)[i])));
3197 }
3198 free((uint64_t*)columnValue);
3199 break;
3200 case SDDS_FLOAT:
3201 for (i=0;i < rows;i++) {
3202 sprintf(buffer, "%.6E", ((float*)columnValue)[i]);
3203 PyList_SetItem(v, i, PyFloat_FromDouble(atof(buffer)));
3204 }
3205 free((float*)columnValue);
3206 break;
3207 case SDDS_DOUBLE:
3208 for (i=0;i < rows;i++) {
3209 PyList_SetItem(v, i, PyFloat_FromDouble(((double*)columnValue)[i]));
3210 }
3211 free((double*)columnValue);
3212 break;
3213 case SDDS_CHARACTER:
3214 for (i=0;i < rows;i++) {
3215 sprintf(buffer, "%c", ((char*)columnValue)[i]);
3216 PyList_SetItem(v, i, PyString_FromString(buffer));
3217 }
3218 free((char*)columnValue);
3219 break;
3220 case SDDS_STRING:
3221 for (i=0;i < rows;i++) {
3222 PyList_SetItem(v, i, PyString_FromString(((char**)columnValue)[i]));
3223 }
3224 for (i=0;i < rows;i++)
3225 free(((char**)columnValue)[i]);
3226 free((char**)columnValue);
3227 break;
3228 default:
3229 return NULL;
3230 }
3231 return v;
3232}
void * SDDS_GetColumn(SDDS_DATASET *SDDS_dataset, char *column_name)
Retrieves a copy of the data for a specified column, including only rows marked as "of interest".
int32_t SDDS_GetColumnIndex(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the index of a named column in the SDDS dataset.
char ** SDDS_GetColumnNames(SDDS_DATASET *SDDS_dataset, int32_t *number)
Retrieves the names of all columns in the SDDS dataset.
int32_t SDDS_GetColumnType(SDDS_DATASET *SDDS_dataset, int32_t index)
Retrieves the data type of a column in the SDDS dataset by its index.

◆ sddsdata_GetColumnDefinition()

static PyObject * sddsdata_GetColumnDefinition ( PyObject * self,
PyObject * args )
static

Retrieves the definition of a column in a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex (long): Dataset index.
  • name (char*): Name of the column.
Returns
Python list containing column attributes on success, NULL on error.

Definition at line 1883 of file sddsdatamodule.c.

1884{
1885 long fileIndex;
1886 char *name;
1887 COLUMN_DEFINITION *pardef;
1888 PyObject *v;
1889 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &name)) {
1890 return NULL;
1891 }
1892 if ((pardef = SDDS_GetColumnDefinition(&dataset_f[fileIndex], name)) == NULL)
1893 return NULL;
1894 if (!(v = PyList_New(6)))
1895 return NULL;
1896
1897 if (pardef->symbol)
1898 PyList_SetItem(v, 0, PyString_FromString(pardef->symbol));
1899 else
1900 PyList_SetItem(v, 0, PyString_FromString(""));
1901 if (pardef->units)
1902 PyList_SetItem(v, 1, PyString_FromString(pardef->units));
1903 else
1904 PyList_SetItem(v, 1, PyString_FromString(""));
1905 if (pardef->description)
1906 PyList_SetItem(v, 2, PyString_FromString(pardef->description));
1907 else
1908 PyList_SetItem(v, 2, PyString_FromString(""));
1909 if (pardef->format_string)
1910 PyList_SetItem(v, 3, PyString_FromString(pardef->format_string));
1911 else
1912 PyList_SetItem(v, 3, PyString_FromString(""));
1913 PyList_SetItem(v, 4, PyLong_FromLong(pardef->type));
1914 PyList_SetItem(v, 5, PyLong_FromLong(pardef->field_length));
1915
1917
1918 return v;
1919}
int32_t SDDS_FreeColumnDefinition(COLUMN_DEFINITION *source)
Frees memory allocated for a column definition.
COLUMN_DEFINITION * SDDS_GetColumnDefinition(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the definition of a specified column from the SDDS dataset.
Definition SDDS_utils.c:978

◆ sddsdata_GetColumnIndex()

static PyObject * sddsdata_GetColumnIndex ( PyObject * self,
PyObject * args )
static

Retrieves the index of a column in a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex (long): Dataset index.
  • name (char*): Name of the column.
Returns
Python integer (index on success, -1 on error).

Definition at line 1750 of file sddsdatamodule.c.

1751{
1752 long fileIndex;
1753 char *name;
1754 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &name)) {
1755 return PyLong_FromLong(-1);
1756 }
1757 return PyLong_FromLong(SDDS_GetColumnIndex(&dataset_f[fileIndex], name));
1758}

◆ sddsdata_GetColumnNameFromIndex()

static PyObject * sddsdata_GetColumnNameFromIndex ( PyObject * self,
PyObject * args )
static

Retrieves a column name by its index from a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex: Index of the dataset file.
  • index: Index of the column.
Returns
PyObject*:
  • NULL on error.
  • Column name string on success.

Definition at line 2358 of file sddsdatamodule.c.

2359{
2360 long fileIndex;
2361 long index;
2362 char **data;
2363 int32_t number;
2364 PyObject *v;
2365 long i;
2366 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &index)) {
2367 return NULL;
2368 }
2369 data = SDDS_GetColumnNames(&dataset_f[fileIndex], &number);
2370 if (!(data))
2371 return NULL;
2372 if ((index >= 0) && (index < number)) {
2373 v = PyString_FromString(data[index]);
2374 for (i=0;i<number;i++)
2375 free(data[i]);
2376 free(data);
2377 return v;
2378 }
2379 for (i=0;i<number;i++)
2380 free(data[i]);
2381 free(data);
2382 return NULL;
2383}

◆ sddsdata_GetColumnNames()

static PyObject * sddsdata_GetColumnNames ( PyObject * self,
PyObject * args )
static

Retrieves all column names from a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex: Index of the dataset file.
Returns
PyObject*:
  • NULL on error.
  • List of column names on success.

Definition at line 2396 of file sddsdatamodule.c.

2397{
2398 long fileIndex;
2399 long index;
2400 char **data;
2401 int32_t number;
2402 PyObject *v;
2403 long i;
2404 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
2405 return NULL;
2406 }
2407 data = SDDS_GetColumnNames(&dataset_f[fileIndex], &number);
2408 if (!(data))
2409 return NULL;
2410 if (!(v = PyList_New(number)))
2411 return NULL;
2412 for (index = 0; index < number; index++)
2413 PyList_SetItem(v, index, PyString_FromString(data[index]));
2414 for (i=0;i<number;i++)
2415 free(data[i]);
2416 free(data);
2417 return v;
2418}

◆ sddsdata_GetColumnType()

static PyObject * sddsdata_GetColumnType ( PyObject * self,
PyObject * args )
static

Retrieves the type of a column in a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex (long): Dataset index.
  • index (long): Column index.
Returns
Python integer (type on success, 0 on error).

Definition at line 1807 of file sddsdatamodule.c.

1808{
1809 long fileIndex;
1810 long index;
1811 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &index)) {
1812 return 0;
1813 }
1814 return PyLong_FromLong(SDDS_GetColumnType(&dataset_f[fileIndex], index));
1815}

◆ sddsdata_GetDescription()

static PyObject * sddsdata_GetDescription ( PyObject * self,
PyObject * args )
static

Gets the description (text and contents) of the dataset.

Parameters
selfPython object (unused).
argsPython arguments tuple containing:
  • fileIndex (long): Index of the dataset file.
Returns
PyObject*:
  • PyList of [text, contents] on success.
  • NULL on error.

Definition at line 1365 of file sddsdatamodule.c.

1366{
1367 long fileIndex;
1368 char *text;
1369 char *contents;
1370 PyObject *v;
1371 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
1372 return NULL;
1373 }
1374 if (SDDS_GetDescription(&dataset_f[fileIndex], &text, &contents) == 0) {
1375 return NULL;
1376 }
1377 if (!(v = PyList_New(2)))
1378 return NULL;
1379 if (text) {
1380 PyList_SetItem(v, 0, PyString_FromString(text));
1381 free(text);
1382 } else {
1383 PyList_SetItem(v, 0, PyString_FromString(""));
1384 }
1385 if (contents) {
1386 PyList_SetItem(v, 1, PyString_FromString(contents));
1387 free(contents);
1388 } else {
1389 PyList_SetItem(v, 1, PyString_FromString(""));
1390 }
1391 return v;
1392}
int32_t SDDS_GetDescription(SDDS_DATASET *SDDS_dataset, char **text, char **contents)
Retrieves the text and contents descriptions from an SDDS dataset.

◆ sddsdata_GetDescriptionContents()

static PyObject * sddsdata_GetDescriptionContents ( PyObject * self,
PyObject * args )
static

Retrieves the description contents for a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex (long): Index of the dataset file.
Returns
Python string containing the description contents, or NULL on error.

Definition at line 1426 of file sddsdatamodule.c.

1427{
1428 long fileIndex;
1429 char *text;
1430 char *contents;
1431 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
1432 return NULL;
1433 }
1434 if (SDDS_GetDescription(&dataset_f[fileIndex], &text, &contents) == 0) {
1435 return NULL;
1436 }
1437 if (contents)
1438 return PyString_FromString(contents);
1439 return PyString_FromString("");
1440}

◆ sddsdata_GetDescriptionText()

static PyObject * sddsdata_GetDescriptionText ( PyObject * self,
PyObject * args )
static

Retrieves the description text for a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex (long): Index of the dataset file.
Returns
Python string containing the description text, or NULL on error.

Definition at line 1402 of file sddsdatamodule.c.

1403{
1404 long fileIndex;
1405 char *text;
1406 char *contents;
1407 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
1408 return NULL;
1409 }
1410 if (SDDS_GetDescription(&dataset_f[fileIndex], &text, &contents) == 0) {
1411 return NULL;
1412 }
1413 if (text)
1414 return PyString_FromString(text);
1415 return PyString_FromString("");
1416}

◆ sddsdata_GetMode()

static PyObject * sddsdata_GetMode ( PyObject * self,
PyObject * args )
static

Retrieves the data mode of a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex: Index of the dataset file.
Returns
PyObject*:
  • Data mode of the dataset.

Definition at line 3552 of file sddsdatamodule.c.

3553{
3554 long fileIndex;
3555 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
3556 return 0;
3557 }
3558 return PyLong_FromLong(dataset_f[fileIndex].layout.data_mode.mode);
3559}

◆ sddsdata_GetNamedArrayType()

static PyObject * sddsdata_GetNamedArrayType ( PyObject * self,
PyObject * args )
static

Retrieves the type of an array by name in a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex (long): Dataset index.
  • name (char*): Name of the array.
Returns
Python integer (type on success, 0 on error).

Definition at line 1864 of file sddsdatamodule.c.

1865{
1866 long fileIndex;
1867 char *name;
1868 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &name)) {
1869 return 0;
1870 }
1871 return PyLong_FromLong(SDDS_GetNamedArrayType(&dataset_f[fileIndex], name));
1872}
int32_t SDDS_GetNamedArrayType(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the data type of an array in the SDDS dataset by its name.

◆ sddsdata_GetNamedColumnType()

static PyObject * sddsdata_GetNamedColumnType ( PyObject * self,
PyObject * args )
static

Retrieves the type of a column by name in a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex (long): Dataset index.
  • name (char*): Name of the column.
Returns
Python integer (type on success, 0 on error).

Definition at line 1845 of file sddsdatamodule.c.

1846{
1847 long fileIndex;
1848 char *name;
1849 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &name)) {
1850 return 0;
1851 }
1852 return PyLong_FromLong(SDDS_GetNamedColumnType(&dataset_f[fileIndex], name));
1853}
int32_t SDDS_GetNamedColumnType(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the data type of a column in the SDDS dataset by its name.

◆ sddsdata_GetNamedParameterType()

static PyObject * sddsdata_GetNamedParameterType ( PyObject * self,
PyObject * args )
static

Retrieves the type of a parameter by name in a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex (long): Dataset index.
  • name (char*): Name of the parameter.
Returns
Python integer (type on success, 0 on error).

Definition at line 2001 of file sddsdatamodule.c.

2002{
2003 long fileIndex;
2004 char *name;
2005 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &name)) {
2006 return 0;
2007 }
2008 return PyLong_FromLong(SDDS_GetNamedParameterType(&dataset_f[fileIndex], name));
2009}
int32_t SDDS_GetNamedParameterType(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the data type of a parameter in the SDDS dataset by its name.

◆ sddsdata_GetParameter()

static PyObject * sddsdata_GetParameter ( PyObject * self,
PyObject * args )
static

Retrieves the value of a parameter from a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex: Index of the dataset file.
  • indexOrName: Index or name of the parameter.
Returns
PyObject*:
  • NULL on error.
  • Parameter value on success.

Definition at line 3443 of file sddsdatamodule.c.

3444{
3445 long fileIndex;
3446 PyObject *indexOrName;
3447 long originalType;
3448 void *parameterValue;
3449 char *name;
3450 char **data;
3451 int32_t number;
3452 char buffer[40];
3453 long index;
3454 long i;
3455 PyObject *v=NULL;
3456 if (!PyArg_ParseTuple(args, "lO", &fileIndex, &indexOrName)) {
3457 return NULL;
3458 }
3459 if (PyString_Check(indexOrName)) {
3460 index = SDDS_GetParameterIndex(&dataset_f[fileIndex], (char*)PyString_AsString(indexOrName));
3461 } else if (PyNumber_Check(indexOrName)) {
3462 if (PyInt_Check(indexOrName))
3463 index = PyInt_AsLong(indexOrName);
3464 else if (PyLong_Check(indexOrName))
3465 index = PyLong_AsLong(indexOrName);
3466 else
3467 return NULL;
3468 } else
3469 return NULL;
3470
3471 data = SDDS_GetParameterNames(&dataset_f[fileIndex], &number);
3472 if (!(data))
3473 return NULL;
3474 if ((index >= 0) && (index < number)) {
3475 name = data[index];
3476 } else {
3477 return NULL;
3478 }
3479 if (!name) {
3480 return NULL;
3481 }
3482
3483 parameterValue = SDDS_GetParameter(&(dataset_f[fileIndex]), name, NULL);
3484
3485 for (i=0;i<number;i++)
3486 free(data[i]);
3487 free(data);
3488
3489 if (!(parameterValue)) {
3490 return NULL;
3491 }
3492 originalType = SDDS_GetParameterType(&dataset_f[fileIndex], index);
3493
3494 switch (originalType) {
3495 case SDDS_SHORT:
3496 v = PyLong_FromLong((long)(((short*)parameterValue)[0]));
3497 free((short*)parameterValue);
3498 break;
3499 case SDDS_USHORT:
3500 v = PyLong_FromLong((long)(((unsigned short*)parameterValue)[0]));
3501 free((unsigned short*)parameterValue);
3502 break;
3503 case SDDS_LONG:
3504 v = PyLong_FromLong((long)(((int32_t*)parameterValue)[0]));
3505 free((int32_t*)parameterValue);
3506 break;
3507 case SDDS_ULONG:
3508 v = PyLong_FromUnsignedLong((unsigned long)(((uint32_t*)parameterValue)[0]));
3509 free((uint32_t*)parameterValue);
3510 break;
3511 case SDDS_LONG64:
3512 v = PyLong_FromLongLong((long long)(((int64_t*)parameterValue)[0]));
3513 free((int64_t*)parameterValue);
3514 break;
3515 case SDDS_ULONG64:
3516 v = PyLong_FromUnsignedLongLong((unsigned long long)(((uint64_t*)parameterValue)[0]));
3517 free((uint64_t*)parameterValue);
3518 break;
3519 case SDDS_FLOAT:
3520 sprintf(buffer, "%.6E", ((float*)parameterValue)[0]);
3521 v = PyFloat_FromDouble(atof(buffer));
3522 free((float*)parameterValue);
3523 break;
3524 case SDDS_DOUBLE:
3525 v = PyFloat_FromDouble(((double*)parameterValue)[0]);
3526 free((double*)parameterValue);
3527 break;
3528 case SDDS_CHARACTER:
3529 sprintf(buffer, "%c", ((char*)parameterValue)[0]);
3530 v = PyString_FromString(buffer);
3531 free((char*)parameterValue);
3532 break;
3533 case SDDS_STRING:
3534 v = PyString_FromString(((char**)parameterValue)[0]);
3535 free(((char**)parameterValue)[0]);
3536 free((char**)parameterValue);
3537 break;
3538 }
3539 return v;
3540}
void * SDDS_GetParameter(SDDS_DATASET *SDDS_dataset, char *parameter_name, void *memory)
Retrieves the value of a specified parameter from the current data table of a data set.
int32_t SDDS_GetParameterType(SDDS_DATASET *SDDS_dataset, int32_t index)
Retrieves the data type of a parameter in the SDDS dataset by its index.
char ** SDDS_GetParameterNames(SDDS_DATASET *SDDS_dataset, int32_t *number)
Retrieves the names of all parameters in the SDDS dataset.
int32_t SDDS_GetParameterIndex(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the index of a named parameter in the SDDS dataset.

◆ sddsdata_GetParameterDefinition()

static PyObject * sddsdata_GetParameterDefinition ( PyObject * self,
PyObject * args )
static

Retrieves the definition of a parameter in a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex (long): Dataset index.
  • name (char*): Name of the parameter.
Returns
Python list containing parameter attributes on success, NULL on error.

Definition at line 2020 of file sddsdatamodule.c.

2021{
2022 long fileIndex;
2023 char *name;
2024 PARAMETER_DEFINITION *pardef;
2025 PyObject *v;
2026 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &name)) {
2027 return NULL;
2028 }
2029 if ((pardef = SDDS_GetParameterDefinition(&dataset_f[fileIndex], name)) == NULL)
2030 return NULL;
2031 if (!(v = PyList_New(6)))
2032 return NULL;
2033
2034 if (pardef->symbol)
2035 PyList_SetItem(v, 0, PyString_FromString(pardef->symbol));
2036 else
2037 PyList_SetItem(v, 0, PyString_FromString(""));
2038 if (pardef->units)
2039 PyList_SetItem(v, 1, PyString_FromString(pardef->units));
2040 else
2041 PyList_SetItem(v, 1, PyString_FromString(""));
2042 if (pardef->description)
2043 PyList_SetItem(v, 2, PyString_FromString(pardef->description));
2044 else
2045 PyList_SetItem(v, 2, PyString_FromString(""));
2046 if (pardef->format_string)
2047 PyList_SetItem(v, 3, PyString_FromString(pardef->format_string));
2048 else
2049 PyList_SetItem(v, 3, PyString_FromString(""));
2050 PyList_SetItem(v, 4, PyLong_FromLong(pardef->type));
2051 if (pardef->fixed_value)
2052 PyList_SetItem(v, 5, PyString_FromString(pardef->fixed_value));
2053 else
2054 PyList_SetItem(v, 5, PyString_FromString(""));
2055
2057
2058 return v;
2059}
PARAMETER_DEFINITION * SDDS_GetParameterDefinition(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the definition of a specified parameter from the SDDS dataset.
int32_t SDDS_FreeParameterDefinition(PARAMETER_DEFINITION *source)
Frees memory allocated for a parameter definition.

◆ sddsdata_GetParameterIndex()

static PyObject * sddsdata_GetParameterIndex ( PyObject * self,
PyObject * args )
static

Retrieves the index of a parameter in a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex (long): Dataset index.
  • name (char*): Name of the parameter.
Returns
Python integer (index on success, -1 on error).

Definition at line 1788 of file sddsdatamodule.c.

1789{
1790 long fileIndex;
1791 char *name;
1792 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &name)) {
1793 return PyLong_FromLong(-1);
1794 }
1795 return PyLong_FromLong(SDDS_GetParameterIndex(&dataset_f[fileIndex], name));
1796}

◆ sddsdata_GetParameterNameFromIndex()

static PyObject * sddsdata_GetParameterNameFromIndex ( PyObject * self,
PyObject * args )
static

Retrieves a parameter name by its index from a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex: Index of the dataset file.
  • index: Index of the parameter.
Returns
PyObject*:
  • NULL on error.
  • Parameter name string on success.

Definition at line 2506 of file sddsdatamodule.c.

2507{
2508 long fileIndex;
2509 long index;
2510 char **data;
2511 int32_t number;
2512 PyObject *v;
2513 long i;
2514 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &index)) {
2515 return NULL;
2516 }
2517 data = SDDS_GetParameterNames(&dataset_f[fileIndex], &number);
2518 if (!(data))
2519 return NULL;
2520 if ((index >= 0) && (index < number)) {
2521 v = PyString_FromString(data[index]);
2522 for (i=0;i<number;i++)
2523 free(data[i]);
2524 free(data);
2525 return v;
2526 }
2527 for (i=0;i<number;i++)
2528 free(data[i]);
2529 free(data);
2530 return NULL;
2531}

◆ sddsdata_GetParameterNames()

static PyObject * sddsdata_GetParameterNames ( PyObject * self,
PyObject * args )
static

Retrieves all parameter names from a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex: Index of the dataset file.
Returns
PyObject*:
  • NULL on error.
  • List of parameter names on success.

Definition at line 2544 of file sddsdatamodule.c.

2545{
2546 long fileIndex;
2547 long index;
2548 char **data;
2549 int32_t number;
2550 PyObject *v;
2551 long i;
2552 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
2553 return NULL;
2554 }
2555 data = SDDS_GetParameterNames(&dataset_f[fileIndex], &number);
2556 if (!(data))
2557 return NULL;
2558 if (!(v = PyList_New(number)))
2559 return NULL;
2560 for (index = 0; index < number; index++)
2561 PyList_SetItem(v, index, PyString_FromString(data[index]));
2562 for (i=0;i<number;i++)
2563 free(data[i]);
2564 free(data);
2565 return v;
2566}

◆ sddsdata_GetParameterType()

static PyObject * sddsdata_GetParameterType ( PyObject * self,
PyObject * args )
static

Retrieves the type of a parameter in a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex (long): Dataset index.
  • index (long): Parameter index.
Returns
Python integer (type on success, 0 on error).

Definition at line 1982 of file sddsdatamodule.c.

1983{
1984 long fileIndex;
1985 long index;
1986 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &index)) {
1987 return 0;
1988 }
1989 return PyLong_FromLong(SDDS_GetParameterType(&dataset_f[fileIndex], index));
1990}

◆ sddsdata_GetRowFlag()

static PyObject * sddsdata_GetRowFlag ( PyObject * self,
PyObject * args )
static

Gets the flag value for a specific row in the dataset.

Parameters
selfPointer to the Python self object.
argsTuple containing:
  • fileIndex (long): Index of the file dataset.
  • row (long): Row number for which the flag is retrieved.
Returns
PyObject*:
  • -1 on error.
  • Row flag on success.

Definition at line 1222 of file sddsdatamodule.c.

1223{
1224 long fileIndex;
1225 long row;
1226 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &row)) {
1227 return PyLong_FromLong(-1);
1228 }
1229 return PyLong_FromLong(SDDS_GetRowFlag(&dataset_f[fileIndex], row));
1230}
int32_t SDDS_GetRowFlag(SDDS_DATASET *SDDS_dataset, int64_t row)
Retrieves the acceptance flag of a specific row in the current data table.

◆ sddsdata_GetTypeName()

static PyObject * sddsdata_GetTypeName ( PyObject * self,
PyObject * args )
static

Retrieves the name of a given SDDS data type.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • type (long): SDDS data type.
Returns
Python string (type name on success, NULL on error).

Definition at line 2086 of file sddsdatamodule.c.

2087{
2088 long type;
2089 char *name;
2090 char msgbuf[256];
2091 if (!PyArg_ParseTuple(args, "l", &type)) {
2092 return NULL;
2093 }
2094 name = SDDS_GetTypeName(type);
2095 if (name)
2096 return PyString_FromString(name);
2097 sprintf(msgbuf, "sdds.GetTypeName: %ld is an invalid SDDS data type", type);
2098 PyErr_SetString(PyExc_StandardError, msgbuf);
2099 return NULL;
2100}
char * SDDS_GetTypeName(int32_t type)
Retrieves the name of a specified SDDS data type as a string.

◆ sddsdata_GetTypeSize()

static PyObject * sddsdata_GetTypeSize ( PyObject * self,
PyObject * args )
static

Retrieves the size of a given SDDS data type.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • type (long): SDDS data type.
Returns
Python integer (size on success, -1 on error).

Definition at line 2069 of file sddsdatamodule.c.

2070{
2071 long type;
2072 if (!PyArg_ParseTuple(args, "l", &type)) {
2073 return PyLong_FromLong(-1);
2074 }
2075 return PyLong_FromLong(SDDS_GetTypeSize(type));
2076}
int32_t SDDS_GetTypeSize(int32_t type)
Retrieves the size in bytes of a specified SDDS data type.

◆ sddsdata_HasWhitespace()

static PyObject * sddsdata_HasWhitespace ( PyObject * self,
PyObject * args )
static

Determines if a string contains whitespace.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • string (char*): String to check.
Returns
Python integer (1 if true, 0 otherwise).

Definition at line 2196 of file sddsdatamodule.c.

2197{
2198 char *string;
2199 if (!PyArg_ParseTuple(args, "s", &string)) {
2200 return 0;
2201 }
2202 return PyLong_FromLong(SDDS_HasWhitespace(string));
2203}
int32_t SDDS_HasWhitespace(char *string)
Checks if a string contains any whitespace characters.

◆ sddsdata_IdentifyType()

static PyObject * sddsdata_IdentifyType ( PyObject * self,
PyObject * args )
static

Identifies the SDDS data type for a given type name.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • typeName (char*): Name of the data type (e.g., double, float).
Returns
Python integer (type on success, 0 on error).

Definition at line 2110 of file sddsdatamodule.c.

2111{
2112 char *typeName;
2113 if (!PyArg_ParseTuple(args, "s", &typeName)) {
2114 return 0;
2115 }
2116 return PyLong_FromLong(SDDS_IdentifyType(typeName));
2117}
int32_t SDDS_IdentifyType(char *typeName)
Identifies the SDDS data type based on its string name.

◆ sddsdata_InitHeaderlessInput()

static PyObject * sddsdata_InitHeaderlessInput ( PyObject * self,
PyObject * args )
static

Initializes a headerless input for a dataset file.

Parameters
selfPointer to the Python self object.
argsTuple containing:
  • fileIndex (long): Index of the file dataset.
  • filename (char*): Name of the file to initialize.
Returns
PyObject*:
  • 0 on error.
  • 1 on success.

Definition at line 1075 of file sddsdatamodule.c.

1076{
1077 long fileIndex;
1078 char *filename;
1079 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &filename)) {
1080 return 0;
1081 }
1082 return PyLong_FromLong(SDDS_InitializeHeaderlessInput(&dataset_f[fileIndex], filename));
1083}
int32_t SDDS_InitializeHeaderlessInput(SDDS_DATASET *SDDS_dataset, char *filename)
Initializes the SDDS dataset for headerless input.
Definition SDDS_input.c:175

◆ sddsdata_InitializeAppend()

static PyObject * sddsdata_InitializeAppend ( PyObject * self,
PyObject * args )
static

Initializes an SDDS dataset for appending data to a file.

Parameters
selfUnused pointer to the module object.
argsPython tuple containing:
  • fileIndex (long): Index of the dataset in the array.
  • filename (char*): Name of the file to append to.
Returns
PyObject*
  • 1 on success.
  • 0 on error.

Definition at line 71 of file sddsdatamodule.c.

72{
73 long fileIndex;
74 char *filename;
75 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &filename)) {
76 return 0;
77 }
78 return PyLong_FromLong(SDDS_InitializeAppend(&dataset_f[fileIndex], filename));
79}
int32_t SDDS_InitializeAppend(SDDS_DATASET *SDDS_dataset, const char *filename)
Initializes the SDDS dataset for appending data by adding a new page to an existing file.

◆ sddsdata_InitializeAppendToPage()

static PyObject * sddsdata_InitializeAppendToPage ( PyObject * self,
PyObject * args )
static

Initializes appending data to an existing SDDS page in a file.

Parameters
selfUnused pointer to the module object.
argsPython tuple containing:
  • fileIndex (long): Index of the dataset in the array.
  • filename (char*): Name of the file to append to.
  • updateInterval (long): Interval at which data should be updated.
Returns
PyObject*
  • Number of rows in the page on success.
  • 0 on error.

Definition at line 94 of file sddsdatamodule.c.

95{
96 long fileIndex;
97 char *filename;
98 long updateInterval, result;
99 int64_t rowsPresent;
100 if (!PyArg_ParseTuple(args, "lsl", &fileIndex, &filename, &updateInterval)) {
101 return 0;
102 }
103 result = SDDS_InitializeAppendToPage(&dataset_f[fileIndex], filename, updateInterval, &rowsPresent);
104 if (result != 1)
105 return 0;
106 return PyLong_FromLongLong((long long)rowsPresent);
107}
int32_t SDDS_InitializeAppendToPage(SDDS_DATASET *SDDS_dataset, const char *filename, int64_t updateInterval, int64_t *rowsPresentReturn)
Initializes the SDDS dataset for appending data to the last page of an existing file.

◆ sddsdata_InitializeCopy()

static PyObject * sddsdata_InitializeCopy ( PyObject * self,
PyObject * args )
static

Initializes a copy from one SDDS dataset to another.

Parameters
selfUnused.
argsA tuple containing:
  • fileIndexTarget (long): Index of the target dataset.
  • fileIndexSource (long): Index of the source dataset.
  • filename (char*): Name of the target file (can be NULL).
  • filemode (char*): File mode for the target file ("r", "w", "rb", "wb", "m").
Returns
PyObject* A Python integer (1 on success, 0 on error).

Definition at line 706 of file sddsdatamodule.c.

707{
708 long fileIndexTarget;
709 long fileIndexSource;
710 char *filename;
711 char *filemode;
712 if (!PyArg_ParseTuple(args, "llss", &fileIndexTarget, &fileIndexSource, &filename, &filemode)) {
713 return 0;
714 }
715 if (filename)
716 if (strlen(filename) == 0)
717 filename = NULL;
718 return PyLong_FromLong(SDDS_InitializeCopy(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource], filename, filemode));
719}
int32_t SDDS_InitializeCopy(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source, char *filename, char *filemode)
Definition SDDS_copy.c:40

◆ sddsdata_InitializeInput()

static PyObject * sddsdata_InitializeInput ( PyObject * self,
PyObject * args )
static

Initializes an SDDS dataset for input from a file.

Parameters
selfUnused pointer to the module object.
argsPython tuple containing:
  • fileIndex (long): Index of the dataset in the array.
  • filename (char*): Name of the input file.
Returns
PyObject*
  • 1 on success.
  • 0 on error.

Definition at line 49 of file sddsdatamodule.c.

50{
51 long fileIndex;
52 char *filename;
53 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &filename)) {
54 return 0;
55 }
56 return PyLong_FromLong(SDDS_InitializeInput(&dataset_f[fileIndex], filename));
57}
int32_t SDDS_InitializeInput(SDDS_DATASET *SDDS_dataset, char *filename)
Definition SDDS_input.c:49

◆ sddsdata_InitializeOutput()

static PyObject * sddsdata_InitializeOutput ( PyObject * self,
PyObject * args )
static

Initializes an SDDS dataset for output to a file.

Parameters
selfUnused pointer to the module object.
argsPython tuple containing:
  • fileIndex (long): Index of the dataset in the array.
  • data_mode (long): Data mode (e.g., SDDS_BINARY or SDDS_ASCII).
  • lines_per_row (long): Number of lines per row in the output file.
  • description (char*): Description of the dataset.
  • contents (char*): Contents of the dataset.
  • filename (char*): Name of the output file.
Returns
PyObject*
  • 1 on success.
  • 0 on error.

Definition at line 125 of file sddsdatamodule.c.

126{
127 long fileIndex;
128 long data_mode;
129 long lines_per_row;
130 char *description;
131 char *contents;
132 char *filename;
133 if (!PyArg_ParseTuple(args, "lllsss", &fileIndex, &data_mode, &lines_per_row, &description, &contents, &filename)) {
134 return 0;
135 }
136 if (description)
137 if (strlen(description) == 0)
138 description = NULL;
139 if (contents)
140 if (strlen(contents) == 0)
141 contents = NULL;
142 return PyLong_FromLong(SDDS_InitializeOutput(&dataset_f[fileIndex], data_mode, lines_per_row, description, contents, filename));
143}
int32_t SDDS_InitializeOutput(SDDS_DATASET *SDDS_dataset, int32_t data_mode, int32_t lines_per_row, const char *description, const char *contents, const char *filename)
Initializes the SDDS output dataset.

◆ sddsdata_IsValidName()

static PyObject * sddsdata_IsValidName ( PyObject * self,
PyObject * args )
static

Validates a name for SDDS compatibility.

Parameters
selfUnused.
argsA tuple containing:
  • name (char*): The name to validate.
Returns
PyObject* A Python integer (1 if valid, 0 if invalid).

Definition at line 481 of file sddsdatamodule.c.

482{
483 char *name;
484 if (!PyArg_ParseTuple(args, "s", &name)) {
485 return 0;
486 }
487 return PyLong_FromLong(SDDS_IsValidName(name, NULL));
488}
int32_t SDDS_IsValidName(const char *name, const char *class)
Checks if a given name is valid for a specified class within the SDDS dataset.

◆ sddsdata_LengthenTable()

static PyObject * sddsdata_LengthenTable ( PyObject * self,
PyObject * args )
static

Lengthens the table by adding additional rows.

Parameters
selfPointer to the Python self object.
argsTuple containing:
  • fileIndex (long): Index of the file dataset.
  • n_additional_rows (long): Number of rows to add.
Returns
PyObject*:
  • 0 on error.
  • 1 on success.

Definition at line 1015 of file sddsdatamodule.c.

1016{
1017 long fileIndex;
1018 long n_additional_rows;
1019 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &n_additional_rows)) {
1020 return 0;
1021 }
1022 return PyLong_FromLong(SDDS_LengthenTable(&dataset_f[fileIndex], n_additional_rows));
1023}
int32_t SDDS_LengthenTable(SDDS_DATASET *SDDS_dataset, int64_t n_additional_rows)

◆ sddsdata_NumberOfErrors()

static PyObject * sddsdata_NumberOfErrors ( PyObject * self,
PyObject * args )
static

Returns the number of errors recorded.

Parameters
selfPython object (unused).
argsPython tuple (unused).
Returns
Python integer representing the number of errors.

Definition at line 1449 of file sddsdatamodule.c.

1450{
1451 return PyLong_FromLong(SDDS_NumberOfErrors());
1452}
int32_t SDDS_NumberOfErrors()
Retrieves the number of errors recorded by SDDS library routines.
Definition SDDS_utils.c:304

◆ sddsdata_ParameterCount()

static PyObject * sddsdata_ParameterCount ( PyObject * self,
PyObject * args )
static

Gets the count of parameters in the dataset.

Parameters
selfPython object (unused).
argsPython arguments tuple containing:
  • fileIndex (long): Index of the dataset file.
Returns
PyObject*: Number of parameters as PyLong.

Definition at line 1347 of file sddsdatamodule.c.

1348{
1349 long fileIndex;
1350 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
1351 return 0;
1352 }
1353 return PyLong_FromLong(SDDS_ParameterCount(&dataset_f[fileIndex]));
1354}
int32_t SDDS_ParameterCount(SDDS_DATASET *page)
Retrieves the number of parameters in the SDDS dataset.

◆ sddsdata_PrintErrors()

static PyObject * sddsdata_PrintErrors ( PyObject * self,
PyObject * args )
static

Prints error messages based on the provided mode.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • mode (long): Error print mode. Valid values: 0, 1, 2, 3.
Returns
Python None, or NULL on error.

Definition at line 1552 of file sddsdatamodule.c.

1553{
1554 long mode;
1555 if (!PyArg_ParseTuple(args, "l", &mode)) {
1556 return NULL;
1557 }
1558 SDDS_PrintErrors(stderr, mode);
1559 Py_INCREF(Py_None);
1560 return Py_None;
1561}
void SDDS_PrintErrors(FILE *fp, int32_t mode)
Prints recorded error messages to a specified file stream.
Definition SDDS_utils.c:432

◆ sddsdata_ProcessArrayString()

static PyObject * sddsdata_ProcessArrayString ( PyObject * self,
PyObject * args )
static

Processes an array definition string.

Parameters
selfUnused.
argsA tuple containing:
  • fileIndex (long): Index of the dataset.
  • string (char*): Array definition string.
Returns
PyObject* A Python integer (1 on success, 0 on error).

Definition at line 662 of file sddsdatamodule.c.

663{
664 long fileIndex;
665 char *string;
666 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &string)) {
667 return 0;
668 }
669 return PyLong_FromLong(SDDS_ProcessArrayString(&dataset_f[fileIndex], string));
670}
int32_t SDDS_ProcessArrayString(SDDS_DATASET *SDDS_dataset, char *string)
Process an array definition string.

◆ sddsdata_ProcessColumnString()

static PyObject * sddsdata_ProcessColumnString ( PyObject * self,
PyObject * args )
static

Processes a column definition string.

Parameters
selfUnused.
argsA tuple containing:
  • fileIndex (long): Index of the dataset.
  • string (char*): Column definition string.
  • mode (long): Mode for processing (0 for SDDS_NORMAL_DEFINITION, 1 for SDDS_WRITEONLY_DEFINITION).
Returns
PyObject* A Python integer (1 on success, 0 on error).

Definition at line 641 of file sddsdatamodule.c.

642{
643 long fileIndex;
644 char *string;
645 long mode;
646 if (!PyArg_ParseTuple(args, "lsl", &fileIndex, &string, &mode)) {
647 return 0;
648 }
649 return PyLong_FromLong(SDDS_ProcessColumnString(&dataset_f[fileIndex], string, mode));
650}
int32_t SDDS_ProcessColumnString(SDDS_DATASET *SDDS_dataset, char *string, int32_t mode)
Process a column definition string.

◆ sddsdata_ProcessParameterString()

static PyObject * sddsdata_ProcessParameterString ( PyObject * self,
PyObject * args )
static

Processes a parameter definition string.

Parameters
selfUnused.
argsA tuple containing:
  • fileIndex (long): Index of the dataset.
  • string (char*): Parameter definition string.
  • mode (long): Mode for processing (0 for SDDS_NORMAL_DEFINITION, 1 for SDDS_WRITEONLY_DEFINITION).
Returns
PyObject* A Python integer (1 on success, 0 on error).

Definition at line 683 of file sddsdatamodule.c.

684{
685 long fileIndex;
686 char *string;
687 long mode;
688 if (!PyArg_ParseTuple(args, "lsl", &fileIndex, &string, &mode)) {
689 return 0;
690 }
691 return PyLong_FromLong(SDDS_ProcessParameterString(&dataset_f[fileIndex], string, mode));
692}
int32_t SDDS_ProcessParameterString(SDDS_DATASET *SDDS_dataset, char *string, int32_t mode)
Process a parameter definition string.

◆ sddsdata_ReadPage()

static PyObject * sddsdata_ReadPage ( PyObject * self,
PyObject * args )
static

Reads the current page from the dataset file.

Parameters
selfPointer to the Python self object.
argsTuple containing:
  • fileIndex (long): Index of the file dataset.
Returns
PyObject*:
  • 0 on error.
  • -1 on EOF.
  • Page number on success.

Definition at line 1096 of file sddsdatamodule.c.

1097{
1098 long fileIndex;
1099 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
1100 return 0;
1101 }
1102 return PyLong_FromLong(SDDS_ReadPage(&dataset_f[fileIndex]));
1103}
int32_t SDDS_ReadPage(SDDS_DATASET *SDDS_dataset)

◆ sddsdata_ReadPageLastRows()

static PyObject * sddsdata_ReadPageLastRows ( PyObject * self,
PyObject * args )
static

Reads the last rows of the current page from the dataset file.

Parameters
selfPointer to the Python self object.
argsTuple containing:
  • fileIndex (long): Index of the file dataset.
  • last_rows (long): Number of last rows to read.
Returns
PyObject*:
  • 0 on error.
  • -1 on EOF.
  • Page number on success.

Definition at line 1141 of file sddsdatamodule.c.

1142{
1143 long fileIndex;
1144 long last_rows;
1145 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &last_rows)) {
1146 return 0;
1147 }
1148 return PyLong_FromLong(SDDS_ReadPageLastRows(&dataset_f[fileIndex], last_rows));
1149}
int32_t SDDS_ReadPageLastRows(SDDS_DATASET *SDDS_dataset, int64_t last_rows)

◆ sddsdata_ReadPageSparse()

static PyObject * sddsdata_ReadPageSparse ( PyObject * self,
PyObject * args )
static

Reads a sparse page from the dataset file.

Parameters
selfPointer to the Python self object.
argsTuple containing:
  • fileIndex (long): Index of the file dataset.
  • sparse_interval (long): Interval for sparse reading.
  • sparse_offset (long): Offset for sparse reading.
Returns
PyObject*:
  • 0 on error.
  • -1 on EOF.
  • Page number on success.

Definition at line 1118 of file sddsdatamodule.c.

1119{
1120 long fileIndex;
1121 long sparse_interval;
1122 long sparse_offset;
1123 if (!PyArg_ParseTuple(args, "lll", &fileIndex, &sparse_interval, &sparse_offset)) {
1124 return 0;
1125 }
1126 return PyLong_FromLong(SDDS_ReadPageSparse(&dataset_f[fileIndex], 0, sparse_interval, sparse_offset, 0));
1127}
int32_t SDDS_ReadPageSparse(SDDS_DATASET *SDDS_dataset, uint32_t mode, int64_t sparse_interval, int64_t sparse_offset, int32_t sparse_statistics)

◆ sddsdata_RegisterProgramName()

static PyObject * sddsdata_RegisterProgramName ( PyObject * self,
PyObject * args )
static

Registers a program name for use in error messages.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • name (char*): Name of the program.
Returns
Python None, or NULL on error.

Definition at line 1533 of file sddsdatamodule.c.

1534{
1535 char *name;
1536 if (!PyArg_ParseTuple(args, "s", &name)) {
1537 return NULL;
1538 }
1540 Py_INCREF(Py_None);
1541 return Py_None;
1542}
void SDDS_RegisterProgramName(const char *name)
Registers the executable program name for use in error messages.
Definition SDDS_utils.c:288

◆ sddsdata_RestoreLayout()

static PyObject * sddsdata_RestoreLayout ( PyObject * self,
PyObject * args )
static

Restores the layout of an SDDS dataset.

Parameters
selfUnused.
argsA tuple containing:
  • fileIndex (long): Index of the dataset.
Returns
PyObject* A Python integer (1 on success, 0 on error).

Definition at line 957 of file sddsdatamodule.c.

958{
959 long fileIndex;
960 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
961 return 0;
962 }
963 return PyLong_FromLong(SDDS_RestoreLayout(&dataset_f[fileIndex]));
964}
int32_t SDDS_RestoreLayout(SDDS_DATASET *SDDS_dataset)
Definition SDDS_copy.c:697

◆ sddsdata_RowCount()

static PyObject * sddsdata_RowCount ( PyObject * self,
PyObject * args )
static

Gets the number of rows in the dataset.

Parameters
selfPointer to the Python self object.
argsTuple containing:
  • fileIndex (long): Index of the file dataset.
Returns
PyObject*:
  • Number of rows in the dataset.

Definition at line 1160 of file sddsdatamodule.c.

1161{
1162 long fileIndex;
1163 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
1164 return 0;
1165 }
1166 return PyLong_FromLongLong((long long)SDDS_RowCount(&dataset_f[fileIndex]));
1167}

◆ sddsdata_SaveLayout()

static PyObject * sddsdata_SaveLayout ( PyObject * self,
PyObject * args )
static

Saves the layout of an SDDS dataset.

Parameters
selfUnused.
argsA tuple containing:
  • fileIndex (long): Index of the dataset.
Returns
PyObject* A Python integer (1 on success, 0 on error).

Definition at line 939 of file sddsdatamodule.c.

940{
941 long fileIndex;
942 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
943 return 0;
944 }
945 return PyLong_FromLong(SDDS_SaveLayout(&dataset_f[fileIndex]));
946}
int32_t SDDS_SaveLayout(SDDS_DATASET *SDDS_dataset)
Definition SDDS_copy.c:615

◆ sddsdata_SetArray()

static PyObject * sddsdata_SetArray ( PyObject * self,
PyObject * args )
static

Sets an array value in a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex: Index of the dataset file.
  • indexOrName: Index or name of the array.
  • v: Array values.
  • dim: Array dimensions.
Returns
PyObject*:
  • 0 on error.
  • 1 on success.

Definition at line 2656 of file sddsdatamodule.c.

2657{
2658 long fileIndex;
2659 long elements;
2660 PyObject *indexOrName;
2661 PyObject *v;
2662 PyObject *dim;
2663 long type;
2664 long i;
2665 void *data = NULL;
2666 long index;
2667 long result=0;
2668 PyObject *temp;
2669 ARRAY_DEFINITION *arraydef;
2670 char **names=NULL;
2671 int32_t number;
2672 int32_t dimensions;
2673 int32_t *dimension=NULL;
2674
2675 if (!PyArg_ParseTuple(args, "lOOO", &fileIndex, &indexOrName, &v, &dim)) {
2676 return 0;
2677 }
2678 if (PyString_Check(indexOrName)) {
2679 index = SDDS_GetArrayIndex(&dataset_f[fileIndex], (char*)PyString_AsString(indexOrName));
2680 if ((arraydef = SDDS_GetArrayDefinition(&dataset_f[fileIndex], (char*)PyString_AsString(indexOrName))) == NULL)
2681 return 0;
2682 } else if (PyNumber_Check(indexOrName)) {
2683 if (PyInt_Check(indexOrName))
2684 index = PyInt_AsLong(indexOrName);
2685 else if (PyLong_Check(indexOrName))
2686 index = PyLong_AsLong(indexOrName);
2687 else
2688 return 0;
2689 names = SDDS_GetArrayNames(&dataset_f[fileIndex], &number);
2690 if (!(names))
2691 return 0;
2692 if (number <= index)
2693 return 0;
2694 if ((arraydef = SDDS_GetArrayDefinition(&dataset_f[fileIndex], names[index])) == NULL)
2695 return 0;
2696 } else
2697 return 0;
2698 type = arraydef->type;
2699 dimensions = arraydef->dimensions;
2700
2701 if (dimensions != PyList_Size(dim))
2702 return 0;
2703 dimension = malloc(sizeof(int32_t)*dimensions);
2704
2705 for (i=0;i<dimensions;i++) {
2706 temp = PyList_GetItem(dim, i);
2707 if (PyInt_Check(temp))
2708 dimension[i] = PyInt_AsLong(temp);
2709 else if (PyLong_Check(temp))
2710 dimension[i] = PyLong_AsLong(temp);
2711 else
2712 return 0;
2713 }
2714
2715 elements = (long)PyList_Size(v);
2716 switch (type) {
2717 case SDDS_SHORT:
2718 data = malloc(sizeof(short)*elements);
2719 for (i=0;i<elements;i++) {
2720 temp = PyList_GetItem(v, i);
2721 if (PyLong_Check(temp))
2722 ((short*)data)[i] = (short)PyLong_AsLong(temp);
2723 else
2724 ((short*)data)[i] = (short)PyInt_AsLong(temp);
2725 }
2726 break;
2727 case SDDS_USHORT:
2728 data = malloc(sizeof(unsigned short)*elements);
2729 for (i=0;i<elements;i++) {
2730 temp = PyList_GetItem(v, i);
2731 if (PyLong_Check(temp))
2732 ((unsigned short*)data)[i] = (unsigned short)PyLong_AsLong(temp);
2733 else
2734 ((unsigned short*)data)[i] = (unsigned short)PyInt_AsLong(temp);
2735 }
2736 break;
2737 case SDDS_LONG:
2738 data = malloc(sizeof(int32_t)*elements);
2739 for (i=0;i<elements;i++) {
2740 temp = PyList_GetItem(v, i);
2741 if (PyLong_Check(temp))
2742 ((int32_t*)data)[i] = (int32_t)PyLong_AsLong(temp);
2743 else
2744 ((int32_t*)data)[i] = (int32_t)PyInt_AsLong(temp);
2745 }
2746 break;
2747 case SDDS_ULONG:
2748 data = malloc(sizeof(uint32_t)*elements);
2749 for (i=0;i<elements;i++) {
2750 temp = PyList_GetItem(v, i);
2751 if (PyLong_Check(temp))
2752 ((uint32_t*)data)[i] = (uint32_t)PyLong_AsUnsignedLong(temp);
2753 else
2754 ((uint32_t*)data)[i] = (uint32_t)PyInt_AsUnsignedLong(temp);
2755 }
2756 break;
2757 case SDDS_LONG64:
2758 data = malloc(sizeof(int64_t)*elements);
2759 for (i=0;i<elements;i++) {
2760 temp = PyList_GetItem(v, i);
2761 if (PyLong_Check(temp))
2762 ((int64_t*)data)[i] = (int64_t)PyLong_AsLongLong(temp);
2763 else
2764 ((int64_t*)data)[i] = (int64_t)PyInt_AsLongLong(temp);
2765 }
2766 break;
2767 case SDDS_ULONG64:
2768 data = malloc(sizeof(uint64_t)*elements);
2769 for (i=0;i<elements;i++) {
2770 temp = PyList_GetItem(v, i);
2771 if (PyLong_Check(temp))
2772 ((uint64_t*)data)[i] = (uint64_t)PyLong_AsUnsignedLongLong(temp);
2773 else
2774 ((uint64_t*)data)[i] = (uint64_t)PyInt_AsUnsignedLongLong(temp);
2775 }
2776 break;
2777 case SDDS_FLOAT:
2778 data = malloc(sizeof(float)*elements);
2779 for (i=0;i<elements;i++)
2780 ((float*)data)[i] = (float)PyFloat_AsDouble(PyList_GetItem(v, i));
2781 break;
2782 case SDDS_DOUBLE:
2783 data = malloc(sizeof(double)*elements);
2784 for (i=0;i<elements;i++)
2785 ((double*)data)[i] = (double)PyFloat_AsDouble(PyList_GetItem(v, i));
2786 break;
2787 case SDDS_CHARACTER:
2788 data = malloc(sizeof(char)*elements);
2789 for (i=0;i<elements;i++)
2790 ((char*)data)[i] = (char)(PyString_AsString(PyList_GetItem(v, i))[0]);
2791 break;
2792 case SDDS_STRING:
2793 data = malloc(sizeof(char*)*elements);
2794 for (i=0;i<elements;i++)
2795 SDDS_CopyString(((char**)data)+i, PyString_AsString(PyList_GetItem(v, i)));
2796 break;
2797 }
2798 if (PyString_Check(indexOrName)) {
2799 result = SDDS_SetArray(&dataset_f[fileIndex],(char*)PyString_AsString(indexOrName),SDDS_CONTIGUOUS_DATA,data,dimension);
2800 } else {
2801 result = SDDS_SetArray(&dataset_f[fileIndex],names[index],SDDS_CONTIGUOUS_DATA,data,dimension);
2802 for (i=0;i<number;i++)
2803 free(names[i]);
2804 free(names);
2805 }
2806 switch (type) {
2807 case SDDS_SHORT:
2808 free((short*)data);
2809 break;
2810 case SDDS_USHORT:
2811 free((unsigned short*)data);
2812 break;
2813 case SDDS_LONG:
2814 free((int32_t*)data);
2815 break;
2816 case SDDS_ULONG:
2817 free((uint32_t*)data);
2818 break;
2819 case SDDS_LONG64:
2820 free((int64_t*)data);
2821 break;
2822 case SDDS_ULONG64:
2823 free((uint64_t*)data);
2824 break;
2825 case SDDS_FLOAT:
2826 free((float*)data);
2827 break;
2828 case SDDS_DOUBLE:
2829 free((double*)data);
2830 break;
2831 case SDDS_CHARACTER:
2832 free((char*)data);
2833 break;
2834 case SDDS_STRING:
2835 for (i=0;i<elements;i++)
2836 free(((char**)data)[i]);
2837 free((char**)data);
2838 break;
2839 }
2840 if (dimension) free(dimension);
2841 return PyLong_FromLong(result);
2842}
int32_t SDDS_SetArray(SDDS_DATASET *SDDS_dataset, char *array_name, int32_t mode, void *data_pointer, int32_t *dimension)
Sets the values of an array variable in the SDDS dataset using specified dimensions.
int32_t SDDS_CopyString(char **target, const char *source)
Copies a source string to a target string with memory allocation.
Definition SDDS_utils.c:856

◆ sddsdata_SetAutoCheckMode()

static PyObject * sddsdata_SetAutoCheckMode ( PyObject * self,
PyObject * args )
static

Sets the auto-check mode for datasets.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • newMode: New auto-check mode (0 or 1).
Returns
PyObject*: Previous mode.

Definition at line 2337 of file sddsdatamodule.c.

2338{
2339 long newMode;
2340 if (!PyArg_ParseTuple(args, "l", &newMode)) {
2341 return 0;
2342 }
2343 return PyLong_FromLong(SDDS_SetAutoCheckMode(newMode));
2344}
uint32_t SDDS_SetAutoCheckMode(uint32_t newMode)
Sets the automatic check mode for SDDS dataset validation.
Definition SDDS_utils.c:533

◆ sddsdata_SetColumn()

static PyObject * sddsdata_SetColumn ( PyObject * self,
PyObject * args )
static

Sets a column value in a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex: Index of the dataset file.
  • indexOrName: Index or name of the column.
  • v: List of values to set for the column.
Returns
PyObject*:
  • 0 on error.
  • 1 on success.

Definition at line 2857 of file sddsdatamodule.c.

2858{
2859 long fileIndex;
2860 long rows;
2861 PyObject *indexOrName;
2862 PyObject *v;
2863 long type;
2864 long i;
2865 void *data = NULL;
2866 long index;
2867 long result=0;
2868 PyObject *temp;
2869 if (!PyArg_ParseTuple(args, "lOO", &fileIndex, &indexOrName, &v)) {
2870 return 0;
2871 }
2872 if (PyString_Check(indexOrName)) {
2873 index = SDDS_GetColumnIndex(&dataset_f[fileIndex], (char*)PyString_AsString(indexOrName));
2874 } else if (PyNumber_Check(indexOrName)) {
2875 if (PyInt_Check(indexOrName))
2876 index = PyInt_AsLong(indexOrName);
2877 else if (PyLong_Check(indexOrName))
2878 index = PyLong_AsLong(indexOrName);
2879 else
2880 return 0;
2881 } else
2882 return 0;
2883 if ((type = SDDS_GetColumnType(&dataset_f[fileIndex], index)) == 0)
2884 return 0;
2885 rows = (long)PyList_Size(v);
2886 switch (type) {
2887 case SDDS_SHORT:
2888 data = malloc(sizeof(short)*rows);
2889 for (i=0;i<rows;i++) {
2890 temp = PyList_GetItem(v, i);
2891 if (PyLong_Check(temp))
2892 ((short*)data)[i] = (short)PyLong_AsLong(temp);
2893 else
2894 ((short*)data)[i] = (short)PyInt_AsLong(temp);
2895 }
2896 break;
2897 case SDDS_USHORT:
2898 data = malloc(sizeof(unsigned short)*rows);
2899 for (i=0;i<rows;i++) {
2900 temp = PyList_GetItem(v, i);
2901 if (PyLong_Check(temp))
2902 ((unsigned short*)data)[i] = (unsigned short)PyLong_AsLong(temp);
2903 else
2904 ((unsigned short*)data)[i] = (unsigned short)PyInt_AsLong(temp);
2905 }
2906 break;
2907 case SDDS_LONG:
2908 data = malloc(sizeof(int32_t)*rows);
2909 for (i=0;i<rows;i++) {
2910 temp = PyList_GetItem(v, i);
2911 if (PyLong_Check(temp))
2912 ((int32_t*)data)[i] = (int32_t)PyLong_AsLong(temp);
2913 else
2914 ((int32_t*)data)[i] = (int32_t)PyInt_AsLong(temp);
2915 }
2916 break;
2917 case SDDS_ULONG:
2918 data = malloc(sizeof(uint32_t)*rows);
2919 for (i=0;i<rows;i++) {
2920 temp = PyList_GetItem(v, i);
2921 if (PyLong_Check(temp))
2922 ((uint32_t*)data)[i] = (uint32_t)PyLong_AsUnsignedLong(temp);
2923 else
2924 ((uint32_t*)data)[i] = (uint32_t)PyInt_AsUnsignedLong(temp);
2925 }
2926 break;
2927 case SDDS_LONG64:
2928 data = malloc(sizeof(int64_t)*rows);
2929 for (i=0;i<rows;i++) {
2930 temp = PyList_GetItem(v, i);
2931 if (PyLong_Check(temp))
2932 ((int64_t*)data)[i] = (int64_t)PyLong_AsLongLong(temp);
2933 else
2934 ((int64_t*)data)[i] = (int64_t)PyInt_AsLongLong(temp);
2935 }
2936 break;
2937 case SDDS_ULONG64:
2938 data = malloc(sizeof(uint64_t)*rows);
2939 for (i=0;i<rows;i++) {
2940 temp = PyList_GetItem(v, i);
2941 if (PyLong_Check(temp))
2942 ((uint64_t*)data)[i] = (uint64_t)PyLong_AsUnsignedLongLong(temp);
2943 else
2944 ((uint64_t*)data)[i] = (uint64_t)PyInt_AsUnsignedLongLong(temp);
2945 }
2946 break;
2947 case SDDS_FLOAT:
2948 data = malloc(sizeof(float)*rows);
2949 for (i=0;i<rows;i++)
2950 ((float*)data)[i] = (float)PyFloat_AsDouble(PyList_GetItem(v, i));
2951 break;
2952 case SDDS_DOUBLE:
2953 data = malloc(sizeof(double)*rows);
2954 for (i=0;i<rows;i++)
2955 ((double*)data)[i] = (double)PyFloat_AsDouble(PyList_GetItem(v, i));
2956 break;
2957 case SDDS_CHARACTER:
2958 data = malloc(sizeof(char)*rows);
2959 for (i=0;i<rows;i++)
2960 ((char*)data)[i] = (char)(PyString_AsString(PyList_GetItem(v, i))[0]);
2961 break;
2962 case SDDS_STRING:
2963 data = malloc(sizeof(char*)*rows);
2964 for (i=0;i<rows;i++)
2965 SDDS_CopyString(((char**)data)+i, PyString_AsString(PyList_GetItem(v, i)));
2966 break;
2967 }
2968 result = SDDS_SetColumn(&dataset_f[fileIndex],SDDS_SET_BY_INDEX,data,rows,index,NULL);
2969 switch (type) {
2970 case SDDS_SHORT:
2971 free((short*)data);
2972 break;
2973 case SDDS_USHORT:
2974 free((unsigned short*)data);
2975 break;
2976 case SDDS_LONG:
2977 free((int32_t*)data);
2978 break;
2979 case SDDS_ULONG:
2980 free((uint32_t*)data);
2981 break;
2982 case SDDS_LONG64:
2983 free((int64_t*)data);
2984 break;
2985 case SDDS_ULONG64:
2986 free((uint64_t*)data);
2987 break;
2988 case SDDS_FLOAT:
2989 free((float*)data);
2990 break;
2991 case SDDS_DOUBLE:
2992 free((double*)data);
2993 break;
2994 case SDDS_CHARACTER:
2995 free((char*)data);
2996 break;
2997 case SDDS_STRING:
2998 for (i=0;i<rows;i++)
2999 free(((char**)data)[i]);
3000 free((char**)data);
3001 break;
3002 }
3003 return PyLong_FromLong(result);
3004}
int32_t SDDS_SetColumn(SDDS_DATASET *SDDS_dataset, int32_t mode, void *data, int64_t rows,...)
Sets the values for one data column in the current data table of an SDDS dataset.

◆ sddsdata_SetColumnFlags()

static PyObject * sddsdata_SetColumnFlags ( PyObject * self,
PyObject * args )
static

Sets the column flags for the dataset.

Parameters
selfPointer to the Python self object.
argsTuple containing:
  • fileIndex (long): Index of the file dataset.
  • column_flag_value (long): Flag value (valid values: 0, 1).
Returns
PyObject*:
  • 0 on error.
  • 1 on success.

Definition at line 1180 of file sddsdatamodule.c.

1181{
1182 long fileIndex;
1183 long column_flag_value;
1184 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &column_flag_value)) {
1185 return 0;
1186 }
1187 return PyLong_FromLong(SDDS_SetColumnFlags(&dataset_f[fileIndex], column_flag_value));
1188}
int32_t SDDS_SetColumnFlags(SDDS_DATASET *SDDS_dataset, int32_t column_flag_value)
Sets the acceptance flags for all columns in the current data table of a data set.

◆ sddsdata_SetColumnMajorOrder()

static PyObject * sddsdata_SetColumnMajorOrder ( PyObject * self,
PyObject * args )
static

Sets the data order for the SDDS dataset to column-major.

Parameters
selfUnused pointer to the module object.
argsPython tuple containing:
  • fileIndex (long): Index of the dataset in the array.
Returns
PyObject*
  • Py_None (NULL return value in Python).

Definition at line 155 of file sddsdatamodule.c.

156{
157 long fileIndex;
158 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
159 return Py_None;
160 }
161 dataset_f[fileIndex].layout.data_mode.column_major = 1;
162 return Py_None;
163}

◆ sddsdata_SetDataMode()

static PyObject * sddsdata_SetDataMode ( PyObject * self,
PyObject * args )
static

Sets the data mode for a given dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex: Index of the dataset file.
  • newmode: New data mode to be set.
Returns
PyObject*:
  • 0 on error.
  • 1 on success.

Definition at line 2296 of file sddsdatamodule.c.

2297{
2298 long fileIndex;
2299 long newmode;
2300 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &newmode)) {
2301 return 0;
2302 }
2303 return PyLong_FromLong(SDDS_SetDataMode(&dataset_f[fileIndex], newmode));
2304}
int32_t SDDS_SetDataMode(SDDS_DATASET *SDDS_dataset, int32_t newmode)
Sets the data mode (ASCII or Binary) for the SDDS dataset.

◆ sddsdata_SetError()

static PyObject * sddsdata_SetError ( PyObject * self,
PyObject * args )
static

Sets an error description.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • error_text (char*): Description of the error.
Returns
Python None, or NULL on error.

Definition at line 1476 of file sddsdatamodule.c.

1477{
1478 char *error_text;
1479 if (!PyArg_ParseTuple(args, "s", &error_text)) {
1480 return NULL;
1481 }
1482 SDDS_SetError(error_text);
1483 Py_INCREF(Py_None);
1484 return Py_None;
1485}
void SDDS_SetError(char *error_text)
Records an error message in the SDDS error stack.
Definition SDDS_utils.c:379

◆ sddsdata_SetFixedRowCountMode()

static PyObject * sddsdata_SetFixedRowCountMode ( PyObject * self,
PyObject * args )
static

Sets the row count mode for an SDDS dataset to fixed row count mode.

Parameters
selfUnused pointer to the module object.
argsPython tuple containing:
  • fileIndex (long): Index of the dataset in the array.
Returns
PyObject*
  • Py_None (Python's None).

Definition at line 175 of file sddsdatamodule.c.

176{
177 long fileIndex;
178 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
179 return Py_None;
180 }
181 SDDS_SetRowCountMode(&dataset_f[fileIndex], SDDS_FIXEDROWCOUNT);
182 return Py_None;
183}
int32_t SDDS_SetRowCountMode(SDDS_DATASET *SDDS_dataset, uint32_t mode)
Sets the row count mode for the SDDS dataset.

◆ sddsdata_SetNameValidityFlags()

static PyObject * sddsdata_SetNameValidityFlags ( PyObject * self,
PyObject * args )
static

Sets name validity flags to allow any name.

Parameters
selfUnused.
argsUnused.
Returns
PyObject* A Python integer representing the previous value of nameValidityFlags.

Definition at line 498 of file sddsdatamodule.c.

499{
500 return PyLong_FromLong(SDDS_SetNameValidityFlags(SDDS_ALLOW_ANY_NAME));
501}
int32_t SDDS_SetNameValidityFlags(uint32_t flags)
Sets the validity flags for parameter and column names in the SDDS dataset.

◆ sddsdata_SetParameter()

static PyObject * sddsdata_SetParameter ( PyObject * self,
PyObject * args )
static

Sets a parameter value in a dataset by index or name.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex: Index of the dataset file.
  • indexOrName: Index or name of the parameter.
  • v: Value to set.
Returns
PyObject*:
  • 0 on error.
  • 1 on success.

Definition at line 2581 of file sddsdatamodule.c.

2582{
2583 long fileIndex;
2584 PyObject *indexOrName;
2585 PyObject *v;
2586 long index;
2587 long type;
2588 if (!PyArg_ParseTuple(args, "lOO", &fileIndex, &indexOrName, &v)) {
2589 return 0;
2590 }
2591 if (PyString_Check(indexOrName)) {
2592 index = SDDS_GetParameterIndex(&dataset_f[fileIndex], (char*)PyString_AsString(indexOrName));
2593 } else if (PyNumber_Check(indexOrName)) {
2594 if (PyInt_Check(indexOrName))
2595 index = PyInt_AsLong(indexOrName);
2596 else if (PyLong_Check(indexOrName))
2597 index = PyLong_AsLong(indexOrName);
2598 else
2599 return 0;
2600 } else
2601 return 0;
2602 if ((type = SDDS_GetParameterType(&dataset_f[fileIndex], index)) == 0)
2603 return 0;
2604 switch (type) {
2605 case SDDS_SHORT:
2606 case SDDS_USHORT:
2607 case SDDS_LONG:
2608 if (PyLong_Check(v)) {
2609 return PyLong_FromLong(SDDS_SetParameters(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,index,PyLong_AsLong(v),-1));
2610 } else {
2611 return PyLong_FromLong(SDDS_SetParameters(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,index,PyInt_AsLong(v),-1));
2612 }
2613 case SDDS_ULONG:
2614 if (PyLong_Check(v)) {
2615 return PyLong_FromLong(SDDS_SetParameters(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,index,PyLong_AsUnsignedLong(v),-1));
2616 } else {
2617 return PyLong_FromLong(SDDS_SetParameters(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,index,PyInt_AsUnsignedLong(v),-1));
2618 }
2619 case SDDS_LONG64:
2620 if (PyLong_Check(v)) {
2621 return PyLong_FromLong(SDDS_SetParameters(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,index,PyLong_AsLongLong(v),-1));
2622 } else {
2623 return PyLong_FromLong(SDDS_SetParameters(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,index,PyInt_AsLongLong(v),-1));
2624 }
2625 case SDDS_ULONG64:
2626 if (PyLong_Check(v)) {
2627 return PyLong_FromLong(SDDS_SetParameters(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,index,PyLong_AsUnsignedLongLong(v),-1));
2628 } else {
2629 return PyLong_FromLong(SDDS_SetParameters(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,index,PyInt_AsUnsignedLongLong(v),-1));
2630 }
2631 case SDDS_FLOAT:
2632 case SDDS_DOUBLE:
2633 return PyLong_FromLong(SDDS_SetParameters(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,index,PyFloat_AsDouble(v),-1));
2634 case SDDS_CHARACTER:
2635 return PyLong_FromLong(SDDS_SetParameters(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,index,(char)(PyString_AsString(v)[0]),-1));
2636 case SDDS_STRING:
2637 return PyLong_FromLong(SDDS_SetParameters(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,index,PyString_AsString(v),-1));
2638 }
2639 return PyLong_FromLong(0);
2640}
int32_t SDDS_SetParameters(SDDS_DATASET *SDDS_dataset, int32_t mode,...)

◆ sddsdata_SetRowFlags()

static PyObject * sddsdata_SetRowFlags ( PyObject * self,
PyObject * args )
static

Sets the row flags for the dataset.

Parameters
selfPointer to the Python self object.
argsTuple containing:
  • fileIndex (long): Index of the file dataset.
  • row_flag_value (long): Flag value (valid values: 0, 1).
Returns
PyObject*:
  • 0 on error.
  • 1 on success.

Definition at line 1201 of file sddsdatamodule.c.

1202{
1203 long fileIndex;
1204 long row_flag_value;
1205 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &row_flag_value)) {
1206 return 0;
1207 }
1208 return PyLong_FromLong(SDDS_SetRowFlags(&dataset_f[fileIndex], row_flag_value));
1209}
int32_t SDDS_SetRowFlags(SDDS_DATASET *SDDS_dataset, int32_t row_flag_value)
Sets the acceptance flags for all rows in the current data table of a data set.

◆ sddsdata_SetRowMajorOrder()

static PyObject * sddsdata_SetRowMajorOrder ( PyObject * self,
PyObject * args )
static

Sets the data order for the SDDS dataset to row-major.

Parameters
selfUnused pointer to the module object.
argsPython tuple containing:
  • fileIndex (long): Index of the dataset in the array.
Returns
PyObject*
  • Py_None (Python's None).

Definition at line 195 of file sddsdatamodule.c.

196{
197 long fileIndex;
198 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
199 return Py_None;
200 }
201 dataset_f[fileIndex].layout.data_mode.column_major = 0;
202 return Py_None;
203}

◆ sddsdata_SetRowValues()

static PyObject * sddsdata_SetRowValues ( PyObject * self,
PyObject * args )
static

Sets values for a specific row in a dataset.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndex: Index of the dataset file.
  • row: Row number to set values for.
  • v: List of column-value pairs (alternating column name and value).
Returns
PyObject*:
  • 0 on error.
  • 1 on success.

Definition at line 3019 of file sddsdatamodule.c.

3020{
3021 long fileIndex;
3022 long row, elements;
3023 PyObject *v;
3024 long type;
3025 long i;
3026 long index;
3027 PyObject *temp;
3028 if (!PyArg_ParseTuple(args, "llO", &fileIndex, &row, &v)) {
3029 return 0;
3030 }
3031 elements = (long)PyList_Size(v);
3032 for (i=0; i<elements; i=i+2) {
3033 index = SDDS_GetColumnIndex(&dataset_f[fileIndex], (char*)PyString_AsString(PyList_GetItem(v, i)));
3034 temp = PyList_GetItem(v, i+1);
3035 if ((type = SDDS_GetColumnType(&dataset_f[fileIndex], index)) == 0)
3036 return 0;
3037 switch (type) {
3038 case SDDS_SHORT:
3039 case SDDS_USHORT:
3040 case SDDS_LONG:
3041 if (PyLong_Check(temp)) {
3042 if (SDDS_SetRowValues(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,row,index,PyLong_AsLong(temp),-1) == 0)
3043 return 0;
3044 } else {
3045 if (SDDS_SetRowValues(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,row,index,PyInt_AsLong(temp),-1) == 0)
3046 return 0;
3047 }
3048 break;
3049 case SDDS_ULONG:
3050 if (PyLong_Check(temp)) {
3051 if (SDDS_SetRowValues(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,row,index,PyLong_AsUnsignedLong(temp),-1) == 0)
3052 return 0;
3053 } else {
3054 if (SDDS_SetRowValues(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,row,index,PyInt_AsUnsignedLong(temp),-1) == 0)
3055 return 0;
3056 }
3057 break;
3058 case SDDS_LONG64:
3059 if (PyLong_Check(temp)) {
3060 if (SDDS_SetRowValues(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,row,index,PyLong_AsLongLong(temp),-1) == 0)
3061 return 0;
3062 } else {
3063 if (SDDS_SetRowValues(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,row,index,PyInt_AsLongLong(temp),-1) == 0)
3064 return 0;
3065 }
3066 break;
3067 case SDDS_ULONG64:
3068 if (PyLong_Check(temp)) {
3069 if (SDDS_SetRowValues(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,row,index,PyLong_AsUnsignedLongLong(temp),-1) == 0)
3070 return 0;
3071 } else {
3072 if (SDDS_SetRowValues(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,row,index,PyInt_AsUnsignedLongLong(temp),-1) == 0)
3073 return 0;
3074 }
3075 break;
3076 case SDDS_FLOAT:
3077 case SDDS_DOUBLE:
3078 if (SDDS_SetRowValues(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,row,index,PyFloat_AsDouble(temp),-1) == 0)
3079 return 0;
3080 break;
3081 case SDDS_CHARACTER:
3082 if (SDDS_SetRowValues(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,row,index,(char)(PyString_AsString(temp)[0]),-1) == 0)
3083 return 0;
3084 break;
3085 case SDDS_STRING:
3086 if (SDDS_SetRowValues(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,row,index,PyString_AsString(temp),-1) == 0)
3087 return 0;
3088 break;
3089 }
3090 }
3091 return PyLong_FromLong(1);
3092}
int32_t SDDS_SetRowValues(SDDS_DATASET *SDDS_dataset, int32_t mode, int64_t row,...)

◆ sddsdata_SetTerminateMode()

static PyObject * sddsdata_SetTerminateMode ( PyObject * self,
PyObject * args )
static

Sets the termination mode for SDDS to avoid freeing strings in arrays and tables.

Sets the termination mode to TERMINATE_DONT_FREE_ARRAY_STRINGS and TERMINATE_DONT_FREE_TABLE_STRINGS.

Parameters
selfUnused pointer to the module object.
argsUnused.
Returns
PyObject*
  • Py_None (Python's None).

Definition at line 277 of file sddsdatamodule.c.

278{
279 SDDS_SetTerminateMode(TERMINATE_DONT_FREE_TABLE_STRINGS+TERMINATE_DONT_FREE_ARRAY_STRINGS);
280 Py_INCREF(Py_None);
281 return Py_None;
282}
void SDDS_SetTerminateMode(uint32_t mode)

◆ sddsdata_StartPage()

static PyObject * sddsdata_StartPage ( PyObject * self,
PyObject * args )
static

Starts a page in an SDDS dataset.

Parameters
selfUnused.
argsA tuple containing:
  • fileIndex (long): Index of the dataset.
  • expected_n_rows (long): Expected number of rows on the page.
Returns
PyObject* A Python integer (1 on success, 0 on error).

Definition at line 976 of file sddsdatamodule.c.

977{
978 long fileIndex;
979 long expected_n_rows;
980 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &expected_n_rows)) {
981 return 0;
982 }
983 return PyLong_FromLong(SDDS_StartPage(&dataset_f[fileIndex], expected_n_rows));
984}
int32_t SDDS_StartPage(SDDS_DATASET *SDDS_dataset, int64_t expected_n_rows)

◆ sddsdata_StringIsBlank()

static PyObject * sddsdata_StringIsBlank ( PyObject * self,
PyObject * args )
static

Checks if a string is blank.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • s (char*): String to check.
Returns
Python integer (1 if true, 0 otherwise).

Definition at line 2213 of file sddsdatamodule.c.

2214{
2215 char *s;
2216 if (!PyArg_ParseTuple(args, "s", &s)) {
2217 return 0;
2218 }
2219 return PyLong_FromLong(SDDS_StringIsBlank(s));
2220}
int32_t SDDS_StringIsBlank(char *s)
Checks if a string is blank (contains only whitespace characters).

◆ sddsdata_Terminate()

static PyObject * sddsdata_Terminate ( PyObject * self,
PyObject * args )
static

Terminates an SDDS dataset, releasing any associated resources.

Parameters
selfUnused pointer to the module object.
argsPython tuple containing:
  • fileIndex (long): Index of the dataset in the array.
Returns
PyObject*
  • 1 on success.
  • 0 on error.

Definition at line 256 of file sddsdatamodule.c.

257{
258 long fileIndex;
259 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
260 return 0;
261 }
262 return PyLong_FromLong(SDDS_Terminate(&dataset_f[fileIndex]));
263}
int32_t SDDS_Terminate(SDDS_DATASET *SDDS_dataset)

◆ sddsdata_TransferAllArrayDefinitions()

static PyObject * sddsdata_TransferAllArrayDefinitions ( PyObject * self,
PyObject * args )
static

Transfers all array definitions from one dataset to another.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndexTarget (long): Target dataset index.
  • fileIndexSource (long): Source dataset index.
  • mode (long): Transfer mode. Valid values: 0, 1, 2, 3.
Returns
Python integer (1 on success, 0 on error).

Definition at line 1709 of file sddsdatamodule.c.

1710{
1711 long fileIndexTarget;
1712 long fileIndexSource;
1713 long mode;
1714 if (!PyArg_ParseTuple(args, "lll", &fileIndexTarget, &fileIndexSource, &mode)) {
1715 return 0;
1716 }
1717 return PyLong_FromLong(SDDS_TransferAllArrayDefinitions(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource], mode));
1718}
int32_t SDDS_TransferAllArrayDefinitions(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source, uint32_t mode)
Transfers all array definitions from a source dataset to a target dataset.

◆ sddsdata_TransferAllColumnDefinitions()

static PyObject * sddsdata_TransferAllColumnDefinitions ( PyObject * self,
PyObject * args )
static

Transfers all column definitions from one dataset to another.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndexTarget (long): Target dataset index.
  • fileIndexSource (long): Source dataset index.
  • mode (long): Transfer mode. Valid values: 0, 1, 2, 3.
Returns
Python integer (1 on success, 0 on error).

Definition at line 1688 of file sddsdatamodule.c.

1689{
1690 long fileIndexTarget;
1691 long fileIndexSource;
1692 long mode;
1693 if (!PyArg_ParseTuple(args, "lll", &fileIndexTarget, &fileIndexSource, &mode)) {
1694 return 0;
1695 }
1696 return PyLong_FromLong(SDDS_TransferAllColumnDefinitions(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource], mode));
1697}
int32_t SDDS_TransferAllColumnDefinitions(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source, uint32_t mode)
Transfers all column definitions from a source dataset to a target dataset.

◆ sddsdata_TransferAllParameterDefinitions()

static PyObject * sddsdata_TransferAllParameterDefinitions ( PyObject * self,
PyObject * args )
static

Transfers all parameter definitions from one dataset to another.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndexTarget (long): Target dataset index.
  • fileIndexSource (long): Source dataset index.
  • mode (long): Transfer mode. Valid values: 0, 1, 2, 3.
Returns
Python integer (1 on success, 0 on error).

Definition at line 1730 of file sddsdatamodule.c.

1731{
1732 long fileIndexTarget;
1733 long fileIndexSource;
1734 long mode;
1735 if (!PyArg_ParseTuple(args, "lll", &fileIndexTarget, &fileIndexSource, &mode)) {
1736 return 0;
1737 }
1738 return PyLong_FromLong(SDDS_TransferAllParameterDefinitions(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource], mode));
1739}
int32_t SDDS_TransferAllParameterDefinitions(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source, uint32_t mode)
Transfers all parameter definitions from a source dataset to a target dataset.

◆ sddsdata_TransferArrayDefinition()

static PyObject * sddsdata_TransferArrayDefinition ( PyObject * self,
PyObject * args )
static

Transfers an array definition from one dataset to another.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndexTarget (long): Target dataset index.
  • fileIndexSource (long): Source dataset index.
  • name (char*): Name of the array to transfer.
  • newName (char*): New name for the array (optional).
Returns
Python integer (1 on success, 0 on error).

Definition at line 1597 of file sddsdatamodule.c.

1598{
1599 long fileIndexTarget;
1600 long fileIndexSource;
1601 char *name;
1602 char *newName;
1603 if (!PyArg_ParseTuple(args, "llss", &fileIndexTarget, &fileIndexSource, &name, &newName)) {
1604 return 0;
1605 }
1606 return PyLong_FromLong(SDDS_TransferArrayDefinition(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource], name, newName));
1607}
int32_t SDDS_TransferArrayDefinition(SDDS_DATASET *target, SDDS_DATASET *source, char *name, char *newName)
Transfers an array definition from a source dataset to a target dataset.

◆ sddsdata_TransferColumnDefinition()

static PyObject * sddsdata_TransferColumnDefinition ( PyObject * self,
PyObject * args )
static

Transfers a column definition from one dataset to another.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndexTarget (long): Target dataset index.
  • fileIndexSource (long): Source dataset index.
  • name (char*): Name of the column to transfer.
  • newName (char*): New name for the column (optional).
Returns
Python integer (1 on success, 0 on error).

Definition at line 1574 of file sddsdatamodule.c.

1575{
1576 long fileIndexTarget;
1577 long fileIndexSource;
1578 char *name;
1579 char *newName;
1580 if (!PyArg_ParseTuple(args, "llss", &fileIndexTarget, &fileIndexSource, &name, &newName)) {
1581 return 0;
1582 }
1583 return PyLong_FromLong(SDDS_TransferColumnDefinition(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource], name, newName));
1584}
int32_t SDDS_TransferColumnDefinition(SDDS_DATASET *target, SDDS_DATASET *source, char *name, char *newName)
Transfers a column definition from a source dataset to a target dataset.

◆ sddsdata_TransferParameterDefinition()

static PyObject * sddsdata_TransferParameterDefinition ( PyObject * self,
PyObject * args )
static

Transfers a parameter definition from one dataset to another.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • fileIndexTarget (long): Target dataset index.
  • fileIndexSource (long): Source dataset index.
  • name (char*): Name of the parameter to transfer.
  • newName (char*): New name for the parameter (optional).
Returns
Python integer (1 on success, 0 on error).

Definition at line 1620 of file sddsdatamodule.c.

1621{
1622 long fileIndexTarget;
1623 long fileIndexSource;
1624 char *name;
1625 char *newName;
1626 if (!PyArg_ParseTuple(args, "llss", &fileIndexTarget, &fileIndexSource, &name, &newName)) {
1627 return 0;
1628 }
1629 return PyLong_FromLong(SDDS_TransferParameterDefinition(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource], name, newName));
1630}
int32_t SDDS_TransferParameterDefinition(SDDS_DATASET *target, SDDS_DATASET *source, char *name, char *newName)
Transfers a parameter definition from a source dataset to a target dataset.

◆ sddsdata_UpdatePage()

static PyObject * sddsdata_UpdatePage ( PyObject * self,
PyObject * args )
static

Updates the page based on the specified mode.

Parameters
selfPointer to the Python self object.
argsTuple containing:
  • fileIndex (long): Index of the file dataset.
  • mode (long): Update mode.
Returns
PyObject*:
  • 0 on error.
  • 1 on success.

Definition at line 1055 of file sddsdatamodule.c.

1056{
1057 long fileIndex, mode;
1058 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &mode)) {
1059 return 0;
1060 }
1061 return PyLong_FromLong(SDDS_UpdatePage(&dataset_f[fileIndex], mode));
1062}
int32_t SDDS_UpdatePage(SDDS_DATASET *SDDS_dataset, uint32_t mode)
Updates the current page of the SDDS dataset.

◆ sddsdata_Warning()

static PyObject * sddsdata_Warning ( PyObject * self,
PyObject * args )
static

Displays a warning message on stderr.

Parameters
selfPython object (unused).
argsPython tuple containing:
  • message (char*): Warning message to display.
Returns
Python None, or NULL on error.

Definition at line 1514 of file sddsdatamodule.c.

1515{
1516 char *message;
1517 if (!PyArg_ParseTuple(args, "s", &message)) {
1518 return NULL;
1519 }
1520 SDDS_Warning(message);
1521 Py_INCREF(Py_None);
1522 return Py_None;
1523}
void SDDS_Warning(char *message)
Prints a warning message to stderr.
Definition SDDS_utils.c:362

◆ sddsdata_WriteLayout()

static PyObject * sddsdata_WriteLayout ( PyObject * self,
PyObject * args )
static

Writes the layout of an SDDS dataset.

Parameters
selfUnused.
argsA tuple containing:
  • fileIndex (long): Index of the dataset.
Returns
PyObject* A Python integer (1 on success, 0 on error).

Definition at line 602 of file sddsdatamodule.c.

603{
604 long fileIndex;
605 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
606 return 0;
607 }
608 return PyLong_FromLong(SDDS_WriteLayout(&dataset_f[fileIndex]));
609}
int32_t SDDS_WriteLayout(SDDS_DATASET *SDDS_dataset)
Writes the SDDS layout header to the output file.

◆ sddsdata_WritePage()

static PyObject * sddsdata_WritePage ( PyObject * self,
PyObject * args )
static

Writes the current page of the dataset to the file.

Parameters
selfPointer to the Python self object.
argsTuple containing:
  • fileIndex (long): Index of the file dataset.
Returns
PyObject*:
  • 0 on error.
  • 1 on success.

Definition at line 1035 of file sddsdatamodule.c.

1036{
1037 long fileIndex;
1038 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
1039 return 0;
1040 }
1041 return PyLong_FromLong(SDDS_WritePage(&dataset_f[fileIndex]));
1042}
int32_t SDDS_WritePage(SDDS_DATASET *SDDS_dataset)
Writes the current data table to the output file.