81#include "nn_2d_interpolate.h"
87 CLO_INDEPENDENT_COLUMN,
107char *option[N_OPTIONS] = {
108 "pipe",
"independentColumn",
"dependentColumn",
"scale",
109 "outDimension",
"range",
"zoom",
"dimensionThin",
"clusterThin",
110 "preprocess",
"algorithm",
"weight",
"vertex",
"npoints",
"verbose",
"merge",
"file",
"majorOrder"};
112static const char *USAGE =
113 "Usage: sdds2dinterpolate [<input>] [<output>]\n"
114 " [-pipe=[input][,output]]\n"
115 " [-independentColumn=xcolumn=<string>,ycolumn=<string>[,errorColumn=<string>]]\n"
116 " [-dependentColumn=<list of z column names separated by commas>]\n"
117 " [-scale=circle|square]\n"
118 " [-outDimension=xdimension=<nx>,ydimension=<ny>]\n"
119 " [-range=xminimum=<value>,xmaximum=<value>,yminimum=<value>,ymaximum=<value>]\n"
121 " [-dimensionThin=xdimension=<nx>,ydimension=<ny>]\n"
122 " [-clusterThin=<value>]\n"
124 " [-algorithm=linear|sibson|nonsibson[,average=<value>][,sensitivity=<value>]]\n"
125 " [-weight=<value>]\n"
127 " [-npoints=<integer>]\n"
130 " [-file=<output points file>[,<xName>,<yName>]]\n"
131 " [-majorOrder=row|column]\n"
132 "Detailed option descriptions are as follows:\n"
133 " -independentColumn: Specifies the independent columns for X, Y, and optional error.\n"
134 " -dependentColumn: Specifies the dependent Z columns to interpolate.\n"
135 " -scale: Choose between 'circle' or 'square' scaling methods.\n"
136 " -outDimension: Define the output grid dimensions in X and Y.\n"
137 " -range: Set the minimum and maximum values for X and Y in the output grid.\n"
138 " -zoom: Zoom in or out on the output grid.\n"
139 " -dimensionThin: Thin input data by averaging within specified grid dimensions.\n"
140 " -clusterThin: Thin input data by clustering points based on a maximum distance.\n"
141 " -preprocess: Output data without performing interpolation.\n"
142 " -algorithm: Select the interpolation algorithm and its parameters.\n"
143 " -weight: Set the minimal allowed weight for a vertex.\n"
144 " -vertex: Enable verbose output for a specific vertex.\n"
145 " -npoints: Define the number of output points.\n"
146 " -verbose: Enable verbose output during processing.\n"
147 " -merge: Merge data from all input pages before interpolation.\n"
148 " -file: Specify an SDDS file with output points.\n"
149 " -majorOrder: Set the output file's data order to 'row' or 'column'.\n"
150 "Program by Hairong Shang. " __DATE__
" " __TIME__
", SVN revision: " SVN_VERSION
"\n";
155 double xmin, xmax, ymin, ymax, dx, dy;
161#define LINEAR_NN 0x0001UL
162#define SIBSON_NN 0x0002UL
163#define NONSIBSON_NN 0x0004UL
165char *algorithm_option[ALGORITHMS] = {
"nn",
"csa"};
167#define SCALE_OPTIONS 2
168char *scale_option[SCALE_OPTIONS] = {
"circle",
"square"};
171void ReadInputFile(
char *inputFile,
char *xCol,
char *yCol,
char **zColMatch,
long zColMatches,
char ***zCol, int32_t *zCols,
172 char *stdCol,
long *pages,
long **rows,
double ***x,
double ***y,
double ****z,
double ***std,
SDDS_DATASET *SDDS_in);
174 char *xName,
char *yName,
char **zCol,
long zCols,
short columnMajorOrder);
175void WriteOutputPage(
SDDS_DATASET *SDDS_out,
char *xCol,
char *yCol,
char *zCol, specs *spec,
int nout, point *pout,
long writepage);
176void ReadPointFile(
char *pointsFile,
char *xCol,
char *yCol,
long *point_pages,
OUT_POINT **out_point);
177int interpolate_output_points(
int nin, point **pin,
double *std,
char *xCol,
char *yCol,
char *xName,
char *yName,
180static char *INFINITY_OPTION[1] = {
"infinity"};
182int main(
int argc,
char *argv[]) {
184 char *inputFile, *outputFile, *xCol =
"x", *yCol =
"y", **zCol = NULL, *stdCol =
"StdError", *pointsFile = NULL, **zColMatch = NULL;
185 char *pointsFileXName = NULL, *pointsFileYName = NULL;
186 long i, j, i_arg, k, scale, *rows, pages, merge = 0, point_pages = 0, writepage = 0, zColMatches = 0;
188 unsigned long dummyFlags = 0, pipeFlags = 0, majorOrderFlag;
190 double **x = NULL, **y = NULL, ***z = NULL, xmin = 0, xmax = 0, ymin = 0, ymax = 0, **std = NULL, *std_all = NULL;
191 specs *spec = specs_create();
197 short columnMajorOrder = -1;
201 inputFile = outputFile = NULL;
203 argc =
scanargs(&s_arg, argc, argv);
205 fprintf(stderr,
"%s", USAGE);
209 for (i_arg = 1; i_arg < argc; i_arg++) {
210 if (s_arg[i_arg].arg_type == OPTION) {
212 switch (
match_string(s_arg[i_arg].list[0], option, N_OPTIONS, 0)) {
213 case CLO_MAJOR_ORDER:
215 s_arg[i_arg].n_items -= 1;
216 if (s_arg[i_arg].n_items > 0 &&
217 (!
scanItemList(&majorOrderFlag, s_arg[i_arg].list + 1, &s_arg[i_arg].n_items, 0,
218 "row", -1, NULL, 0, SDDS_ROW_MAJOR_ORDER,
219 "column", -1, NULL, 0, SDDS_COLUMN_MAJOR_ORDER, NULL))) {
220 SDDS_Bomb(
"Invalid -majorOrder syntax/values");
222 if (majorOrderFlag & SDDS_COLUMN_MAJOR_ORDER)
223 columnMajorOrder = 1;
224 else if (majorOrderFlag & SDDS_ROW_MAJOR_ORDER)
225 columnMajorOrder = 0;
228 if (s_arg[i_arg].n_items != 2 && s_arg[i_arg].n_items != 4)
230 pointsFile = s_arg[i_arg].list[1];
231 if (s_arg[i_arg].n_items == 4) {
232 pointsFileXName = s_arg[i_arg].list[2];
233 pointsFileYName = s_arg[i_arg].list[3];
237 if (!
processPipeOption(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1, &pipeFlags))
240 case CLO_INDEPENDENT_COLUMN:
241 if (s_arg[i_arg].n_items < 3)
242 SDDS_Bomb(
"Invalid -independentColumn syntax.");
243 s_arg[i_arg].n_items--;
244 if (!
scanItemList(&dummyFlags, s_arg[i_arg].list + 1, &s_arg[i_arg].n_items, 0,
248 SDDS_Bomb(
"Invalid -independentColumn syntax");
249 s_arg[i_arg].n_items++;
251 case CLO_DEPENDENT_COLUMN:
252 if (s_arg[i_arg].n_items < 2)
253 SDDS_Bomb(
"Invalid -dependentColumn syntax.");
254 zColMatches = s_arg[i_arg].n_items - 1;
255 zColMatch =
tmalloc(
sizeof(*zColMatch) * zColMatches);
256 for (i = 0; i < zColMatches; i++)
257 zColMatch[i] = s_arg[i_arg].list[i + 1];
260 if (s_arg[i_arg].n_items != 2)
262 if ((scale =
match_string(s_arg[i_arg].list[1], scale_option, SCALE_OPTIONS, 0)) == -1) {
263 fprintf(stderr,
"Invalid scale option - %s provided.\n", s_arg[i_arg].list[1]);
266 spec->square = !scale;
267 spec->invariant = scale;
269 case CLO_OUT_DIMENSION:
270 if (s_arg[i_arg].n_items != 3)
271 SDDS_Bomb(
"Invalid -outDimension syntax.");
272 s_arg[i_arg].n_items--;
273 if (!
scanItemList(&dummyFlags, s_arg[i_arg].list + 1, &s_arg[i_arg].n_items, 0,
274 "xdimension",
SDDS_LONG, &spec->nx, 1, 0,
275 "ydimension",
SDDS_LONG, &spec->ny, 1, 0, NULL))
276 SDDS_Bomb(
"Invalid -outDimension syntax");
277 s_arg[i_arg].n_items++;
278 if (spec->nx <= 0 || spec->nx > NMAX || spec->ny <= 0 || spec->ny > NMAX)
279 SDDS_Bomb(
"Invalid size for output grid.");
280 spec->generate_points = 1;
283 if (s_arg[i_arg].n_items < 2)
285 s_arg[i_arg].n_items--;
286 if (!
scanItemList(&dummyFlags, s_arg[i_arg].list + 1, &s_arg[i_arg].n_items, 0,
292 s_arg[i_arg].n_items++;
293 if (spec->xmin > spec->xmax || spec->ymin > spec->ymax ||
294 isnan(spec->xmin) || isnan(spec->xmax) || isnan(spec->ymin) || isnan(spec->ymax))
299 if (s_arg[i_arg].n_items != 2)
301 if (!
get_double(&spec->zoom, s_arg[i_arg].list[1]))
302 SDDS_Bomb(
"Invalid -zoom value provided.");
304 case CLO_DIMENSION_THIN:
305 if (s_arg[i_arg].n_items != 3)
306 SDDS_Bomb(
"Invalid -dimensionThin syntax.");
307 s_arg[i_arg].n_items--;
308 if (!
scanItemList(&dummyFlags, s_arg[i_arg].list + 1, &s_arg[i_arg].n_items, 0,
309 "xdimension",
SDDS_LONG, &spec->nxd, 1, 0,
310 "ydimension",
SDDS_LONG, &spec->nyd, 1, 0, NULL))
311 SDDS_Bomb(
"Invalid -dimensionThin syntax");
312 s_arg[i_arg].n_items++;
315 case CLO_CLUSTER_THIN:
316 if (s_arg[i_arg].n_items != 2)
317 SDDS_Bomb(
"Invalid -clusterThin syntax.");
318 if (!
get_double(&spec->rmax, s_arg[i_arg].list[1]))
319 SDDS_Bomb(
"Invalid -clusterThin value provided.");
326 if (s_arg[i_arg].n_items < 2)
328 if ((spec->method =
match_string(s_arg[i_arg].list[1], algorithm_option, ALGORITHMS, 0)) == -1) {
329 fprintf(stderr,
"Invalid algorithm - %s provided, has to be nn or csa.\n", s_arg[i_arg].list[1]);
333 s_arg[i_arg].n_items -= 2;
334 if (!
scanItemList(&dummyFlags, s_arg[i_arg].list + 2, &s_arg[i_arg].n_items, 0,
335 "linear", -1, NULL, 0, LINEAR_NN,
336 "sibson", -1, NULL, 0, SIBSON_NN,
337 "nonSibson", -1, NULL, 0, NONSIBSON_NN,
342 if (!dummyFlags || dummyFlags & LINEAR_NN) {
344 }
else if (dummyFlags & SIBSON_NN) {
346 }
else if (dummyFlags & NONSIBSON_NN) {
347 nn_rule = NON_SIBSONIAN;
349 s_arg[i_arg].n_items += 2;
352 if (s_arg[i_arg].n_items != 2)
354 if (
match_string(s_arg[i_arg].list[1], INFINITY_OPTION, 1, 0) == 0)
355 spec->wmin = -DBL_MAX;
357 if (!
get_double(&spec->wmin, s_arg[i_arg].list[1]))
358 SDDS_Bomb(
"Invalid weight value provided.");
362 if (s_arg[i_arg].n_items != 2)
364 if (!
get_int(&nn_test_vertice, s_arg[i_arg].list[1]))
365 SDDS_Bomb(
"Invalid vertex value provided.");
369 if (s_arg[i_arg].n_items != 2)
371 if (!
get_int(&spec->npoints, s_arg[i_arg].list[1]))
372 SDDS_Bomb(
"Invalid npoints value provided.");
381 fprintf(stderr,
"Unknown option - %s provided.\n", s_arg[i_arg].list[0]);
387 inputFile = s_arg[i_arg].list[0];
388 else if (!outputFile)
389 outputFile = s_arg[i_arg].list[0];
395 processFilenames(
"sdds2dinterpolate", &inputFile, &outputFile, pipeFlags, 0, NULL);
396 if (!spec->generate_points && !spec->nointerp && !pointsFile) {
397 fprintf(stderr,
"No output grid specified.\n");
402 spec->nxd = spec->nx;
404 spec->nyd = spec->ny;
405 if (spec->nxd <= 0 || spec->nyd <= 0) {
406 fprintf(stderr,
"Invalid grid size for thinning.\n");
410 if (spec->npoints == 1) {
414 spec->npoints = spec->nx * spec->ny;
416 ReadInputFile(inputFile, xCol, yCol, zColMatch, zColMatches, &zCol, &zCols, stdCol, &pages, &rows, &x, &y, &z, &std, &SDDS_in);
418 SetupOutputFile(&SDDS_out, &SDDS_in, outputFile, xCol, yCol, pointsFileXName, pointsFileYName,
419 zCol, zCols, columnMajorOrder);
423 ReadPointFile(pointsFile, pointsFileXName ? pointsFileXName : xCol, pointsFileYName ? pointsFileYName : yCol,
424 &point_pages, &out_point);
425 pin =
tmalloc(
sizeof(*pin) * zCols);
427 for (i = 0; i < pages; i++) {
429 xmin = xmax = x[0][0];
430 ymin = ymax = y[0][0];
432 for (k = 0; k < zCols; k++)
433 pin[k] =
SDDS_Realloc(pin[k],
sizeof(**pin) * (nin + rows[i]));
435 std_all =
SDDS_Realloc(std_all,
sizeof(*std_all) * (nin + rows[i]));
436 for (j = 0; j < rows[i]; j++) {
439 else if (x[i][j] > xmax)
443 else if (y[i][j] > ymax)
445 for (k = 0; k < zCols; k++) {
446 pin[k][nin + j].x = x[i][j];
447 pin[k][nin + j].y = y[i][j];
448 pin[k][nin + j].z = z[k][i][j];
451 std_all[nin + j] = std[i][j];
456 for (k = 0; k < zCols; k++) {
469 for (k = 0; k < zCols; k++) {
485 if (!interpolate_output_points(nin, pin, std_all, xCol, yCol, pointsFileXName, pointsFileYName,
486 zCol, zCols, spec, pages, out_point, &SDDS_out))
490 for (k = 0; k < zCols; k++) {
491 if (spec->method == NN) {
492 do_nn_2d_interpolate(spec, &nin, &pin[k], &nout, &pout);
493 }
else if (spec->method == CSA) {
494 do_csa_2d_interpolate(spec, nin, pin[k], &nout, &pout, std_all);
496 if (!spec->nointerp) {
498 WriteOutputPage(&SDDS_out, pointsFileXName ? pointsFileXName : xCol,
499 pointsFileYName ? pointsFileYName : yCol,
500 zCol[k], spec, nout, pout, 0);
503 for (i = 0; i < nout; i++) {
505 zCol[k], pout[i].z, NULL))
515 for (i = 0; i < pages; i++) {
516 xmin = xmax = x[i][0];
517 ymin = ymax = y[i][0];
519 for (j = 0; j < nin; j++) {
522 else if (x[i][j] > xmax)
526 else if (y[i][j] > ymax)
535 for (k = 0; k < zCols; k++) {
536 pin[k] = malloc(
sizeof(**pin) * nin);
537 for (j = 0; j < rows[i]; j++) {
538 pin[k][j].x = x[i][j];
539 pin[k][j].y = y[i][j];
540 pin[k][j].z = z[k][i][j];
552 if (!interpolate_output_points(nin, pin, std_all, xCol, yCol, pointsFileXName, pointsFileYName,
553 zCol, zCols, spec, point_pages, out_point, &SDDS_out))
557 for (k = 0; k < zCols; k++) {
558 if (spec->method == NN) {
559 do_nn_2d_interpolate(spec, &nin, &pin[k], &nout, &pout);
560 }
else if (spec->method == CSA) {
561 do_csa_2d_interpolate(spec, nin, pin[k], &nout, &pout, std_all);
563 if (!spec->nointerp) {
565 WriteOutputPage(&SDDS_out, pointsFileXName ? pointsFileXName : xCol,
566 pointsFileYName ? pointsFileYName : yCol,
567 zCol[k], spec, nout, pout, 0);
570 for (j = 0; j < nout; j++) {
572 zCol[k], pout[j].z, NULL))
588 for (k = 0; k < zCols; k++)
595 for (k = 0; k < zCols; k++)
600 if (point_pages && out_point) {
601 for (i = 0; i < point_pages; i++) {
602 free(out_point[i].pout);
610 for (i = 0; i < zCols; i++)
617void ReadInputFile(
char *inputFile,
char *xCol,
char *yCol,
char **zColMatch,
long zColMatches,
char ***zCol, int32_t *zCols,
618 char *stdCol,
long *pages,
long **rows,
double ***x,
double ***y,
double ****z,
double ***std,
SDDS_DATASET *SDDS_in) {
620 long i, pages0 = 0, std_exist = 0;
625 *zCol =
tmalloc(
sizeof(**zCol));
632 fprintf(stderr,
"No dependent columns found in input file.\n");
636 *z =
tmalloc(
sizeof(**z) * (*zCols));
639 fprintf(stderr,
"X column - %s does not exist!\n", xCol);
643 fprintf(stderr,
"Y column - %s does not exist!\n", yCol);
646 for (i = 0; i < *zCols; i++) {
648 fprintf(stderr,
"Z column - %s does not exist!\n", (*zCol)[i]);
659 if (rows1 > INT32_MAX) {
660 fprintf(stderr,
"Too many input rows for 2D interpolate library routines.\n");
663 *rows =
SDDS_Realloc(*rows,
sizeof(**rows) * (pages0 + 1));
664 (*rows)[pages0] = rows1;
665 if (!(*x =
SDDS_Realloc(*x,
sizeof(**x) * (pages0 + 1))) ||
667 fprintf(stderr,
"Memory allocation error for X and Y data.\n");
670 for (i = 0; i < *zCols; i++) {
671 if (!((*z)[i] =
SDDS_Realloc((*z)[i],
sizeof(***z) * (pages0 + 1)))) {
672 fprintf(stderr,
"Memory allocation error for Z data.\n");
677 if (!(*std =
SDDS_Realloc(*std,
sizeof(**std) * (pages0 + 1)))) {
678 fprintf(stderr,
"Memory allocation error for standard error.\n");
681 (*std)[pages0] = NULL;
684 (*x)[pages0] = (*y)[pages0] = NULL;
688 for (i = 0; i < *zCols; i++) {
689 (*z)[i][pages0] = NULL;
699 fprintf(stderr,
"No data found in the input file.\n");
707 char *xName,
char *yName,
char **zCol,
long zCols,
short columnMajorOrder) {
708 char tmpstr[256], *xUnits = NULL, *yUnits = NULL;
718 if (columnMajorOrder != -1)
719 SDDS_out->layout.data_mode.column_major = columnMajorOrder;
721 SDDS_out->layout.data_mode.column_major = SDDS_in->layout.data_mode.column_major;
722 for (i = 0; i < zCols; i++) {
729 sprintf(tmpstr,
"%sDimension", xName ? xName : xCol);
732 sprintf(tmpstr,
"%sDimension", yName ? yName : yCol);
735 sprintf(tmpstr,
"%sInterval", xName ? xName : xCol);
738 sprintf(tmpstr,
"%sInterval", yName ? yName : yCol);
741 sprintf(tmpstr,
"%sMinimum", xName ? xName : xCol);
744 sprintf(tmpstr,
"%sMinimum", yName ? yName : yCol);
747 sprintf(tmpstr,
"%sMaximum", xName ? xName : xCol);
750 sprintf(tmpstr,
"%sMaximum", yName ? yName : yCol);
761void WriteOutputPage(
SDDS_DATASET *SDDS_out,
char *xCol,
char *yCol,
char *zCol, specs *spec,
int nout, point *pout,
long writepage) {
768 "Variable1Name", xCol,
769 "Variable2Name", yCol, NULL))
771 sprintf(tmpstr,
"%sDimension", xCol);
772 if (!
SDDS_SetParameters(SDDS_out, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE, tmpstr, spec->nx, NULL))
774 sprintf(tmpstr,
"%sDimension", yCol);
775 if (!
SDDS_SetParameters(SDDS_out, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE, tmpstr, spec->ny, NULL))
777 sprintf(tmpstr,
"%sInterval", xCol);
778 if (!
SDDS_SetParameters(SDDS_out, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE, tmpstr, spec->dx, NULL))
780 sprintf(tmpstr,
"%sInterval", yCol);
781 if (!
SDDS_SetParameters(SDDS_out, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE, tmpstr, spec->dy, NULL))
783 sprintf(tmpstr,
"%sMinimum", xCol);
784 if (!
SDDS_SetParameters(SDDS_out, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE, tmpstr, spec->xmin, NULL))
786 sprintf(tmpstr,
"%sMinimum", yCol);
787 if (!
SDDS_SetParameters(SDDS_out, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE, tmpstr, spec->ymin, NULL))
789 sprintf(tmpstr,
"%sMaximum", xCol);
790 if (!
SDDS_SetParameters(SDDS_out, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE, tmpstr, spec->xmax, NULL))
792 sprintf(tmpstr,
"%sMaximum", yCol);
793 if (!
SDDS_SetParameters(SDDS_out, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE, tmpstr, spec->ymax, NULL))
795 for (i = 0; i < nout; i++) {
799 zCol, pout[i].z, NULL))
806void ReadPointFile(
char *inputFile,
char *xCol,
char *yCol,
long *pages,
OUT_POINT **out_point) {
810 double *x, *y, xmin, xmax, firstx, firsty, ymin, ymax;
816 fprintf(stderr,
"X column - %s does not exist!\n", xCol);
820 fprintf(stderr,
"Y column - %s does not exist!\n", yCol);
827 if (rows1 > INT32_MAX) {
828 fprintf(stderr,
"Too many input rows for 2D interpolate library routines.\n");
831 *out_point =
SDDS_Realloc(*out_point,
sizeof(**out_point) * (pages0 + 1));
833 (*out_point)[pages0].pout = malloc(
sizeof(point) * rows1);
834 (*out_point)[pages0].nout = rows1;
838 xmin = xmax = firstx = x[0];
839 ymin = ymax = firsty = y[0];
842 for (i = 0; i < rows1; i++) {
843 (*out_point)[pages0].pout[i].x = x[i];
844 (*out_point)[pages0].pout[i].y = y[i];
847 else if (x[i] > xmax)
853 else if (y[i] > ymax)
860 (*out_point)[pages0].xmin = xmin;
861 (*out_point)[pages0].xmax = xmax;
862 (*out_point)[pages0].ymin = ymin;
863 (*out_point)[pages0].ymax = ymax;
864 (*out_point)[pages0].nx = nx;
865 (*out_point)[pages0].ny = ny;
867 (*out_point)[pages0].dx = (xmax - xmin) / (nx - 1);
869 (*out_point)[pages0].dx = 0;
871 (*out_point)[pages0].dy = (ymax - ymin) / (ny - 1);
873 (*out_point)[pages0].dy = 0;
879 fprintf(stderr,
"No data found in the points file.\n");
886int interpolate_output_points(
int nin, point **pin,
double *std,
char *xCol,
char *yCol,
char *xName,
char *yName,
888 int nout, page, k, writepage = 0, i;
891 for (page = 0; page < pages; page++) {
892 nout = out_point[page].nout;
893 pout = out_point[page].pout;
894 spec->nx = out_point[page].nx;
895 spec->ny = out_point[page].ny;
896 spec->xmin = out_point[page].xmin;
897 spec->xmax = out_point[page].xmax;
898 spec->dx = out_point[page].dx;
899 spec->ymin = out_point[page].ymin;
900 spec->ymax = out_point[page].ymax;
901 spec->dy = out_point[page].dy;
902 for (k = 0; k < zCols; k++) {
903 if (spec->method == NN) {
904 do_nn_2d_interpolate(spec, &nin, &pin[k], &nout, &pout);
906 do_csa_2d_interpolate(spec, nin, pin[k], &nout, &pout, std);
908 if (!spec->nointerp) {
910 WriteOutputPage(SDDS_out, xName ? xName : xCol, yName ? yName : yCol, zCol[k], spec, nout, pout, 0);
913 for (i = 0; i < nout; i++) {
915 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.