54char *option[N_OPTIONS] = {
55 "pipe",
"profileType",
"columnPrefix",
56 "method",
"areaOfInterest",
"background"};
59 "Usage: sddsimageprofiles [<inputfile>] [<outputfile>]\n"
61 " -pipe=[input][,output] Specify input and/or output via pipe.\n"
62 " -columnPrefix=<prefix> Set the column prefix.\n"
63 " -profileType={x|y} Choose profile type: 'x' or 'y'.\n"
64 " -method={centerLine|integrated|averaged|peak} Select the method for profile analysis.\n"
65 " -background=<filename> Specify a background image file.\n"
66 " -areaOfInterest=<rowStart>,<rowEnd>,<columnStart>,<columnEnd> Define the area of interest.\n\n"
67 "Program by Robert Soliday. (\"" __DATE__
" " __TIME__
"\", SVN revision: " SVN_VERSION
")\n\n"
69 " If this option is not specified, it is a real profile.\n"
70 " If centerLine is specified, it will find the row with the\n"
71 " greatest integrated profile and display that line only.\n"
72 " If integrated is specified, it will sum all the profiles\n"
73 " together. If averaged is specified, it will divide the sum\n"
74 " of all the profiles by the number of profiles. If peak is\n"
75 " specified, it will find the peak point and display the profile\n"
80 unsigned short *ushortData;
84 uint64_t *ulong64Data;
90 long method, int64_t x1, int64_t x2,
long y1,
long y2,
long *colIndex,
double *colIndex2);
93 long method, int64_t x1, int64_t x2,
long y1,
long y2,
long *colIndex,
double *colIndex2);
95int64_t xPeakLine(
IMAGE_DATA *data, int32_t *type,
long *colIndex, int64_t x1, int64_t x2,
long y1,
long y2);
97long yPeakLine(
IMAGE_DATA *data, int32_t *type,
long *colIndex, int64_t x1, int64_t x2,
long y1,
long y2);
99int64_t xCenterLine(
IMAGE_DATA *data, int32_t *type,
long *colIndex, int64_t x1, int64_t x2,
long y1,
long y2);
101long yCenterLine(
IMAGE_DATA *data, int32_t *type,
long *colIndex, int64_t x1, int64_t x2,
long y1,
long y2);
104 double **colIndex2,
char *colPrefix,
long *validColumns);
106int main(
int argc,
char **argv) {
111 char *input = NULL, *output = NULL, *colPrefix = NULL, *background = NULL;
112 long profileType = 1, noWarnings = 0, tmpfile_used = 0, method = 0;
113 unsigned long pipeFlags = 0;
114 int64_t rows, bg_rows, j;
115 long i, validColumns = 0, bg_validColumns = 0;
116 int32_t *type = NULL, *bg_type = NULL;
118 int64_t rowStart = 1, rowEnd = 0;
119 long columnStart = 1, columnEnd = 0;
121 long *colIndex, *bg_colIndex;
122 double *colIndex2, *bg_colIndex2;
125 argc =
scanargs(&s_arg, argc, argv);
130 for (i_arg = 1; i_arg < argc; i_arg++) {
131 if (s_arg[i_arg].arg_type == OPTION) {
132 switch (
match_string(s_arg[i_arg].list[0], option, N_OPTIONS, 0)) {
133 case SET_PROFILETYPE:
134 if (s_arg[i_arg].n_items != 2)
135 SDDS_Bomb(
"invalid -profileType syntax");
136 if (strcmp(
"x", s_arg[i_arg].list[1]) == 0)
138 if (strcmp(
"y", s_arg[i_arg].list[1]) == 0)
142 if (s_arg[i_arg].n_items != 2)
143 SDDS_Bomb(
"invalid -columnPrefix syntax");
144 colPrefix = s_arg[i_arg].list[1];
147 if (s_arg[i_arg].n_items != 2)
149 if ((strncasecmp(
"centralLine", s_arg[i_arg].list[1], strlen(s_arg[i_arg].list[1])) == 0) ||
150 (strncasecmp(
"centerLine", s_arg[i_arg].list[1], strlen(s_arg[i_arg].list[1])) == 0))
152 if (strncasecmp(
"integrated", s_arg[i_arg].list[1], strlen(s_arg[i_arg].list[1])) == 0)
154 if (strncasecmp(
"averaged", s_arg[i_arg].list[1], strlen(s_arg[i_arg].list[1])) == 0)
156 if (strncasecmp(
"peak", s_arg[i_arg].list[1], strlen(s_arg[i_arg].list[1])) == 0)
159 case SET_AREAOFINTEREST:
160 if (s_arg[i_arg].n_items != 5)
161 SDDS_Bomb(
"invalid -areaOfInterest syntax");
162 if (sscanf(s_arg[i_arg].list[1],
"%" SCNd64, &rowStart) != 1 || rowStart <= 0)
163 SDDS_Bomb(
"invalid -areaOfInterest syntax or value");
164 if (sscanf(s_arg[i_arg].list[2],
"%" SCNd64, &rowEnd) != 1 || rowEnd <= 0)
165 SDDS_Bomb(
"invalid -areaOfInterest syntax or value");
166 if (sscanf(s_arg[i_arg].list[3],
"%ld", &columnStart) != 1 || columnStart <= 0)
167 SDDS_Bomb(
"invalid -areaOfInterest syntax or value");
168 if (sscanf(s_arg[i_arg].list[4],
"%ld", &columnEnd) != 1 || columnEnd <= 0)
169 SDDS_Bomb(
"invalid -areaOfInterest syntax or value");
172 if (s_arg[i_arg].n_items != 2)
174 background = s_arg[i_arg].list[1];
177 if (!
processPipeOption(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1, &pipeFlags))
181 fprintf(stderr,
"error: unknown switch: %s\n", s_arg[i_arg].list[0]);
187 input = s_arg[i_arg].list[0];
188 else if (output == NULL)
189 output = s_arg[i_arg].list[0];
195 if (colPrefix == NULL) {
196 fprintf(stderr,
"error: missing columnPrefix\n");
200 processFilenames(
"sddsimageprofiles", &input, &output, pipeFlags, noWarnings, &tmpfile_used);
203 rows = GetData(&SDDS_orig, input, &data, &type, &colIndex, &colIndex2, colPrefix, &validColumns);
206 fprintf(stderr,
"error: no rows in image file\n");
210 if (background != NULL) {
212 bg_rows = GetData(&SDDS_bg, background, &bg_data, &bg_type, &bg_colIndex, &bg_colIndex2, colPrefix, &bg_validColumns);
213 if (rows != bg_rows) {
214 fprintf(stderr,
"error: background has a different number of rows\n");
217 if (validColumns != bg_validColumns) {
218 fprintf(stderr,
"error: background has a different number of columns\n");
222 for (i = 0; i < validColumns; i++) {
223 if (type[colIndex[i]] != bg_type[bg_colIndex[i]]) {
224 fprintf(stderr,
"error: column types don't match with background image\n");
227 if (colIndex2[i] != bg_colIndex2[i]) {
228 fprintf(stderr,
"error: image rows don't match with background image\n");
231 switch (type[colIndex[i]]) {
233 for (j = 0; j < rows; j++)
234 data[colIndex[i]].shortData[j] -= bg_data[bg_colIndex[i]].shortData[j];
237 for (j = 0; j < rows; j++)
238 data[colIndex[i]].ushortData[j] -= bg_data[bg_colIndex[i]].ushortData[j];
241 for (j = 0; j < rows; j++)
242 data[colIndex[i]].longData[j] -= bg_data[bg_colIndex[i]].longData[j];
245 for (j = 0; j < rows; j++)
246 data[colIndex[i]].ulongData[j] -= bg_data[bg_colIndex[i]].ulongData[j];
249 for (j = 0; j < rows; j++)
250 data[colIndex[i]].long64Data[j] -= bg_data[bg_colIndex[i]].long64Data[j];
253 for (j = 0; j < rows; j++)
254 data[colIndex[i]].ulong64Data[j] -= bg_data[bg_colIndex[i]].ulong64Data[j];
257 for (j = 0; j < rows; j++)
258 data[colIndex[i]].floatData[j] -= bg_data[bg_colIndex[i]].floatData[j];
261 for (j = 0; j < rows; j++)
262 data[colIndex[i]].doubleData[j] -= bg_data[bg_colIndex[i]].doubleData[j];
276 if (profileType == 1) {
308 if ((rowEnd > rows) || (rowEnd < rowStart))
311 if ((columnEnd > validColumns) || (columnEnd < columnStart))
312 columnEnd = validColumns;
314 if (profileType == 1) {
315 xImageProfile(data, type, rows, &SDDS_dataset, method, rowStart - 1, rowEnd, columnStart - 1, columnEnd, colIndex, colIndex2);
317 yImageProfile(data, type, rows, &SDDS_dataset, method, rowStart - 1, rowEnd, columnStart - 1, columnEnd, colIndex, colIndex2);
326 for (i = 0; i < validColumns; i++) {
327 switch (type[colIndex[i]]) {
329 free(data[colIndex[i]].shortData);
332 free(data[colIndex[i]].ushortData);
335 free(data[colIndex[i]].longData);
338 free(data[colIndex[i]].ulongData);
341 free(data[colIndex[i]].long64Data);
344 free(data[colIndex[i]].ulong64Data);
347 free(data[colIndex[i]].floatData);
350 free(data[colIndex[i]].doubleData);
358 if (background != NULL) {
359 for (i = 0; i < validColumns; i++) {
360 switch (bg_type[bg_colIndex[i]]) {
362 free(bg_data[bg_colIndex[i]].shortData);
365 free(bg_data[bg_colIndex[i]].ushortData);
368 free(bg_data[bg_colIndex[i]].longData);
371 free(bg_data[bg_colIndex[i]].ulongData);
374 free(bg_data[bg_colIndex[i]].long64Data);
377 free(bg_data[bg_colIndex[i]].ulong64Data);
380 free(bg_data[bg_colIndex[i]].floatData);
383 free(bg_data[bg_colIndex[i]].doubleData);
397 int64_t x1, int64_t x2,
long y1,
long y2,
long *colIndex,
double *colIndex2) {
405 index = malloc(
sizeof(int64_t) * rows);
406 values = malloc(
sizeof(
double) * rows);
409 for (i = x1; i < x2; i++) {
410 switch (type[colIndex[y1]]) {
412 val = data[colIndex[y1]].shortData[i];
415 val = data[colIndex[y1]].ushortData[i];
418 val = data[colIndex[y1]].longData[i];
421 val = data[colIndex[y1]].ulongData[i];
424 val = data[colIndex[y1]].long64Data[i];
427 val = data[colIndex[y1]].ulong64Data[i];
430 val = data[colIndex[y1]].floatData[i];
433 val = data[colIndex[y1]].doubleData[i];
436 for (j = y1 + 1; j < y2; j++) {
437 switch (type[colIndex[j]]) {
439 if (val < data[colIndex[j]].shortData[i])
440 val = data[colIndex[j]].shortData[i];
443 if (val < data[colIndex[j]].ushortData[i])
444 val = data[colIndex[j]].ushortData[i];
447 if (val < data[colIndex[j]].longData[i])
448 val = data[colIndex[j]].longData[i];
451 if (val < data[colIndex[j]].ulongData[i])
452 val = data[colIndex[j]].ulongData[i];
455 if (val < data[colIndex[j]].long64Data[i])
456 val = data[colIndex[j]].long64Data[i];
459 if (val < data[colIndex[j]].ulong64Data[i])
460 val = data[colIndex[j]].ulong64Data[i];
463 if (val < data[colIndex[j]].floatData[i])
464 val = data[colIndex[j]].floatData[i];
467 if (val < data[colIndex[j]].doubleData[i])
468 val = data[colIndex[j]].doubleData[i];
476 }
else if ((method == 1) || (method == 4)) {
478 center = yPeakLine(data, type, colIndex, x1, x2, y1, y2);
480 center = yCenterLine(data, type, colIndex, x1, x2, y1, y2);
482 for (i = x1; i < x2; i++) {
483 switch (type[colIndex[center]]) {
485 val = data[colIndex[center]].shortData[i];
488 val = data[colIndex[center]].ushortData[i];
491 val = data[colIndex[center]].longData[i];
494 val = data[colIndex[center]].ulongData[i];
497 val = data[colIndex[center]].long64Data[i];
500 val = data[colIndex[center]].ulong64Data[i];
503 val = data[colIndex[center]].floatData[i];
506 val = data[colIndex[center]].doubleData[i];
513 }
else if ((method == 2) || (method == 3)) {
514 for (i = x1; i < x2; i++) {
516 for (j = y1; j < y2; j++) {
517 switch (type[colIndex[j]]) {
519 val += data[colIndex[j]].shortData[i];
522 val += data[colIndex[j]].ushortData[i];
525 val += data[colIndex[j]].longData[i];
528 val += data[colIndex[j]].ulongData[i];
531 val += data[colIndex[j]].long64Data[i];
534 val += data[colIndex[j]].ulong64Data[i];
537 val += data[colIndex[j]].floatData[i];
540 val += data[colIndex[j]].doubleData[i];
548 values[k] = val / (y2 - y1);
557 sprintf(value,
"(%" PRId64
",%ld) x (%" PRId64
",%ld)", x1 + 1, y1 + 1, x2, y2);
558 if (
SDDS_SetParameters(SDDS_dataset, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE,
"Zone", value, NULL) != 1) {
562 if (
SDDS_SetColumn(SDDS_dataset, SDDS_SET_BY_NAME, index, k,
"x", NULL) != 1) {
566 if (
SDDS_SetColumn(SDDS_dataset, SDDS_SET_BY_NAME, values, k,
"y", NULL) != 1) {
580 int64_t x1, int64_t x2,
long y1,
long y2,
long *colIndex,
double *colIndex2) {
590 index = malloc(
sizeof(
double) * (y2 - y1));
591 values = malloc(
sizeof(
double) * (y2 - y1));
594 for (i = y1; i < y2; i++) {
595 switch (type[colIndex[i]]) {
597 val = data[colIndex[i]].shortData[x1];
600 val = data[colIndex[i]].ushortData[x1];
603 val = data[colIndex[i]].longData[x1];
606 val = data[colIndex[i]].ulongData[x1];
609 val = data[colIndex[i]].long64Data[x1];
612 val = data[colIndex[i]].ulong64Data[x1];
615 val = data[colIndex[i]].floatData[x1];
618 val = data[colIndex[i]].doubleData[x1];
623 for (j = x1 + 1; j < x2; j++) {
624 switch (type[colIndex[i]]) {
626 if (val < data[colIndex[i]].shortData[j]) {
627 val = data[colIndex[i]].shortData[j];
631 if (val < data[colIndex[i]].ushortData[j]) {
632 val = data[colIndex[i]].ushortData[j];
636 if (val < data[colIndex[i]].longData[j]) {
637 val = data[colIndex[i]].longData[j];
641 if (val < data[colIndex[i]].ulongData[j]) {
642 val = data[colIndex[i]].ulongData[j];
646 if (val < data[colIndex[i]].long64Data[j]) {
647 val = data[colIndex[i]].long64Data[j];
651 if (val < data[colIndex[i]].ulong64Data[j]) {
652 val = data[colIndex[i]].ulong64Data[j];
656 if (val < data[colIndex[i]].floatData[j]) {
657 val = data[colIndex[i]].floatData[j];
661 if (val < data[colIndex[i]].doubleData[j]) {
662 val = data[colIndex[i]].doubleData[j];
669 index[k] = colIndex2[i];
673 }
else if ((method == 1) || (method == 4)) {
675 center = xPeakLine(data, type, colIndex, x1, x2, y1, y2);
677 center = xCenterLine(data, type, colIndex, x1, x2, y1, y2);
679 for (i = y1; i < y2; i++) {
680 switch (type[colIndex[i]]) {
682 val = data[colIndex[i]].shortData[center];
685 val = data[colIndex[i]].ushortData[center];
688 val = data[colIndex[i]].longData[center];
691 val = data[colIndex[i]].ulongData[center];
694 val = data[colIndex[i]].long64Data[center];
697 val = data[colIndex[i]].ulong64Data[center];
700 val = data[colIndex[i]].floatData[center];
703 val = data[colIndex[i]].doubleData[center];
708 index[k] = colIndex2[i];
712 }
else if ((method == 2) || (method == 3)) {
713 for (i = y1; i < y2; i++) {
715 switch (type[colIndex[i]]) {
717 for (j = x1; j < x2; j++)
718 val += data[colIndex[i]].shortData[j];
721 for (j = x1; j < x2; j++)
722 val += data[colIndex[i]].ushortData[j];
725 for (j = x1; j < x2; j++)
726 val += data[colIndex[i]].longData[j];
729 for (j = x1; j < x2; j++)
730 val += data[colIndex[i]].ulongData[j];
733 for (j = x1; j < x2; j++)
734 val += data[colIndex[i]].long64Data[j];
737 for (j = x1; j < x2; j++)
738 val += data[colIndex[i]].ulong64Data[j];
741 for (j = x1; j < x2; j++)
742 val += data[colIndex[i]].floatData[j];
745 for (j = x1; j < x2; j++)
746 val += data[colIndex[i]].doubleData[j];
751 index[k] = colIndex2[i];
755 values[k] = val / (x2 - x1);
764 sprintf(value,
"(%" PRId64
",%ld) x (%" PRId64
",%ld)", x1 + 1, y1 + 1, x2, y2);
765 if (
SDDS_SetParameters(SDDS_dataset, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE,
"Zone", value, NULL) != 1) {
769 if (
SDDS_SetColumn(SDDS_dataset, SDDS_SET_BY_NAME, index, k,
"y", NULL) != 1) {
773 if (
SDDS_SetColumn(SDDS_dataset, SDDS_SET_BY_NAME, values, k,
"x", NULL) != 1) {
786int64_t xPeakLine(
IMAGE_DATA *data, int32_t *type,
long *colIndex, int64_t x1, int64_t x2,
long y1,
long y2) {
792 switch (type[colIndex[y1]]) {
794 maxValue = data[colIndex[y1]].shortData[x1];
797 maxValue = data[colIndex[y1]].ushortData[x1];
800 maxValue = data[colIndex[y1]].longData[x1];
803 maxValue = data[colIndex[y1]].ulongData[x1];
806 maxValue = data[colIndex[y1]].long64Data[x1];
809 maxValue = data[colIndex[y1]].ulong64Data[x1];
812 maxValue = data[colIndex[y1]].floatData[x1];
815 maxValue = data[colIndex[y1]].doubleData[x1];
818 for (i = y1; i < y2; i++) {
819 for (j = x1; j < x2; j++) {
820 switch (type[colIndex[i]]) {
822 if (maxValue < data[colIndex[i]].shortData[j]) {
823 maxValue = data[colIndex[i]].shortData[j];
828 if (maxValue < data[colIndex[i]].ushortData[j]) {
829 maxValue = data[colIndex[i]].ushortData[j];
834 if (maxValue < data[colIndex[i]].longData[j]) {
835 maxValue = data[colIndex[i]].longData[j];
840 if (maxValue < data[colIndex[i]].ulongData[j]) {
841 maxValue = data[colIndex[i]].ulongData[j];
846 if (maxValue < data[colIndex[i]].long64Data[j]) {
847 maxValue = data[colIndex[i]].long64Data[j];
852 if (maxValue < data[colIndex[i]].ulong64Data[j]) {
853 maxValue = data[colIndex[i]].ulong64Data[j];
858 if (maxValue < data[colIndex[i]].floatData[j]) {
859 maxValue = data[colIndex[i]].floatData[j];
864 if (maxValue < data[colIndex[i]].doubleData[j]) {
865 maxValue = data[colIndex[i]].doubleData[j];
875long yPeakLine(
IMAGE_DATA *data, int32_t *type,
long *colIndex, int64_t x1, int64_t x2,
long y1,
long y2) {
882 switch (type[colIndex[y1]]) {
884 maxValue = data[colIndex[y1]].shortData[x1];
887 maxValue = data[colIndex[y1]].ushortData[x1];
890 maxValue = data[colIndex[y1]].longData[x1];
893 maxValue = data[colIndex[y1]].ulongData[x1];
896 maxValue = data[colIndex[y1]].long64Data[x1];
899 maxValue = data[colIndex[y1]].ulong64Data[x1];
902 maxValue = data[colIndex[y1]].floatData[x1];
905 maxValue = data[colIndex[y1]].doubleData[x1];
908 for (i = y1; i < y2; i++) {
909 for (j = x1; j < x2; j++) {
910 switch (type[colIndex[i]]) {
912 if (maxValue < data[colIndex[i]].shortData[j]) {
913 maxValue = data[colIndex[i]].shortData[j];
918 if (maxValue < data[colIndex[i]].ushortData[j]) {
919 maxValue = data[colIndex[i]].ushortData[j];
924 if (maxValue < data[colIndex[i]].longData[j]) {
925 maxValue = data[colIndex[i]].longData[j];
930 if (maxValue < data[colIndex[i]].ulongData[j]) {
931 maxValue = data[colIndex[i]].ulongData[j];
936 if (maxValue < data[colIndex[i]].long64Data[j]) {
937 maxValue = data[colIndex[i]].long64Data[j];
942 if (maxValue < data[colIndex[i]].ulong64Data[j]) {
943 maxValue = data[colIndex[i]].ulong64Data[j];
948 if (maxValue < data[colIndex[i]].floatData[j]) {
949 maxValue = data[colIndex[i]].floatData[j];
954 if (maxValue < data[colIndex[i]].doubleData[j]) {
955 maxValue = data[colIndex[i]].doubleData[j];
965int64_t xCenterLine(
IMAGE_DATA *data, int32_t *type,
long *colIndex, int64_t x1, int64_t x2,
long y1,
long y2) {
966 int64_t i, j, start = 1;
967 double val = 0, maxValue = 0;
970 for (i = x1; i < x2; i++) {
972 for (j = y1; j < y2; j++) {
973 switch (type[colIndex[j]]) {
975 val += data[colIndex[j]].shortData[i];
978 val += data[colIndex[j]].ushortData[i];
981 val += data[colIndex[j]].longData[i];
984 val += data[colIndex[j]].ulongData[i];
987 val += data[colIndex[j]].long64Data[i];
990 val += data[colIndex[j]].ulong64Data[i];
993 val += data[colIndex[j]].floatData[i];
996 val += data[colIndex[j]].doubleData[i];
1005 if (val > maxValue) {
1014long yCenterLine(
IMAGE_DATA *data, int32_t *type,
long *colIndex, int64_t x1, int64_t x2,
long y1,
long y2) {
1017 double val, maxValue = 0;
1020 for (i = y1; i < y2; i++) {
1022 for (j = x1; j < x2; j++)
1023 switch (type[colIndex[i]]) {
1025 val += data[colIndex[i]].shortData[j];
1028 val += data[colIndex[i]].ushortData[j];
1031 val += data[colIndex[i]].longData[j];
1034 val += data[colIndex[i]].ulongData[j];
1037 val += data[colIndex[i]].long64Data[j];
1040 val += data[colIndex[i]].ulong64Data[j];
1043 val += data[colIndex[i]].floatData[j];
1046 val += data[colIndex[i]].doubleData[j];
1056 if (val > maxValue) {
1066 double **colIndex2,
char *colPrefix,
long *validColumns) {
1070 int32_t orig_column_names;
1071 char **orig_column_name;
1086 *data = malloc(
sizeof(
IMAGE_DATA) * orig_column_names);
1087 *type = malloc(
sizeof(int32_t) * orig_column_names);
1096 rows = SDDS_RowCount(SDDS_orig);
1097 *colIndex = malloc(
sizeof(
long) * orig_column_names);
1098 *colIndex2 = malloc(
sizeof(
double) * orig_column_names);
1101 for (i = 0; i < orig_column_names; i++) {
1103 if ((*type)[i] == 0) {
1108 switch ((*type)[i]) {
1110 (*data)[i].shortData =
SDDS_GetColumn(SDDS_orig, orig_column_name[i]);
1113 (*data)[i].ushortData =
SDDS_GetColumn(SDDS_orig, orig_column_name[i]);
1116 (*data)[i].longData =
SDDS_GetColumn(SDDS_orig, orig_column_name[i]);
1119 (*data)[i].ulongData =
SDDS_GetColumn(SDDS_orig, orig_column_name[i]);
1122 (*data)[i].long64Data =
SDDS_GetColumn(SDDS_orig, orig_column_name[i]);
1125 (*data)[i].ulong64Data =
SDDS_GetColumn(SDDS_orig, orig_column_name[i]);
1128 (*data)[i].floatData =
SDDS_GetColumn(SDDS_orig, orig_column_name[i]);
1131 (*data)[i].doubleData =
SDDS_GetColumn(SDDS_orig, orig_column_name[i]);
1136 if (strncmp(colPrefix, orig_column_name[i], strlen(colPrefix)) != 0) {
1139 (*colIndex)[*validColumns] = i;
1148 if (*validColumns == 0) {
1149 fprintf(stderr,
"error: no valid columns in image file\n");
1153 for (i = 0; i < *validColumns; i++) {
1154 (*colIndex2)[i] = atof(orig_column_name[(*colIndex)[i]] + strlen(colPrefix));
1157 for (i = 0; i < *validColumns; i++) {
1158 for (j = i + 1; j < *validColumns; j++) {
1159 if ((*colIndex2)[j] < (*colIndex2)[i]) {
1160 temp = (*colIndex)[i];
1161 temp2 = (*colIndex2)[i];
1162 (*colIndex)[i] = (*colIndex)[j];
1163 (*colIndex2)[i] = (*colIndex2)[j];
1164 (*colIndex)[j] = temp;
1165 (*colIndex2)[j] = temp2;
SDDS (Self Describing Data Set) Data Types Definitions and Function Prototypes.
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_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_GetNamedColumnType(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the data type of a column in the SDDS dataset by its name.
char ** SDDS_GetColumnNames(SDDS_DATASET *SDDS_dataset, int32_t *number)
Retrieves the names of all columns 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.
void SDDS_Bomb(char *message)
Terminates the program after printing an error message and recorded errors.
#define SDDS_ULONG
Identifier for the unsigned 32-bit integer data type.
#define SDDS_FLOAT
Identifier for the float data type.
#define SDDS_STRING
Identifier for the string data type.
#define SDDS_ULONG64
Identifier for the unsigned 64-bit integer data type.
#define SDDS_LONG
Identifier for the signed 32-bit integer data type.
#define SDDS_SHORT
Identifier for the signed short integer data type.
#define SDDS_USHORT
Identifier for the unsigned short integer data type.
#define SDDS_DOUBLE
Identifier for the double data type.
#define SDDS_LONG64
Identifier for the signed 64-bit integer data type.
void bomb(char *error, char *usage)
Reports error messages to the terminal and aborts the program.
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)