100char *option[N_OPTIONS] = {
101 "bins",
"lowerlimit",
"upperlimit",
"datacolumn",
102 "filter",
"sizeofbins",
"weightcolumn",
103 "normalize",
"statistics",
"sides",
"verbose",
"pipe",
"cdf",
"expand",
104 "majorOrder",
"regions",
"threads"
108 "Usage: sddshist [<inputfile>] [<outputfile>]\n"
109 " [-pipe=[input][,output]]\n"
110 " -dataColumn=<column-name>\n"
112 " -bins=<number> |\n"
113 " -sizeOfBins=<value> |\n"
114 " -regions=filename=<filename>,position=<columnName>,name=<columnName>\n"
116 " [-lowerLimit=<value>]\n"
117 " [-upperLimit=<value>]\n"
118 " [-expand=<factor>]\n"
119 " [-filter=<column-name>,<lower-limit>,<upper-limit>]\n"
120 " [-weightColumn=<column-name>]\n"
121 " [-sides[=<points>]]\n"
122 " [-normalize[={sum|area|peak}]]\n"
124 " [-threads=<number>]\n"
127 " [-majorOrder=row|column]\n"
129 " -pipe=[input][,output] Use pipe for input and/or output.\n"
130 " -dataColumn=<column-name> Specify the column to histogram.\n"
131 " -bins=<number> Set the number of bins for the histogram.\n"
132 " -sizeOfBins=<value> Set the size of each bin.\n"
133 " -regions=filename=<filename>,position=<columnName>,name=<columnName>\n"
134 " Define region-based histogramming.\n"
135 " -lowerLimit=<value> Set the lower limit of the histogram.\n"
136 " -upperLimit=<value> Set the upper limit of the histogram.\n"
137 " -expand=<factor> Expand the range of the histogram by the given factor.\n"
138 " -filter=<column-name>,<lower>,<upper> Filter data points based on column values.\n"
139 " -weightColumn=<column-name> Weight the histogram with the specified column.\n"
140 " -sides[=<points>] Add sides to the histogram down to zero level.\n"
141 " -normalize[={sum|area|peak}] Normalize the histogram.\n"
142 " -cdf[=only] Include the CDF in the output. Use 'only' to exclude the histogram.\n"
143 " -threads=<number> Specify the number of threads to use.\n"
144 " -statistics Include statistical information in the output.\n"
145 " -verbose Enable informational printouts during processing.\n"
146 " -majorOrder=row|column Set the major order of data.\n\n"
147 "Program by Michael Borland. (" __DATE__
" " __TIME__
", SVN revision: " SVN_VERSION
")\n";
149#define NORMALIZE_PEAK 0
150#define NORMALIZE_AREA 1
151#define NORMALIZE_SUM 2
152#define NORMALIZE_NO 3
153#define N_NORMALIZE_OPTIONS 4
154char *normalize_option[N_NORMALIZE_OPTIONS] = {
155 "peak",
"area",
"sum",
"no"
158static int64_t filter(
double *x,
double *y,
double *filterData, int64_t npts,
double lower_filter,
double upper_filter);
160 char *dataColumn,
char *weightColumn,
char *filterColumn,
double lowerFilter,
161 double upperFilter,
SDDS_DATASET *regionTable,
char *regionNameColumn,
long doStats,
162 int64_t bins,
double binSize,
long normalizeMode,
short columnMajorOrder);
165static long iIndep, iFreq, iBins, iBinSize, iLoFilter, iUpFilter, iMean, iRMS, iStDev, iPoints, iCdf;
166static short cdfOnly, freOnly;
168int64_t readRegionFile(
SDDS_DATASET *SDDSin,
char *filename,
char *positionColumn,
char *nameColumn,
double **regionPosition,
char ***regionName);
169void classifyByRegion(
double *data,
double *weight, int64_t points,
double *histogram,
double *regionPosition, int64_t bins);
170static long make_histogram_threaded(
double *hist,
long n_bins,
double lo,
double hi,
double *data,
171 int64_t n_pts,
long new_start,
int threads);
172static long make_histogram_weighted_threaded(
double *hist,
long n_bins,
double lo,
double hi,
double *data,
173 int64_t n_pts,
long new_start,
double *weight,
int threads);
175int main(
int argc,
char **argv) {
177 long binsGiven, lowerLimitGiven, upperLimitGiven;
182 double *hist, *hist1;
186 double lowerLimit, upperLimit;
187 double givenLowerLimit, givenUpperLimit;
188 double range, binSize;
191 double mean, rms, standDev, mad;
192 char *filterColumn, *dataColumn, *weightColumn;
193 double lowerFilter = 0, upperFilter = 0;
195 SCANNED_ARG *scanned;
196 char *inputfile, *outputfile;
200 long normalizeMode, doSides, verbose, readCode;
202 unsigned long pipeFlags, majorOrderFlag, regionFlags = 0;
204 double expansionFactor = 0;
205 short columnMajorOrder = -1;
206 char *regionFilename = NULL, *regionPositionColumn = NULL, *regionNameColumn = NULL;
207 double *regionPosition = NULL;
208 int64_t nRegions = 0;
209 char **regionName = NULL;
214 argc =
scanargs(&scanned, argc, argv);
216 fprintf(stderr,
"%s\n", USAGE);
220 binsGiven = lowerLimitGiven = upperLimitGiven = 0;
221 binSize = doSides = 0;
222 inputfile = outputfile = NULL;
223 dataColumn = filterColumn = weightColumn = NULL;
224 doStats = verbose = 0;
225 normalizeMode = NORMALIZE_NO;
231 for (i = 1; i < argc; i++) {
232 if (scanned[i].arg_type == OPTION) {
233 switch (
match_string(scanned[i].list[0], option, N_OPTIONS, 0)) {
234 case SET_MAJOR_ORDER:
236 scanned[i].n_items--;
237 if (scanned[i].n_items > 0 && (!
scanItemList(&majorOrderFlag, scanned[i].list + 1, &scanned[i].n_items, 0,
"row", -1, NULL, 0, SDDS_ROW_MAJOR_ORDER,
"column", -1, NULL, 0, SDDS_COLUMN_MAJOR_ORDER, NULL)))
238 SDDS_Bomb(
"invalid -majorOrder syntax/values");
239 if (majorOrderFlag & SDDS_COLUMN_MAJOR_ORDER)
240 columnMajorOrder = 1;
241 else if (majorOrderFlag & SDDS_ROW_MAJOR_ORDER)
242 columnMajorOrder = 0;
246 SDDS_Bomb(
"-bins specified more than once");
248 if (sscanf(scanned[i].list[1],
"%" SCNd64, &bins) != 1 || bins <= 0)
253 SDDS_Bomb(
"-lowerLimit specified more than once");
255 if (sscanf(scanned[i].list[1],
"%lf", &givenLowerLimit) != 1)
256 SDDS_Bomb(
"invalid value for lowerLimit");
260 SDDS_Bomb(
"-upperLimit specified more than once");
262 if (sscanf(scanned[i].list[1],
"%lf", &givenUpperLimit) != 1)
263 SDDS_Bomb(
"invalid value for upperLimit");
267 if (sscanf(scanned[i].list[1],
"%lf", &expansionFactor) != 1 || expansionFactor <= 0)
272 SDDS_Bomb(
"-dataColumn specified more than once");
273 if (scanned[i].n_items != 2)
274 SDDS_Bomb(
"invalid -dataColumn syntax---supply name");
275 dataColumn = scanned[i].list[1];
279 SDDS_Bomb(
"multiple filter specifications not allowed");
280 if (scanned[i].n_items != 4 || sscanf(scanned[i].list[2],
"%lf", &lowerFilter) != 1 ||
281 sscanf(scanned[i].list[3],
"%lf", &upperFilter) != 1 || lowerFilter > upperFilter)
282 SDDS_Bomb(
"invalid -filter syntax/values");
283 filterColumn = scanned[i].list[1];
285 case SET_WEIGHTCOLUMN:
287 SDDS_Bomb(
"multiple weighting columns not allowed");
288 if (scanned[i].n_items != 2)
289 SDDS_Bomb(
"-weightColumn requires a column name");
290 weightColumn = scanned[i].list[1];
293 if (scanned[i].n_items == 1)
294 normalizeMode = NORMALIZE_SUM;
295 else if (scanned[i].n_items != 2 || (normalizeMode =
match_string(scanned[i].list[1], normalize_option, N_NORMALIZE_OPTIONS, 0)) < 0)
302 if (scanned[i].n_items == 1)
304 else if (scanned[i].n_items > 2 || (sscanf(scanned[i].list[1],
"%ld", &doSides) != 1 || doSides <= 0))
311 if (sscanf(scanned[i].list[1],
"%le", &binSize) != 1 || binSize <= 0)
319 if (scanned[i].n_items == 1)
322 if (scanned[i].n_items != 2)
324 cdf = scanned[i].list[1];
325 if (strcmp(cdf,
"only") != 0)
326 SDDS_Bomb(
"invalid -cdf value, it should be -cdf or -cdf=only");
331 case SET_REGION_FILE:
332 if (scanned[i].n_items != 4)
335 scanned[i].n_items -= 1;
336 if (!
scanItemList(®ionFlags, scanned[i].list + 1, &scanned[i].n_items, 0,
338 "position",
SDDS_STRING, ®ionPositionColumn, 1, 2,
339 "name",
SDDS_STRING, ®ionNameColumn, 1, 4, NULL) ||
340 regionFlags != (1 + 2 + 4) || !regionFilename || !regionPositionColumn || !regionNameColumn)
344 if (scanned[i].n_items != 2 ||
345 !sscanf(scanned[i].list[1],
"%d", &threads) || threads < 1)
349 fprintf(stderr,
"Error: option %s not recognized\n", scanned[i].list[0]);
356 inputfile = scanned[i].list[0];
357 else if (!outputfile)
358 outputfile = scanned[i].list[0];
366 if (binSize && binsGiven && regionFlags)
367 SDDS_Bomb(
"Provide only one of -bins, -sizeOfBins, or -regions");
371 SDDS_Bomb(
"-dataColumn must be specified");
374 if (!(nRegions = readRegionFile(&SDDSregion, regionFilename, regionPositionColumn, regionNameColumn, ®ionPosition, ®ionName)))
375 SDDS_Bomb(
"Problem with region file. Check existence and type of columns");
380 hist =
tmalloc(
sizeof(*hist) * (bins + 2 * doSides));
381 CDF = CDF1 =
tmalloc(
sizeof(*hist) * (bins + 2 * doSides));
382 indep =
tmalloc(
sizeof(*indep) * (bins + 2 * doSides));
390 if (!setupOutputFile(&outTable, outputfile, &inTable, inputfile, dataColumn, weightColumn, filterColumn, lowerFilter, upperFilter, &SDDSregion, regionNameColumn, doStats, bins, binSize, normalizeMode, columnMajorOrder))
393 data = weightData = filterData = NULL;
402 if (rows && filterColumn)
403 points = filter(data, weightData, filterData, rows, lowerFilter, upperFilter);
417 classifyByRegion(data, weightData, points, hist, regionPosition, bins);
420 if (!lowerLimitGiven) {
421 lowerLimit = (points > 0) ? data[0] : 0;
422 for (i = 0; i < points; i++)
423 if (lowerLimit > data[i])
424 lowerLimit = data[i];
426 lowerLimit = givenLowerLimit;
428 if (!upperLimitGiven) {
429 upperLimit = (points > 0) ? data[0] : 0;
430 for (i = 0; i < points; i++)
431 if (upperLimit < data[i])
432 upperLimit = data[i];
434 upperLimit = givenUpperLimit;
437 range = upperLimit - lowerLimit;
438 if (!lowerLimitGiven)
439 lowerLimit -= range * 1e-7;
440 if (!upperLimitGiven)
441 upperLimit += range * 1e-7;
442 if (upperLimit == lowerLimit) {
444 upperLimit += binSize / 2;
445 lowerLimit -= binSize / 2;
446 }
else if (fabs(upperLimit) < sqrt(DBL_MIN)) {
447 upperLimit = sqrt(DBL_MIN);
448 lowerLimit = -sqrt(DBL_MIN);
450 upperLimit += upperLimit * (1 + 2 * DBL_EPSILON);
451 lowerLimit -= upperLimit * (1 - 2 * DBL_EPSILON);
454 if (expansionFactor > 0) {
455 double center = (upperLimit + lowerLimit) / 2;
456 range = expansionFactor * (upperLimit - lowerLimit);
457 lowerLimit = center - range / 2;
458 upperLimit = center + range / 2;
460 dx = (upperLimit - lowerLimit) / bins;
464 range = ((range / binSize) + 1) * binSize;
465 middle = (lowerLimit + upperLimit) / 2;
466 lowerLimit = middle - range / 2;
467 upperLimit = middle + range / 2;
469 bins = range / binSize + 0.5;
470 if (bins < 1 && !doSides)
472 indep =
trealloc(indep,
sizeof(*indep) * (bins + 2 * doSides));
473 hist =
trealloc(hist,
sizeof(*hist) * (bins + 2 * doSides));
474 CDF =
trealloc(CDF,
sizeof(*hist) * (bins + 2 * doSides));
477 for (i = -doSides; i < bins + doSides; i++)
478 indep[i + doSides] = (i + 0.5) * dx + lowerLimit;
479 hist1 = hist + doSides;
480 CDF1 = CDF + doSides;
482 hist[0] = hist[bins + doSides] = 0;
486 pointsBinned = make_histogram_threaded(hist1, bins, lowerLimit, upperLimit, data, points, 1, threads);
488 pointsBinned = make_histogram_weighted_threaded(hist1, bins, lowerLimit, upperLimit, data, points, 1, weightData, threads);
492 for (i = 0; i < bins + doSides; i++) {
495 CDF1[0] = hist1[0] / sum;
496 for (i = 1; i < bins + doSides; i++) {
497 CDF1[i] = CDF1[i - 1] + hist1[i] / sum;
501 fprintf(stderr,
"%ld points of %" PRId64
" from page %ld histogrammed in %" PRId64
" bins\n", pointsBinned, rows, readCode, bins);
503 if (normalizeMode != NORMALIZE_NO) {
505 switch (normalizeMode) {
511 for (i = 0; i < bins; i++)
513 if (normalizeMode == NORMALIZE_AREA)
517 SDDS_Bomb(
"invalid normalize mode--consult programmer.");
521 for (i = 0; i < bins; i++)
530 !
SDDS_SetParameters(&outTable, SDDS_SET_BY_INDEX | SDDS_PASS_BY_VALUE, iBins, bins, iBinSize, dx, iPoints, pointsBinned, -1))
533 if (!
SDDS_SetColumn(&outTable, SDDS_SET_BY_INDEX, regionPosition, bins, iIndep) ||
534 !
SDDS_SetColumn(&outTable, SDDS_SET_BY_NAME, regionName, bins, regionNameColumn))
536 if (!freOnly && !
SDDS_SetColumn(&outTable, SDDS_SET_BY_INDEX, CDF, bins, iCdf))
538 if (!cdfOnly && !
SDDS_SetColumn(&outTable, SDDS_SET_BY_INDEX, hist, bins, iFreq))
544 (points && (!
SDDS_SetColumn(&outTable, SDDS_SET_BY_INDEX, indep, bins + 2 * doSides, iIndep))) ||
545 !
SDDS_SetParameters(&outTable, SDDS_SET_BY_INDEX | SDDS_PASS_BY_VALUE, iBins, bins, iBinSize, dx, iPoints, pointsBinned, -1))
548 if (points && !
SDDS_SetColumn(&outTable, SDDS_SET_BY_INDEX, CDF, bins + 2 * doSides, iCdf))
552 if (points && !
SDDS_SetColumn(&outTable, SDDS_SET_BY_INDEX, hist, bins + 2 * doSides, iFreq))
557 if (filterColumn && points &&
558 !
SDDS_SetParameters(&outTable, SDDS_SET_BY_INDEX | SDDS_PASS_BY_VALUE, iLoFilter, lowerFilter, iUpFilter, upperFilter, -1))
560 if (doStats && points &&
561 !
SDDS_SetParameters(&outTable, SDDS_SET_BY_INDEX | SDDS_PASS_BY_VALUE, iMean, mean, iRMS, rms, iStDev, standDev, -1))
572 data = weightData = filterData = NULL;
590static int64_t filter(
double *x,
double *y,
double *filterData, int64_t npts,
double lower_filter,
double upper_filter) {
592 static char *keep = NULL;
593 static int64_t maxPoints = 0;
595 if (maxPoints < npts)
596 keep =
trealloc(keep,
sizeof(*keep) * (maxPoints = npts));
598 for (i = 0; i < npts; i++) {
599 if (filterData[i] < lower_filter || filterData[i] > upper_filter)
605 for (i = j = 0; i < npts; i++)
612 filterData[j] = filterData[i];
621 char *dataColumn,
char *weightColumn,
char *filterColumn,
double lowerFilter,
622 double upperFilter,
SDDS_DATASET *regionTable,
char *regionNameColumn,
long doStats,
623 int64_t bins,
double binSize,
long normalizeMode,
short columnMajorOrder) {
624 char *symbol, *units, *dataUnits, *outputFormat;
630 if (columnMajorOrder != -1)
631 outTable->layout.data_mode.column_major = columnMajorOrder;
633 outTable->layout.data_mode.column_major = inTable->layout.data_mode.column_major;
649 switch (normalizeMode) {
651 symbol =
"RelativeFrequency";
655 symbol =
"NormalizedFrequency";
657 units =
tmalloc(
sizeof(*units) * (strlen(dataUnits) + 5));
658 if (strchr(dataUnits,
' '))
659 sprintf(units,
"1/(%s)", dataUnits);
661 sprintf(units,
"1/%s", dataUnits);
666 symbol =
"FractionalFrequency";
671 char *weightUnits = NULL;
674 symbol =
"WeightedNumberOfOccurrences";
677 symbol =
"NumberOfOccurrences";
689 sprintf(s,
"%sCdf", dataColumn);
717 buffer =
tmalloc(
sizeof(*buffer) * (strlen(dataColumn) + 20));
718 sprintf(buffer,
"%sMean", dataColumn);
721 sprintf(buffer,
"%sRms", dataColumn);
724 sprintf(buffer,
"%sStDev", dataColumn);
736int64_t readRegionFile(
SDDS_DATASET *SDDSin,
char *filename,
char *positionColumn,
char *nameColumn,
double **regionPosition,
char ***regionName) {
739 SDDS_ReadPage(SDDSin) != 1 || (rows = SDDS_RowCount(SDDSin)) < 1 ||
743 for (i = 1; i < rows; i++)
744 if ((*regionPosition)[i] <= (*regionPosition)[i - 1]) {
745 fprintf(stderr,
"sddshist: Error in region position data: row %" PRId64
" is %21.15e while row %" PRId64
" is %21.15e\n",
746 i - 1, (*regionPosition)[i - 1], i, (*regionPosition)[i]);
749 *regionPosition =
SDDS_Realloc(*regionPosition,
sizeof(**regionPosition) * (rows + 1));
750 (*regionPosition)[rows] = DBL_MAX;
751 *regionName =
SDDS_Realloc(*regionName,
sizeof(**regionName) * (rows + 1));
752 cp_str(&(*regionName)[rows],
"Beyond");
756void classifyByRegion(
double *data,
double *weight, int64_t points,
double *histogram,
double *regionPosition, int64_t bins) {
759 for (iBin = 0; iBin < bins; iBin++)
762 for (iData = 0; iData < points; iData++) {
764 for (iBin = 0; iBin < bins - 1; iBin++) {
765 if (data[iData] < regionPosition[iBin])
769 histogram[iBin] += weight[iData];
771 histogram[iBin] += 1;
776static long make_histogram_threaded(
double *hist,
long n_bins,
double lo,
double hi,
double *data,
777 int64_t n_pts,
long new_start,
int threads) {
778 double bin_size, *partial;
779 long *counts, count = 0;
780 int activeThreads, thread;
783 if (threads <= 1 || n_pts <= 0 || n_bins <= 0)
784 return make_histogram(hist, n_bins, lo, hi, data, n_pts, new_start);
786 activeThreads = threads;
787 if (activeThreads > n_pts)
788 activeThreads = (int)n_pts;
789 if (activeThreads <= 1)
790 return make_histogram(hist, n_bins, lo, hi, data, n_pts, new_start);
793 for (i = 0; i < n_bins; i++)
795 bin_size = (hi - lo) / n_bins;
796 partial = calloc((
size_t)activeThreads * n_bins,
sizeof(*partial));
797 counts = calloc(activeThreads,
sizeof(*counts));
798 if (!partial || !counts)
801#pragma omp parallel for if (activeThreads > 1) num_threads(activeThreads)
802 for (thread = 0; thread < activeThreads; thread++) {
803 int64_t start = thread * (n_pts / activeThreads);
804 int64_t end = (thread == activeThreads - 1) ? n_pts : (thread + 1) * (n_pts / activeThreads);
805 double *local = partial + (size_t)thread * n_bins;
807 for (int64_t point = start; point < end; point++) {
808 double dbin = (data[point] - lo) / bin_size;
812 if (bin < 0 || bin >= n_bins)
817 counts[thread] = localCount;
820 for (thread = 0; thread < activeThreads; thread++) {
821 double *local = partial + (size_t)thread * n_bins;
822 count += counts[thread];
823 for (i = 0; i < n_bins; i++)
831static long make_histogram_weighted_threaded(
double *hist,
long n_bins,
double lo,
double hi,
double *data,
832 int64_t n_pts,
long new_start,
double *weight,
int threads) {
833 double bin_size, *partial;
834 long *counts, count = 0;
835 int activeThreads, thread;
838 if (threads <= 1 || n_pts <= 0 || n_bins <= 0)
841 activeThreads = threads;
842 if (activeThreads > n_pts)
843 activeThreads = (int)n_pts;
844 if (activeThreads <= 1)
848 for (i = 0; i < n_bins; i++)
850 bin_size = (hi - lo) / n_bins;
851 partial = calloc((
size_t)activeThreads * n_bins,
sizeof(*partial));
852 counts = calloc(activeThreads,
sizeof(*counts));
853 if (!partial || !counts)
856#pragma omp parallel for if (activeThreads > 1) num_threads(activeThreads)
857 for (thread = 0; thread < activeThreads; thread++) {
858 int64_t start = thread * (n_pts / activeThreads);
859 int64_t end = (thread == activeThreads - 1) ? n_pts : (thread + 1) * (n_pts / activeThreads);
860 double *local = partial + (size_t)thread * n_bins;
862 for (int64_t point = start; point < end; point++) {
863 double dbin = (data[point] - lo) / bin_size;
867 if (bin < 0 || bin >= n_bins)
869 local[bin] += weight[point];
872 counts[thread] = localCount;
875 for (thread = 0; thread < activeThreads; thread++) {
876 double *local = partial + (size_t)thread * n_bins;
877 count += counts[thread];
878 for (i = 0; i < n_bins; i++)
SDDS (Self Describing Data Set) Data Types Definitions and Function Prototypes.
int32_t SDDS_CopyParameters(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source)
int32_t SDDS_StartPage(SDDS_DATASET *SDDS_dataset, int64_t expected_n_rows)
int32_t SDDS_SetParameters(SDDS_DATASET *SDDS_dataset, int32_t mode,...)
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.
int32_t SDDS_ChangeColumnInformation(SDDS_DATASET *SDDS_dataset, char *field_name, void *memory, int32_t mode,...)
Modifies a specific field in a column definition within the SDDS dataset.
int32_t SDDS_GetColumnInformation(SDDS_DATASET *SDDS_dataset, char *field_name, void *memory, int32_t mode,...)
Retrieves information about a specified column in the SDDS dataset.
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.
int32_t SDDS_WritePage(SDDS_DATASET *SDDS_dataset)
Writes the current data table to the output file.
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.
int32_t SDDS_WriteLayout(SDDS_DATASET *SDDS_dataset)
Writes the SDDS layout header to the output file.
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_TransferColumnDefinition(SDDS_DATASET *target, SDDS_DATASET *source, char *name, char *newName)
Transfers a column definition from a source dataset to a target dataset.
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.
int32_t SDDS_GetColumnIndex(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the index of a named column in the SDDS dataset.
void SDDS_PrintErrors(FILE *fp, int32_t mode)
Prints recorded error messages to a specified file stream.
void SDDS_RegisterProgramName(const char *name)
Registers the executable program name for use in error messages.
int32_t SDDS_StringIsBlank(char *s)
Checks if a string is blank (contains only whitespace characters).
void SDDS_Bomb(char *message)
Terminates the program after printing an error message and recorded errors.
void * SDDS_Realloc(void *old_ptr, size_t new_size)
Reallocates memory to a new size.
#define SDDS_STRING
Identifier for the string data type.
#define SDDS_LONG
Identifier for the signed 32-bit integer data type.
#define SDDS_DOUBLE
Identifier for the double data type.
void * trealloc(void *old_ptr, uint64_t size_of_block)
Reallocates a memory block to a new size.
void * tmalloc(uint64_t size_of_block)
Allocates a memory block of the specified size with zero initialization.
char * cp_str(char **s, char *t)
Copies a string, allocating memory for storage.
double max_in_array(double *array, long n)
Finds the maximum value in an array of doubles.
long make_histogram_weighted(double *hist, long n_bins, double lo, double hi, double *data, long n_pts, long new_start, double *weight)
Compiles a weighted histogram from data points.
long make_histogram(double *hist, long n_bins, double lo, double hi, double *data, int64_t n_pts, long new_start)
Compiles a histogram from data points.
long match_string(char *string, char **option, long n_options, long mode)
Matches a given string against an array of option strings based on specified modes.
long computeWeightedMomentsThreaded(double *mean, double *rms, double *standDev, double *meanAbsoluteDev, double *x, double *w, long n, long numThreads)
Computes weighted statistical moments of an array using multiple threads.
long computeMomentsThreaded(double *mean, double *rms, double *standDev, double *meanAbsoluteDev, double *x, long n, long numThreads)
Computes the mean, RMS, standard deviation, and mean absolute deviation of an array using multiple th...
int scanargs(SCANNED_ARG **scanned, int argc, char **argv)
long processPipeOption(char **item, long items, unsigned long *flags)
void processFilenames(char *programName, char **input, char **output, unsigned long pipeFlags, long noWarnings, long *tmpOutputUsed)
long scanItemList(unsigned long *flags, char **item, long *items, unsigned long mode,...)
Scans a list of items and assigns values based on provided keywords and types.