1 /*********************************************************************
2 Statistics - Statistical analysis on input dataset.
3 Statistics 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) 2015-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 MAIN_H
24 #define MAIN_H
25 
26 /* Include necessary headers */
27 #include <gnuastro/data.h>
28 
29 #include <gnuastro-internal/options.h>
30 
31 /* Progarm names.  */
32 #define PROGRAM_NAME   "Statistics"    /* Program full name.       */
33 #define PROGRAM_EXEC   "aststatistics" /* Program executable name. */
34 #define PROGRAM_STRING PROGRAM_NAME" (" PACKAGE_NAME ") " PACKAGE_VERSION
35 
36 
37 
38 
39 
40 /* Input formats. */
41 enum statistics_input_format
42   {
43     INPUT_FORMAT_INVALID,
44 
45     INPUT_FORMAT_TABLE,
46     INPUT_FORMAT_IMAGE,
47   };
48 
49 
50 
51 
52 
53 /* Main program parameters structure */
54 struct statisticsparams
55 {
56   /* From command-line */
57   struct gal_options_common_params cp; /* Common parameters.             */
58   gal_list_i32_t         *singlevalue; /* Single value calculations.     */
59   gal_list_f64_t  *tp_args;  /* Arguments for printing.                  */
60   char          *inputname;  /* Input filename.                          */
61   gal_list_str_t  *columns;  /* Column name or number if input is table. */
62   char             *refcol;  /* Reference column name or number.         */
63   float       greaterequal;  /* Only use values >= this value.           */
64   float      greaterequal2;  /* Only use values >= this value (2D hist). */
65   float           lessthan;  /* Only use values <  this value.           */
66   float          lessthan2;  /* Only use values <  this value (2D hist). */
67   float           quantmin;  /* Quantile min or range: from Q to 1-Q.    */
68   float           quantmax;  /* Quantile maximum.                        */
69   uint8_t           ontile;  /* Do single value calculations on tiles.   */
70   uint8_t      interpolate;  /* Use interpolation to fill blank tiles.   */
71 
72   uint8_t        asciihist;  /* Print an ASCII histogram.                */
73   uint8_t         asciicfp;  /* Print an ASCII cumulative frequency plot.*/
74   uint8_t        histogram;  /* Save histogram in output.                */
75   char        *histogram2d;  /* Save 2D-histogram as image or table.     */
76   uint8_t       cumulative;  /* Save cumulative distibution in output.   */
77   double            mirror;  /* Mirror value for hist and CFP.           */
78   uint8_t              sky;  /* Find the Sky value over the image.       */
79   uint8_t        sigmaclip;  /* So sigma-clipping over all dataset.      */
80   gal_data_t      *contour;  /* Levels to show contours.                 */
81 
82   size_t           numbins;  /* Number of bins in histogram or CFP.      */
83   size_t          numbins2;  /* No. of second-dim bins in 2D histogram.  */
84   size_t      numasciibins;  /* Number of bins in ASCII plots.           */
85   size_t       asciiheight;  /* Height of ASCII histogram or CFP plots.  */
86   uint8_t        normalize;  /* set the sum of all bins to 1.            */
87   uint8_t   manualbinrange;  /* Set bin min/max manually, not from data. */
88   float        onebinstart;  /* Shift bins to start at this value.       */
89   float       onebinstart2;  /* Shift bins to start at this value.       */
90   uint8_t        maxbinone;  /* Set the maximum bin to 1.                */
91   float         mirrordist;  /* Maximum distance after mirror for mode.  */
92 
93   char         *kernelname;  /* File name of kernel to convolve input.   */
94   char               *khdu;  /* Kernel HDU.                              */
95   float       meanmedqdiff;  /* Mode and median quantile difference.     */
96   float       outliersigma;  /* Multiple of sigma to define outlier.     */
97   double   outliersclip[2];  /* Outlier Sigma-clipping params.           */
98   size_t       smoothwidth;  /* Width of flat kernel to smooth interpd.  */
99   uint8_t         checksky;  /* Save the steps for deriving the Sky.     */
100   double    sclipparams[2];  /* Muliple and parameter of sigma clipping. */
101   uint8_t ignoreblankintiles;/* Ignore input's blank values.             */
102 
103 
104   /* Internal */
105   uint8_t      inputformat;  /* Format of input dataset.                 */
106   int          numoutfiles;  /* Number of output files made in this run. */
107   uint8_t        needssort;  /* If sorting is needed.                    */
108   gal_data_t        *input;  /* Input data structure.                    */
109   gal_data_t       *sorted;  /* Sorted input data structure.             */
110   gal_data_t    *reference;  /* Reference data structure.                */
111   int               isfits;  /* Input is a FITS file.                    */
112   int             hdu_type;  /* Type of HDU (image or table).            */
113   gal_data_t       *kernel;  /* Kernel for convolution of input for Sky. */
114   gal_data_t    *convolved;  /* Convolved input.                         */
115   gal_data_t        *sky_t;  /* Sky on each tile.                        */
116   gal_data_t        *std_t;  /* Sky standard deviation on each tile.     */
117   char       *checkskyname;  /* Name of file for Sky calculation steps.  */
118   time_t           rawtime;  /* Starting time of the program.            */
119 };
120 
121 #endif
122