detmon_lg.h

00001 /* $Id: detmon_lg.h,v 1.3 2012/01/26 12:33:23 amodigli Exp $
00002  *
00003  * This file is part of the irplib package
00004  * Copyright (C) 2002, 2003 European Southern Observatory
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA
00019  */
00020 
00021 /*
00022  * $Author: amodigli $
00023  * $Date: 2012/01/26 12:33:23 $
00024  * $Revision: 1.3 $
00025  * $Name: detmon-1_2_0 $
00026  */
00027 
00028 #ifndef IRPLIB_DETMON_LG_H
00029 #define IRPLIB_DETMON_LG_H
00030 
00031 /*----------------------------------------------------------------------------
00032                                    Includes
00033  ----------------------------------------------------------------------------*/
00034 
00035 #include <cpl.h>
00036 #include <detmon_cpl_size.h>
00037 
00038 /*----------------------------------------------------------------------------
00039                                    Prototypes
00040  ----------------------------------------------------------------------------*/
00041 /* Define here the DO.CATG keywords */
00042 #define DETMON_LG_ON_RAW_OLD                    "ON_RAW"
00043 #define DETMON_LG_OFF_RAW_OLD           "OFF_RAW"
00044 #define DETMON_LG_ON_RAW_NEW                    "DETMON_LAMP_ON"
00045 #define DETMON_LG_OFF_RAW_NEW           "DETMON_LAMP_OFF"
00046 
00047 
00048 #define NIR TRUE
00049 #define OPT FALSE
00050 
00051 #define DETMON_QC_COUNTS_MIN  "ESO QC COUNTS MIN"
00052 #define DETMON_QC_COUNTS_MIN_C     "Minimum median value used in linearity test (in a user defined region) [ADU]"
00053 
00054 #define DETMON_QC_COUNTS_MAX  "ESO QC COUNTS MAX"
00055 #define DETMON_QC_COUNTS_MAX_C     "Maximum median value used in linearity test (in a user defined region) [ADU]"
00056 
00057 #define DETMON_QC_CONAD       "ESO QC CONAD"
00058 #define DETMON_QC_CONAD_C     "CONAD value [el/ADU]"
00059 
00060 #define DETMON_QC_CONAD_CORR       "ESO QC CONAD CORR"
00061 #define DETMON_QC_CONAD_CORR_C     "CONAD value taken QC.AUTOCORR into account [el/ADU]"
00062 
00063 #define DETMON_QC_GAIN        "ESO QC GAIN"
00064 #define DETMON_QC_GAIN_C      "GAIN (see QC.METHOD) [ADU/el]"
00065 
00066 #define DETMON_QC_GAIN_MSE    "ESO QC GAIN MSE"
00067 #define DETMON_QC_GAIN_MSE_C  "Measured Squared error in GAIN computation"
00068 
00069 #define DETMON_QC_RON         "ESO QC RON"
00070 #define DETMON_QC_RON_C       "RON obtained as independent term (PTC method)"
00071 
00072 #define DETMON_QC_AUTOCORR    "ESO QC AUTOCORR"
00073 #define DETMON_QC_AUTOCORR_C  "Autocorrelation factor computed as sum of " \
00074                               "all pixels in autocorrelation image"
00075 #define DETMON_QC_GAIN_CORR   "ESO QC GAIN CORR"
00076 #define DETMON_QC_GAIN_CORR_C "GAIN taken QC.AUTOCORR into account [el/ADU]"
00077 
00078 #define DETMON_QC_LAMP_FLUX   "ESO QC LAMP FLUX"
00079 #define DETMON_QC_LAMP_FLUX_C "Lamp flux"
00080 
00081 #define DETMON_QC_NUM_BPM     "ESO QC NUM BPM"
00082 #define DETMON_QC_NUM_BPM_C   "Number of bad pixels detected according to "\
00083                               "polynomial information"
00084 
00085 #define DETMON_QC_LAMP_STAB   "ESO QC LAMP STAB"
00086 #define DETMON_QC_LAMP_STAB_C "Lamp stability"
00087 
00088 #define DETMON_QC_METHOD      "ESO QC METHOD"
00089 #define DETMON_QC_METHOD_C    "Method applied to compute GAIN"
00090 
00091 #define DETMON_QC_LIN_EFF     "ESO QC LIN EFF"
00092 #define DETMON_QC_LIN_EFF_C   "Effective non-linearity correction"
00093 
00094 #define DETMON_QC_LIN_EFF_FLUX     "ESO QC LIN EFF FLUX"
00095 #define DETMON_QC_LIN_EFF_FLUX_C   "FLux level at which effective non-linearity correction is computed"
00096 
00097 #define DETMON_QC_LIN_COEF    "ESO QC LIN COEF"
00098 #define DETMON_QC_LIN_COEF_C  "Linearity coefficient value"
00099 
00100 
00101 #define DETMON_QC_LIN_COEF_ERR     "ESO QC LIN EFF ERR"
00102 #define DETMON_QC_LIN_COEF_ERR_C   "Linearity coefficient error value"
00103 #define DETMON_QC_LIN_COEF_MSE_ERR_C   "Linearity coefficient measured square error value"
00104 
00105 
00106 #define DETMON_QC_ERRFIT     "ESO QC ERRFIT"
00107 #define DETMON_QC_ERRFIT_C   "Error of fit"
00108 #define DETMON_QC_ERRFIT_MSE_C   "Measured square error of fit"
00109 
00110 
00111 #define DETMON_QC_CONTAM     "ESO QC CONTAM"
00112 #define DETMON_QC_CONTAM_C   "Detector contamination in a region"
00113 
00114 #define DETMON_QC_FPN     "ESO QC FPN"
00115 #define DETMON_QC_FPN_C   "Flat pattern noise"
00116 
00117 /* Macros to generate the recipe(s) description(s) */
00118 #define detmon_lg_get_description(RECIPE_NAME, PIPE_NAME,              \
00119                   DETMON_LG_ON_RAW_NEW,                 \
00120                   DETMON_LG_OFF_RAW_NEW,                \
00121                   DETMON_LG_ON_RAW_OLD,                \
00122                                   DETMON_LG_OFF_RAW_OLD)                \
00123     RECIPE_NAME " -- " PIPE_NAME " linearity/gain recipe for OPT/IR.\n"           \
00124     "The files listed in the Set Of Frames must be tagged:\n"                 \
00125     "the raw-on-file.fits  "DETMON_LG_ON_RAW_NEW"  and\n"                      \
00126     "the raw-off-file.fits "DETMON_LG_OFF_RAW_NEW"\n"                          \
00127     "For backward compatibility are alternatively still supported the following tags:\n" \
00128     "the raw-on-file.fits  "DETMON_LG_ON_RAW_OLD"  and\n"                      \
00129     "the raw-off-file.fits "DETMON_LG_OFF_RAW_OLD"\n"                          \
00130     "The recipe requires at least order+1 valid pairs of ON frames\n"         \
00131     "and order+1 valid pairs of OFF frames, \n"                               \
00132     "where order is the value of the 'order' parameter.\n"                    \
00133     "There is no requirement for pairs of OFF frames if collapse parameter"   \
00134     "is set to true.\n"                                                       \
00135     "Frames with median flux over --filter will be excluded from the"         \
00136     "computation.\n"                                                          \
00137     "To perform a stability check you need frames with at least 2 DIT"        \
00138     "values\n"                                                                \
00139     "NOTE for multiextension cases: it is mandatory to modify the --exts"     \
00140     "parameter, either to -1 (all extensions) or to any valid extension nb.\n"
00141 
00142 #define REGEXP "ARCFILE|MJD-OBS|ESO TPL ID|DATE-OBS|ESO DET DIT|ESO DET NDIT"
00143 
00144 typedef unsigned long irplib_gain_flag;
00145 
00146 #define IRPLIB_GAIN_PTC           ((irplib_gain_flag) 1 << 1)
00147 #define IRPLIB_GAIN_MEDIAN        ((irplib_gain_flag) 1 << 2)
00148 #define IRPLIB_GAIN_NO_COLLAPSE   ((irplib_gain_flag) 1 << 3)
00149 #define IRPLIB_GAIN_COLLAPSE      ((irplib_gain_flag) 1 << 4)
00150 #define IRPLIB_GAIN_WITH_AUTOCORR ((irplib_gain_flag) 1 << 5)
00151 #define IRPLIB_GAIN_WITH_RESCALE  ((irplib_gain_flag) 1 << 6)
00152 #define IRPLIB_GAIN_OPT           ((irplib_gain_flag) 1 << 7)
00153 #define IRPLIB_GAIN_NIR           ((irplib_gain_flag) 1 << 8)
00154 
00155 typedef unsigned long irplib_lin_flag;
00156 
00157 #define IRPLIB_LIN_NO_COLLAPSE   ((irplib_lin_flag) 1 << 10)
00158 #define IRPLIB_LIN_COLLAPSE      ((irplib_lin_flag) 1 << 11)
00159 #define IRPLIB_LIN_PIX2PIX       ((irplib_lin_flag) 1 << 12)
00160 #define IRPLIB_LIN_WITH_RESCALE  ((irplib_lin_flag) 1 << 13)
00161 #define IRPLIB_LIN_OPT           ((irplib_lin_flag) 1 << 14)
00162 #define IRPLIB_LIN_NIR           ((irplib_lin_flag) 1 << 15)
00163 
00164 cpl_error_code
00165 detmon_lg(cpl_frameset            * frameset,
00166                  const cpl_parameterlist * parlist,
00167                  const char              * tag_on,
00168                  const char              * tag_off,
00169                  const char              * recipe_name,
00170                  const char              * pipeline_name,
00171                  const char              * pafregexp,
00172                  const cpl_propertylist  * pro_lintbl,
00173                  const cpl_propertylist  * pro_gaintbl,
00174                  const cpl_propertylist  * pro_coeffscube,
00175                  const cpl_propertylist  * pro_bpm,
00176                  const cpl_propertylist  * pro_corr,
00177                  const cpl_propertylist  * pro_diff,
00178                  const char              * package,
00179                  int                    (* compare) (const cpl_frame *,
00180                              const cpl_frame *),
00181          int                    (* load_fset) (const cpl_frameset *,
00182                                cpl_type,
00183                                                cpl_imagelist *),
00184                  const cpl_boolean         opt_nir);
00185 
00186 
00187 cpl_image * detmon_image_correlate(const cpl_image       *,
00188                                           const cpl_image       *,
00189                                           const int              ,
00190                                           const int              );
00191 
00192 cpl_error_code
00193 detmon_lg_fill_parlist_nir_default(cpl_parameterlist *,
00194                               const char        *,
00195                               const char        *);
00196 
00197 cpl_error_code
00198 detmon_lg_fill_parlist_opt_default(cpl_parameterlist *,
00199                               const char        *,
00200                               const char        *);
00201 
00202 cpl_error_code
00203 detmon_lg_fill_parlist(cpl_parameterlist * parlist,
00204                           const char *recipe_name, const char *pipeline_name,
00205               const char *method,
00206                           int order,
00207                           double kappa,
00208                           int niter,
00209                           int llx,
00210                           int lly,
00211                           int urx,
00212                           int ury,
00213                           int ref_level,
00214                           const char * intermediate,
00215                           const char * autocorr,
00216                           const char * collapse,
00217                           const char * rescale,
00218                   const char * pix2pix,
00219                   const char * bpmbin,
00220                           int filter,
00221                           int m,
00222                           int n,
00223                   double tolerance,
00224                   const char * pafgen,
00225                   const char * pafname,
00226                           int llx1,
00227                           int lly1,
00228                           int urx1,
00229                           int ury1,
00230                           int llx2,
00231                           int lly2,
00232                           int urx2,
00233                           int ury2,
00234                           int llx3,
00235                           int lly3,
00236                           int urx3,
00237                           int ury3,
00238                           int llx4,
00239                           int lly4,
00240                           int urx4,
00241                           int ury4,
00242                           int llx5,
00243                           int lly5,
00244                           int urx5,
00245                           int ury5,
00246                   int exts,
00247                           cpl_boolean opt_nir);
00248 
00249 cpl_image *
00250 detmon_autocorrelate(const cpl_image *,
00251                             const int, const int);
00252 
00253 cpl_table *
00254 detmon_gain(const cpl_imagelist  *,
00255            const cpl_imagelist  *,
00256            const cpl_vector     *,
00257            const cpl_vector     *,
00258            double                ,
00259            int                   ,
00260            int                   ,
00261            int                   ,
00262            int                   ,
00263                    double                ,
00264                    int                   ,
00265                    int                   ,
00266                    int                   ,
00267            cpl_propertylist     *,
00268            unsigned              ,
00269            cpl_imagelist       **,
00270            cpl_imagelist       **);
00271 
00272 cpl_table *
00273 detmon_lin(const cpl_imagelist  *,
00274           const cpl_imagelist  *,
00275           const cpl_vector     *,
00276           double                ,
00277           int                   ,
00278           int                   ,
00279           int                   ,
00280           int                   ,
00281           int                   ,
00282           int                   ,
00283                   double,
00284                   cpl_boolean,
00285           cpl_propertylist     *,
00286           unsigned              ,
00287           cpl_imagelist       **,
00288           cpl_image           **);
00289 
00290 cpl_error_code
00291 detmon_lg_set_tag(cpl_frameset* set, const char** tag_on, const char** tag_off);
00292 #endif

Generated on 7 Mar 2012 for DETMON Pipeline Reference Manual by  doxygen 1.6.1