62char *option[N_OPTIONS] = {
63 "pipe",
"profileType",
"columnPrefix",
64 "method",
"areaOfInterest",
"background"};
67 "sddsimageprofiles [<inputfile>] [<outputfile>]\n"
68 " [-pipe=[input][,output]]\n"
69 " -columnPrefix=<prefix>\n"
70 " [-profileType={x|y}]\n"
71 " [-method={centerLine|integrated|averaged|peak}]\n"
72 " [-background=<filename>]\n"
73 " [-areaOfInterest=<rowStart>,<rowEnd>,<columnStart>,<columnEnd>]\n"
75 " -pipe=[input][,output] Specify input and/or output via pipe.\n"
76 " -columnPrefix=<prefix> Set the column prefix.\n"
77 " -profileType={x|y} Choose profile type: 'x' or 'y'.\n"
78 " -method={centerLine|integrated|averaged|peak} Select the method for profile analysis.\n"
79 " -background=<filename> Specify a background image file.\n"
80 " -areaOfInterest=<rowStart>,<rowEnd>,<columnStart>,<columnEnd> Define the area of interest.\n\n"
81 "Program by Robert Soliday. (\"" __DATE__
" " __TIME__
"\", SVN revision: " SVN_VERSION
")\n\n"
83 " If this option is not specified, it is a real profile.\n"
84 " If centerLine is specified, it will find the row with the\n"
85 " greatest integrated profile and display that line only.\n"
86 " If integrated is specified, it will sum all the profiles\n"
87 " together. If averaged is specified, it will divide the sum\n"
88 " of all the profiles by the number of profiles. If peak is\n"
89 " specified, it will find the peak point and display the profile\n"
94 unsigned short *ushortData;
98 uint64_t *ulong64Data;
104 long method, int64_t x1, int64_t x2,
long y1,
long y2,
long *colIndex,
double *colIndex2);
107 long method, int64_t x1, int64_t x2,
long y1,
long y2,
long *colIndex,
double *colIndex2);
109int64_t xPeakLine(
IMAGE_DATA *data, int32_t *type,
long *colIndex, int64_t x1, int64_t x2,
long y1,
long y2);
111long yPeakLine(
IMAGE_DATA *data, int32_t *type,
long *colIndex, int64_t x1, int64_t x2,
long y1,
long y2);
113int64_t xCenterLine(
IMAGE_DATA *data, int32_t *type,
long *colIndex, int64_t x1, int64_t x2,
long y1,
long y2);
115long yCenterLine(
IMAGE_DATA *data, int32_t *type,
long *colIndex, int64_t x1, int64_t x2,
long y1,
long y2);
118 double **colIndex2,
char *colPrefix,
long *validColumns);
120int main(
int argc,
char **argv) {
125 char *input = NULL, *output = NULL, *colPrefix = NULL, *background = NULL;
126 long profileType = 1, noWarnings = 0, tmpfile_used = 0, method = 0;
127 unsigned long pipeFlags = 0;
128 int64_t rows, bg_rows, j;
129 long i, validColumns = 0, bg_validColumns = 0;
130 int32_t *type = NULL, *bg_type = NULL;
132 int64_t rowStart = 1, rowEnd = 0;
133 long columnStart = 1, columnEnd = 0;
135 long *colIndex, *bg_colIndex;
136 double *colIndex2, *bg_colIndex2;
139 argc =
scanargs(&s_arg, argc, argv);
144 for (i_arg = 1; i_arg < argc; i_arg++) {
145 if (s_arg[i_arg].arg_type == OPTION) {
146 switch (
match_string(s_arg[i_arg].list[0], option, N_OPTIONS, 0)) {
147 case SET_PROFILETYPE:
148 if (s_arg[i_arg].n_items != 2)
149 SDDS_Bomb(
"invalid -profileType syntax");
150 if (strcmp(
"x", s_arg[i_arg].list[1]) == 0)
152 if (strcmp(
"y", s_arg[i_arg].list[1]) == 0)
156 if (s_arg[i_arg].n_items != 2)
157 SDDS_Bomb(
"invalid -columnPrefix syntax");
158 colPrefix = s_arg[i_arg].list[1];
161 if (s_arg[i_arg].n_items != 2)
163 if ((strncasecmp(
"centralLine", s_arg[i_arg].list[1], strlen(s_arg[i_arg].list[1])) == 0) ||
164 (strncasecmp(
"centerLine", s_arg[i_arg].list[1], strlen(s_arg[i_arg].list[1])) == 0))
166 if (strncasecmp(
"integrated", s_arg[i_arg].list[1], strlen(s_arg[i_arg].list[1])) == 0)
168 if (strncasecmp(
"averaged", s_arg[i_arg].list[1], strlen(s_arg[i_arg].list[1])) == 0)
170 if (strncasecmp(
"peak", s_arg[i_arg].list[1], strlen(s_arg[i_arg].list[1])) == 0)
173 case SET_AREAOFINTEREST:
174 if (s_arg[i_arg].n_items != 5)
175 SDDS_Bomb(
"invalid -areaOfInterest syntax");
176 if (sscanf(s_arg[i_arg].list[1],
"%" SCNd64, &rowStart) != 1 || rowStart <= 0)
177 SDDS_Bomb(
"invalid -areaOfInterest syntax or value");
178 if (sscanf(s_arg[i_arg].list[2],
"%" SCNd64, &rowEnd) != 1 || rowEnd <= 0)
179 SDDS_Bomb(
"invalid -areaOfInterest syntax or value");
180 if (sscanf(s_arg[i_arg].list[3],
"%ld", &columnStart) != 1 || columnStart <= 0)
181 SDDS_Bomb(
"invalid -areaOfInterest syntax or value");
182 if (sscanf(s_arg[i_arg].list[4],
"%ld", &columnEnd) != 1 || columnEnd <= 0)
183 SDDS_Bomb(
"invalid -areaOfInterest syntax or value");
186 if (s_arg[i_arg].n_items != 2)
188 background = s_arg[i_arg].list[1];
191 if (!
processPipeOption(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1, &pipeFlags))
195 fprintf(stderr,
"error: unknown switch: %s\n", s_arg[i_arg].list[0]);
201 input = s_arg[i_arg].list[0];
202 else if (output == NULL)
203 output = s_arg[i_arg].list[0];
209 if (colPrefix == NULL) {
210 fprintf(stderr,
"error: missing columnPrefix\n");
214 processFilenames(
"sddsimageprofiles", &input, &output, pipeFlags, noWarnings, &tmpfile_used);
217 rows = GetData(&SDDS_orig, input, &data, &type, &colIndex, &colIndex2, colPrefix, &validColumns);
220 fprintf(stderr,
"error: no rows in image file\n");
224 if (background != NULL) {
226 bg_rows = GetData(&SDDS_bg, background, &bg_data, &bg_type, &bg_colIndex, &bg_colIndex2, colPrefix, &bg_validColumns);
227 if (rows != bg_rows) {
228 fprintf(stderr,
"error: background has a different number of rows\n");
231 if (validColumns != bg_validColumns) {
232 fprintf(stderr,
"error: background has a different number of columns\n");
236 for (i = 0; i < validColumns; i++) {
237 if (type[colIndex[i]] != bg_type[bg_colIndex[i]]) {
238 fprintf(stderr,
"error: column types don't match with background image\n");
241 if (colIndex2[i] != bg_colIndex2[i]) {
242 fprintf(stderr,
"error: image rows don't match with background image\n");
245 switch (type[colIndex[i]]) {
247 for (j = 0; j < rows; j++)
248 data[colIndex[i]].shortData[j] -= bg_data[bg_colIndex[i]].shortData[j];
251 for (j = 0; j < rows; j++)
252 data[colIndex[i]].ushortData[j] -= bg_data[bg_colIndex[i]].ushortData[j];
255 for (j = 0; j < rows; j++)
256 data[colIndex[i]].longData[j] -= bg_data[bg_colIndex[i]].longData[j];
259 for (j = 0; j < rows; j++)
260 data[colIndex[i]].ulongData[j] -= bg_data[bg_colIndex[i]].ulongData[j];
263 for (j = 0; j < rows; j++)
264 data[colIndex[i]].long64Data[j] -= bg_data[bg_colIndex[i]].long64Data[j];
267 for (j = 0; j < rows; j++)
268 data[colIndex[i]].ulong64Data[j] -= bg_data[bg_colIndex[i]].ulong64Data[j];
271 for (j = 0; j < rows; j++)
272 data[colIndex[i]].floatData[j] -= bg_data[bg_colIndex[i]].floatData[j];
275 for (j = 0; j < rows; j++)
276 data[colIndex[i]].doubleData[j] -= bg_data[bg_colIndex[i]].doubleData[j];
290 if (profileType == 1) {
322 if ((rowEnd > rows) || (rowEnd < rowStart))
325 if ((columnEnd > validColumns) || (columnEnd < columnStart))
326 columnEnd = validColumns;
328 if (profileType == 1) {
329 xImageProfile(data, type, rows, &SDDS_dataset, method, rowStart - 1, rowEnd, columnStart - 1, columnEnd, colIndex, colIndex2);
331 yImageProfile(data, type, rows, &SDDS_dataset, method, rowStart - 1, rowEnd, columnStart - 1, columnEnd, colIndex, colIndex2);
340 for (i = 0; i < validColumns; i++) {
341 switch (type[colIndex[i]]) {
343 free(data[colIndex[i]].shortData);
346 free(data[colIndex[i]].ushortData);
349 free(data[colIndex[i]].longData);
352 free(data[colIndex[i]].ulongData);
355 free(data[colIndex[i]].long64Data);
358 free(data[colIndex[i]].ulong64Data);
361 free(data[colIndex[i]].floatData);
364 free(data[colIndex[i]].doubleData);
372 if (background != NULL) {
373 for (i = 0; i < validColumns; i++) {
374 switch (bg_type[bg_colIndex[i]]) {
376 free(bg_data[bg_colIndex[i]].shortData);
379 free(bg_data[bg_colIndex[i]].ushortData);
382 free(bg_data[bg_colIndex[i]].longData);
385 free(bg_data[bg_colIndex[i]].ulongData);
388 free(bg_data[bg_colIndex[i]].long64Data);
391 free(bg_data[bg_colIndex[i]].ulong64Data);
394 free(bg_data[bg_colIndex[i]].floatData);
397 free(bg_data[bg_colIndex[i]].doubleData);
411 int64_t x1, int64_t x2,
long y1,
long y2,
long *colIndex,
double *colIndex2) {
419 index = malloc(
sizeof(int64_t) * rows);
420 values = malloc(
sizeof(
double) * rows);
423 for (i = x1; i < x2; i++) {
424 switch (type[colIndex[y1]]) {
426 val = data[colIndex[y1]].shortData[i];
429 val = data[colIndex[y1]].ushortData[i];
432 val = data[colIndex[y1]].longData[i];
435 val = data[colIndex[y1]].ulongData[i];
438 val = data[colIndex[y1]].long64Data[i];
441 val = data[colIndex[y1]].ulong64Data[i];
444 val = data[colIndex[y1]].floatData[i];
447 val = data[colIndex[y1]].doubleData[i];
450 for (j = y1 + 1; j < y2; j++) {
451 switch (type[colIndex[j]]) {
453 if (val < data[colIndex[j]].shortData[i])
454 val = data[colIndex[j]].shortData[i];
457 if (val < data[colIndex[j]].ushortData[i])
458 val = data[colIndex[j]].ushortData[i];
461 if (val < data[colIndex[j]].longData[i])
462 val = data[colIndex[j]].longData[i];
465 if (val < data[colIndex[j]].ulongData[i])
466 val = data[colIndex[j]].ulongData[i];
469 if (val < data[colIndex[j]].long64Data[i])
470 val = data[colIndex[j]].long64Data[i];
473 if (val < data[colIndex[j]].ulong64Data[i])
474 val = data[colIndex[j]].ulong64Data[i];
477 if (val < data[colIndex[j]].floatData[i])
478 val = data[colIndex[j]].floatData[i];
481 if (val < data[colIndex[j]].doubleData[i])
482 val = data[colIndex[j]].doubleData[i];
490 }
else if ((method == 1) || (method == 4)) {
492 center = yPeakLine(data, type, colIndex, x1, x2, y1, y2);
494 center = yCenterLine(data, type, colIndex, x1, x2, y1, y2);
496 for (i = x1; i < x2; i++) {
497 switch (type[colIndex[center]]) {
499 val = data[colIndex[center]].shortData[i];
502 val = data[colIndex[center]].ushortData[i];
505 val = data[colIndex[center]].longData[i];
508 val = data[colIndex[center]].ulongData[i];
511 val = data[colIndex[center]].long64Data[i];
514 val = data[colIndex[center]].ulong64Data[i];
517 val = data[colIndex[center]].floatData[i];
520 val = data[colIndex[center]].doubleData[i];
527 }
else if ((method == 2) || (method == 3)) {
528 for (i = x1; i < x2; i++) {
530 for (j = y1; j < y2; j++) {
531 switch (type[colIndex[j]]) {
533 val += data[colIndex[j]].shortData[i];
536 val += data[colIndex[j]].ushortData[i];
539 val += data[colIndex[j]].longData[i];
542 val += data[colIndex[j]].ulongData[i];
545 val += data[colIndex[j]].long64Data[i];
548 val += data[colIndex[j]].ulong64Data[i];
551 val += data[colIndex[j]].floatData[i];
554 val += data[colIndex[j]].doubleData[i];
562 values[k] = val / (y2 - y1);
571 sprintf(value,
"(%" PRId64
",%ld) x (%" PRId64
",%ld)", x1 + 1, y1 + 1, x2, y2);
572 if (
SDDS_SetParameters(SDDS_dataset, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE,
"Zone", value, NULL) != 1) {
576 if (
SDDS_SetColumn(SDDS_dataset, SDDS_SET_BY_NAME, index, k,
"x", NULL) != 1) {
580 if (
SDDS_SetColumn(SDDS_dataset, SDDS_SET_BY_NAME, values, k,
"y", NULL) != 1) {
594 int64_t x1, int64_t x2,
long y1,
long y2,
long *colIndex,
double *colIndex2) {
604 index = malloc(
sizeof(
double) * (y2 - y1));
605 values = malloc(
sizeof(
double) * (y2 - y1));
608 for (i = y1; i < y2; i++) {
609 switch (type[colIndex[i]]) {
611 val = data[colIndex[i]].shortData[x1];
614 val = data[colIndex[i]].ushortData[x1];
617 val = data[colIndex[i]].longData[x1];
620 val = data[colIndex[i]].ulongData[x1];
623 val = data[colIndex[i]].long64Data[x1];
626 val = data[colIndex[i]].ulong64Data[x1];
629 val = data[colIndex[i]].floatData[x1];
632 val = data[colIndex[i]].doubleData[x1];
637 for (j = x1 + 1; j < x2; j++) {
638 switch (type[colIndex[i]]) {
640 if (val < data[colIndex[i]].shortData[j]) {
641 val = data[colIndex[i]].shortData[j];
645 if (val < data[colIndex[i]].ushortData[j]) {
646 val = data[colIndex[i]].ushortData[j];
650 if (val < data[colIndex[i]].longData[j]) {
651 val = data[colIndex[i]].longData[j];
655 if (val < data[colIndex[i]].ulongData[j]) {
656 val = data[colIndex[i]].ulongData[j];
660 if (val < data[colIndex[i]].long64Data[j]) {
661 val = data[colIndex[i]].long64Data[j];
665 if (val < data[colIndex[i]].ulong64Data[j]) {
666 val = data[colIndex[i]].ulong64Data[j];
670 if (val < data[colIndex[i]].floatData[j]) {
671 val = data[colIndex[i]].floatData[j];
675 if (val < data[colIndex[i]].doubleData[j]) {
676 val = data[colIndex[i]].doubleData[j];
683 index[k] = colIndex2[i];
687 }
else if ((method == 1) || (method == 4)) {
689 center = xPeakLine(data, type, colIndex, x1, x2, y1, y2);
691 center = xCenterLine(data, type, colIndex, x1, x2, y1, y2);
693 for (i = y1; i < y2; i++) {
694 switch (type[colIndex[i]]) {
696 val = data[colIndex[i]].shortData[center];
699 val = data[colIndex[i]].ushortData[center];
702 val = data[colIndex[i]].longData[center];
705 val = data[colIndex[i]].ulongData[center];
708 val = data[colIndex[i]].long64Data[center];
711 val = data[colIndex[i]].ulong64Data[center];
714 val = data[colIndex[i]].floatData[center];
717 val = data[colIndex[i]].doubleData[center];
722 index[k] = colIndex2[i];
726 }
else if ((method == 2) || (method == 3)) {
727 for (i = y1; i < y2; i++) {
729 switch (type[colIndex[i]]) {
731 for (j = x1; j < x2; j++)
732 val += data[colIndex[i]].shortData[j];
735 for (j = x1; j < x2; j++)
736 val += data[colIndex[i]].ushortData[j];
739 for (j = x1; j < x2; j++)
740 val += data[colIndex[i]].longData[j];
743 for (j = x1; j < x2; j++)
744 val += data[colIndex[i]].ulongData[j];
747 for (j = x1; j < x2; j++)
748 val += data[colIndex[i]].long64Data[j];
751 for (j = x1; j < x2; j++)
752 val += data[colIndex[i]].ulong64Data[j];
755 for (j = x1; j < x2; j++)
756 val += data[colIndex[i]].floatData[j];
759 for (j = x1; j < x2; j++)
760 val += data[colIndex[i]].doubleData[j];
765 index[k] = colIndex2[i];
769 values[k] = val / (x2 - x1);
778 sprintf(value,
"(%" PRId64
",%ld) x (%" PRId64
",%ld)", x1 + 1, y1 + 1, x2, y2);
779 if (
SDDS_SetParameters(SDDS_dataset, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE,
"Zone", value, NULL) != 1) {
783 if (
SDDS_SetColumn(SDDS_dataset, SDDS_SET_BY_NAME, index, k,
"y", NULL) != 1) {
787 if (
SDDS_SetColumn(SDDS_dataset, SDDS_SET_BY_NAME, values, k,
"x", NULL) != 1) {
800int64_t xPeakLine(
IMAGE_DATA *data, int32_t *type,
long *colIndex, int64_t x1, int64_t x2,
long y1,
long y2) {
806 switch (type[colIndex[y1]]) {
808 maxValue = data[colIndex[y1]].shortData[x1];
811 maxValue = data[colIndex[y1]].ushortData[x1];
814 maxValue = data[colIndex[y1]].longData[x1];
817 maxValue = data[colIndex[y1]].ulongData[x1];
820 maxValue = data[colIndex[y1]].long64Data[x1];
823 maxValue = data[colIndex[y1]].ulong64Data[x1];
826 maxValue = data[colIndex[y1]].floatData[x1];
829 maxValue = data[colIndex[y1]].doubleData[x1];
832 for (i = y1; i < y2; i++) {
833 for (j = x1; j < x2; j++) {
834 switch (type[colIndex[i]]) {
836 if (maxValue < data[colIndex[i]].shortData[j]) {
837 maxValue = data[colIndex[i]].shortData[j];
842 if (maxValue < data[colIndex[i]].ushortData[j]) {
843 maxValue = data[colIndex[i]].ushortData[j];
848 if (maxValue < data[colIndex[i]].longData[j]) {
849 maxValue = data[colIndex[i]].longData[j];
854 if (maxValue < data[colIndex[i]].ulongData[j]) {
855 maxValue = data[colIndex[i]].ulongData[j];
860 if (maxValue < data[colIndex[i]].long64Data[j]) {
861 maxValue = data[colIndex[i]].long64Data[j];
866 if (maxValue < data[colIndex[i]].ulong64Data[j]) {
867 maxValue = data[colIndex[i]].ulong64Data[j];
872 if (maxValue < data[colIndex[i]].floatData[j]) {
873 maxValue = data[colIndex[i]].floatData[j];
878 if (maxValue < data[colIndex[i]].doubleData[j]) {
879 maxValue = data[colIndex[i]].doubleData[j];
889long yPeakLine(
IMAGE_DATA *data, int32_t *type,
long *colIndex, int64_t x1, int64_t x2,
long y1,
long y2) {
896 switch (type[colIndex[y1]]) {
898 maxValue = data[colIndex[y1]].shortData[x1];
901 maxValue = data[colIndex[y1]].ushortData[x1];
904 maxValue = data[colIndex[y1]].longData[x1];
907 maxValue = data[colIndex[y1]].ulongData[x1];
910 maxValue = data[colIndex[y1]].long64Data[x1];
913 maxValue = data[colIndex[y1]].ulong64Data[x1];
916 maxValue = data[colIndex[y1]].floatData[x1];
919 maxValue = data[colIndex[y1]].doubleData[x1];
922 for (i = y1; i < y2; i++) {
923 for (j = x1; j < x2; j++) {
924 switch (type[colIndex[i]]) {
926 if (maxValue < data[colIndex[i]].shortData[j]) {
927 maxValue = data[colIndex[i]].shortData[j];
932 if (maxValue < data[colIndex[i]].ushortData[j]) {
933 maxValue = data[colIndex[i]].ushortData[j];
938 if (maxValue < data[colIndex[i]].longData[j]) {
939 maxValue = data[colIndex[i]].longData[j];
944 if (maxValue < data[colIndex[i]].ulongData[j]) {
945 maxValue = data[colIndex[i]].ulongData[j];
950 if (maxValue < data[colIndex[i]].long64Data[j]) {
951 maxValue = data[colIndex[i]].long64Data[j];
956 if (maxValue < data[colIndex[i]].ulong64Data[j]) {
957 maxValue = data[colIndex[i]].ulong64Data[j];
962 if (maxValue < data[colIndex[i]].floatData[j]) {
963 maxValue = data[colIndex[i]].floatData[j];
968 if (maxValue < data[colIndex[i]].doubleData[j]) {
969 maxValue = data[colIndex[i]].doubleData[j];
979int64_t xCenterLine(
IMAGE_DATA *data, int32_t *type,
long *colIndex, int64_t x1, int64_t x2,
long y1,
long y2) {
980 int64_t i, j, start = 1;
981 double val = 0, maxValue = 0;
984 for (i = x1; i < x2; i++) {
986 for (j = y1; j < y2; j++) {
987 switch (type[colIndex[j]]) {
989 val += data[colIndex[j]].shortData[i];
992 val += data[colIndex[j]].ushortData[i];
995 val += data[colIndex[j]].longData[i];
998 val += data[colIndex[j]].ulongData[i];
1001 val += data[colIndex[j]].long64Data[i];
1004 val += data[colIndex[j]].ulong64Data[i];
1007 val += data[colIndex[j]].floatData[i];
1010 val += data[colIndex[j]].doubleData[i];
1019 if (val > maxValue) {
1028long yCenterLine(
IMAGE_DATA *data, int32_t *type,
long *colIndex, int64_t x1, int64_t x2,
long y1,
long y2) {
1031 double val, maxValue = 0;
1034 for (i = y1; i < y2; i++) {
1036 for (j = x1; j < x2; j++)
1037 switch (type[colIndex[i]]) {
1039 val += data[colIndex[i]].shortData[j];
1042 val += data[colIndex[i]].ushortData[j];
1045 val += data[colIndex[i]].longData[j];
1048 val += data[colIndex[i]].ulongData[j];
1051 val += data[colIndex[i]].long64Data[j];
1054 val += data[colIndex[i]].ulong64Data[j];
1057 val += data[colIndex[i]].floatData[j];
1060 val += data[colIndex[i]].doubleData[j];
1070 if (val > maxValue) {
1080 double **colIndex2,
char *colPrefix,
long *validColumns) {
1084 int32_t orig_column_names;
1085 char **orig_column_name;
1100 *data = malloc(
sizeof(
IMAGE_DATA) * orig_column_names);
1101 *type = malloc(
sizeof(int32_t) * orig_column_names);
1110 rows = SDDS_RowCount(SDDS_orig);
1111 *colIndex = malloc(
sizeof(
long) * orig_column_names);
1112 *colIndex2 = malloc(
sizeof(
double) * orig_column_names);
1115 for (i = 0; i < orig_column_names; i++) {
1117 if ((*type)[i] == 0) {
1122 switch ((*type)[i]) {
1124 (*data)[i].shortData =
SDDS_GetColumn(SDDS_orig, orig_column_name[i]);
1127 (*data)[i].ushortData =
SDDS_GetColumn(SDDS_orig, orig_column_name[i]);
1130 (*data)[i].longData =
SDDS_GetColumn(SDDS_orig, orig_column_name[i]);
1133 (*data)[i].ulongData =
SDDS_GetColumn(SDDS_orig, orig_column_name[i]);
1136 (*data)[i].long64Data =
SDDS_GetColumn(SDDS_orig, orig_column_name[i]);
1139 (*data)[i].ulong64Data =
SDDS_GetColumn(SDDS_orig, orig_column_name[i]);
1142 (*data)[i].floatData =
SDDS_GetColumn(SDDS_orig, orig_column_name[i]);
1145 (*data)[i].doubleData =
SDDS_GetColumn(SDDS_orig, orig_column_name[i]);
1150 if (strncmp(colPrefix, orig_column_name[i], strlen(colPrefix)) != 0) {
1153 (*colIndex)[*validColumns] = i;
1162 if (*validColumns == 0) {
1163 fprintf(stderr,
"error: no valid columns in image file\n");
1167 for (i = 0; i < *validColumns; i++) {
1168 (*colIndex2)[i] = atof(orig_column_name[(*colIndex)[i]] + strlen(colPrefix));
1171 for (i = 0; i < *validColumns; i++) {
1172 for (j = i + 1; j < *validColumns; j++) {
1173 if ((*colIndex2)[j] < (*colIndex2)[i]) {
1174 temp = (*colIndex)[i];
1175 temp2 = (*colIndex2)[i];
1176 (*colIndex)[i] = (*colIndex)[j];
1177 (*colIndex2)[i] = (*colIndex2)[j];
1178 (*colIndex)[j] = temp;
1179 (*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)