crires_spec_wavecal.c

00001 /* $Id: crires_spec_wavecal.c,v 1.69 2011/03/22 09:17:12 yjung Exp $
00002  *
00003  * This file is part of the CRIRES Pipeline
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 /*
00022  * $Author: yjung $
00023  * $Date: 2011/03/22 09:17:12 $
00024  * $Revision: 1.69 $
00025  * $Name: crire-2_1_1 $
00026  */
00027 
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031 
00032 /*-----------------------------------------------------------------------------
00033                                 Includes
00034  -----------------------------------------------------------------------------*/
00035 
00036 #include "crires_recipe.h"
00037 
00038 #include "crires_combine.h"
00039 #include "crires_wlcalib.h"
00040 #include "crires_extract.h"
00041 #include "crires_model_kernel.h"
00042 
00043 /*-----------------------------------------------------------------------------
00044                                 Define
00045  -----------------------------------------------------------------------------*/
00046 
00047 #define RECIPE_STRING "crires_spec_wavecal"
00048 
00049 /*-----------------------------------------------------------------------------
00050                             Functions prototypes
00051  -----------------------------------------------------------------------------*/
00052 
00053 static int crires_spec_wavecal_save(const cpl_imagelist *, 
00054         const cpl_imagelist *, const cpl_table **, const cpl_parameterlist *, 
00055         cpl_frameset *) ;
00056 
00057 static char crires_spec_wavecal_description[] =
00058 "crires_spec_wavecal -- Wavelength calibration\n"
00059 "The files listed in the Set Of Frames (sof-file) must be tagged:\n"
00060 "raw-file.fits "CRIRES_SPEC_WAVECAL_SKY_RAW" or\n"
00061 "raw-file.fits "CRIRES_SPEC_WAVECAL_LAMP_RAW" or\n" 
00062 "raw-file.fits "CRIRES_SPEC_WAVECAL_ABS_RAW" or\n" 
00063 "flat-file.fits "CRIRES_CALPRO_FLAT" or\n"
00064 "bpm-file.fits "CRIRES_CALPRO_BPM" or\n"
00065 "dark-file.fits "CRIRES_CALPRO_DARK" or\n"
00066 "detlin-file.fits "CRIRES_CALPRO_COEFFS_CUBE" or\n"
00067 "catalog-file.fits "CRIRES_CALPRO_THAR_CAT" or\n" 
00068 "catalog-file.fits "CRIRES_CALPRO_OH_CAT" or\n" 
00069 "catalog-file.fits "CRIRES_CALPRO_HITRAN_CAT" or\n" 
00070 "model-config-file.fits "CRIRES_CALPRO_MODEL_CONFIG".\n"
00071 "\n"
00072 "This recipe produces 3 files:\n"
00073 "First product:     the image with the wavelength values.\n"
00074 "                   (PRO TYPE = "CRIRES_PROTYPE_WL_MAP")\n"
00075 "Second product:    the image with the wavelength values from the model.\n"
00076 "                   (PRO TYPE = "CRIRES_PROTYPE_WL_MAP")\n"
00077 "Third product:     the table with the wavelength polynomial coefficients.\n"
00078 "                   (PRO TYPE = "CRIRES_PROTYPE_WL_POLY")\n" ;
00079 
00080 CRIRES_RECIPE_DEFINE(crires_spec_wavecal,
00081         CRIRES_PARAM_WAVES          |
00082         CRIRES_PARAM_DISPLAY        |
00083         CRIRES_PARAM_WL_LOG         |
00084         CRIRES_PARAM_WL_NOLIMIT     |
00085         CRIRES_PARAM_WL_ERROR       |
00086         CRIRES_PARAM_XC_LIMIT       |
00087         CRIRES_PARAM_WL_NBSAMPLES   |
00088         CRIRES_PARAM_WL_STARTY      |
00089         CRIRES_PARAM_WL_STOPY       |
00090         CRIRES_PARAM_DEGREE         |
00091         CRIRES_PARAM_WL_CLEAN,
00092         "Wavelength calibration",
00093         crires_spec_wavecal_description) ;
00094 
00095 /*-----------------------------------------------------------------------------
00096                             Static variables
00097  -----------------------------------------------------------------------------*/
00098 
00099 static struct {
00100     /* Inputs */
00101     double              wstart[CRIRES_NB_DETECTORS] ;
00102     double              wstop[CRIRES_NB_DETECTORS] ;
00103     int                 wl_nolimit ;
00104     int                 wl_log ;
00105     int                 wl_starty ;
00106     int                 wl_stopy ;
00107     double              wl_fwhm ;
00108     double              wl_slitw ;
00109     int                 wl_degree ;
00110     double              wl_err ;
00111     int                 wl_samples ;
00112     int                 wl_clean ;
00113     double              wl_xclimit ;
00114     int                 wl_ppm ;
00115     int                 display ;
00116     /* Outputs */
00117     crires_illum_period period ;
00118     int                 mode ;
00119     double              qc_wlxc[CRIRES_NB_DETECTORS] ;
00120     double              qc_wlcent[CRIRES_NB_DETECTORS] ;
00121     double              qc_wldisp[CRIRES_NB_DETECTORS] ;
00122     double              qc_lines_flux[CRIRES_NB_DETECTORS] ;
00123     double              qc_fwhm[CRIRES_NB_DETECTORS] ;
00124     double              qc_rpower[CRIRES_NB_DETECTORS] ;
00125 } crires_spec_wavecal_config ;
00126 
00127 /*-----------------------------------------------------------------------------
00128                                 Functions code
00129  -----------------------------------------------------------------------------*/
00130 
00131 /*----------------------------------------------------------------------------*/
00138 /*----------------------------------------------------------------------------*/
00139 static int crires_spec_wavecal(
00140         cpl_frameset            *   frameset,
00141         const cpl_parameterlist *   parlist)
00142 {
00143     const char          *   sval ;
00144     cpl_frameset        *   rawframes ;
00145     const char          *   fname ;
00146     const char          *   flat ;
00147     const char          *   dark ;
00148     const char          *   bpm ;
00149     const char          *   detlin ;
00150     const char          *   thar_cat ;
00151     const char          *   n2o_cat ;
00152     const char          *   oh_cat ;
00153     const char          *   hitran_cat ;
00154     const char          *   cfg_model ;
00155     cpl_propertylist    *   plist ;
00156     double                  wmin, wmax ;
00157     cpl_polynomial      *   wave_poly[CRIRES_NB_DETECTORS] ;
00158     cpl_table           **  wl_tab ;
00159     cpl_imagelist       *   wl_map ;
00160     cpl_imagelist       *   wl_map_model ;
00161     int                     power ;
00162     double                  wl_dx1, wl_dx2 ;
00163     int                     i ;
00164 
00165     /* Initialise */
00166     rawframes = NULL ;
00167     for (i=0 ; i<CRIRES_NB_DETECTORS ; i++) {
00168         crires_spec_wavecal_config.qc_wlxc[i] = -1.0 ;
00169         crires_spec_wavecal_config.qc_wlcent[i] = -1.0 ;
00170         crires_spec_wavecal_config.qc_wldisp[i] = -1.0 ;
00171         crires_spec_wavecal_config.qc_lines_flux[i] = -1.0 ;
00172         crires_spec_wavecal_config.qc_fwhm[i] = -1.0 ;
00173         crires_spec_wavecal_config.qc_rpower[i] = -1.0 ;
00174     }
00175     crires_spec_wavecal_config.wl_ppm = 0 ;
00176     crires_spec_wavecal_config.wl_slitw = 2.0 ;
00177     crires_spec_wavecal_config.wl_fwhm = 2.0 ;
00178     
00179     /* Retrieve input parameters */
00180 
00181     sval = crires_parameterlist_get_string(parlist, RECIPE_STRING,
00182             CRIRES_PARAM_WAVES) ;
00183     if (sscanf(sval, "%lg,%lg,%lg,%lg,%lg,%lg,%lg,%lg",
00184                     &crires_spec_wavecal_config.wstart[0],
00185                     &crires_spec_wavecal_config.wstop[0],
00186                     &crires_spec_wavecal_config.wstart[1],
00187                     &crires_spec_wavecal_config.wstop[1],
00188                     &crires_spec_wavecal_config.wstart[2],
00189                     &crires_spec_wavecal_config.wstop[2],
00190                     &crires_spec_wavecal_config.wstart[3],
00191                     &crires_spec_wavecal_config.wstop[3])!=2*CRIRES_NB_DETECTORS){
00192         return -1 ;
00193     }
00194     crires_spec_wavecal_config.display = crires_parameterlist_get_int(parlist,
00195             RECIPE_STRING, CRIRES_PARAM_DISPLAY) ;
00196     crires_spec_wavecal_config.wl_log = crires_parameterlist_get_bool(parlist,
00197             RECIPE_STRING, CRIRES_PARAM_WL_LOG) ;
00198     crires_spec_wavecal_config.wl_nolimit = crires_parameterlist_get_bool(
00199             parlist, RECIPE_STRING, CRIRES_PARAM_WL_NOLIMIT) ;
00200     crires_spec_wavecal_config.wl_degree = crires_parameterlist_get_int(parlist,
00201             RECIPE_STRING, CRIRES_PARAM_DEGREE) ;
00202     crires_spec_wavecal_config.wl_err = crires_parameterlist_get_double(parlist,
00203             RECIPE_STRING, CRIRES_PARAM_WL_ERROR) ;
00204     crires_spec_wavecal_config.wl_xclimit = crires_parameterlist_get_double(
00205             parlist, RECIPE_STRING, CRIRES_PARAM_XC_LIMIT) ;
00206     crires_spec_wavecal_config.wl_starty = crires_parameterlist_get_int(parlist,
00207             RECIPE_STRING, CRIRES_PARAM_WL_STARTY) ;
00208     crires_spec_wavecal_config.wl_stopy = crires_parameterlist_get_int(parlist,
00209             RECIPE_STRING, CRIRES_PARAM_WL_STOPY) ;
00210     crires_spec_wavecal_config.wl_samples = crires_parameterlist_get_int(
00211             parlist, RECIPE_STRING, CRIRES_PARAM_WL_NBSAMPLES) ;
00212     crires_spec_wavecal_config.wl_clean = crires_parameterlist_get_bool(parlist,
00213             RECIPE_STRING, CRIRES_PARAM_WL_CLEAN) ;
00214 
00215     /* Identify the RAW and CALIB frames in the input frameset */
00216     if (crires_dfs_set_groups(frameset, "crires_spec_wavecal")) {
00217         cpl_msg_error(__func__, "Cannot identify RAW and CALIB frames") ;
00218         return -1 ;
00219     }
00220 
00221     /* Retrieve calibration data */
00222     flat        = crires_extract_filename(frameset, CRIRES_CALPRO_FLAT) ;
00223     dark        = crires_extract_filename(frameset, CRIRES_CALPRO_DARK) ;
00224     bpm         = crires_extract_filename(frameset, CRIRES_CALPRO_BPM) ;
00225     detlin      = crires_extract_filename(frameset, CRIRES_CALPRO_COEFFS_CUBE) ;
00226     thar_cat = crires_extract_filename(frameset, CRIRES_CALPRO_THAR_CAT) ;
00227     n2o_cat = crires_extract_filename(frameset, CRIRES_CALPRO_N2O_CAT) ;
00228     oh_cat = crires_extract_filename(frameset, CRIRES_CALPRO_OH_CAT) ;
00229     hitran_cat = crires_extract_filename(frameset, CRIRES_CALPRO_HITRAN_CAT) ;
00230     cfg_model = crires_extract_filename(frameset, CRIRES_CALPRO_MODEL_CONFIG) ;
00231     
00232     /* Retrieve raw frames */
00233     if ((rawframes = crires_extract_frameset(frameset,
00234                     CRIRES_SPEC_WAVECAL_SKY_RAW)) != NULL) {
00235         crires_spec_wavecal_config.mode = 1 ;
00236     } else if ((rawframes = crires_extract_frameset(frameset, 
00237                     CRIRES_SPEC_WAVECAL_LAMP_RAW)) != NULL) {
00238         crires_spec_wavecal_config.mode = 2 ;
00239     } else if ((rawframes = crires_extract_frameset(frameset, 
00240                     CRIRES_SPEC_WAVECAL_ABS_RAW)) != NULL) {
00241         crires_spec_wavecal_config.mode = 3 ;
00242     } else {
00243         cpl_msg_error(__func__, "No raw frame in input") ;
00244         return -1 ;
00245     }
00246 
00247     /* Get the detector illumination period */
00248     crires_spec_wavecal_config.period =
00249         crires_get_detector_illum_period(
00250                 cpl_frame_get_filename(cpl_frameset_get_frame(rawframes, 0))) ;
00251     if (crires_spec_wavecal_config.period == CRIRES_ILLUM_UNKNOWN) {
00252         cpl_msg_error(__func__,
00253                 "Cannot determine the detector illumination period") ;
00254         cpl_frameset_delete(rawframes) ;
00255         return -1 ;
00256     } else {
00257         crires_display_detector_illum(crires_spec_wavecal_config.period) ;
00258     }
00259 
00260     /* Reduce the first raw frame */
00261     fname = cpl_frame_get_filename(cpl_frameset_get_frame(rawframes,0)) ;
00262 
00263     /* Get the Minimum and Maximum wavelengths */
00264     if (crires_spec_wavecal_config.wl_nolimit == 0) {
00265         plist = cpl_propertylist_load(fname, 0) ;
00266         wmin = crires_pfits_get_wlen_min(plist) ;
00267         wmax = crires_pfits_get_wlen_max(plist) ;
00268         cpl_propertylist_delete(plist) ;
00269         if (cpl_error_get_code()) {
00270             wmin = wmax = -1.0 ;
00271             cpl_error_reset() ;
00272         }
00273     } else {
00274         wmin = wmax = -1.0 ;
00275     }
00276 
00277     /* Wavelength calibration */
00278     cpl_msg_info(__func__, "Apply the Wavelength Calibration") ;
00279     cpl_msg_indent_more() ;
00280     if (crires_spec_wavecal_config.mode == 1) {
00281         /* Calibrate from the sky */
00282         cpl_msg_info(__func__, "Get the calibration from the oh/hitran sky") ;
00283         for (i=0 ; i<CRIRES_NB_DETECTORS ; i++) {
00284             cpl_msg_info(__func__, "Calibrate chip number %d", i+1) ;
00285             cpl_msg_indent_more() ;
00286             wave_poly[i] = crires_wlcalib_sky(fname,
00287                     crires_spec_wavecal_config.period,
00288                     oh_cat, flat, dark, bpm, detlin,
00289                     crires_spec_wavecal_config.wstart[i],
00290                     crires_spec_wavecal_config.wstop[i],
00291                     wmin, wmax,
00292                     crires_spec_wavecal_config.wl_log,
00293                     hitran_cat, i+1, 
00294                     crires_spec_wavecal_config.wl_starty,
00295                     crires_spec_wavecal_config.wl_stopy,
00296                     crires_spec_wavecal_config.wl_degree,
00297                     crires_spec_wavecal_config.wl_slitw,
00298                     crires_spec_wavecal_config.wl_fwhm,
00299                     crires_spec_wavecal_config.wl_err,
00300                     crires_spec_wavecal_config.wl_samples,
00301                     crires_spec_wavecal_config.wl_clean,
00302                     crires_spec_wavecal_config.wl_xclimit,
00303                     crires_spec_wavecal_config.wl_ppm,
00304                     (i+1==crires_spec_wavecal_config.display),
00305                     &(crires_spec_wavecal_config.qc_wlxc[i])) ;
00306             cpl_msg_indent_less() ;
00307         }
00308     } else if (crires_spec_wavecal_config.mode == 2) {
00309         /* Calibrate from the lamp */
00310         cpl_msg_info(__func__, "Get the calibration from the thar lamp") ;
00311         for (i=0 ; i<CRIRES_NB_DETECTORS ; i++) {
00312             cpl_msg_info(__func__, "Calibrate chip number %d", i+1) ;
00313             cpl_msg_indent_more() ;
00314             wave_poly[i] = crires_wlcalib_lamp(fname,
00315                     crires_spec_wavecal_config.period,
00316                     thar_cat, flat, dark, bpm, detlin,
00317                     crires_spec_wavecal_config.wstart[i],
00318                     crires_spec_wavecal_config.wstop[i],
00319                     wmin, wmax,
00320                     crires_spec_wavecal_config.wl_log,
00321                     i+1,
00322                     crires_spec_wavecal_config.wl_starty,
00323                     crires_spec_wavecal_config.wl_stopy,
00324                     crires_spec_wavecal_config.wl_degree,
00325                     crires_spec_wavecal_config.wl_slitw,
00326                     crires_spec_wavecal_config.wl_fwhm,
00327                     crires_spec_wavecal_config.wl_err,
00328                     crires_spec_wavecal_config.wl_samples,
00329                     crires_spec_wavecal_config.wl_clean,
00330                     crires_spec_wavecal_config.wl_xclimit,
00331                     crires_spec_wavecal_config.wl_ppm,
00332                     (i+1==crires_spec_wavecal_config.display),
00333                     &(crires_spec_wavecal_config.qc_wlxc[i]),
00334                     &(crires_spec_wavecal_config.qc_lines_flux[i]),
00335                     &(crires_spec_wavecal_config.qc_fwhm[i]),
00336                     &(crires_spec_wavecal_config.qc_rpower[i])) ;
00337             cpl_msg_indent_less() ;
00338         }
00339     } else if (crires_spec_wavecal_config.mode == 3) {
00340         /* Calibrate from the gas cell */
00341         cpl_msg_info(__func__, "Get the calibration from the n2o gas cell") ;
00342         for (i=0 ; i<CRIRES_NB_DETECTORS ; i++) {
00343             cpl_msg_info(__func__, "Calibrate chip number %d", i+1) ;
00344             cpl_msg_indent_more() ;
00345             wave_poly[i] = crires_wlcalib_lamp(fname,
00346                     crires_spec_wavecal_config.period,
00347                     n2o_cat, flat, dark, bpm, detlin,
00348                     crires_spec_wavecal_config.wstart[i],
00349                     crires_spec_wavecal_config.wstop[i],
00350                     wmin, wmax,
00351                     crires_spec_wavecal_config.wl_log,
00352                     i+1,
00353                     crires_spec_wavecal_config.wl_starty,
00354                     crires_spec_wavecal_config.wl_stopy,
00355                     crires_spec_wavecal_config.wl_degree,
00356                     crires_spec_wavecal_config.wl_slitw,
00357                     crires_spec_wavecal_config.wl_fwhm,
00358                     crires_spec_wavecal_config.wl_err,
00359                     crires_spec_wavecal_config.wl_samples,
00360                     crires_spec_wavecal_config.wl_clean,
00361                     crires_spec_wavecal_config.wl_xclimit,
00362                     crires_spec_wavecal_config.wl_ppm,
00363                     (i+1==crires_spec_wavecal_config.display),
00364                     &(crires_spec_wavecal_config.qc_wlxc[i]),
00365                     &(crires_spec_wavecal_config.qc_lines_flux[i]), 
00366                     &(crires_spec_wavecal_config.qc_fwhm[i]),
00367                     &(crires_spec_wavecal_config.qc_rpower[i])) ;
00368             cpl_msg_indent_less() ;
00369         }
00370     }
00371     cpl_msg_indent_less() ;
00372   
00373     /* Check the global wavelength calibration */
00374     for (i=1 ; i<CRIRES_NB_DETECTORS ; i++) {
00375         if (wave_poly[i-1] != NULL && wave_poly[i] != NULL) {
00376             power = 1 ;
00377             wl_dx1 = cpl_polynomial_get_coeff(wave_poly[i-1], &power) ;
00378             wl_dx2 = cpl_polynomial_get_coeff(wave_poly[i], &power) ;
00379             if (wl_dx1<wl_dx2) {
00380                 cpl_msg_warning(__func__,
00381     "The linear coefficient is increasing from chip %d to chip %d : %g -> %g",
00382                         i, i+1, wl_dx1, wl_dx2) ;
00383             }
00384         }
00385     }
00386    
00387     /* Compute the QC parameters */
00388     for (i=0 ; i<CRIRES_NB_DETECTORS ; i++) {
00389         if (wave_poly[i] != NULL) {
00390             crires_spec_wavecal_config.qc_wlcent[i] =
00391                 cpl_polynomial_eval_1d(wave_poly[i], (double)512, NULL) ;
00392             crires_spec_wavecal_config.qc_wldisp[i] =
00393                 (cpl_polynomial_eval_1d(wave_poly[i], (double)1024, NULL) -
00394                  cpl_polynomial_eval_1d(wave_poly[i], (double)1, NULL)) / 1024 ;
00395         }
00396     }
00397  
00398     /* Create the table */
00399     wl_tab = crires_wlcalib_gen_wltab((const cpl_polynomial **)wave_poly) ;
00400     for (i=0 ; i<CRIRES_NB_DETECTORS ; i++) 
00401         if (wave_poly[i] != NULL) cpl_polynomial_delete(wave_poly[i]) ;
00402 
00403     /* Create the wave map */
00404     wl_map = crires_wlcalib_gen_wlmap((const cpl_table **)wl_tab) ;
00405   
00406     /* Get the wl map from the model */
00407     if ((cfg_model != NULL) && (!crires_model_off()) && 
00408             (crires_model_config_check(cfg_model, fname) == 0)) {
00409         cpl_msg_info(__func__, "Call the model to get the wavelength map") ;
00410         cpl_msg_indent_more() ;
00411         wl_map_model = crires_model_wavpix(fname, cfg_model, -1) ;
00412         if (wl_map_model == NULL) {
00413             cpl_msg_warning(__func__, "Model function returns NULL") ;
00414             cpl_error_reset() ;
00415         }
00416         cpl_msg_indent_less() ;
00417     } else {
00418         wl_map_model = NULL ;
00419     }
00420     cpl_frameset_delete(rawframes) ;
00421     
00422     /* Save the product */
00423     cpl_msg_info(__func__, "Save the product") ;
00424     cpl_msg_indent_more() ;
00425     if (crires_spec_wavecal_save(wl_map, wl_map_model, 
00426                 (const cpl_table **)wl_tab, parlist, frameset)) {
00427         cpl_msg_error(__func__, "Cannot save the product") ;
00428         for (i=0 ; i<CRIRES_NB_DETECTORS ; i++) {
00429             cpl_table_delete(wl_tab[i]) ;
00430         }
00431         cpl_free(wl_tab) ;
00432         cpl_imagelist_delete(wl_map) ;
00433         if (wl_map_model) cpl_imagelist_delete(wl_map_model) ;
00434         cpl_msg_indent_less() ;
00435         return -1 ;
00436     }
00437     for (i=0 ; i<CRIRES_NB_DETECTORS ; i++) {
00438         cpl_table_delete(wl_tab[i]) ;
00439     }
00440     cpl_free(wl_tab) ;
00441     cpl_imagelist_delete(wl_map) ;
00442     if (wl_map_model) cpl_imagelist_delete(wl_map_model) ;
00443     cpl_msg_indent_less() ;
00444 
00445     /* Return */
00446     if (cpl_error_get_code()) return -1 ;
00447     else return 0 ;
00448 }
00449 
00450 /*----------------------------------------------------------------------------*/
00460 /*----------------------------------------------------------------------------*/
00461 static int crires_spec_wavecal_save(
00462         const cpl_imagelist     *   ilist,
00463         const cpl_imagelist     *   ilist_model,
00464         const cpl_table         **  wl_tab,
00465         const cpl_parameterlist *   parlist,
00466         cpl_frameset            *   set)
00467 {
00468     cpl_propertylist    **  qclists ;
00469     const cpl_frame     *   ref_frame ;
00470     cpl_propertylist    *   inputlist ;
00471     const char          *   recipe_name = "crires_spec_wavecal" ;
00472     int                     i ;
00473 
00474     /* Get the reference frame */
00475     ref_frame = irplib_frameset_get_first_from_group(set, CPL_FRAME_GROUP_RAW) ;
00476 
00477     /* Create the QC lists */
00478     qclists = cpl_malloc(CRIRES_NB_DETECTORS * sizeof(cpl_propertylist*)) ;
00479     for (i=0 ; i<CRIRES_NB_DETECTORS ; i++) {
00480         qclists[i] = cpl_propertylist_new() ;
00481         cpl_propertylist_append_double(qclists[i], "ESO QC CENTWL",
00482                 crires_spec_wavecal_config.qc_wlcent[i]) ;
00483         cpl_propertylist_append_double(qclists[i], "ESO QC DISPWL",
00484                 crires_spec_wavecal_config.qc_wldisp[i]) ;
00485         cpl_propertylist_append_double(qclists[i], "ESO QC XCORR",
00486                 crires_spec_wavecal_config.qc_wlxc[i]) ;
00487         cpl_propertylist_append_double(qclists[i], "ESO QC LINES FLUX",
00488                 crires_spec_wavecal_config.qc_lines_flux[i]) ;
00489         cpl_propertylist_append_double(qclists[i], "ESO QC FWHM MED",
00490                 crires_spec_wavecal_config.qc_fwhm[i]) ;
00491         cpl_propertylist_append_double(qclists[i], "ESO QC RESOL MED",
00492                 crires_spec_wavecal_config.qc_rpower[i]) ;
00493 
00494         /* Propagate some keywords from input raw frame extensions */
00495         inputlist = cpl_propertylist_load_regexp(
00496                 cpl_frame_get_filename(ref_frame), i+1,
00497                 CRIRES_HEADER_EXT_FORWARD, 0) ;
00498         cpl_propertylist_copy_property_regexp(qclists[i], inputlist,
00499                 CRIRES_HEADER_EXT_FORWARD, 0) ;
00500         cpl_propertylist_delete(inputlist) ;
00501     }
00502 
00503     /* Write the image */
00504     crires_image_save(set,
00505             parlist,
00506             set,
00507             ilist,
00508             recipe_name,
00509             CRIRES_WL_MAP_IMA,
00510             CRIRES_PROTYPE_WL_MAP,
00511             crires_spec_wavecal_config.period,
00512             NULL,
00513             (const cpl_propertylist **)qclists,
00514             PACKAGE "/" PACKAGE_VERSION,
00515             "crires_spec_wavecal_ima.fits") ;
00516 
00517     if (ilist_model != NULL) {
00518         /* Write the image */
00519         crires_image_save(set,
00520                 parlist,
00521                 set,
00522                 ilist_model,
00523                 recipe_name,
00524                 CRIRES_WL_MAP_MODEL_IMA,
00525                 CRIRES_PROTYPE_WL_MAP,
00526                 crires_spec_wavecal_config.period,
00527                 NULL,
00528                 (const cpl_propertylist **)qclists,
00529                 PACKAGE "/" PACKAGE_VERSION,
00530                 "crires_spec_wavecal_ima_model.fits") ;
00531     }
00532 
00533     /* Write the table */
00534     crires_table_save(set,
00535             parlist,
00536             set, 
00537             wl_tab, 
00538             recipe_name,
00539             CRIRES_CALPRO_WAVE, 
00540             CRIRES_PROTYPE_WL_POLY,
00541             NULL,
00542             (const cpl_propertylist **)qclists, 
00543             PACKAGE "/" PACKAGE_VERSION,
00544             "crires_spec_wavecal_tab.fits") ;
00545 
00546     /* Free and return */
00547     for (i=0 ; i<CRIRES_NB_DETECTORS ; i++) {
00548         cpl_propertylist_delete(qclists[i]) ;
00549     }
00550     cpl_free(qclists) ;
00551     return  0;
00552 }

Generated on 22 Mar 2011 for CRIRES Pipeline Reference Manual by  doxygen 1.6.1