CR2RE Pipeline Reference Manual 1.6.7
hdrl_cat_def.h
1/*
2 * This file is part of the HDRL
3 * Copyright (C) 2017 European Southern Observatory
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#ifndef HDRL_CATALOGUE_DEF_H
21#define HDRL_CATALOGUE_DEF_H
22
23
24#include <cpl.h>
25#include <math.h>
26
27
28/*** DEFINES ***/
29
30/* must not be followed by a semicolon! gcc on mac has omp
31 * but it doesn't work for nontrivial cases as libc lacks allocate */
32#if defined (_OPENMP) && !defined( __APPLE__)
33#define HDRL_OMP(x) _Pragma (#x)
34#else
35#define HDRL_OMP(x)
36#endif
37
38/* Catalogue generation parameters */
39#define IMNUM 200 /* Maximum number of images to be deblended */
40#define NPAR 16 /* Number of parameters in a basic results array */
41#define NRADS 13 /* Number of RANDS (RADII) */
42#define NAREAL 8 /* Number of areals profiles */
43
44/* MFLAG values used for tracking the quality of individual pixels */
45#define MF_CLEANPIX 0 /* */
46#define MF_OBJPIX 1 /* */
47#define MF_SATURATED 2 /* */
48#define MF_ZEROCONF 3 /* */
49#define MF_STUPID_VALUE 4 /* */
50#define MF_POSSIBLEOBJ 5 /* */
51
52
53/*** DATA TYPES ***/
54
55typedef struct {
56 cpl_size x; /* */
57 cpl_size y; /* */
58 double z; /* */
59 double zsm; /* */
60 cpl_size iobj; /* */
61} plstruct;
62
63typedef struct {
64
65 cpl_size areal[NAREAL]; /* height above thresh of areal-prof cuts */
66
67 cpl_size lsiz; /* size of a line */
68 cpl_size csiz; /* size of a column */
69 cpl_size maxip; /* max no. of parents ever used. */
70 cpl_size maxbl; /* size of pixel-storage block stack */
71 cpl_size maxpa; /* size of parent-stack. */
72 cpl_size ipnop; /* parent-number-of-pixels, min size of image */
73 cpl_size nimages; /* count of images */
74 cpl_size ipstack; /* parent-name stack pointer */
75 cpl_size ibstack; /* pixel-block name stack pointer */
76 double thresh; /* threshold for image detection */
77 double background; /* background value */
78 double sigma; /* median background sigma */
79 cpl_size multiply; /* smoothing multiplication */
80 double xintmin; /* minimum intensity for consideration */
81 cpl_size mulpix; /* minimum size for considering multiple images */
82 double areal_offset; /* offset in areal profile levels */
83 double fconst; /* Normalisation constant for areal profiles */
84 double saturation; /* saturation level from background analysis */
85 cpl_size icrowd; /* true if deblending routine is to be used */
86
87 cpl_size *blink; /* block-link array */
88 cpl_size *bstack; /* stack of pixel names */
89
90 struct { /* Image control block array */
91 cpl_size first; /* link to first data block */
92 cpl_size last; /* current last block */
93 cpl_size pnop; /* Parent no. pixels (-1 = inactive) */
94 cpl_size growing;
95 cpl_size touch; /* 0 = does not touch an edge */
96 cpl_size pnbp; /* Parent no of bad pixels */
97 } *parent;
98
99 cpl_size *pstack; /* stack of parent names */
100 plstruct *plessey; /* x,y,i storage array */
101 cpl_size *lastline; /* Parents on last line */
102
103 cpl_image *inframe; /* Pointer to original image data frame */
104 cpl_image *conframe; /* Pointer to original confidence map frame */
105 double *indata; /* Pointer to original image data */
106 double *confdata; /* Pointer to original confidence map data */
107 unsigned char *mflag; /* Pointer to mflag array for tracking merges */
108 cpl_mask *opmask; /* Object pixel mask */
109 double rcore; /* Core radius for aperture photometry */
110 double filtfwhm; /* FWHM of smoothing kernel in detection algorithm */
111 plstruct *plarray; /* Plessey structure workspace for passing data to various processing routines */
112 cpl_size npl; /* Size of the above */
113 cpl_size npl_pix; /* Number of pixels in the above structure */
114 double fwhm; /* Value of the seeing */
115
116 struct {
117 cpl_size nbx; /* X dimension of background map */
118 cpl_size nby; /* Y dimension of background map */
119 cpl_size nbsize; /* Size of a side of background map cell */
120 double **bvals; /* Pointer to background map */
121 } backmap;
122} ap_t;
123
124typedef struct {
125 double x; /* x position */
126 double y; /* y position */
127 double total; /* total integrated intensity */
128 cpl_size area; /* image area in pixels */
129 double peak; /* peak image intensity above sky */
130 double xx; /* 2nd moment x */
131 double xy; /* 2nd moment cross term */
132 double yy; /* 2nd moment y */
133 double ecc; /* Eccentricity */
134 cpl_size areal[NAREAL]; /* areal profile of image */
135} apmCat_t;
136
137
138/* cpl_image functions */
139typedef struct {
140 cpl_image *image; /* */
141 cpl_propertylist *ehu; /* */
142} hdrl_casu_fits;
143
144/* cpl_table functions */
145typedef struct {
146 cpl_table *table; /* */
147 cpl_propertylist *ehu; /* */
148} hdrl_casu_tfits;
149
150
151#define HDRL_SATURATION_INIT INFINITY
152
153typedef enum {
154 HDRL_CATALOGUE_BKG = 1,
155 HDRL_CATALOGUE_SEGMAP = 2,
156 HDRL_CATALOGUE_CAT_COMPLETE = 4,
157 HDRL_CATALOGUE_ALL = 7
158} hdrl_catalogue_options;
159
160/* Catalogue structure */
161typedef struct {
162 hdrl_casu_tfits *catalogue; /* cpl_table and property list */
163 cpl_image *segmentation_map; /* */
164 cpl_image *background; /* */
165} hdrl_casu_result;
166
167
168#endif /* HDRL_CATALOGUE_DEF_H */