95 {
96 int iArg;
97 char *indepQuantity, **depenQuantity, **exclude = NULL;
98 long depenQuantities, excludes = 0;
99 char *input, *output;
100 long i, readCode;
101 int64_t rows;
102 int32_t page = 0;
103 unsigned long pipeFlags, majorOrderFlag;
104 SCANNED_ARG *scanned;
106 short columnMajorOrder = -1;
107 double unwrapLimit = 0;
108
110 argc =
scanargs(&scanned, argc, argv);
111 if (argc < 3) {
112 fprintf(stderr, "%s\n", USAGE);
113 exit(EXIT_FAILURE);
114 }
115
116 output = input = NULL;
117 pipeFlags = 0;
118 indepQuantity = NULL;
119 depenQuantity = NULL;
120 depenQuantities = 0;
121
122 for (iArg = 1; iArg < argc; iArg++) {
123 if (scanned[iArg].arg_type == OPTION) {
124
125 switch (
match_string(scanned[iArg].list[0], option, N_OPTIONS, 0)) {
126 case SET_COLUMN:
127 if (indepQuantity)
128 SDDS_Bomb(
"Only one -columns option may be given");
129 if (scanned[iArg].n_items < 2)
131 indepQuantity = scanned[iArg].list[1];
132 if (scanned[iArg].n_items >= 2) {
133 depenQuantity =
tmalloc(
sizeof(*depenQuantity) * (depenQuantities = scanned[iArg].n_items - 2));
134 for (i = 0; i < depenQuantities; i++)
135 depenQuantity[i] = scanned[iArg].list[i + 2];
136 }
137 break;
138
139 case SET_PIPE:
140 if (!
processPipeOption(scanned[iArg].list + 1, scanned[iArg].n_items - 1, &pipeFlags))
142 break;
143
144 case SET_MAJOR_ORDER:
145 majorOrderFlag = 0;
146 scanned[iArg].n_items--;
147 if (scanned[iArg].n_items > 0 &&
148 !
scanItemList(&majorOrderFlag, scanned[iArg].list + 1, &scanned[iArg].n_items, 0,
149 "row", -1, NULL, 0, SDDS_ROW_MAJOR_ORDER,
150 "column", -1, NULL, 0, SDDS_COLUMN_MAJOR_ORDER, NULL))
151 SDDS_Bomb(
"Invalid -majorOrder syntax/values");
152 if (majorOrderFlag & SDDS_COLUMN_MAJOR_ORDER)
153 columnMajorOrder = 1;
154 else if (majorOrderFlag & SDDS_ROW_MAJOR_ORDER)
155 columnMajorOrder = 0;
156 break;
157
158 case SET_UNWRAP_LIMIT:
159 if (scanned[iArg].n_items != 2)
160 SDDS_Bomb(
"Invalid -unwrapLimit syntax/values");
161 if (!
get_double(&unwrapLimit, scanned[iArg].list[1]))
162 SDDS_Bomb(
"Invalid -unwrapLimit syntax/values");
163 break;
164
165 default:
166 fprintf(stderr, "Error: Unknown or ambiguous option: %s\n", scanned[iArg].list[0]);
167 exit(EXIT_FAILURE);
168 break;
169 }
170 } else {
171 if (!input)
172 input = scanned[iArg].list[0];
173 else if (!output)
174 output = scanned[iArg].list[0];
175 else
176 SDDS_Bomb(
"Too many filenames provided");
177 }
178 }
179
180 processFilenames(
"sddsanalyticsignal", &input, &output, pipeFlags, 0, NULL);
181
182 if (!indepQuantity)
183 SDDS_Bomb(
"Supply the independent quantity name with the -columns option");
184
187
189 exit(EXIT_FAILURE);
190
191 excludes = appendToStringArray(&exclude, excludes, indepQuantity);
192
193 if (!depenQuantities)
194 depenQuantities = appendToStringArray(&depenQuantity, depenQuantities, "*");
195
196 if ((depenQuantities = expandColumnPairNames(&SDDSin, &depenQuantity, NULL, depenQuantities,
197 exclude, excludes, FIND_NUMERIC_TYPE, 0)) <= 0) {
199 SDDS_Bomb(
"No quantities selected to FFT");
200 }
201
202#if 0
203 fprintf(stderr, "%ld dependent quantities:\n", depenQuantities);
204 for (i = 0; i < depenQuantities; i++)
205 fprintf(stderr, " %s\n", depenQuantity[i]);
206#endif
207
210
211 if (columnMajorOrder != -1)
212 SDDSout.layout.data_mode.column_major = columnMajorOrder;
213 else
214 SDDSout.layout.data_mode.column_major = SDDSin.layout.data_mode.column_major;
215
216 for (i = 0; i < depenQuantities; i++) {
217 if (!create_fft_columns(&SDDSout, &SDDSin, depenQuantity[i])) {
219 fprintf(stderr, "Error creating output column for %s\n", depenQuantity[i]);
220 exit(EXIT_FAILURE);
221 }
222 }
223
226
228 page++;
231 if (rows) {
234 for (i = 0; i < depenQuantities; i++) {
235 if (!process_data(&SDDSout, &SDDSin, rows, depenQuantity[i], unwrapLimit)) {
237 exit(EXIT_FAILURE);
238 }
239 }
240 } else {
243 }
246 }
247
250 exit(EXIT_FAILURE);
251 }
252
255 exit(EXIT_FAILURE);
256 }
257
258
259
260 return EXIT_SUCCESS;
261}
int32_t SDDS_CopyParameters(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source)
int32_t SDDS_InitializeCopy(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source, char *filename, char *filemode)
int32_t SDDS_CopyPage(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source)
int32_t SDDS_StartPage(SDDS_DATASET *SDDS_dataset, int64_t expected_n_rows)
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_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.
#define SDDS_ANY_NUMERIC_TYPE
Special identifier used by SDDS_Check*() routines to accept any numeric 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.
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)
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.