next up previous contents
Next: SDDS Output of Internally-Generated Up: Two Templates for SDDS Previous: Two Templates for SDDS   Contents

Accessing Data Stored in an SDDS File

SDDS_TABLE SDDS_table;

/* open the file and read the SDDS header */ 
SDDS_InitializeInput(&SDDS_table, filename)

/* see if arrays that are needed are present */
if ((SDDS_CheckArray(&SDDS_table, array_I_need, NULL, 
                    SDDS_ANY_NUMERIC_TYPE, stderr)) != SDDS_CHECK_OKAY) {
    fprintf(stderr, "array %s is not in the data file", 
        array_I_need); 
    exit(1); 
} 
...

/* see if parameters that are needed are present */ 
if ((SDDS_CheckParameter(&SDDS_table, parameter_I_need, NULL, 
                         SDDS_ANY_NUMERIC_TYPE, stderr)) != SDDS_CHECK_OKAY) {
    fprintf(stderr, "parameter %s is not in the data file", 
        parameter_I_need); 
    exit(1); 
} 
...

/* see if columns that are needed are present */ 
if ((SDDS_CheckColumn(&SDDS_table, column_I_need, NULL, 
                    SDDS_ANY_NUMERIC_TYPE, stderr)) != SDDS_CHECK_OKAY) {
    fprintf(stderr, "column %s is not in the data file", 
        column_I_need); 
    exit(1); 
} 
...

/* read and process each data table in the data set */ 
while (SDDS_ReadTable(&SDDS_table)>0) { 
    /* set all rows and all columns to initially be "of interest" */ 
    SDDS_SetColumnFlags(&SDDS_table, 1); 
    SDDS_SetRowFlags(&SDDS_table, 1);

    /* access array data */ SDDS_GetArray(...)

    /* access parameter data */ SDDS_GetParameter(...)

    /* optional row and column selection operations */ 
    SDDS_SetColumnsOfInterest(...); 
    SDDS_SetRowsOfInterest(...); 
    SDDS_FilterRowsOfInterest(...);

    /* access tabular data values */ 
    SDDS_GetValue(...) 
    SDDS_GetRow(...) 
    SDDS_GetColumn(...) 
    ... 
}



Robert Soliday 2006-06-29