1 /*********************************************************************
2 Table - View and manipulate a FITS table structures.
3 Table is part of GNU Astronomy Utilities (Gnuastro) package.
4 
5 Original author:
6      Mohammad Akhlaghi <mohammad@akhlaghi.org>
7 Contributing author(s):
8 Copyright (C) 2016-2021, Free Software Foundation, Inc.
9 
10 Gnuastro is free software: you can redistribute it and/or modify it
11 under the terms of the GNU General Public License as published by the
12 Free Software Foundation, either version 3 of the License, or (at your
13 option) any later version.
14 
15 Gnuastro is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
22 **********************************************************************/
23 #ifndef ARGS_H
24 #define ARGS_H
25 
26 
27 
28 
29 
30 
31 /* Array of acceptable options. */
32 struct argp_option program_options[] =
33   {
34     {
35       "column",
36       UI_KEY_COLUMN,
37       "STR",
38       0,
39       "Column number (counting from 1) or search string.",
40       GAL_OPTIONS_GROUP_INPUT,
41       &p->columns,
42       GAL_TYPE_STRLL,
43       GAL_OPTIONS_RANGE_ANY,
44       GAL_OPTIONS_NOT_MANDATORY,
45       GAL_OPTIONS_NOT_SET
46     },
47     {
48       "wcsfile",
49       UI_KEY_WCSFILE,
50       "FITS",
51       0,
52       "File with WCS if conversion is requested.",
53       GAL_OPTIONS_GROUP_INPUT,
54       &p->wcsfile,
55       GAL_TYPE_STRING,
56       GAL_OPTIONS_RANGE_ANY,
57       GAL_OPTIONS_NOT_MANDATORY,
58       GAL_OPTIONS_NOT_SET
59     },
60     {
61       "wcshdu",
62       UI_KEY_WCSHDU,
63       "STR",
64       0,
65       "HDU in file with WCS for conversion.",
66       GAL_OPTIONS_GROUP_INPUT,
67       &p->wcshdu,
68       GAL_TYPE_STRING,
69       GAL_OPTIONS_RANGE_ANY,
70       GAL_OPTIONS_NOT_MANDATORY,
71       GAL_OPTIONS_NOT_SET
72     },
73     {
74       "catcolumnfile",
75       UI_KEY_CATCOLUMNFILE,
76       "FITS/TXT",
77       0,
78       "File(s) to be concatenated by column.",
79       GAL_OPTIONS_GROUP_INPUT,
80       &p->catcolumnfile,
81       GAL_TYPE_STRLL,
82       GAL_OPTIONS_RANGE_ANY,
83       GAL_OPTIONS_NOT_MANDATORY,
84       GAL_OPTIONS_NOT_SET
85     },
86     {
87       "catcolumnhdu",
88       UI_KEY_CATCOLUMNHDU,
89       "STR/INT",
90       0,
91       "HDU/Extension(s) in catcolumnfile.",
92       GAL_OPTIONS_GROUP_INPUT,
93       &p->catcolumnhdu,
94       GAL_TYPE_STRLL,
95       GAL_OPTIONS_RANGE_ANY,
96       GAL_OPTIONS_NOT_MANDATORY,
97       GAL_OPTIONS_NOT_SET
98     },
99     {
100       "catcolumns",
101       UI_KEY_CATCOLUMNS,
102       "STR",
103       0,
104       "Columns to use in catcolumnfile.",
105       GAL_OPTIONS_GROUP_INPUT,
106       &p->catcolumns,
107       GAL_TYPE_STRLL,
108       GAL_OPTIONS_RANGE_ANY,
109       GAL_OPTIONS_NOT_MANDATORY,
110       GAL_OPTIONS_NOT_SET
111     },
112 
113 
114 
115 
116 
117     /* Output. */
118     {
119       "information",
120       UI_KEY_INFORMATION,
121       0,
122       0,
123       "Only print table and column information.",
124       GAL_OPTIONS_GROUP_OUTPUT,
125       &p->information,
126       GAL_OPTIONS_NO_ARG_TYPE,
127       GAL_OPTIONS_RANGE_0_OR_1,
128       GAL_OPTIONS_NOT_MANDATORY,
129       GAL_OPTIONS_NOT_SET
130     },
131     {
132       "colinfoinstdout",
133       UI_KEY_COLINFOINSTDOUT,
134       0,
135       0,
136       "Column info/metadata when printing to stdout.",
137       GAL_OPTIONS_GROUP_OUTPUT,
138       &p->colinfoinstdout,
139       GAL_OPTIONS_NO_ARG_TYPE,
140       GAL_OPTIONS_RANGE_0_OR_1,
141       GAL_OPTIONS_NOT_MANDATORY,
142       GAL_OPTIONS_NOT_SET
143     },
144     {
145       "catcolumnrawname",
146       UI_KEY_CATCOLUMNRAWNAME,
147       0,
148       0,
149       "Don't touch column names of --catcolumnfile.",
150       GAL_OPTIONS_GROUP_OUTPUT,
151       &p->catcolumnrawname,
152       GAL_OPTIONS_NO_ARG_TYPE,
153       GAL_OPTIONS_RANGE_0_OR_1,
154       GAL_OPTIONS_NOT_MANDATORY,
155       GAL_OPTIONS_NOT_SET
156     },
157     {
158       "colmetadata",
159       UI_KEY_COLMETADATA,
160       "STR,STR[,STR,STR]",
161       0,
162       "Update output metadata (name, unit, comments).",
163       GAL_OPTIONS_GROUP_OUTPUT,
164       &p->colmetadata,
165       GAL_TYPE_STRING,
166       GAL_OPTIONS_RANGE_ANY,
167       GAL_OPTIONS_NOT_MANDATORY,
168       GAL_OPTIONS_NOT_SET,
169       gal_options_parse_name_and_strings
170     },
171 
172 
173 
174 
175 
176     /* Output Rows */
177     {
178       0, 0, 0, 0,
179       "Rows in output:",
180       UI_GROUP_OUTROWS
181     },
182     {
183       "range",
184       UI_KEY_RANGE,
185       "STR,FLT:FLT",
186       0,
187       "Column, and range to limit output.",
188       UI_GROUP_OUTROWS,
189       &p->range,
190       GAL_TYPE_STRING,
191       GAL_OPTIONS_RANGE_ANY,
192       GAL_OPTIONS_NOT_MANDATORY,
193       GAL_OPTIONS_NOT_SET,
194       gal_options_parse_name_and_float64s
195     },
196     {
197       "inpolygon",
198       UI_KEY_INPOLYGON,
199       "STR,STR",
200       0,
201       "Coord. columns that are inside '--polygon'.",
202       GAL_OPTIONS_GROUP_INPUT,
203       &p->inpolygon,
204       GAL_TYPE_STRING,
205       GAL_OPTIONS_RANGE_ANY,
206       GAL_OPTIONS_NOT_MANDATORY,
207       GAL_OPTIONS_NOT_SET,
208       gal_options_parse_csv_strings
209     },
210     {
211       "outpolygon",
212       UI_KEY_OUTPOLYGON,
213       "STR,STR",
214       0,
215       "Coord. columns that are outside '--polygon'.",
216       GAL_OPTIONS_GROUP_INPUT,
217       &p->outpolygon,
218       GAL_TYPE_STRING,
219       GAL_OPTIONS_RANGE_ANY,
220       GAL_OPTIONS_NOT_MANDATORY,
221       GAL_OPTIONS_NOT_SET,
222       gal_options_parse_csv_strings
223     },
224     {
225       "polygon",
226       UI_KEY_POLYGON,
227       "FLT,FLT[:...]",
228       0,
229       "Polygon vertices, also a DS9 region file.",
230       UI_GROUP_OUTROWS,
231       &p->polygon,
232       GAL_TYPE_STRING,
233       GAL_OPTIONS_RANGE_ANY,
234       GAL_OPTIONS_NOT_MANDATORY,
235       GAL_OPTIONS_NOT_SET,
236       gal_options_parse_colon_sep_csv
237     },
238     {
239       "equal",
240       UI_KEY_EQUAL,
241       "STR,FLT[,...]",
242       0,
243       "Column, values to keep in output.",
244       UI_GROUP_OUTROWS,
245       &p->equal,
246       GAL_TYPE_STRING,
247       GAL_OPTIONS_RANGE_ANY,
248       GAL_OPTIONS_NOT_MANDATORY,
249       GAL_OPTIONS_NOT_SET,
250       gal_options_parse_name_and_strings
251     },
252     {
253       "notequal",
254       UI_KEY_NOTEQUAL,
255       "STR,FLT[,...]",
256       0,
257       "Column, values to remove from output.",
258       UI_GROUP_OUTROWS,
259       &p->notequal,
260       GAL_TYPE_STRING,
261       GAL_OPTIONS_RANGE_ANY,
262       GAL_OPTIONS_NOT_MANDATORY,
263       GAL_OPTIONS_NOT_SET,
264       gal_options_parse_name_and_strings
265     },
266     {
267       "sort",
268       UI_KEY_SORT,
269       "STR/INT",
270       0,
271       "Column name or number for sorting.",
272       UI_GROUP_OUTROWS,
273       &p->sort,
274       GAL_TYPE_STRING,
275       GAL_OPTIONS_RANGE_ANY,
276       GAL_OPTIONS_NOT_MANDATORY,
277       GAL_OPTIONS_NOT_SET
278     },
279     {
280       "descending",
281       UI_KEY_DESCENDING,
282       0,
283       0,
284       "Sort in descending order: largets first.",
285       UI_GROUP_OUTROWS,
286       &p->descending,
287       GAL_OPTIONS_NO_ARG_TYPE,
288       GAL_OPTIONS_RANGE_0_OR_1,
289       GAL_OPTIONS_NOT_MANDATORY,
290       GAL_OPTIONS_NOT_SET
291     },
292     {
293       "head",
294       UI_KEY_HEAD,
295       "INT",
296       0,
297       "Only output given number of top rows.",
298       UI_GROUP_OUTROWS,
299       &p->head,
300       GAL_TYPE_SIZE_T,
301       GAL_OPTIONS_RANGE_GE_0,
302       GAL_OPTIONS_NOT_MANDATORY,
303       GAL_OPTIONS_NOT_SET
304     },
305     {
306       "tail",
307       UI_KEY_TAIL,
308       "INT",
309       0,
310       "Only output given number of bottom rows.",
311       UI_GROUP_OUTROWS,
312       &p->tail,
313       GAL_TYPE_SIZE_T,
314       GAL_OPTIONS_RANGE_GE_0,
315       GAL_OPTIONS_NOT_MANDATORY,
316       GAL_OPTIONS_NOT_SET
317     },
318     {
319       "rowlimit",
320       UI_KEY_ROWLIMIT,
321       "INT,INT",
322       0,
323       "Only rows in this row-counter range.",
324       UI_GROUP_OUTROWS,
325       &p->rowlimit,
326       GAL_TYPE_STRING,
327       GAL_OPTIONS_RANGE_GE_0,
328       GAL_OPTIONS_NOT_MANDATORY,
329       GAL_OPTIONS_NOT_SET,
330       gal_options_parse_csv_float64
331     },
332     {
333       "rowrandom",
334       UI_KEY_ROWRANDOM,
335       "INT",
336       0,
337       "Number of rows to select randomly.",
338       UI_GROUP_OUTROWS,
339       &p->rowrandom,
340       GAL_TYPE_SIZE_T,
341       GAL_OPTIONS_RANGE_GE_0,
342       GAL_OPTIONS_NOT_MANDATORY,
343       GAL_OPTIONS_NOT_SET,
344     },
345     {
346       "envseed",
347       UI_KEY_ENVSEED,
348       0,
349       0,
350       "Use GSL_RNG_SEED env. for '--rowrandom'.",
351       UI_GROUP_OUTROWS,
352       &p->envseed,
353       GAL_OPTIONS_NO_ARG_TYPE,
354       GAL_OPTIONS_RANGE_0_OR_1,
355       GAL_OPTIONS_NOT_MANDATORY,
356       GAL_OPTIONS_NOT_SET
357     },
358     {
359       "noblank",
360       UI_KEY_NOBLANK,
361       "STR[,STR]",
362       0,
363       "Remove rows with blank in given columns.",
364       GAL_OPTIONS_GROUP_INPUT,
365       &p->noblank,
366       GAL_TYPE_STRING,
367       GAL_OPTIONS_RANGE_ANY,
368       GAL_OPTIONS_NOT_MANDATORY,
369       GAL_OPTIONS_NOT_SET,
370       gal_options_parse_csv_strings
371     },
372 
373 
374 
375 
376 
377     /* End. */
378     {0}
379   };
380 
381 
382 
383 
384 
385 /* Define the child argp structure. */
386 struct argp
387 gal_options_common_child = {gal_commonopts_options,
388                             gal_options_common_argp_parse,
389                             NULL, NULL, NULL, NULL, NULL};
390 
391 /* Use the child argp structure in list of children (only one for now). */
392 struct argp_child
393 children[]=
394 {
395   {&gal_options_common_child, 0, NULL, 0},
396   {0, 0, 0, 0}
397 };
398 
399 /* Set all the necessary argp parameters. */
400 struct argp
401 thisargp = {program_options, parse_opt, args_doc, doc, children, NULL, NULL};
402 #endif
403