SDDSlib
|
DPL/MPL format input/output functions. More...
Go to the source code of this file.
Macros | |
#define | SDDS_SUPPORT 1 |
#define | OAGBUFSIZ 1024 |
Functions | |
int32_t | SDDS_ReadIntoMplTable (TABLE *mpl_data, char *file, int64_t sample_interval, int32_t mpl_flags, char *SDDS_tags) |
Reads SDDS data into an MPL-compatible table structure. | |
int32_t | SDDS_WriteMplTable (TABLE *mpl_data, char *file) |
Writes an MPL-compatible table to an SDDS file. | |
long | SDDS_AddMplDefinition (SDDS_TABLE *SDDS_table, char *label, char *suffix, char *default_name, char *filename) |
Adds an MPL-compatible column definition to an SDDS dataset. | |
void | SDDS_ExtractNameAndUnit (char **name, char **unit, char *label) |
Extracts the name and unit from a labeled string. | |
void | SDDS_FixMplName (char *name) |
Cleans and fixes an MPL-compatible name by removing specific sequences and extra spaces. | |
void | delete_trailing_blanks (char *s) |
long | get_table (TABLE *tab, char *file, int64_t sample_interval, long flags) |
Gets a table from a file in DPL format. | |
void | put_table (char *file, TABLE *tab, char *format) |
long | get_table_float (TABLE_FLOAT *tab, char *file, long sample_interval, long flags) |
void | put_table_float (char *file, TABLE_FLOAT *tab, char *format) |
float * | float_array_from_double (double *x, long n) |
double * | double_array_from_float (float *x, long n) |
char * | fgets_skip (char *s, long slen, FILE *fp, char skip_char, long skip_lines) |
DPL/MPL format input/output functions.
Contains functions: get_table(), put_table(), float_array_from_double(), get_table_float(), put_table_float(), double_array_from_float(), delete_trailing_blanks(), fgets_skip().
Definition in file table.c.
|
extern |
double * double_array_from_float | ( | float * | x, |
long | n ) |
Definition at line 582 of file table.c.
char * fgets_skip | ( | char * | s, |
long | slen, | ||
FILE * | fp, | ||
char | skip_char, | ||
long | skip_lines ) |
Definition at line 611 of file table.c.
float * float_array_from_double | ( | double * | x, |
long | n ) |
long get_table | ( | TABLE * | tab, |
char * | file, | ||
int64_t | sample_interval, | ||
long | flags ) |
Gets a table from a file in DPL format.
tab | Pointer to a TABLE structure to store the data. |
file | Name of the file to read. |
sample_interval | Sampling interval for reading data points. |
flags | Flags to control the reading behavior. |
Definition at line 45 of file table.c.
long get_table_float | ( | TABLE_FLOAT * | tab, |
char * | file, | ||
long | sample_interval, | ||
long | flags ) |
Definition at line 333 of file table.c.
void put_table | ( | char * | file, |
TABLE * | tab, | ||
char * | format ) |
Definition at line 293 of file table.c.
void put_table_float | ( | char * | file, |
TABLE_FLOAT * | tab, | ||
char * | format ) |
Definition at line 529 of file table.c.
long SDDS_AddMplDefinition | ( | SDDS_DATASET * | SDDS_dataset, |
char * | label, | ||
char * | suffix, | ||
char * | default_name, | ||
char * | filename ) |
Adds an MPL-compatible column definition to an SDDS dataset.
This function defines a new column in the provided SDDS_dataset
based on the given label, suffix, and default name. It handles the extraction of the symbol and unit from the label, ensures that the column name is unique within the dataset, and appends the suffix to create the final column name.
SDDS_dataset | Pointer to the SDDS_DATASET structure where the column will be added. |
label | The label string containing the name and optionally the unit in the format "Name (Unit)". |
suffix | An optional suffix to append to the column name. Can be NULL if no suffix is needed. |
default_name | The default name to use if the label is blank. |
filename | The name of the file being processed, used for error reporting. |
-1
if an error occurs.Definition at line 764 of file SDDS_mplsupport.c.
void SDDS_ExtractNameAndUnit | ( | char ** | name, |
char ** | unit, | ||
char * | label ) |
Extracts the name and unit from a labeled string.
This function parses a label string to separate the name and its associated unit. It looks for the pattern " (unit)" within the label. If found, it splits the label into the name
and unit
components. The function also trims any trailing spaces from the name
.
name | Double pointer to a string where the extracted name will be stored. Memory is allocated internally. |
unit | Double pointer to a string where the extracted unit will be stored. Memory is allocated internally. If no unit is found, *unit is set to NULL . |
label | The input label string containing the name and optionally the unit in the format "Name (Unit)". |
*name
and *unit
if they are not NULL
. Definition at line 730 of file SDDS_mplsupport.c.
void SDDS_FixMplName | ( | char * | name | ) |
Cleans and fixes an MPL-compatible name by removing specific sequences and extra spaces.
This function iterates through the provided name
string and removes any occurrence of a dollar sign ('$') followed by specific characters (‘'a’,
'b',
'n',
'g',
'r',
's',
'e',
'd',
'i',
'v',
'u'`). Additionally, it removes any extra spaces within the string, ensuring that only single spaces remain between words.
name | A mutable string representing the name to be fixed. The string is modified in place. |
name
string is mutable and has sufficient space to handle in-place modifications. Definition at line 684 of file SDDS_mplsupport.c.
int32_t SDDS_ReadIntoMplTable | ( | TABLE * | mpl_data, |
char * | file, | ||
int64_t | sample_interval, | ||
int32_t | mpl_flags, | ||
char * | SDDS_tags ) |
Reads SDDS data into an MPL-compatible table structure.
This function initializes an SDDS dataset from the specified file, processes the data according to the provided sample interval and flags, and populates the mpl_data
table with the sampled data. It handles column and parameter-based matching as specified by SDDS_tags
.
mpl_data | Pointer to the TABLE structure where the SDDS data will be stored. |
file | The filename of the SDDS data file to read. |
sample_interval | The interval at which data points are sampled from the source. |
mpl_flags | Flags controlling the behavior of the MPL data processing. |
SDDS_tags | Optional tags specifying columns or parameters of interest. |
Definition at line 294 of file SDDS_mplsupport.c.
int32_t SDDS_WriteMplTable | ( | TABLE * | mpl_data, |
char * | file ) |
Writes an MPL-compatible table to an SDDS file.
This function initializes an SDDS output file, defines necessary columns based on the provided mpl_data
, and writes the data to the file. It handles optional sigma columns, ensures that the output file does not overwrite existing files by renaming them if necessary, and respects environment variables for output configuration.
mpl_data | Pointer to the TABLE structure containing MPL data to be written. |
file | The filename of the SDDS file where the data will be written. |
1
on successful writing of the MPL table, or 0
if an error occurs.Definition at line 813 of file SDDS_mplsupport.c.