UVES Pipeline Reference Manual  5.4.0
flames_reduce_vcorrel.c
1 
2 /*
3  * This file is part of the ESO UVES Pipeline
4  * Copyright (C) 2004,2005 European Southern Observatory
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA
19  */
20 
21 
22 /*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*/
30 #include <irplib_utils.h>
31 #include <uves_msg.h>
32 #include <uves_error.h>
33 #include <uves_qclog.h>
34 #include <uves_dfs.h>
35 #include <uves_utils_wrappers.h>
36 #include <flames_midas_def.h>
37 #include <flames_corvel.h>
38 #include <flames_reduce_vcorrel.h>
39 
40 
41 // Simultaneous corvel simcal data reduction
42 double DRS_CVEL_MIN = -6.;
43 double DRS_CVEL_MAX = +6.;
44 double DRS_CVEL_STEP = 0.5;
45 
46 
47 int
48 flames_reduce_vcorrel(const char* sci_pfx,
49  const char* cvel_pfx,
50  const char* ccd_id,
51  const int ord_max,
52  const cpl_frame* cvel_tab,
53  const char* xxima_pfx,
54  const char* xwcal_pfx,
55  const double drs_cvel_min,
56  const double drs_cvel_max,
57  double* zero_point,
58  double* avg_cnt,
59  double* sig_cnt,
60  cpl_table* qclog)
61 {
62 
63  int ord = 0;
64  int ord_min=1;
65  char cvel_tab_name[80];
66  char tim_ccf[80];
67  char nim_ccf[80];
68  char iim_pfx[80];
69  char tab_pfx[80];
70  char nim_pfx[80];
71  char tim_pfx[80];
72  char ref_frm[80];
73  char otab[80];
74  const int npix=(drs_cvel_max-drs_cvel_min)/DRS_CVEL_STEP+1;
75 
76  cpl_image* tim_ccf_ima=NULL;
77  cpl_image* nim_ccf_ima=NULL;
78 
79  cpl_table* cvel_tbl=NULL;
80  double ccfcnt[ord_max];
81  int num_ord=0;
82  int status=0;
83  int unit=0;
84  int actvals=0;
85  int null=0;
86 
87  int in_ima_id=0;
88  int iim_pfx_id=0;
89 
90  char out_cvel_tab[80];
91  char out_tot_ima[80];
92  char out_nrm_ima[80];
93  cpl_table* cvel_ord_tbl=NULL;
94  int row_pos=0;
95 
96  cpl_image* tot_ima=NULL;
97  cpl_image* nrm_ima=NULL;
98  int nrow=0;
99 
100  double ccf_max=0;
101  double wav_rng=0;
102  double pix_tot=0;
103  int lin_tot=0;
104  cpl_propertylist* plist_ima_new=NULL;
105  cpl_propertylist* plist_tbl_new=NULL;
106 
107  double corvel_max=0;
108 
109 
110  char key_name[80];
111 
112  const char* command=NULL;
113 
114 
115 
116  //Fixme
117  uves_msg_debug("sci_pfx=%s",sci_pfx);
118  uves_msg_debug("ccd_id=%s",ccd_id);
119 
120  sprintf(otab,"%s%s%s",cvel_pfx,ccd_id,".fits");
121  sprintf(tim_ccf,"%s%s%s%s","tot_",cvel_pfx,ccd_id,".fits");
122  sprintf(nim_ccf,"%s%s%s%s","nrm_",cvel_pfx,ccd_id,".fits");
123  sprintf(iim_pfx,"%s%s%s%s","mw",sci_pfx,xxima_pfx,".fits");
124  sprintf(tab_pfx,"%s%s%s","tab_",ccd_id,"_");
125  sprintf(nim_pfx,"%s%s%s","nrm_",ccd_id,"_");
126  sprintf(tim_pfx,"%s%s%s","tot_",ccd_id,"_");
127  sprintf(ref_frm,"%s%s%s","w",sci_pfx,xwcal_pfx);
128 
129 
130  uves_msg_debug("pointer=%p",cvel_tab);
131 
132  uves_msg("name=%s",cpl_frame_get_filename(cvel_tab));
133  sprintf(cvel_tab_name,"%s",cpl_frame_get_filename(cvel_tab));
134 
135  uves_msg_debug("npix=%d",npix);
136  tim_ccf_ima=cpl_image_new(npix,ord_max,CPL_TYPE_FLOAT);
137  nim_ccf_ima=cpl_image_new(npix,ord_max,CPL_TYPE_FLOAT);
138 
139 
140  //AMO:Fixme
141  row_pos=0;
142  uves_msg_debug("ord_max=%d nlines=%d",ord_max,npix*ord_max);
143  //cvel_tbl=cpl_table_new(npix*ord_max);
144  cvel_tbl=cpl_table_new(0);
145  check_nomsg(cpl_table_new_column(cvel_tbl,"Select",CPL_TYPE_INT));
146  check_nomsg(cpl_table_new_column(cvel_tbl,"ccf_pos",CPL_TYPE_DOUBLE));
147  check_nomsg(cpl_table_new_column(cvel_tbl,"ccf_nrm",CPL_TYPE_DOUBLE));
148  check_nomsg(cpl_table_new_column(cvel_tbl,"ccf_out",CPL_TYPE_DOUBLE));
149  check_nomsg(cpl_table_new_column(cvel_tbl,"ORDER",CPL_TYPE_INT));
150  check_nomsg(plist_ima_new=cpl_propertylist_new());
151 
152 
153 
154  ck0_nomsg(uves_qclog_add_string(qclog,
155  "QC TEST2 ID",
156  "Fibre-Science-QC",
157  "Name of QC test",
158  "%s"));
159  uves_check_rec_status(0);
160 
161  for (ord=ord_min;ord<=ord_max;ord++) {
162  ccfcnt[ord]=0;
163  //for (ord=2;ord<=2;ord++) {
164 
165  sprintf(out_cvel_tab,"%s%s%d%s","tab_",ccd_id,ord,".fits");
166  sprintf(out_tot_ima,"%s%s%d%s","tot_",ccd_id,ord,".fits");
167  sprintf(out_nrm_ima,"%s%s%d%s","nrm_",ccd_id,ord,".fits");
168 
169 
170  uves_msg_debug("vc2 %s %s %s",out_cvel_tab,out_tot_ima,out_nrm_ima);
171  uves_msg_debug("iim_pfx=%s cvel_tab_name=%s ord=%d",
172  iim_pfx,cvel_tab_name,ord);
173 
174  uves_msg_debug("out_cvel_tab=%s",out_cvel_tab);
175  uves_msg_debug("out_tot_ima=%s",out_tot_ima);
176  uves_msg_debug("out_nrm_ima=%s",out_nrm_ima);
177  uves_msg_debug("ord=%d",ord);
178 
179 
180 
181 
182  check_nomsg(flames_corvel(iim_pfx,
183  cvel_tab_name,
184  ord,
185  out_cvel_tab,
186  out_tot_ima,
187  out_nrm_ima,
188  drs_cvel_min,
189  drs_cvel_max,
190  DRS_CVEL_STEP));
191 
192 
193  uves_msg_debug("CVEL MAX=%f MIN=%f STEP=%f",
194  drs_cvel_min,drs_cvel_max,DRS_CVEL_STEP);
195 
196  check_nomsg(tot_ima=cpl_image_load(out_tot_ima,CPL_TYPE_FLOAT,0,0));
197  check_nomsg(nrm_ima=cpl_image_load(out_nrm_ima,CPL_TYPE_FLOAT,0,0));
198  check_nomsg(cpl_image_copy(tim_ccf_ima,tot_ima,1,ord-ord_min+1));
199  check_nomsg(cpl_image_copy(nim_ccf_ima,nrm_ima,1,ord-ord_min+1));
200  check_nomsg(cvel_ord_tbl=cpl_table_load(out_cvel_tab,1,1));
201 
202 
203  check_nomsg(cpl_table_new_column(cvel_ord_tbl,"ORDER",CPL_TYPE_INT));
204  check_nomsg(nrow=cpl_table_get_nrow(cvel_ord_tbl));
205 
206  check_nomsg(cpl_table_fill_column_window_int(cvel_ord_tbl,"ORDER",0,nrow,ord));
207  check_nomsg(cpl_table_insert(cvel_tbl,cvel_ord_tbl,row_pos));
208  row_pos+=nrow;
209 
210  if((status=SCFOPN(out_tot_ima,D_R4_FORMAT,0,F_IMA_TYPE,&in_ima_id))!=0) {
211  uves_msg_error("opening frame %s",out_tot_ima);
212  return flames_midas_error(MAREMMA);
213  }
214 
215  if((status=SCFOPN(iim_pfx,D_R4_FORMAT,0,F_IMA_TYPE,&iim_pfx_id))!=0) {
216  uves_msg_error("opening frame %s",iim_pfx);
217  return flames_midas_error(MAREMMA);
218  }
219 
220 
221 
222  sprintf(key_name,"%s","CORVEL_MAX");
223  if((status=SCDRDD(iim_pfx_id,key_name,1,1,&actvals,&corvel_max,&unit,&null))
224  != 0) {
225  uves_msg_error("Reading descriptor %s from frame %s",
226  key_name,out_tot_ima);
227  return flames_midas_error(MAREMMA);
228  }
229 
230 
231 
232  sprintf(key_name,"%s%d","CCF_PMX",ord);
233  uves_msg_debug("corvel_max=%g",corvel_max);
234  if(!irplib_isnan(corvel_max)) {
235  ccfcnt[ord]=corvel_max;
236  check_nomsg(cpl_propertylist_append_double(plist_ima_new,key_name,
237  corvel_max));
238 
239 
240 
241  ck0_nomsg(uves_qclog_add_double(qclog,
242  cpl_sprintf("%s%d%s",
243  "QC CCF",ord," POSMAX"),
244  corvel_max,
245  "CCF pos Max",
246  "%f"));
247 
248 
249  } else {
250  ccfcnt[ord]=999;
251  check_nomsg(cpl_propertylist_append_double(plist_ima_new,key_name,
252  999));
253 
254 
255 
256 
257  ck0_nomsg(uves_qclog_add_double(qclog,
258  cpl_sprintf("%s%d%s",
259  "QC CCF",ord," POSMAX"),
260  999,
261  "CCF pos Max",
262  "%f"));
263 
264 
265  }
266 
267 
268  sprintf(key_name,"%s","CCF_MAX");
269  if((status=SCDRDD(in_ima_id,key_name,1,1,&actvals,&ccf_max,&unit,&null))
270  != 0) {
271  uves_msg_error("Reading descriptor %s from frame %s",
272  key_name,out_tot_ima);
273  return flames_midas_error(MAREMMA);
274  }
275 
276 
277  sprintf(key_name,"%s%d","CCF_MAX",ord);
278  uves_msg_debug("ccf_max=%g",ccf_max);
279  check_nomsg(cpl_propertylist_append_double(plist_ima_new,key_name,ccf_max));
280 
281 
282  ck0_nomsg(uves_qclog_add_double(qclog,
283  cpl_sprintf("%s%d%s",
284  "QC CCF",ord," INTMAX"),
285  ccf_max,
286  "CCF Int Max",
287  "%f"));
288 
289 
290 
291  sprintf(key_name,"%s","WAV_RNG");
292  if((status=SCDRDD(in_ima_id,key_name,1,1,&actvals,&wav_rng,&unit,&null))
293  != 0) {
294  uves_msg_error("Reading descriptor %s from frame %s",
295  key_name,out_tot_ima);
296  return flames_midas_error(MAREMMA);
297  }
298 
299  sprintf(key_name,"%s%d","WAV_RNG",ord);
300  uves_msg_debug("wav_rng=%g",wav_rng);
301  uves_msg_debug("key_name=%s",key_name);
302  check_nomsg(cpl_propertylist_append_double(plist_ima_new,key_name,wav_rng));
303 
304 
305  ck0_nomsg(uves_qclog_add_double(qclog,
306  cpl_sprintf("%s%d%s",
307  "QC CCF",ord," WAVRNG"),
308  wav_rng,
309  "CCF Range",
310  "%f"));
311 
312 
313 
314  sprintf(key_name,"%s","PIX_TOT");
315  if((status=SCDRDD(in_ima_id,key_name,1,1,&actvals,&pix_tot,&unit,&null))
316  != 0) {
317  uves_msg_error("Reading descriptor %s from frame %s",
318  key_name,out_tot_ima);
319  return flames_midas_error(MAREMMA);
320  }
321 
322 
323  uves_msg_debug("pix_tot=%g",pix_tot);
324  if(!irplib_isinf(pix_tot)) {
325 
326  sprintf(key_name,"%s%d","PIX_TOT",ord);
327  check_nomsg(cpl_propertylist_append_double(plist_ima_new,key_name,pix_tot));
328 
329  ck0_nomsg(uves_qclog_add_double(qclog,
330  cpl_sprintf("%s%d%s",
331  "QC CCF",ord," PIXTOT"),
332  pix_tot,
333  "CCF Pix",
334  "%f"));
335 
336  } else {
337 
338  sprintf(key_name,"%s%d","PIX_TOT",ord);
339  check_nomsg(cpl_propertylist_append_double(plist_ima_new,key_name,999.));
340 
341  ck0_nomsg(uves_qclog_add_double(qclog,
342  cpl_sprintf("%s%d%s",
343  "QC CCF",ord," PIXTOT"),
344  999,
345  "CCF Pix",
346  "%f"));
347 
348 
349  }
350 
351  sprintf(key_name,"%s","LIN_TOT");
352  if((status=SCDRDI(in_ima_id,key_name,1,1,&actvals,&lin_tot,&unit,&null))
353  != 0) {
354  uves_msg_error("Reading descriptor %s from frame %s",
355  key_name,out_tot_ima);
356  return flames_midas_error(MAREMMA);
357  }
358 
359 
360  sprintf(key_name,"%s%d","LIN_TOT",ord);
361 
362  check_nomsg(cpl_propertylist_append_int(plist_ima_new,key_name,lin_tot));
363  uves_msg_debug("lin_tot=%d",lin_tot);
364 
365 
366  ck0_nomsg(uves_qclog_add_int(qclog,
367  cpl_sprintf("%s%d%s",
368  "QC CCF",ord," LINTOT"),
369  pix_tot,
370  "CCF Lin",
371  "%d"));
372 
373 
374  if((status = SCFCLO(in_ima_id))!=0) {
375  uves_msg_error("Closing frame %d",in_ima_id);
376  return flames_midas_error(MAREMMA);
377  }
378  if((status = SCFCLO(iim_pfx_id))!=0) {
379  uves_msg_error("Closing frame %d",iim_pfx_id);
380  return flames_midas_error(MAREMMA);
381  }
382 
383 
384  uves_free_table(&cvel_ord_tbl);
385  uves_free_image(&tot_ima);
386  uves_free_image(&nrm_ima);
387 
388  command=uves_sprintf("%s%s","rm -rf ",out_cvel_tab);
389  system(command);
390  command=uves_sprintf("%s%s","rm -rf ",out_tot_ima);
391  system(command);
392  command=uves_sprintf("%s%s","rm -rf ",out_nrm_ima);
393  system(command);
394 
395 
396  } //end loop over orders
397 
398 
399  check_nomsg(cpl_image_save(tim_ccf_ima, "tot_ima.fits",CPL_BPP_IEEE_FLOAT,
400  plist_ima_new,CPL_IO_DEFAULT));
401  check_nomsg(cpl_image_save(nim_ccf_ima, "nrm_ima.fits",CPL_BPP_IEEE_FLOAT,
402  plist_ima_new,CPL_IO_DEFAULT));
403 
404  check_nomsg(cpl_table_save(cvel_tbl, plist_tbl_new, NULL, otab,
405  CPL_IO_DEFAULT));
406 
407  uves_free_image(&tim_ccf_ima);
408  uves_free_image(&nim_ccf_ima);
409  uves_free_table(&cvel_tbl);
410 
411  ord = ord_max-ord_min+1;
412  //flames_cveltab(cpfx_ccd_id_tbl,ord);
413 
414 
415 
416  num_ord = 0;
417  *avg_cnt=0;
418  for (ord=ord_min; ord<= ord_max; ord++) {
419  if (ccfcnt[ord] != 999) {
420  *avg_cnt +=ccfcnt[ord];
421  uves_msg_debug("POSMAX avg=%g cnt=%g ord=%d",*avg_cnt,ccfcnt[ord],ord);
422  num_ord += 1;
423  }
424  }
425 
426  *avg_cnt /= num_ord;
427  *sig_cnt=0;
428  for (ord = ord_min; ord <= ord_max; ord++) {
429  if (ccfcnt[ord] != 999) {
430  *sig_cnt += (ccfcnt[ord]-*avg_cnt)*(ccfcnt[ord]-*avg_cnt);
431  uves_msg_debug("sig=%g cnt=%g ord=%d",*sig_cnt,ccfcnt[ord],ord);
432  }
433  }
434  *sig_cnt = sqrt(*sig_cnt/(num_ord-1));
435 
436  *zero_point+=(*avg_cnt);
437 
438 
439  /*
440  uves_msg("POSMAX avg=%g sig=%g zp=%g",*avg_cnt,*sig_cnt,*zero_point);
441  */
442 
443  ck0_nomsg(uves_qclog_add_double(qclog,
444  "QC CCF POSAVG",
445  *avg_cnt,
446  "CCF pos avg",
447  "%f"));
448 
449 
450  ck0_nomsg(uves_qclog_add_double(qclog,
451  "QC CCF POSRMS",
452  *sig_cnt,
453  "CCF pos rms",
454  "%f"));
455  /* commented out to match FUVES-MIDAS results
456 
457  ck0_nomsg(uves_qclog_add_double(qclog,
458  "QC CCF POSOFF",
459  *zero_point,
460  "CCF pos avg from ThAr calibration",
461  "%f"));
462 
463  */
464 
465 
466 
467  uves_msg_debug("POSAVG=%f POSRMS=%f",*avg_cnt,*sig_cnt);
468 
469 
470  /*
471  do ord = ord_min ord_max
472 
473  CORVEL/FLAMES {iim_pfx}{ord}.bdf {cvel_tab} {ord} -
474  {tab_pfx}{ord}.tbl {tim_pfx}{ord}.bdf {nim_pfx}{ord}.bdf
475 
476 
477 
478  insert/ima {tim_pfx}{ord}.bdf {tim_ccf} @1,@{ord}
479  insert/ima {nim_pfx}{ord}.bdf {nim_ccf} @1,@{ord}
480 
481  create/column {tab_pfx}{ord}.tbl :ORDER
482  compute/table {tab_pfx}{ord}.tbl :ORDER = {ord}
483  if counter .eq. 0 then
484  merge/table {tab_pfx}{ord}.tbl {cpfx}_{ccd_id}.tbl
485  counter = counter + 1
486  else
487  -rename {cpfx}_{ccd_id}.tbl tmp.tbl
488  merge/table tmp.tbl {tab_pfx}{ord}.tbl {cpfx}_{ccd_id}.tbl
489  endif
490  copy/dd {iim_pfx}{ord}.bdf CORVEL_MAX {cpfx}_{ccd_id}.tbl CCF_PMX{ord}
491  qc1log/out 1 {otab} "QC.CCF{ord}.POSMAX" {{iim_pfx}{ord}.bdf,CORVEL_MAX} "CCF pos Max"
492  qc1log/out 1 {otab} "QC.CCF{ord}.INTMAX" {{tab_pfx}{ord}.tbl,CCF_MAX} "CCF Int Max"
493  qc1log/out 1 {otab} "QC.CCF{ord}.WAVRNG" {{tab_pfx}{ord}.tbl,WAV_RNG} "CCF Range"
494  qc1log/out 1 {otab} "QC.CCF{ord}.PIXTOT" {{tab_pfx}{ord}.tbl,PIX_TOT} "CCF Pix"
495  qc1log/out 1 {otab} "QC.CCF{ord}.LINTOT" {{tab_pfx}{ord}.tbl,LIN_TOT} "CCF Lin"
496  if "{{iim_pfx}{ord}.bdf,CORVEL_MAX}" .ne. "NAN" then
497  ccfcnt({ord}) = {{iim_pfx}{ord}.bdf,CORVEL_MAX}
498  else
499  mess/out 2 {pid} "Pos Max Nan for order {ord}. Skip it"
500  ccfcnt({ord}) = 999
501  endif
502 
503  copy/dd {tab_pfx}{ord}.tbl CCF_MAX {cpfx}_{ccd_id}.tbl CCF_MAX{ord}
504  copy/dd {tab_pfx}{ord}.tbl WAV_RNG {cpfx}_{ccd_id}.tbl WAV_RNG{ord}
505  copy/dd {tab_pfx}{ord}.tbl PIX_TOT {cpfx}_{ccd_id}.tbl PIX_TOT{ord}
506  copy/dd {tab_pfx}{ord}.tbl LIN_TOT {cpfx}_{ccd_id}.tbl LIN_TOT{ord}
507 
508 
509 
510  copy/dd {iim_pfx}{ord}.bdf CORVEL_MAX {tim_ccf} CCF_PMX{ord}
511  copy/dd {tim_pfx}{ord}.bdf CCF_MAX {tim_ccf} CCF_MAX{ord}
512  copy/dd {tim_pfx}{ord}.bdf WAV_RNG {tim_ccf} WAV_RNG{ord}
513  copy/dd {tim_pfx}{ord}.bdf PIX_TOT {tim_ccf} PIX_TOT{ord}
514  copy/dd {tim_pfx}{ord}.bdf LIN_TOT {tim_ccf} LIN_TOT{ord}
515 
516  copy/dd {iim_pfx}{ord}.bdf CORVEL_MAX {nim_ccf} CCF_PMX{ord}
517  copy/dd {nim_pfx}{ord}.bdf CCF_MAX {nim_ccf} CCF_MAX{ord}
518  copy/dd {nim_pfx}{ord}.bdf WAV_RNG {nim_ccf} WAV_RNG{ord}
519  copy/dd {nim_pfx}{ord}.bdf PIX_TOT {nim_ccf} PIX_TOT{ord}
520  copy/dd {nim_pfx}{ord}.bdf LIN_TOT {nim_ccf} LIN_TOT{ord}
521 
522  enddo
523  ord = {ord_max}-{ord_min}+1
524  CVELTAB/FLAMES {cpfx}_{ccd_id}.tbl {ord}
525 
526 
527 
528  nord = 0
529  do ord = ord_min ord_max
530  if ccfcnt({ord}) .ne. 999 then
531  avgcnt = avgcnt+ccfcnt({ord})
532  nord = nord+1
533  endif
534  enddo
535  avgcnt = avgcnt/(nord)
536  do ord = ord_min ord_max
537  if ccfcnt({ord}) .ne. 999 then
538  sigcnt = sigcnt+(ccfcnt({ord})-avgcnt)*(ccfcnt({ord})-avgcnt)
539  endif
540  enddo
541  sigcnt = m$sqrt(sigcnt/(nord-1))
542 
543 
544  mess/out {DRS_MES_LEV} {pid} "POSAVG={avgcnt} POSRMS={sigcnt}"
545  qc1log/out 1 {otab} "QC.CCF.POSAVG" {avgcnt} "CCF pos avg"
546  qc1log/out 1 {otab} "QC.CCF.POSRMS" {sigcnt} "CCF pos rms"
547  qc1log/out 1 {otab} "QC.CCF.POSOFF" {p8} "CCF pos avg from ThAr calibration"
548 
549  qc1log/out 3
550  return {avgcnt}
551  !set/format {cpfx}_{ccd_id}.tbl
552 
553 
554  */
555  cleanup:
556 
557  if(plist_ima_new!=NULL) {
558  uves_msg_warning("free");
559  cpl_propertylist_delete(plist_ima_new);
560  plist_ima_new=NULL;
561  }
562  uves_free_table(&cvel_tbl);
563  uves_free_image(&tim_ccf_ima);
564  uves_free_image(&nim_ccf_ima);
565  uves_free_image(&tot_ima);
566  uves_free_image(&nrm_ima);
567  uves_free_table(&cvel_ord_tbl);
568 
569 
570 
571  if (cpl_error_get_code() != CPL_ERROR_NONE) {
572  uves_check_rec_status(9);
573  //uves_free_imagelist(&obj_cor);
574  return -1;
575  } else {
576  return 0;
577  }
578 
579 }
580