52#include "nn_2d_interpolate.h"
58 CLO_INDEPENDENT_COLUMN,
78char *option[N_OPTIONS] = {
79 "pipe",
"independentColumn",
"dependentColumn",
"scale",
80 "outDimension",
"range",
"zoom",
"dimensionThin",
"clusterThin",
81 "preprocess",
"algorithm",
"weight",
"vertex",
"npoints",
"verbose",
"merge",
"file",
"majorOrder"};
83static const char *USAGE =
84 "Usage: sdds2dinterpolate <input> <output> [options]\n"
87 " -pipe=[input][,output]\n"
88 " -independentColumn=xcolumn=<string>,ycolumn=<string>[,errorColumn=<string>]\n"
89 " -dependentColumn=<list of z column names separated by comma>\n"
90 " -scale=circle|square\n"
91 " -outDimension=xdimension=<nx>,ydimension=<ny>\n"
92 " -range=xminimum=<value>,xmaximum=<value>,yminimum=<value>,ymaximum=<value>\n"
94 " -dimensionThin=xdimension=<nx>,ydimension=<ny>\n"
95 " -clusterThin=<value>\n"
97 " -algorithm=<string>,linear|sibson|nonsibson[,average=<value>][,sensitivity=<value>]\n"
100 " -npoints=<integer>\n"
103 " -file=<output points file>[,<xName>,<yName>]\n"
104 " -majorOrder=row|column\n"
106 "Detailed option descriptions are as follows:\n"
107 " -independentColumn: Specifies the independent columns for X, Y, and optional error.\n"
108 " -dependentColumn: Specifies the dependent Z columns to interpolate.\n"
109 " -scale: Choose between 'circle' or 'square' scaling methods.\n"
110 " -outDimension: Define the output grid dimensions in X and Y.\n"
111 " -range: Set the minimum and maximum values for X and Y in the output grid.\n"
112 " -zoom: Zoom in or out on the output grid.\n"
113 " -dimensionThin: Thin input data by averaging within specified grid dimensions.\n"
114 " -clusterThin: Thin input data by clustering points based on a maximum distance.\n"
115 " -preprocess: Output data without performing interpolation.\n"
116 " -algorithm: Select the interpolation algorithm and its parameters.\n"
117 " -weight: Set the minimal allowed weight for a vertex.\n"
118 " -vertex: Enable verbose output for a specific vertex.\n"
119 " -npoints: Define the number of output points.\n"
120 " -verbose: Enable verbose output during processing.\n"
121 " -merge: Merge data from all input pages before interpolation.\n"
122 " -file: Specify an SDDS file with output points.\n"
123 " -majorOrder: Set the output file's data order to 'row' or 'column'.\n"
124 "Program by Hairong Shang. " __DATE__
" " __TIME__
", SVN revision: " SVN_VERSION
"\n";
129 double xmin, xmax, ymin, ymax, dx, dy;
135#define LINEAR_NN 0x0001UL
136#define SIBSON_NN 0x0002UL
137#define NONSIBSON_NN 0x0004UL
139char *algorithm_option[ALGORITHMS] = {
"nn",
"csa"};
141#define SCALE_OPTIONS 2
142char *scale_option[SCALE_OPTIONS] = {
"circle",
"square"};
145void ReadInputFile(
char *inputFile,
char *xCol,
char *yCol,
char **zColMatch,
long zColMatches,
char ***zCol, int32_t *zCols,
146 char *stdCol,
long *pages,
long **rows,
double ***x,
double ***y,
double ****z,
double ***std,
SDDS_DATASET *SDDS_in);
148 char *xName,
char *yName,
char **zCol,
long zCols,
short columnMajorOrder);
149void WriteOutputPage(
SDDS_DATASET *SDDS_out,
char *xCol,
char *yCol,
char *zCol, specs *spec,
int nout, point *pout,
long writepage);
150void ReadPointFile(
char *pointsFile,
char *xCol,
char *yCol,
long *point_pages,
OUT_POINT **out_point);
151int interpolate_output_points(
int nin, point **pin,
double *std,
char *xCol,
char *yCol,
char *xName,
char *yName,
154static char *INFINITY_OPTION[1] = {
"infinity"};
156int main(
int argc,
char *argv[]) {
158 char *inputFile, *outputFile, *xCol =
"x", *yCol =
"y", **zCol = NULL, *stdCol =
"StdError", *pointsFile = NULL, **zColMatch = NULL;
159 char *pointsFileXName = NULL, *pointsFileYName = NULL;
160 long i, j, i_arg, k, scale, *rows, pages, merge = 0, point_pages = 0, writepage = 0, zColMatches = 0;
162 unsigned long dummyFlags = 0, pipeFlags = 0, majorOrderFlag;
164 double **x = NULL, **y = NULL, ***z = NULL, xmin = 0, xmax = 0, ymin = 0, ymax = 0, **std = NULL, *std_all = NULL;
165 specs *spec = specs_create();
171 short columnMajorOrder = -1;
175 inputFile = outputFile = NULL;
177 argc =
scanargs(&s_arg, argc, argv);
179 fprintf(stderr,
"%s", USAGE);
183 for (i_arg = 1; i_arg < argc; i_arg++) {
184 if (s_arg[i_arg].arg_type == OPTION) {
186 switch (
match_string(s_arg[i_arg].list[0], option, N_OPTIONS, 0)) {
187 case CLO_MAJOR_ORDER:
189 s_arg[i_arg].n_items -= 1;
190 if (s_arg[i_arg].n_items > 0 &&
191 (!
scanItemList(&majorOrderFlag, s_arg[i_arg].list + 1, &s_arg[i_arg].n_items, 0,
192 "row", -1, NULL, 0, SDDS_ROW_MAJOR_ORDER,
193 "column", -1, NULL, 0, SDDS_COLUMN_MAJOR_ORDER, NULL))) {
194 SDDS_Bomb(
"Invalid -majorOrder syntax/values");
196 if (majorOrderFlag & SDDS_COLUMN_MAJOR_ORDER)
197 columnMajorOrder = 1;
198 else if (majorOrderFlag & SDDS_ROW_MAJOR_ORDER)
199 columnMajorOrder = 0;
202 if (s_arg[i_arg].n_items != 2 && s_arg[i_arg].n_items != 4)
204 pointsFile = s_arg[i_arg].list[1];
205 if (s_arg[i_arg].n_items == 4) {
206 pointsFileXName = s_arg[i_arg].list[2];
207 pointsFileYName = s_arg[i_arg].list[3];
211 if (!
processPipeOption(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1, &pipeFlags))
214 case CLO_INDEPENDENT_COLUMN:
215 if (s_arg[i_arg].n_items < 3)
216 SDDS_Bomb(
"Invalid -independentColumn syntax.");
217 s_arg[i_arg].n_items--;
218 if (!
scanItemList(&dummyFlags, s_arg[i_arg].list + 1, &s_arg[i_arg].n_items, 0,
222 SDDS_Bomb(
"Invalid -independentColumn syntax");
223 s_arg[i_arg].n_items++;
225 case CLO_DEPENDENT_COLUMN:
226 if (s_arg[i_arg].n_items < 2)
227 SDDS_Bomb(
"Invalid -dependentColumn syntax.");
228 zColMatches = s_arg[i_arg].n_items - 1;
229 zColMatch =
tmalloc(
sizeof(*zColMatch) * zColMatches);
230 for (i = 0; i < zColMatches; i++)
231 zColMatch[i] = s_arg[i_arg].list[i + 1];
234 if (s_arg[i_arg].n_items != 2)
236 if ((scale =
match_string(s_arg[i_arg].list[1], scale_option, SCALE_OPTIONS, 0)) == -1) {
237 fprintf(stderr,
"Invalid scale option - %s provided.\n", s_arg[i_arg].list[1]);
240 spec->square = !scale;
241 spec->invariant = scale;
243 case CLO_OUT_DIMENSION:
244 if (s_arg[i_arg].n_items != 3)
245 SDDS_Bomb(
"Invalid -outDimension syntax.");
246 s_arg[i_arg].n_items--;
247 if (!
scanItemList(&dummyFlags, s_arg[i_arg].list + 1, &s_arg[i_arg].n_items, 0,
248 "xdimension",
SDDS_LONG, &spec->nx, 1, 0,
249 "ydimension",
SDDS_LONG, &spec->ny, 1, 0, NULL))
250 SDDS_Bomb(
"Invalid -outDimension syntax");
251 s_arg[i_arg].n_items++;
252 if (spec->nx <= 0 || spec->nx > NMAX || spec->ny <= 0 || spec->ny > NMAX)
253 SDDS_Bomb(
"Invalid size for output grid.");
254 spec->generate_points = 1;
257 if (s_arg[i_arg].n_items < 2)
259 s_arg[i_arg].n_items--;
260 if (!
scanItemList(&dummyFlags, s_arg[i_arg].list + 1, &s_arg[i_arg].n_items, 0,
266 s_arg[i_arg].n_items++;
267 if (spec->xmin > spec->xmax || spec->ymin > spec->ymax ||
268 isnan(spec->xmin) || isnan(spec->xmax) || isnan(spec->ymin) || isnan(spec->ymax))
273 if (s_arg[i_arg].n_items != 2)
275 if (!
get_double(&spec->zoom, s_arg[i_arg].list[1]))
276 SDDS_Bomb(
"Invalid -zoom value provided.");
278 case CLO_DIMENSION_THIN:
279 if (s_arg[i_arg].n_items != 3)
280 SDDS_Bomb(
"Invalid -dimensionThin syntax.");
281 s_arg[i_arg].n_items--;
282 if (!
scanItemList(&dummyFlags, s_arg[i_arg].list + 1, &s_arg[i_arg].n_items, 0,
283 "xdimension",
SDDS_LONG, &spec->nxd, 1, 0,
284 "ydimension",
SDDS_LONG, &spec->nyd, 1, 0, NULL))
285 SDDS_Bomb(
"Invalid -dimensionThin syntax");
286 s_arg[i_arg].n_items++;
289 case CLO_CLUSTER_THIN:
290 if (s_arg[i_arg].n_items != 2)
291 SDDS_Bomb(
"Invalid -clusterThin syntax.");
292 if (!
get_double(&spec->rmax, s_arg[i_arg].list[1]))
293 SDDS_Bomb(
"Invalid -clusterThin value provided.");
300 if (s_arg[i_arg].n_items < 2)
302 if ((spec->method =
match_string(s_arg[i_arg].list[1], algorithm_option, ALGORITHMS, 0)) == -1) {
303 fprintf(stderr,
"Invalid algorithm - %s provided, has to be nn or csa.\n", s_arg[i_arg].list[1]);
307 s_arg[i_arg].n_items -= 2;
308 if (!
scanItemList(&dummyFlags, s_arg[i_arg].list + 2, &s_arg[i_arg].n_items, 0,
309 "linear", -1, NULL, 0, LINEAR_NN,
310 "sibson", -1, NULL, 0, SIBSON_NN,
311 "nonSibson", -1, NULL, 0, NONSIBSON_NN,
316 if (!dummyFlags || dummyFlags & LINEAR_NN) {
318 }
else if (dummyFlags & SIBSON_NN) {
320 }
else if (dummyFlags & NONSIBSON_NN) {
321 nn_rule = NON_SIBSONIAN;
323 s_arg[i_arg].n_items += 2;
326 if (s_arg[i_arg].n_items != 2)
328 if (
match_string(s_arg[i_arg].list[1], INFINITY_OPTION, 1, 0) == 0)
329 spec->wmin = -DBL_MAX;
331 if (!
get_double(&spec->wmin, s_arg[i_arg].list[1]))
332 SDDS_Bomb(
"Invalid weight value provided.");
336 if (s_arg[i_arg].n_items != 2)
338 if (!
get_int(&nn_test_vertice, s_arg[i_arg].list[1]))
339 SDDS_Bomb(
"Invalid vertex value provided.");
343 if (s_arg[i_arg].n_items != 2)
345 if (!
get_int(&spec->npoints, s_arg[i_arg].list[1]))
346 SDDS_Bomb(
"Invalid npoints value provided.");
355 fprintf(stderr,
"Unknown option - %s provided.\n", s_arg[i_arg].list[0]);
361 inputFile = s_arg[i_arg].list[0];
362 else if (!outputFile)
363 outputFile = s_arg[i_arg].list[0];
369 processFilenames(
"sdds2dinterpolate", &inputFile, &outputFile, pipeFlags, 0, NULL);
370 if (!spec->generate_points && !spec->nointerp && !pointsFile) {
371 fprintf(stderr,
"No output grid specified.\n");
376 spec->nxd = spec->nx;
378 spec->nyd = spec->ny;
379 if (spec->nxd <= 0 || spec->nyd <= 0) {
380 fprintf(stderr,
"Invalid grid size for thinning.\n");
384 if (spec->npoints == 1) {
388 spec->npoints = spec->nx * spec->ny;
390 ReadInputFile(inputFile, xCol, yCol, zColMatch, zColMatches, &zCol, &zCols, stdCol, &pages, &rows, &x, &y, &z, &std, &SDDS_in);
392 SetupOutputFile(&SDDS_out, &SDDS_in, outputFile, xCol, yCol, pointsFileXName, pointsFileYName,
393 zCol, zCols, columnMajorOrder);
397 ReadPointFile(pointsFile, pointsFileXName ? pointsFileXName : xCol, pointsFileYName ? pointsFileYName : yCol,
398 &point_pages, &out_point);
399 pin =
tmalloc(
sizeof(*pin) * zCols);
401 for (i = 0; i < pages; i++) {
403 xmin = xmax = x[0][0];
404 ymin = ymax = y[0][0];
406 for (k = 0; k < zCols; k++)
407 pin[k] =
SDDS_Realloc(pin[k],
sizeof(**pin) * (nin + rows[i]));
409 std_all =
SDDS_Realloc(std_all,
sizeof(*std_all) * (nin + rows[i]));
410 for (j = 0; j < rows[i]; j++) {
413 else if (x[i][j] > xmax)
417 else if (y[i][j] > ymax)
419 for (k = 0; k < zCols; k++) {
420 pin[k][nin + j].x = x[i][j];
421 pin[k][nin + j].y = y[i][j];
422 pin[k][nin + j].z = z[k][i][j];
425 std_all[nin + j] = std[i][j];
430 for (k = 0; k < zCols; k++) {
443 for (k = 0; k < zCols; k++) {
459 if (!interpolate_output_points(nin, pin, std_all, xCol, yCol, pointsFileXName, pointsFileYName,
460 zCol, zCols, spec, pages, out_point, &SDDS_out))
464 for (k = 0; k < zCols; k++) {
465 if (spec->method == NN) {
466 do_nn_2d_interpolate(spec, &nin, &pin[k], &nout, &pout);
467 }
else if (spec->method == CSA) {
468 do_csa_2d_interpolate(spec, nin, pin[k], &nout, &pout, std_all);
470 if (!spec->nointerp) {
472 WriteOutputPage(&SDDS_out, pointsFileXName ? pointsFileXName : xCol,
473 pointsFileYName ? pointsFileYName : yCol,
474 zCol[k], spec, nout, pout, 0);
477 for (i = 0; i < nout; i++) {
479 zCol[k], pout[i].z, NULL))
489 for (i = 0; i < pages; i++) {
490 xmin = xmax = x[i][0];
491 ymin = ymax = y[i][0];
493 for (j = 0; j < nin; j++) {
496 else if (x[i][j] > xmax)
500 else if (y[i][j] > ymax)
509 for (k = 0; k < zCols; k++) {
510 pin[k] = malloc(
sizeof(**pin) * nin);
511 for (j = 0; j < rows[i]; j++) {
512 pin[k][j].x = x[i][j];
513 pin[k][j].y = y[i][j];
514 pin[k][j].z = z[k][i][j];
526 if (!interpolate_output_points(nin, pin, std_all, xCol, yCol, pointsFileXName, pointsFileYName,
527 zCol, zCols, spec, point_pages, out_point, &SDDS_out))
531 for (k = 0; k < zCols; k++) {
532 if (spec->method == NN) {
533 do_nn_2d_interpolate(spec, &nin, &pin[k], &nout, &pout);
534 }
else if (spec->method == CSA) {
535 do_csa_2d_interpolate(spec, nin, pin[k], &nout, &pout, std_all);
537 if (!spec->nointerp) {
539 WriteOutputPage(&SDDS_out, pointsFileXName ? pointsFileXName : xCol,
540 pointsFileYName ? pointsFileYName : yCol,
541 zCol[k], spec, nout, pout, 0);
544 for (j = 0; j < nout; j++) {
546 zCol[k], pout[j].z, NULL))
562 for (k = 0; k < zCols; k++)
569 for (k = 0; k < zCols; k++)
574 if (point_pages && out_point) {
575 for (i = 0; i < point_pages; i++) {
576 free(out_point[i].pout);
584 for (i = 0; i < zCols; i++)
591void ReadInputFile(
char *inputFile,
char *xCol,
char *yCol,
char **zColMatch,
long zColMatches,
char ***zCol, int32_t *zCols,
592 char *stdCol,
long *pages,
long **rows,
double ***x,
double ***y,
double ****z,
double ***std,
SDDS_DATASET *SDDS_in) {
594 long i, pages0 = 0, std_exist = 0;
599 *zCol =
tmalloc(
sizeof(**zCol));
606 fprintf(stderr,
"No dependent columns found in input file.\n");
610 *z =
tmalloc(
sizeof(**z) * (*zCols));
613 fprintf(stderr,
"X column - %s does not exist!\n", xCol);
617 fprintf(stderr,
"Y column - %s does not exist!\n", yCol);
620 for (i = 0; i < *zCols; i++) {
622 fprintf(stderr,
"Z column - %s does not exist!\n", (*zCol)[i]);
633 if (rows1 > INT32_MAX) {
634 fprintf(stderr,
"Too many input rows for 2D interpolate library routines.\n");
637 *rows =
SDDS_Realloc(*rows,
sizeof(**rows) * (pages0 + 1));
638 (*rows)[pages0] = rows1;
639 if (!(*x =
SDDS_Realloc(*x,
sizeof(**x) * (pages0 + 1))) ||
641 fprintf(stderr,
"Memory allocation error for X and Y data.\n");
644 for (i = 0; i < *zCols; i++) {
645 if (!((*z)[i] =
SDDS_Realloc((*z)[i],
sizeof(***z) * (pages0 + 1)))) {
646 fprintf(stderr,
"Memory allocation error for Z data.\n");
651 if (!(*std =
SDDS_Realloc(*std,
sizeof(**std) * (pages0 + 1)))) {
652 fprintf(stderr,
"Memory allocation error for standard error.\n");
655 (*std)[pages0] = NULL;
658 (*x)[pages0] = (*y)[pages0] = NULL;
662 for (i = 0; i < *zCols; i++) {
663 (*z)[i][pages0] = NULL;
673 fprintf(stderr,
"No data found in the input file.\n");
681 char *xName,
char *yName,
char **zCol,
long zCols,
short columnMajorOrder) {
682 char tmpstr[256], *xUnits = NULL, *yUnits = NULL;
692 if (columnMajorOrder != -1)
693 SDDS_out->layout.data_mode.column_major = columnMajorOrder;
695 SDDS_out->layout.data_mode.column_major = SDDS_in->layout.data_mode.column_major;
696 for (i = 0; i < zCols; i++) {
703 sprintf(tmpstr,
"%sDimension", xName ? xName : xCol);
706 sprintf(tmpstr,
"%sDimension", yName ? yName : yCol);
709 sprintf(tmpstr,
"%sInterval", xName ? xName : xCol);
712 sprintf(tmpstr,
"%sInterval", yName ? yName : yCol);
715 sprintf(tmpstr,
"%sMinimum", xName ? xName : xCol);
718 sprintf(tmpstr,
"%sMinimum", yName ? yName : yCol);
721 sprintf(tmpstr,
"%sMaximum", xName ? xName : xCol);
724 sprintf(tmpstr,
"%sMaximum", yName ? yName : yCol);
735void WriteOutputPage(
SDDS_DATASET *SDDS_out,
char *xCol,
char *yCol,
char *zCol, specs *spec,
int nout, point *pout,
long writepage) {
742 "Variable1Name", xCol,
743 "Variable2Name", yCol, NULL))
745 sprintf(tmpstr,
"%sDimension", xCol);
746 if (!
SDDS_SetParameters(SDDS_out, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE, tmpstr, spec->nx, NULL))
748 sprintf(tmpstr,
"%sDimension", yCol);
749 if (!
SDDS_SetParameters(SDDS_out, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE, tmpstr, spec->ny, NULL))
751 sprintf(tmpstr,
"%sInterval", xCol);
752 if (!
SDDS_SetParameters(SDDS_out, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE, tmpstr, spec->dx, NULL))
754 sprintf(tmpstr,
"%sInterval", yCol);
755 if (!
SDDS_SetParameters(SDDS_out, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE, tmpstr, spec->dy, NULL))
757 sprintf(tmpstr,
"%sMinimum", xCol);
758 if (!
SDDS_SetParameters(SDDS_out, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE, tmpstr, spec->xmin, NULL))
760 sprintf(tmpstr,
"%sMinimum", yCol);
761 if (!
SDDS_SetParameters(SDDS_out, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE, tmpstr, spec->ymin, NULL))
763 sprintf(tmpstr,
"%sMaximum", xCol);
764 if (!
SDDS_SetParameters(SDDS_out, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE, tmpstr, spec->xmax, NULL))
766 sprintf(tmpstr,
"%sMaximum", yCol);
767 if (!
SDDS_SetParameters(SDDS_out, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE, tmpstr, spec->ymax, NULL))
769 for (i = 0; i < nout; i++) {
773 zCol, pout[i].z, NULL))
780void ReadPointFile(
char *inputFile,
char *xCol,
char *yCol,
long *pages,
OUT_POINT **out_point) {
784 double *x, *y, xmin, xmax, firstx, firsty, ymin, ymax;
790 fprintf(stderr,
"X column - %s does not exist!\n", xCol);
794 fprintf(stderr,
"Y column - %s does not exist!\n", yCol);
801 if (rows1 > INT32_MAX) {
802 fprintf(stderr,
"Too many input rows for 2D interpolate library routines.\n");
805 *out_point =
SDDS_Realloc(*out_point,
sizeof(**out_point) * (pages0 + 1));
807 (*out_point)[pages0].pout = malloc(
sizeof(point) * rows1);
808 (*out_point)[pages0].nout = rows1;
812 xmin = xmax = firstx = x[0];
813 ymin = ymax = firsty = y[0];
816 for (i = 0; i < rows1; i++) {
817 (*out_point)[pages0].pout[i].x = x[i];
818 (*out_point)[pages0].pout[i].y = y[i];
821 else if (x[i] > xmax)
827 else if (y[i] > ymax)
834 (*out_point)[pages0].xmin = xmin;
835 (*out_point)[pages0].xmax = xmax;
836 (*out_point)[pages0].ymin = ymin;
837 (*out_point)[pages0].ymax = ymax;
838 (*out_point)[pages0].nx = nx;
839 (*out_point)[pages0].ny = ny;
841 (*out_point)[pages0].dx = (xmax - xmin) / (nx - 1);
843 (*out_point)[pages0].dx = 0;
845 (*out_point)[pages0].dy = (ymax - ymin) / (ny - 1);
847 (*out_point)[pages0].dy = 0;
853 fprintf(stderr,
"No data found in the points file.\n");
860int interpolate_output_points(
int nin, point **pin,
double *std,
char *xCol,
char *yCol,
char *xName,
char *yName,
862 int nout, page, k, writepage = 0, i;
865 for (page = 0; page < pages; page++) {
866 nout = out_point[page].nout;
867 pout = out_point[page].pout;
868 spec->nx = out_point[page].nx;
869 spec->ny = out_point[page].ny;
870 spec->xmin = out_point[page].xmin;
871 spec->xmax = out_point[page].xmax;
872 spec->dx = out_point[page].dx;
873 spec->ymin = out_point[page].ymin;
874 spec->ymax = out_point[page].ymax;
875 spec->dy = out_point[page].dy;
876 for (k = 0; k < zCols; k++) {
877 if (spec->method == NN) {
878 do_nn_2d_interpolate(spec, &nin, &pin[k], &nout, &pout);
880 do_csa_2d_interpolate(spec, nin, pin[k], &nout, &pout, std);
882 if (!spec->nointerp) {
884 WriteOutputPage(SDDS_out, xName ? xName : xCol, yName ? yName : yCol, zCol[k], spec, nout, pout, 0);
887 for (i = 0; i < nout; i++) {
889 zCol[k], pout[i].z, NULL))
SDDS (Self Describing Data Set) Data Types Definitions and Function Prototypes.
int32_t SDDS_SetRowValues(SDDS_DATASET *SDDS_dataset, int32_t mode, int64_t row,...)
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_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_DefineSimpleParameter(SDDS_DATASET *SDDS_dataset, const char *name, const char *unit, int32_t type)
Defines a simple data parameter within the SDDS dataset.
int32_t SDDS_WritePage(SDDS_DATASET *SDDS_dataset)
Writes the current data table to the output file.
int32_t SDDS_WriteLayout(SDDS_DATASET *SDDS_dataset)
Writes the SDDS layout header to the output file.
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.
char ** getMatchingSDDSNames(SDDS_DATASET *dataset, char **matchName, int32_t matches, int32_t *names, short type)
Retrieves an array of matching SDDS entity names based on specified criteria.
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.
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.
void SDDS_Bomb(char *message)
Terminates the program after printing an error message and recorded errors.
int32_t SDDS_CopyString(char **target, const char *source)
Copies a source string to a target string with memory allocation.
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_ANY_NUMERIC_TYPE
Special identifier used by SDDS_Check*() routines to accept any numeric type.
#define SDDS_DOUBLE
Identifier for the double data type.
void * tmalloc(uint64_t size_of_block)
Allocates a memory block of the specified size with zero initialization.
int get_double(double *dptr, char *s)
Parses a double value from the given string.
int get_int(int *iptr, char *s)
Parses an integer value from the given string.
char * delete_chars(char *s, char *t)
Removes all occurrences of characters found in string t from string s.
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.
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)
void free_scanargs(SCANNED_ARG **scanned, int argc)
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.