flames_reduce_vcorrel.c

00001 
00002 /*
00003  * This file is part of the ESO UVES Pipeline
00004  * Copyright (C) 2004,2005 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, 51 Franklin St, Fifth Floor, Boston, MA  02111-1307  USA
00019  */
00020 
00021 
00022 /*---------------------------------------------------------------------------*/
00029 /*---------------------------------------------------------------------------*/
00030 #include <irplib_utils.h>
00031 #include <uves_msg.h>
00032 #include <uves_error.h>
00033 #include <uves_qclog.h>
00034 #include <uves_dfs.h>
00035 #include <uves_utils_wrappers.h>
00036 #include <flames_midas_def.h>
00037 #include <flames_corvel.h>
00038 #include <flames_reduce_vcorrel.h>
00039 
00040 
00041 // Simultaneous corvel simcal data reduction
00042 double DRS_CVEL_MIN = -6.;
00043 double DRS_CVEL_MAX = +6.;
00044 double DRS_CVEL_STEP = 0.5;
00045 
00046 
00047 int
00048 flames_reduce_vcorrel(const char* sci_pfx, 
00049                       const char* cvel_pfx, 
00050                       const char* ccd_id,
00051                       const int ord_max,
00052                       const cpl_frame* cvel_tab, 
00053                       const char* xxima_pfx, 
00054                       const char* xwcal_pfx,
00055                       const double drs_cvel_min,
00056                       const double drs_cvel_max,
00057                       double* zero_point,
00058                       double* avg_cnt,
00059                       double* sig_cnt,
00060               cpl_table* qclog)
00061 {
00062 
00063    int ord = 0;
00064    int ord_min=1;
00065    char cvel_tab_name[80];
00066    char tim_ccf[80];
00067    char nim_ccf[80];
00068    char iim_pfx[80];
00069    char tab_pfx[80];
00070    char nim_pfx[80];
00071    char tim_pfx[80];
00072    char ref_frm[80];
00073    char otab[80];
00074    const int npix=(drs_cvel_max-drs_cvel_min)/DRS_CVEL_STEP+1;
00075 
00076    cpl_image* tim_ccf_ima=NULL;
00077    cpl_image* nim_ccf_ima=NULL;
00078 
00079    cpl_table* cvel_tbl=NULL;
00080    double ccfcnt[ord_max];
00081    int    num_ord=0;
00082    int status=0;
00083    int unit=0;
00084    int actvals=0;
00085    int null=0;
00086  
00087    int in_ima_id=0;
00088    int iim_pfx_id=0;
00089 
00090    char out_cvel_tab[80];
00091    char out_tot_ima[80];
00092    char out_nrm_ima[80];
00093    cpl_table* cvel_ord_tbl=NULL;
00094    int row_pos=0;
00095 
00096    cpl_image* tot_ima=NULL;
00097    cpl_image* nrm_ima=NULL;
00098    int nrow=0;
00099 
00100    double ccf_max=0;
00101    double wav_rng=0;
00102    double pix_tot=0;
00103    int lin_tot=0;
00104    cpl_propertylist* plist_ima_new=NULL;
00105    cpl_propertylist* plist_tbl_new=NULL;
00106 
00107    double corvel_max=0;
00108 
00109 
00110    char key_name[80];
00111 
00112    const char* command=NULL;
00113 
00114 
00115 
00116    //Fixme
00117    uves_msg_debug("sci_pfx=%s",sci_pfx);
00118    uves_msg_debug("ccd_id=%s",ccd_id);
00119 
00120    sprintf(otab,"%s%s%s",cvel_pfx,ccd_id,".fits");
00121    sprintf(tim_ccf,"%s%s%s%s","tot_",cvel_pfx,ccd_id,".fits");
00122    sprintf(nim_ccf,"%s%s%s%s","nrm_",cvel_pfx,ccd_id,".fits");
00123    sprintf(iim_pfx,"%s%s%s%s","mw",sci_pfx,xxima_pfx,".fits");
00124    sprintf(tab_pfx,"%s%s%s","tab_",ccd_id,"_");
00125    sprintf(nim_pfx,"%s%s%s","nrm_",ccd_id,"_");
00126    sprintf(tim_pfx,"%s%s%s","tot_",ccd_id,"_");
00127    sprintf(ref_frm,"%s%s%s","w",sci_pfx,xwcal_pfx);
00128 
00129 
00130    uves_msg_debug("pointer=%p",cvel_tab);
00131 
00132    uves_msg("name=%s",cpl_frame_get_filename(cvel_tab));
00133    sprintf(cvel_tab_name,"%s",cpl_frame_get_filename(cvel_tab));
00134 
00135    uves_msg_debug("npix=%d",npix);
00136    tim_ccf_ima=cpl_image_new(npix,ord_max,CPL_TYPE_FLOAT);
00137    nim_ccf_ima=cpl_image_new(npix,ord_max,CPL_TYPE_FLOAT);
00138 
00139 
00140    //AMO:Fixme
00141    row_pos=0;
00142    uves_msg_debug("ord_max=%d nlines=%d",ord_max,npix*ord_max);
00143    //cvel_tbl=cpl_table_new(npix*ord_max);
00144    cvel_tbl=cpl_table_new(0);
00145    check_nomsg(cpl_table_new_column(cvel_tbl,"Select",CPL_TYPE_INT));
00146    check_nomsg(cpl_table_new_column(cvel_tbl,"ccf_pos",CPL_TYPE_DOUBLE));
00147    check_nomsg(cpl_table_new_column(cvel_tbl,"ccf_nrm",CPL_TYPE_DOUBLE));
00148    check_nomsg(cpl_table_new_column(cvel_tbl,"ccf_out",CPL_TYPE_DOUBLE));
00149    check_nomsg(cpl_table_new_column(cvel_tbl,"ORDER",CPL_TYPE_INT));
00150    check_nomsg(plist_ima_new=cpl_propertylist_new());
00151 
00152 
00153   
00154    ck0_nomsg(uves_qclog_add_string(qclog,
00155                    "QC TEST2 ID",
00156                    "Fibre-Science-QC",
00157                    "Name of QC test",
00158                    "%s"));
00159    uves_check_rec_status(0);
00160 
00161    for (ord=ord_min;ord<=ord_max;ord++) {
00162       ccfcnt[ord]=0;
00163       //for (ord=2;ord<=2;ord++) {
00164  
00165       sprintf(out_cvel_tab,"%s%s%d%s","tab_",ccd_id,ord,".fits");
00166       sprintf(out_tot_ima,"%s%s%d%s","tot_",ccd_id,ord,".fits");
00167       sprintf(out_nrm_ima,"%s%s%d%s","nrm_",ccd_id,ord,".fits");
00168 
00169  
00170       uves_msg_debug("vc2 %s %s %s",out_cvel_tab,out_tot_ima,out_nrm_ima);
00171       uves_msg_debug("iim_pfx=%s cvel_tab_name=%s ord=%d",
00172                        iim_pfx,cvel_tab_name,ord);
00173  
00174       uves_msg_debug("out_cvel_tab=%s",out_cvel_tab);
00175       uves_msg_debug("out_tot_ima=%s",out_tot_ima);
00176       uves_msg_debug("out_nrm_ima=%s",out_nrm_ima);
00177       uves_msg_debug("ord=%d",ord);
00178 
00179  
00180 
00181 
00182       check_nomsg(flames_corvel(iim_pfx,
00183                                 cvel_tab_name,
00184                                 ord,
00185                                 out_cvel_tab,
00186                                 out_tot_ima,
00187                                 out_nrm_ima,
00188                                 drs_cvel_min,
00189                                 drs_cvel_max,
00190                                 DRS_CVEL_STEP));
00191 
00192 
00193       uves_msg_debug("CVEL MAX=%f MIN=%f STEP=%f",
00194                drs_cvel_min,drs_cvel_max,DRS_CVEL_STEP);
00195 
00196       check_nomsg(tot_ima=cpl_image_load(out_tot_ima,CPL_TYPE_FLOAT,0,0));
00197       check_nomsg(nrm_ima=cpl_image_load(out_nrm_ima,CPL_TYPE_FLOAT,0,0));
00198       check_nomsg(cpl_image_copy(tim_ccf_ima,tot_ima,1,ord-ord_min+1));
00199       check_nomsg(cpl_image_copy(nim_ccf_ima,nrm_ima,1,ord-ord_min+1));
00200       check_nomsg(cvel_ord_tbl=cpl_table_load(out_cvel_tab,1,1));
00201  
00202 
00203       check_nomsg(cpl_table_new_column(cvel_ord_tbl,"ORDER",CPL_TYPE_INT));
00204       check_nomsg(nrow=cpl_table_get_nrow(cvel_ord_tbl));
00205 
00206       check_nomsg(cpl_table_fill_column_window_int(cvel_ord_tbl,"ORDER",0,nrow,ord));
00207       check_nomsg(cpl_table_insert(cvel_tbl,cvel_ord_tbl,row_pos));
00208       row_pos+=nrow;
00209 
00210       if((status=SCFOPN(out_tot_ima,D_R4_FORMAT,0,F_IMA_TYPE,&in_ima_id))!=0) {
00211          uves_msg_error("opening frame %s",out_tot_ima);
00212          return flames_midas_error(MAREMMA);
00213       }
00214 
00215       if((status=SCFOPN(iim_pfx,D_R4_FORMAT,0,F_IMA_TYPE,&iim_pfx_id))!=0) {
00216          uves_msg_error("opening frame %s",iim_pfx);
00217          return flames_midas_error(MAREMMA);
00218       }
00219 
00220 
00221 
00222       sprintf(key_name,"%s","CORVEL_MAX");
00223       if((status=SCDRDD(iim_pfx_id,key_name,1,1,&actvals,&corvel_max,&unit,&null)) 
00224          != 0) {
00225     uves_msg_error("Reading descriptor %s from frame %s",
00226                key_name,out_tot_ima);
00227          return flames_midas_error(MAREMMA);
00228       }
00229 
00230  
00231 
00232       sprintf(key_name,"%s%d","CCF_PMX",ord);
00233       uves_msg_debug("corvel_max=%g",corvel_max);
00234       if(!irplib_isnan(corvel_max)) {
00235          ccfcnt[ord]=corvel_max;
00236      check_nomsg(cpl_propertylist_append_double(plist_ima_new,key_name,
00237                             corvel_max));
00238 
00239 
00240          
00241      ck0_nomsg(uves_qclog_add_double(qclog,
00242                      cpl_sprintf("%s%d%s",
00243                              "QC CCF",ord," POSMAX"),
00244                      corvel_max,
00245                      "CCF pos Max",
00246                      "%f"));
00247      
00248 
00249       } else {
00250          ccfcnt[ord]=999;
00251      check_nomsg(cpl_propertylist_append_double(plist_ima_new,key_name,
00252                             999));
00253 
00254 
00255      
00256      
00257      ck0_nomsg(uves_qclog_add_double(qclog,
00258                      cpl_sprintf("%s%d%s",
00259                              "QC CCF",ord," POSMAX"),
00260                      999,
00261                      "CCF pos Max",
00262                      "%f"));
00263      
00264 
00265       }
00266 
00267 
00268       sprintf(key_name,"%s","CCF_MAX");
00269       if((status=SCDRDD(in_ima_id,key_name,1,1,&actvals,&ccf_max,&unit,&null)) 
00270          != 0) {
00271     uves_msg_error("Reading descriptor %s from frame %s",
00272                key_name,out_tot_ima);
00273          return flames_midas_error(MAREMMA);
00274       }
00275 
00276 
00277       sprintf(key_name,"%s%d","CCF_MAX",ord);
00278       uves_msg_debug("ccf_max=%g",ccf_max);
00279       check_nomsg(cpl_propertylist_append_double(plist_ima_new,key_name,ccf_max));
00280 
00281       
00282       ck0_nomsg(uves_qclog_add_double(qclog,
00283                     cpl_sprintf("%s%d%s",
00284                         "QC CCF",ord," INTMAX"),
00285                       ccf_max,
00286                       "CCF Int Max",
00287                       "%f"));
00288 
00289       
00290  
00291       sprintf(key_name,"%s","WAV_RNG");
00292       if((status=SCDRDD(in_ima_id,key_name,1,1,&actvals,&wav_rng,&unit,&null)) 
00293          != 0) {
00294     uves_msg_error("Reading descriptor %s from frame %s",
00295                key_name,out_tot_ima);
00296          return flames_midas_error(MAREMMA);
00297       }
00298 
00299       sprintf(key_name,"%s%d","WAV_RNG",ord);
00300       uves_msg_debug("wav_rng=%g",wav_rng);
00301       uves_msg_debug("key_name=%s",key_name);
00302       check_nomsg(cpl_propertylist_append_double(plist_ima_new,key_name,wav_rng));
00303 
00304       
00305       ck0_nomsg(uves_qclog_add_double(qclog,
00306                     cpl_sprintf("%s%d%s",
00307                         "QC CCF",ord," WAVRNG"),
00308                       wav_rng,
00309                       "CCF Range",
00310                       "%f"));
00311 
00312       
00313      
00314       sprintf(key_name,"%s","PIX_TOT");
00315       if((status=SCDRDD(in_ima_id,key_name,1,1,&actvals,&pix_tot,&unit,&null)) 
00316          != 0) {
00317     uves_msg_error("Reading descriptor %s from frame %s",
00318                key_name,out_tot_ima);
00319          return flames_midas_error(MAREMMA);
00320       }
00321  
00322      
00323       uves_msg_debug("pix_tot=%g",pix_tot);
00324       if(!irplib_isinf(pix_tot)) {
00325 
00326     sprintf(key_name,"%s%d","PIX_TOT",ord);
00327     check_nomsg(cpl_propertylist_append_double(plist_ima_new,key_name,pix_tot));
00328 
00329     ck0_nomsg(uves_qclog_add_double(qclog,
00330                     cpl_sprintf("%s%d%s",
00331                             "QC CCF",ord," PIXTOT"),
00332                     pix_tot,
00333                     "CCF Pix",
00334                     "%f"));
00335 
00336       } else {
00337 
00338     sprintf(key_name,"%s%d","PIX_TOT",ord);
00339     check_nomsg(cpl_propertylist_append_double(plist_ima_new,key_name,999.));
00340 
00341     ck0_nomsg(uves_qclog_add_double(qclog,
00342                     cpl_sprintf("%s%d%s",
00343                             "QC CCF",ord," PIXTOT"),
00344                     999,
00345                     "CCF Pix",
00346                     "%f"));
00347 
00348 
00349       }
00350 
00351       sprintf(key_name,"%s","LIN_TOT");
00352       if((status=SCDRDI(in_ima_id,key_name,1,1,&actvals,&lin_tot,&unit,&null)) 
00353          != 0) {
00354     uves_msg_error("Reading descriptor %s from frame %s",
00355                key_name,out_tot_ima);
00356          return flames_midas_error(MAREMMA);
00357       }
00358 
00359 
00360       sprintf(key_name,"%s%d","LIN_TOT",ord);
00361 
00362       check_nomsg(cpl_propertylist_append_int(plist_ima_new,key_name,lin_tot));
00363       uves_msg_debug("lin_tot=%d",lin_tot);
00364 
00365            
00366       ck0_nomsg(uves_qclog_add_int(qclog,
00367                     cpl_sprintf("%s%d%s",
00368                         "QC CCF",ord," LINTOT"),
00369                       pix_tot,
00370                       "CCF Lin",
00371                       "%d"));
00372      
00373      
00374       if((status = SCFCLO(in_ima_id))!=0) {
00375          uves_msg_error("Closing frame %d",in_ima_id);
00376          return flames_midas_error(MAREMMA);
00377       }
00378       if((status = SCFCLO(iim_pfx_id))!=0) {
00379          uves_msg_error("Closing frame %d",iim_pfx_id);
00380          return flames_midas_error(MAREMMA);
00381       }
00382  
00383      
00384       uves_free_table(&cvel_ord_tbl);
00385       uves_free_image(&tot_ima);
00386       uves_free_image(&nrm_ima);
00387 
00388       command=uves_sprintf("%s%s","rm -rf ",out_cvel_tab);
00389       system(command);
00390       command=uves_sprintf("%s%s","rm -rf ",out_tot_ima);
00391       system(command);
00392       command=uves_sprintf("%s%s","rm -rf ",out_nrm_ima);
00393       system(command);
00394 
00395 
00396    } //end loop over orders
00397 
00398 
00399    check_nomsg(cpl_image_save(tim_ccf_ima, "tot_ima.fits",CPL_BPP_IEEE_FLOAT,
00400                   plist_ima_new,CPL_IO_DEFAULT));
00401    check_nomsg(cpl_image_save(nim_ccf_ima, "nrm_ima.fits",CPL_BPP_IEEE_FLOAT,
00402                   plist_ima_new,CPL_IO_DEFAULT));
00403  
00404    check_nomsg(cpl_table_save(cvel_tbl, plist_tbl_new, NULL, otab, 
00405                   CPL_IO_DEFAULT));
00406  
00407    uves_free_image(&tim_ccf_ima);
00408    uves_free_image(&nim_ccf_ima);
00409    uves_free_table(&cvel_tbl);
00410 
00411    ord = ord_max-ord_min+1;
00412    //flames_cveltab(cpfx_ccd_id_tbl,ord);
00413 
00414 
00415 
00416    num_ord = 0;
00417    *avg_cnt=0;
00418    for (ord=ord_min; ord<= ord_max; ord++) {
00419       if (ccfcnt[ord] != 999) {
00420          *avg_cnt +=ccfcnt[ord];
00421          uves_msg_debug("POSMAX avg=%g cnt=%g ord=%d",*avg_cnt,ccfcnt[ord],ord);
00422          num_ord += 1;
00423       }
00424    }
00425  
00426    *avg_cnt /= num_ord;
00427    *sig_cnt=0;
00428    for (ord = ord_min; ord <= ord_max; ord++) {
00429       if (ccfcnt[ord] != 999) {
00430          *sig_cnt += (ccfcnt[ord]-*avg_cnt)*(ccfcnt[ord]-*avg_cnt);
00431          uves_msg_debug("sig=%g cnt=%g ord=%d",*sig_cnt,ccfcnt[ord],ord);
00432       }
00433    }
00434    *sig_cnt = sqrt(*sig_cnt/(num_ord-1));
00435 
00436    *zero_point+=(*avg_cnt);
00437 
00438 
00439    /*
00440    uves_msg("POSMAX avg=%g sig=%g zp=%g",*avg_cnt,*sig_cnt,*zero_point);
00441    */
00442 
00443    ck0_nomsg(uves_qclog_add_double(qclog,
00444                    "QC CCF POSAVG",
00445                    *avg_cnt,
00446                    "CCF pos avg",
00447                    "%f"));
00448 
00449 
00450    ck0_nomsg(uves_qclog_add_double(qclog,
00451                    "QC CCF POSRMS",
00452                    *sig_cnt,
00453                    "CCF pos rms",
00454                    "%f"));
00455    /* commented out to match FUVES-MIDAS results
00456 
00457   ck0_nomsg(uves_qclog_add_double(qclog,
00458                    "QC CCF POSOFF",
00459                    *zero_point,
00460                    "CCF pos avg from ThAr calibration",
00461                    "%f"));
00462 
00463    */
00464  
00465 
00466 
00467    uves_msg_debug("POSAVG=%f POSRMS=%f",*avg_cnt,*sig_cnt);
00468  
00469 
00470    /*
00471      do ord = ord_min ord_max
00472 
00473      CORVEL/FLAMES {iim_pfx}{ord}.bdf {cvel_tab} {ord} -
00474      {tab_pfx}{ord}.tbl {tim_pfx}{ord}.bdf {nim_pfx}{ord}.bdf
00475     
00476  
00477 
00478      insert/ima {tim_pfx}{ord}.bdf {tim_ccf} @1,@{ord}
00479      insert/ima {nim_pfx}{ord}.bdf {nim_ccf} @1,@{ord}
00480      
00481      create/column {tab_pfx}{ord}.tbl :ORDER
00482      compute/table {tab_pfx}{ord}.tbl :ORDER = {ord}
00483      if counter .eq. 0 then
00484      merge/table {tab_pfx}{ord}.tbl  {cpfx}_{ccd_id}.tbl
00485      counter = counter + 1
00486      else
00487      -rename {cpfx}_{ccd_id}.tbl tmp.tbl
00488      merge/table tmp.tbl {tab_pfx}{ord}.tbl  {cpfx}_{ccd_id}.tbl  
00489      endif
00490      copy/dd {iim_pfx}{ord}.bdf CORVEL_MAX {cpfx}_{ccd_id}.tbl CCF_PMX{ord}
00491      qc1log/out 1 {otab}  "QC.CCF{ord}.POSMAX" {{iim_pfx}{ord}.bdf,CORVEL_MAX} "CCF pos Max"
00492      qc1log/out 1 {otab}  "QC.CCF{ord}.INTMAX" {{tab_pfx}{ord}.tbl,CCF_MAX} "CCF Int Max"
00493      qc1log/out 1 {otab}  "QC.CCF{ord}.WAVRNG" {{tab_pfx}{ord}.tbl,WAV_RNG} "CCF Range"
00494      qc1log/out 1 {otab}  "QC.CCF{ord}.PIXTOT" {{tab_pfx}{ord}.tbl,PIX_TOT} "CCF Pix"
00495      qc1log/out 1 {otab}  "QC.CCF{ord}.LINTOT" {{tab_pfx}{ord}.tbl,LIN_TOT} "CCF Lin"
00496      if "{{iim_pfx}{ord}.bdf,CORVEL_MAX}" .ne. "NAN" then
00497      ccfcnt({ord}) = {{iim_pfx}{ord}.bdf,CORVEL_MAX}
00498      else
00499      mess/out 2 {pid} "Pos Max Nan for order {ord}. Skip it"
00500      ccfcnt({ord}) = 999
00501      endif
00502 
00503      copy/dd {tab_pfx}{ord}.tbl CCF_MAX {cpfx}_{ccd_id}.tbl CCF_MAX{ord}
00504      copy/dd {tab_pfx}{ord}.tbl WAV_RNG {cpfx}_{ccd_id}.tbl WAV_RNG{ord}
00505      copy/dd {tab_pfx}{ord}.tbl PIX_TOT {cpfx}_{ccd_id}.tbl PIX_TOT{ord}
00506      copy/dd {tab_pfx}{ord}.tbl LIN_TOT {cpfx}_{ccd_id}.tbl LIN_TOT{ord}
00507 
00508 
00509 
00510      copy/dd {iim_pfx}{ord}.bdf CORVEL_MAX {tim_ccf} CCF_PMX{ord}
00511      copy/dd {tim_pfx}{ord}.bdf CCF_MAX    {tim_ccf} CCF_MAX{ord}
00512      copy/dd {tim_pfx}{ord}.bdf WAV_RNG    {tim_ccf} WAV_RNG{ord}
00513      copy/dd {tim_pfx}{ord}.bdf PIX_TOT    {tim_ccf} PIX_TOT{ord}
00514      copy/dd {tim_pfx}{ord}.bdf LIN_TOT    {tim_ccf} LIN_TOT{ord}
00515 
00516      copy/dd {iim_pfx}{ord}.bdf CORVEL_MAX {nim_ccf} CCF_PMX{ord}
00517      copy/dd {nim_pfx}{ord}.bdf CCF_MAX    {nim_ccf} CCF_MAX{ord}
00518      copy/dd {nim_pfx}{ord}.bdf WAV_RNG    {nim_ccf} WAV_RNG{ord}
00519      copy/dd {nim_pfx}{ord}.bdf PIX_TOT    {nim_ccf} PIX_TOT{ord}
00520      copy/dd {nim_pfx}{ord}.bdf LIN_TOT    {nim_ccf} LIN_TOT{ord}
00521 
00522      enddo
00523      ord = {ord_max}-{ord_min}+1
00524      CVELTAB/FLAMES {cpfx}_{ccd_id}.tbl {ord}
00525 
00526 
00527 
00528      nord = 0
00529      do ord = ord_min ord_max
00530      if ccfcnt({ord}) .ne. 999 then
00531      avgcnt = avgcnt+ccfcnt({ord})
00532      nord = nord+1
00533      endif
00534      enddo
00535      avgcnt = avgcnt/(nord)
00536      do ord = ord_min ord_max
00537      if ccfcnt({ord}) .ne. 999 then
00538      sigcnt = sigcnt+(ccfcnt({ord})-avgcnt)*(ccfcnt({ord})-avgcnt)
00539      endif
00540      enddo
00541      sigcnt = m$sqrt(sigcnt/(nord-1))
00542 
00543 
00544      mess/out {DRS_MES_LEV} {pid} "POSAVG={avgcnt} POSRMS={sigcnt}"
00545      qc1log/out 1 {otab}  "QC.CCF.POSAVG" {avgcnt} "CCF pos avg"
00546      qc1log/out 1 {otab}  "QC.CCF.POSRMS" {sigcnt} "CCF pos rms"
00547      qc1log/out 1 {otab}  "QC.CCF.POSOFF" {p8}  "CCF pos avg from ThAr calibration"
00548 
00549      qc1log/out 3
00550      return {avgcnt}
00551      !set/format {cpfx}_{ccd_id}.tbl
00552 
00553 
00554    */
00555   cleanup:
00556 
00557    if(plist_ima_new!=NULL) {
00558      uves_msg_warning("free");
00559       cpl_propertylist_delete(plist_ima_new);
00560       plist_ima_new=NULL;
00561    }
00562    uves_free_table(&cvel_tbl);
00563    uves_free_image(&tim_ccf_ima);
00564    uves_free_image(&nim_ccf_ima);
00565    uves_free_image(&tot_ima);
00566    uves_free_image(&nrm_ima);
00567    uves_free_table(&cvel_ord_tbl);
00568  
00569 
00570 
00571    if (cpl_error_get_code() != CPL_ERROR_NONE) {
00572       uves_check_rec_status(9);
00573       //uves_free_imagelist(&obj_cor);
00574       return -1;
00575    } else {
00576       return 0;
00577    }
00578 
00579 }
00580 

Generated on 8 Mar 2011 for UVES Pipeline Reference Manual by  doxygen 1.6.1