X-shooter Pipeline Reference Manual 3.8.15
xsh_data_rec.c
Go to the documentation of this file.
1/* *
2 * This file is part of the ESO X-shooter Pipeline *
3 * Copyright (C) 2006 European Southern Observatory *
4 * *
5 * This library 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, 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA *
18 * */
19
20/*
21 * $Author: amodigli $
22 * $Date: 2013-03-01 17:03:01 $
23 * $Revision: 1.67 $
24 */
25
26#ifdef HAVE_CONFIG_H
27#include <config.h>
28#endif
29
30/*---------------------------------------------------------------------------*/
35/*---------------------------------------------------------------------------*/
36
40/*-----------------------------------------------------------------------------
41 Includes
42 ----------------------------------------------------------------------------*/
43#include <string.h>
44#include <math.h>
45#include <xsh_utils_table.h>
46#include <xsh_data_rec.h>
47#include <xsh_error.h>
48#include <xsh_msg.h>
49#include <xsh_pfits.h>
50#include <xsh_dfs.h>
51#include <cpl.h>
52
53/*----------------------------------------------------------------------------
54 Function implementation
55 ----------------------------------------------------------------------------*/
63 const char * fname )
64{
65 int i ;
66 FILE * fout = NULL;
67
68 XSH_ASSURE_NOT_NULL( list) ;
69 if ( fname == NULL ) {
70 fout = stdout;
71 }
72 else {
73 fout = fopen( fname, "w" ) ;
74 }
75 XSH_ASSURE_NOT_NULL( fout ) ;
76
77 fprintf( fout, "Rec List. Nb of orders: %d\n", list->size ) ;
78 for( i = 0 ; i<list->size ; i++ ) {
79 fprintf( fout, " Entry %2d: Order %d, Nlambda: %d, Nslit: %d\n",
80 i, list->list[i].order, list->list[i].nlambda,
81 list->list[i].nslit ) ;
82 }
83
84 cleanup:
85 if ( fname != NULL && fout != NULL ) fclose( fout ) ;
86 return ;
87}
88
89
90/*---------------------------------------------------------------------------*/
99/*---------------------------------------------------------------------------*/
101{
102 xsh_rec_list *result = NULL;
103 XSH_ARM xsh_arm;
104 int size;
105
106 /* check input parameters */
107 XSH_ASSURE_NOT_NULL( instr);
108
109 /* Get arm */
110 xsh_arm = xsh_instrument_get_arm( instr) ;
111
112 /* Special necessary for tests */
113 if ( instr->config != NULL )
114 size = instr->config->orders;
115 else if( xsh_arm == XSH_ARM_UVB){
117 }
118 else if ( xsh_arm == XSH_ARM_VIS){
120 }
121 else if ( xsh_arm == XSH_ARM_NIR){
123 }
124 else {
125 size = 0;
126 }
127 check(result = xsh_rec_list_create_with_size( size, instr));
128
129 cleanup:
130 if ( cpl_error_get_code() != CPL_ERROR_NONE) {
131 xsh_rec_list_free( &result);
132 }
133 return result;
134}
135
136/*---------------------------------------------------------------------------*/
146/*---------------------------------------------------------------------------*/
148{
149 xsh_rec_list* result = NULL;
150
151 /* check input parameters */
152 XSH_ASSURE_NOT_NULL( instr);
154
155 /* Allocate memory */
156 XSH_CALLOC(result, xsh_rec_list, 1);
157
158 /* Special necessary for tests */
159 result->size = size;
160
161 XSH_ASSURE_NOT_ILLEGAL(result->size > 0);
162 result->instrument = instr;
163 XSH_CALLOC( result->list, xsh_rec, result->size);
165 result->slit_min = 0.0;
166 result->slit_max = 0.0;
167 result->nslit = 0;
168
169 cleanup:
170 if ( cpl_error_get_code() != CPL_ERROR_NONE) {
171 xsh_rec_list_free( &result);
172 }
173 return result;
174}
175/*---------------------------------------------------------------------------*/
190/*---------------------------------------------------------------------------*/
191void xsh_rec_list_set_data_size( xsh_rec_list * list, int idx, int absorder,
192 int nlambda, int ns )
193{
194 xsh_rec * prec = NULL ;
195 int depth ;
196
197 XSH_ASSURE_NOT_NULL( list) ;
198 XSH_ASSURE_NOT_ILLEGAL( idx < list->size);
199 XSH_CMP_INT( idx, >=, 0, "Index not in range",);
200 XSH_CMP_INT( idx, <, list->size, "Index not in range",);
201 XSH_CMP_INT( ns, >, 0, "Check size in slit",);
202 XSH_CMP_INT( nlambda, >, 0, "Check size in lambda",);
203
204 prec = &list->list[idx] ;
205 XSH_ASSURE_NOT_NULL( prec);
206
207 //if ( list->max_nlambda < nlambda ) list->max_nlambda = nlambda ;
208 //if ( list->max_nslit < ns ) list->max_nslit = ns;
209 depth = nlambda*ns;
210
211 prec->order = absorder;
212 prec->nlambda = nlambda;
213 prec->nslit = ns;
214 xsh_msg_dbg_high( "Rec Data Size: nlambda: %d, ns: %d, depth: %d",
215 nlambda, ns, depth);
216 XSH_CALLOC( prec->slit, float, ns) ;
217 XSH_CALLOC( prec->lambda, double, nlambda);
218 XSH_CALLOC( prec->data1, float, depth);
219 XSH_CALLOC( prec->errs1, float, depth);
220 XSH_CALLOC( prec->qual1, int, depth);
221
222 cleanup:
223 return ;
224}
225
228{
229 xsh_rec_list * new = NULL ;
230 int nb_orders, order ;
231
233
234 /* Loop over orders */
235 nb_orders = old->size ;
236 for( order = 0 ; order < nb_orders ; order++ ) {
237 int absorder, nslit, nlambda ;
238 float * fold, * fnew ;
239 int * iold, * inew ;
240 double * dold, * dnew ;
241
242 absorder = xsh_rec_list_get_order( old, order ) ;
243 nslit = xsh_rec_list_get_nslit( old, order ) ;
244 nlambda = xsh_rec_list_get_nlambda( old, order ) ;
245
246 check( xsh_rec_list_set_data_size( new, order, absorder, nlambda, nslit ));
247
248 /* Now copy data, errs and qual */
249 fold = xsh_rec_list_get_data1( old, order ) ;
250 fnew = xsh_rec_list_get_data1( new, order ) ;
251 memcpy( fnew, fold, nlambda*nslit*sizeof( float ) ) ;
252
253 fold = xsh_rec_list_get_errs1( old, order ) ;
254 fnew = xsh_rec_list_get_errs1( new, order ) ;
255 memcpy( fnew, fold, nlambda*nslit*sizeof( float ) ) ;
256
257 iold = xsh_rec_list_get_qual1( old, order ) ;
258 inew = xsh_rec_list_get_qual1( new, order ) ;
259 memcpy( inew, iold, nlambda*nslit*sizeof( int ) ) ;
260
261 fold = xsh_rec_list_get_slit( old, order ) ;
262 fnew = xsh_rec_list_get_slit( new, order ) ;
263 memcpy( fnew, fold, nslit*sizeof( float ) ) ;
264
265 dold = xsh_rec_list_get_lambda( old, order ) ;
266 dnew = xsh_rec_list_get_lambda( new, order ) ;
267 memcpy( dnew, dold, nlambda*sizeof( double ) ) ;
268 }
269
270 xsh_free_propertylist(&(new->header));
271 new->header = cpl_propertylist_duplicate( old->header ) ;
272 new->instrument = xsh_instrument_duplicate( old->instrument ) ;
273
274 cleanup:
275 return new ;
276}
277
278/*---------------------------------------------------------------------------*/
287/*---------------------------------------------------------------------------*/
288
291{
292 xsh_rec_list* result = NULL;
293 const char * tablename = NULL ;
294 cpl_table * table = NULL;
295 cpl_propertylist* header = NULL;
296 int nbext, i ;
297 int size;
298
299 /* check input parameters */
300 XSH_ASSURE_NOT_NULL(frame);
302
303 /* get table filename */
304 check(tablename = cpl_frame_get_filename(frame));
305 xsh_msg_dbg_low( "Loading Rectified Frame: %s", tablename ) ;
306
307 check( size = cpl_frame_get_nextensions( frame));
308
309 /* Create internal structure */
310 /* Allocate memory */
311 XSH_CALLOC(result, xsh_rec_list, 1);
312 result->size = size;
313 XSH_ASSURE_NOT_ILLEGAL(result->size > 0);
314 result->instrument = instrument;
315
316 XSH_CALLOC( result->list, xsh_rec, result->size);
317
319
320 check(header = cpl_propertylist_load(tablename,0));
321 check(cpl_propertylist_erase_regexp(header,
322 "^(ARCFILE|ORIGFILE|CHECKSUM|DATASUM)$", CPL_FALSE));
323 check(cpl_propertylist_append(result->header, header));
324 //xsh_msg("tablename=%s",tablename);
325 //check(result->slit_min=xsh_pfits_get_extract_slit_min(header));
326 //check(result->slit_max=xsh_pfits_get_extract_slit_max(header));
327
328 xsh_free_propertylist(&header);
329
330 nbext = size;
331
332 xsh_msg_dbg_medium( " Nb of extensions: %d", nbext ) ;
333 /* Loop over FITS extensions */
334 for( i = 0 ; i<nbext ; i++ ) {
335 int nb, k, order, depth, nlambda, nslit ;
336 const cpl_array * data_array ;
337 const float * farray = NULL ;
338 const int * iarray = NULL ;
339
340 check( table = cpl_table_load( tablename, i+1, 0 ) ) ;
342 CPL_TYPE_INT, 0, &order));
343 /* Now populate the structure */
344 result->list[i].order = order ;
346 CPL_TYPE_INT, 0, &nlambda ));
347 result->list[i].nlambda = nlambda ;
349 CPL_TYPE_INT, 0, &nslit ));
350 result->list[i].nslit = nslit ;
351 xsh_rec_list_set_data_size( result, i, order, nlambda, nslit ) ;
352 /* Get arrays (slit, lambda) */
353 if (nslit > 1){
355 result->list[i].slit, nslit));
356 }
357 else{
359 CPL_TYPE_FLOAT, 0, result->list[i].slit ));
360 }
362 result->list[i].lambda, nlambda));
363
364 /* Get arrays (flux, errs, qual ) */
365 depth = nlambda*nslit ;
366
367 check( data_array = cpl_table_get_array( table,
369 0 )) ;
370 nb = cpl_array_get_size( data_array ) ;
371 XSH_ASSURE_NOT_ILLEGAL( nb == depth ) ;
372
373 /* Copy FLUX1 data to rec_list */
374 check( farray = cpl_array_get_data_float_const( data_array ) ) ;
375 for( k = 0 ; k<depth ; k++ ) *(result->list[i].data1+k) = *farray++ ;
376
377 farray = NULL ;
378 check( data_array = cpl_table_get_array( table,
380 0 )) ;
381 check( nb = cpl_array_get_size( data_array ) ) ;
382 /* Copy ERRS1 data to rec_list */
383 check( farray = cpl_array_get_data_float_const( data_array ) ) ;
384 for( k = 0 ; k<depth ; k++ ) *(result->list[i].errs1+k) = *farray++ ;
385
386 check( data_array = cpl_table_get_array( table,
388 0 )) ;
389 nb = cpl_array_get_size( data_array ) ;
390 /* Copy QUAL1 data to rec_list */
391 iarray = cpl_array_get_data_int_const( data_array ) ;
392 for( k = 0 ; k<depth ; k++ ) *(result->list[i].qual1+k) = *iarray++ ;
393
394 xsh_msg_dbg_low( " Loaded, order %d, nlambda %d, nslit %d",
395 order, nlambda, nslit ) ;
396
397 cpl_table_delete( table ) ;
398 }
399
400 cleanup:
401 xsh_free_propertylist(&header);
402 return result ;
403}
404
405
406
409{
410 xsh_rec_list* result = NULL;
411 const char * imagelist_name = NULL ;
412 cpl_image * ima_data = NULL;
413 cpl_image * ima_errs = NULL;
414 cpl_image * ima_qual = NULL;
415 cpl_propertylist* header = NULL;
416 cpl_propertylist* hdata=NULL;
417 cpl_propertylist* herrs=NULL;
418 cpl_propertylist* hqual=NULL;
419 const char* ext_name=NULL;
420
421 int nbext, i,j ;
422 int size;
423
424 /* check input parameters */
425 XSH_ASSURE_NOT_NULL(frame);
427
428
429 /* get table filename */
430 check(imagelist_name = cpl_frame_get_filename(frame));
431 xsh_msg_dbg_low( "Loading Rectified Frame: %s", imagelist_name ) ;
432
433 check( nbext = cpl_frame_get_nextensions( frame));
434
435
436 size=(nbext+1)/3;
437
438 /* Create internal structure */
439 /* Allocate memory */
440 XSH_CALLOC(result, xsh_rec_list, 1);
441 result->size = size;
442 XSH_ASSURE_NOT_ILLEGAL(result->size > 0);
443 result->instrument = instrument;
444
445 XSH_CALLOC( result->list, xsh_rec, result->size);
446
448
449
450 check(header = cpl_propertylist_load(imagelist_name,0));
451 check(cpl_propertylist_erase_regexp(header,
452 "^(ARCFILE|ORIGFILE|CHECKSUM|DATASUM)$", CPL_FALSE));
453 check(cpl_propertylist_append(result->header, header));
454
455 xsh_free_propertylist(&header);
456
457 //nbext = size;
458
459 xsh_msg_dbg_medium( " Nb of extensions: %d", nbext ) ;
460 /* Loop over FITS extensions */
461
462 for( i = 0,j=0 ; j<nbext ; i++, j+=3 ) {
463 int k, order, depth, nlambda, nslit ;
464 const float * farray = NULL ;
465 const int * iarray = NULL ;
466 double s_step=0;
467 double w_step=0;
468 double s_start=0;
469 double w_start=0;
470 int sx=0;
471 int sy=0;
472
473 check(ima_data=cpl_image_load(imagelist_name,XSH_PRE_DATA_TYPE,0,j+0));
474 check(ima_errs=cpl_image_load(imagelist_name,XSH_PRE_ERRS_TYPE,0,j+1));
475 check(ima_qual=cpl_image_load(imagelist_name,XSH_PRE_QUAL_TYPE,0,j+2));
476
477 check( hdata = cpl_propertylist_load( imagelist_name, j+0 ) ) ;
478 check( herrs = cpl_propertylist_load( imagelist_name, j+1 ) ) ;
479 check( hqual = cpl_propertylist_load( imagelist_name, j+2 ) ) ;
480 check(ext_name=xsh_pfits_get_extname(herrs));
481 order=10*(ext_name[3]-48)+(ext_name[4]-48);
482 //xsh_msg("iter=%d order=%d",i,order);
483
484 /* Now populate the structure */
485 result->list[i].order = order ;
486
487 nlambda=xsh_pfits_get_naxis1(herrs);
488 nslit=xsh_pfits_get_naxis2(herrs);
489
490 w_step=xsh_pfits_get_cdelt1(herrs);
491 s_step=xsh_pfits_get_cdelt2(herrs);
492
493 w_start=xsh_pfits_get_crval1(herrs);
494 s_start=xsh_pfits_get_crval2(herrs);
495
496 result->list[i].nlambda = nlambda ;
497 result->list[i].nslit = nslit ;
498
499 xsh_rec_list_set_data_size( result, i, order, nlambda, nslit ) ;
500
501 /* Get arrays (slit, lambda) */
502 if (nslit > 1){
503 for(k=0;k<nslit;k++) {
504 *(result->list[i].slit+k)=(s_start+k*s_step);
505 }
506 }
507 else{
508 for(k=0;k<nslit;k++) {
509 *(result->list[i].slit+k)=0;
510 }
511 }
512
513
514 for(k=0;k<nlambda;k++) {
515 *(result->list[i].lambda+k)=(w_start+k*w_step);
516 }
517 /* Get arrays (flux, errs, qual ) */
518 depth = nlambda*nslit ;
519
520 /* Copy FLUX1 data to rec_list */
521 check( farray = cpl_image_get_data_float( ima_data)) ;
522 sx = cpl_image_get_size_x( ima_data ) ;
523 sy = cpl_image_get_size_y( ima_data ) ;
524 XSH_ASSURE_NOT_ILLEGAL( sx*sy == depth ) ;
525
526 for( k = 0 ; k<depth ; k++ ) *(result->list[i].data1+k) = *farray++ ;
527 farray = NULL ;
528
529 /* Copy ERRS1 data to rec_list */
530 check( farray = cpl_image_get_data_float( ima_errs)) ;
531 for( k = 0 ; k<depth ; k++ ) *(result->list[i].errs1+k) = *farray++ ;
532
533 /* Copy QUAL1 data to rec_list */
534 check( iarray = cpl_image_get_data_int( ima_qual)) ;
535 for( k = 0 ; k<depth ; k++ ) *(result->list[i].qual1+k) = *iarray++ ;
536
537 xsh_msg_dbg_low( " Loaded, order %d, nlambda %d, nslit %d",
538 order, nlambda, nslit ) ;
539
540 xsh_free_image( &ima_data ) ;
541 xsh_free_image( &ima_errs ) ;
542 xsh_free_image( &ima_qual ) ;
543 xsh_free_propertylist( &hdata ) ;
544 xsh_free_propertylist( &herrs ) ;
545 xsh_free_propertylist( &hqual ) ;
546
547 }
548
549 cleanup:
550 xsh_free_image( &ima_data ) ;
551 xsh_free_image( &ima_errs ) ;
552 xsh_free_image( &ima_qual ) ;
553 xsh_free_propertylist( &hdata ) ;
554 xsh_free_propertylist( &herrs ) ;
555 xsh_free_propertylist( &hqual ) ;
556
557 xsh_free_propertylist(&header);
558
559 return result ;
560}
561
562
565{
566 xsh_rec_list* result = NULL;
567 const char * imagelist_name = NULL ;
568 cpl_vector * vec_data = NULL;
569 cpl_vector * vec_errs = NULL;
570 cpl_vector * vec_qual = NULL;
571 cpl_propertylist* header = NULL;
572 cpl_propertylist* hdata=NULL;
573 cpl_propertylist* herrs=NULL;
574 cpl_propertylist* hqual=NULL;
575 const char* ext_name=NULL;
576
577 int nbext, i,j ;
578 int size;
579
580 /* check input parameters */
581 XSH_ASSURE_NOT_NULL(frame);
583
584
585 /* get table filename */
586 check(imagelist_name = cpl_frame_get_filename(frame));
587 xsh_msg_dbg_low( "Loading Rectified Frame: %s", imagelist_name ) ;
588
589 check( nbext = cpl_frame_get_nextensions( frame));
590
591
592 size=(nbext+1)/3;
593
594 /* Create internal structure */
595 /* Allocate memory */
596 XSH_CALLOC(result, xsh_rec_list, 1);
597 result->size = size;
598 XSH_ASSURE_NOT_ILLEGAL(result->size > 0);
599 result->instrument = instrument;
600
601 XSH_CALLOC( result->list, xsh_rec, result->size);
602
604
605
606 check(header = cpl_propertylist_load(imagelist_name,0));
607 check(cpl_propertylist_erase_regexp(header,
608 "^(ARCFILE|ORIGFILE|CHECKSUM|DATASUM)$", CPL_FALSE));
609 check(cpl_propertylist_append(result->header, header));
610
611 xsh_free_propertylist(&header);
612
613 //nbext = size;
614
615 xsh_msg_dbg_medium( " Nb of extensions: %d", nbext ) ;
616 /* Loop over FITS extensions */
617
618 for( i = 0,j=0 ; j<nbext ; i++, j+=3 ) {
619 int k, order, depth, nlambda;
620 const double * farray = NULL ;
621 const double * iarray = NULL ;
622 double w_step=0;
623 double w_start=0;
624 int sx=0;
625
626 check(vec_data=cpl_vector_load(imagelist_name,j+0));
627 check(vec_errs=cpl_vector_load(imagelist_name,j+1));
628 check(vec_qual=cpl_vector_load(imagelist_name,j+2));
629
630 check( hdata = cpl_propertylist_load( imagelist_name, j+0 ) ) ;
631 check( herrs = cpl_propertylist_load( imagelist_name, j+1 ) ) ;
632 check( hqual = cpl_propertylist_load( imagelist_name, j+2 ) ) ;
633 check(ext_name=xsh_pfits_get_extname(herrs));
634 order=10*(ext_name[3]-48)+(ext_name[4]-48);
635 //xsh_msg("iter=%d order=%d",i,order);
636
637 /* Now populate the structure */
638 result->list[i].order = order ;
639
640 nlambda=xsh_pfits_get_naxis1(herrs);
641
642 w_step=xsh_pfits_get_cdelt1(herrs);
643
644 w_start=xsh_pfits_get_crval1(herrs);
645
646 result->list[i].nlambda = nlambda ;
647
648 xsh_rec_list_set_data_size( result, i, order, nlambda, 1 ) ;
649
650 /* Get arrays (lambda) */
651 for(k=0;k<nlambda;k++) {
652 *(result->list[i].lambda+k)=(w_start+k*w_step);
653 }
654 /* Get arrays (flux, errs, qual ) */
655 depth = nlambda;
656
657 /* Copy FLUX1 data to rec_list */
658 check( farray = cpl_vector_get_data( vec_data)) ;
659 sx = cpl_vector_get_size( vec_data ) ;
660 XSH_ASSURE_NOT_ILLEGAL( sx == depth ) ;
661
662 for( k = 0 ; k<depth ; k++ ) *(result->list[i].data1+k) = (float)*farray++ ;
663 farray = NULL ;
664
665 /* Copy ERRS1 data to rec_list */
666 check( farray = cpl_vector_get_data( vec_errs)) ;
667 for( k = 0 ; k<depth ; k++ ) *(result->list[i].errs1+k) = (float)*farray++ ;
668
669 /* Copy QUAL1 data to rec_list */
670 check( iarray = cpl_vector_get_data( vec_qual)) ;
671 for( k = 0 ; k<depth ; k++ ) *(result->list[i].qual1+k) = (int)*iarray++ ;
672
673 xsh_msg_dbg_low( " Loaded, order %d, nlambda %d",order, nlambda) ;
674
675 xsh_free_vector( &vec_data ) ;
676 xsh_free_vector( &vec_errs ) ;
677 xsh_free_vector( &vec_qual ) ;
678 xsh_free_propertylist( &hdata ) ;
679 xsh_free_propertylist( &herrs ) ;
680 xsh_free_propertylist( &hqual ) ;
681
682 }
683
684 cleanup:
685 xsh_free_vector( &vec_data ) ;
686 xsh_free_vector( &vec_errs ) ;
687 xsh_free_vector( &vec_qual ) ;
688 xsh_free_propertylist( &hdata ) ;
689 xsh_free_propertylist( &herrs ) ;
690 xsh_free_propertylist( &hqual ) ;
691
692 xsh_free_propertylist(&header);
693
694 return result ;
695}
696
697
698/*---------------------------------------------------------------------------*/
712/*---------------------------------------------------------------------------*/
713cpl_frame * xsh_rec_list_frame_invert( cpl_frame * rec_frame,
714 const char *tag, xsh_instrument *instrument)
715{
716 cpl_frame *result = NULL;
717 xsh_rec_list *rec_list = NULL;
718 int norders, order;
719 float *data = NULL;
720 char fname[256];
721 //const char* orig_name = NULL;
722
723 XSH_ASSURE_NOT_NULL( rec_frame);
726
727 check( rec_list = xsh_rec_list_load( rec_frame, instrument));
728
729 /* Loop over orders */
730 norders = rec_list->size;
731 for( order = 0; order < norders; order++) {
732 int i;
733 int img_size, nlambda, nslit;
734
735 check( nlambda = xsh_rec_list_get_nlambda( rec_list, order));
736 check( nslit = xsh_rec_list_get_nslit( rec_list, order));
737 img_size = nlambda * nslit;
738
739 check( data = xsh_rec_list_get_data1( rec_list, order ) ) ;
740 for( i = 0 ; i< img_size ; i++, data++ ) {
741 *data *= -1.;
742 }
743 }
744
745 /* Now save with a new name */
746 sprintf( fname,"%s.fits", tag);
747 check( result = xsh_rec_list_save( rec_list, fname, tag, 0 ) ) ;
748
749 cleanup:
750 xsh_rec_list_free( &rec_list ) ;
751 return result ;
752}
753
754/*---------------------------------------------------------------------------*/
759/*---------------------------------------------------------------------------*/
761{
762 if (list != NULL && *list != NULL ) {
763 /*
764 BUG - Laurent - 09-01-2009
765 Something strange occurs (under Linux, not MacOs):
766 in the recipe xsh_scired_slit_nod, for UVB (not for VIS), there is
767 a crash in this function during one of the cpl_free calls.
768 In order to allow continuation of tests, freeing of the rec_list
769 is - temporarily - disable until the problem is understood and
770 fixed.
771 */
772 int i ;
773 xsh_rec_list * plist = NULL;
774
775 plist = *list;
776 /* free the list */
777
778 for (i = 0; i < plist->size; i++) {
779 xsh_rec * pr = &(plist->list[i]) ;
780
781 xsh_msg_dbg_high( "Freeing order index %d", i ) ;
782 if ( pr == NULL ) continue ;
783 xsh_msg_dbg_high( " Abs Order: %d", pr->order ) ;
784 cpl_free( pr->slit ) ;
785 cpl_free( pr->lambda ) ;
786 cpl_free( pr->data1 ) ;
787 cpl_free( pr->errs1 ) ;
788 cpl_free( pr->qual1 ) ;
789 }
790 if ((*list)->list){
791 cpl_free((*list)->list);
792 }
793
794 xsh_free_propertylist(&((*list)->header));
795 cpl_free(*list);
796 *list = NULL;
797 }
798}
799
800
801
802/*---------------------------------------------------------------------------*/
808/*---------------------------------------------------------------------------*/
809cpl_propertylist * xsh_rec_list_get_header(xsh_rec_list* list)
810{
811 cpl_propertylist * res = NULL;
812
814 res = list->header;
815 cleanup:
816 return res;
817}
818
828{
829 int res = 0 ;
830
832 res = list->list[idx].nslit ;
833
834 cleanup:
835 return res ;
836}
837
847{
848 int res = 0 ;
849
851 res = list->list[idx].order ;
852
853 cleanup:
854 return res ;
855}
856
866{
867 int res = 0 ;
868
869 XSH_ASSURE_NOT_NULL( list);
870 res = list->list[idx].nlambda ;
871
872 cleanup:
873 return res ;
874}
875
884float * xsh_rec_list_get_slit( xsh_rec_list* list, int idx )
885{
886 float * res = NULL ;
887
889 res = list->list[idx].slit ;
890
891 cleanup:
892 return res ;
893}
894
895
904{
905 double res = 0 ;
906
908 res = list->slit_min ;
909
910 cleanup:
911 return res ;
912}
913
914
915
924{
925 double res = 0 ;
926
928 res = list->slit_max ;
929
930 cleanup:
931 return res ;
932}
933
934
936{
937 double lambda_min = 10000;
938 int i;
939
940 XSH_ASSURE_NOT_NULL( list);
941
942 for( i=0; i< list->size; i++){
943 if ( list->list[i].lambda != NULL){
944 double lambda;
945
946 lambda = list->list[i].lambda[0];
947 if ( lambda < lambda_min){
948 lambda_min = lambda;
949 }
950 }
951 }
952
953 cleanup:
954 return lambda_min;
955}
956
958{
959 double lambda_max =0.0;
960 int i;
961
962 XSH_ASSURE_NOT_NULL( list);
963
964 for( i=0; i< list->size; i++){
965 if ( list->list[i].lambda != NULL){
966 double lambda;
967
968 lambda = list->list[i].lambda[list->list[i].nlambda-1];
969 if ( lambda > lambda_max){
970 lambda_max = lambda;
971 }
972 }
973 }
974 cleanup:
975 return lambda_max;
976}
977
978
987cpl_error_code xsh_rec_list_set_slit_min( xsh_rec_list* list, const double val)
988{
989
991 list->slit_min = val;
992
993 cleanup:
994 return cpl_error_get_code() ;
995}
996
997
998
1007cpl_error_code xsh_rec_list_set_slit_max( xsh_rec_list* list,const double val)
1008{
1009
1010 XSH_ASSURE_NOT_NULL(list);
1011 list->slit_max = val;
1012
1013 cleanup:
1014 return cpl_error_get_code() ;
1015}
1016
1017
1026double* xsh_rec_list_get_lambda( xsh_rec_list* list, int idx )
1027{
1028 double* res = NULL ;
1029
1030 XSH_ASSURE_NOT_NULL(list);
1031 res = list->list[idx].lambda ;
1032
1033 cleanup:
1034 return res ;
1035}
1036
1045float * xsh_rec_list_get_data1( xsh_rec_list* list, int idx )
1046{
1047 float * res = NULL ;
1048
1049 XSH_ASSURE_NOT_NULL(list);
1050 res = list->list[idx].data1 ;
1051
1052 cleanup:
1053 return res ;
1054}
1055
1064float * xsh_rec_list_get_errs1( xsh_rec_list* list, int idx )
1065{
1066 float * res = NULL ;
1067
1068 XSH_ASSURE_NOT_NULL(list);
1069 res = list->list[idx].errs1 ;
1070
1071 cleanup:
1072 return res ;
1073}
1074
1084{
1085 int * res = NULL ;
1086
1087 XSH_ASSURE_NOT_NULL(list);
1088 res = list->list[idx].qual1 ;
1089
1090 cleanup:
1091 return res ;
1092}
1093/*---------------------------------------------------------------------------*/
1094
1095/*---------------------------------------------------------------------------*/
1111/*---------------------------------------------------------------------------*/
1112cpl_frame* xsh_rec_list_save( xsh_rec_list* list, const char* filename,
1113 const char* tag, int is_temp)
1114{
1115 cpl_frame * result = NULL ;
1116 cpl_table * table = NULL;
1117 int nlambda = 0, nslit = 0, depth = 0;
1118 cpl_array * dim = NULL, * temp_array = NULL ;
1119 int i, k, order;
1120 unsigned mode = CPL_IO_DEFAULT;
1121
1122 /* check input parameters */
1123 XSH_ASSURE_NOT_NULL( list);
1124 XSH_ASSURE_NOT_NULL( filename);
1125 XSH_ASSURE_NOT_ILLEGAL( list->size > 0);
1126
1127 /* Loop over Orders, as we create one table per order */
1128 for( i = 0 ; i < list->size ; i++ ) {
1129
1130 nlambda = list->list[i].nlambda;
1131 nslit = list->list[i].nslit;
1132 depth = nlambda*nslit;
1133 order = list->list[i].order;
1134
1135 /* skip the order */
1136 if (depth == 0){
1137 continue;
1138 }
1139 check( table = cpl_table_new( 1));
1140
1141 /* create column names */
1142 check(cpl_table_new_column( table, XSH_REC_TABLE_COLNAME_ORDER,
1143 CPL_TYPE_INT));
1144 check(cpl_table_new_column( table, XSH_REC_TABLE_COLNAME_NLAMBDA,
1145 CPL_TYPE_INT));
1146 check(cpl_table_new_column( table, XSH_REC_TABLE_COLNAME_NSLIT,
1147 CPL_TYPE_INT));
1148 check(cpl_table_new_column_array( table, XSH_REC_TABLE_COLNAME_LAMBDA,
1149 CPL_TYPE_DOUBLE, nlambda));
1150 check(cpl_table_new_column_array( table, XSH_REC_TABLE_COLNAME_SLIT,
1151 CPL_TYPE_FLOAT, nslit));
1152 check(cpl_table_new_column_array( table, XSH_REC_TABLE_COLNAME_FLUX1,
1153 CPL_TYPE_FLOAT, depth));
1154 check( cpl_table_new_column_array( table, XSH_REC_TABLE_COLNAME_ERRS1,
1155 CPL_TYPE_FLOAT, depth));
1156 check( cpl_table_new_column_array( table, XSH_REC_TABLE_COLNAME_QUAL1,
1157 CPL_TYPE_INT, depth));
1158
1159 /* Set column array dimensions */
1160 check( dim = cpl_array_new( 1, CPL_TYPE_INT)) ;
1161 cpl_array_set_int( dim, 0, nlambda);
1162 check( cpl_table_set_column_dimensions(
1163 table, XSH_REC_TABLE_COLNAME_LAMBDA, dim));
1164 cpl_array_set_int( dim, 0, nslit);
1165 check( cpl_table_set_column_dimensions( table,
1167 xsh_free_array( &dim);
1168
1169 check( dim = cpl_array_new( 2, CPL_TYPE_INT)) ;
1170 cpl_array_set_int( dim, 0, nlambda);
1171 cpl_array_set_int( dim, 1, nslit);
1172
1173 check( cpl_table_set_column_dimensions( table,
1175 check( cpl_table_set_column_dimensions( table,
1177 check( cpl_table_set_column_dimensions( table,
1179 xsh_free_array( &dim);
1180
1181 /* Populate the basic columns */
1182 check( cpl_table_set_int( table, XSH_REC_TABLE_COLNAME_ORDER, 0,
1183 order));
1184 check( cpl_table_set_int( table, XSH_REC_TABLE_COLNAME_NLAMBDA, 0,
1185 nlambda));
1186 check( cpl_table_set_int( table, XSH_REC_TABLE_COLNAME_NSLIT, 0,
1187 nslit));
1188
1189 /* Create an array for slits and fill it*/
1190 check ( temp_array = cpl_array_new( nslit, CPL_TYPE_FLOAT));
1191 for( k = 0 ; k<nslit ; k++ ) {
1192 check( cpl_array_set_float( temp_array, k,
1193 *(list->list[i].slit+k)));
1194 }
1195 /* Insert into table */
1196 check( cpl_table_set_array( table, XSH_REC_TABLE_COLNAME_SLIT, 0,
1197 temp_array));
1198 xsh_free_array( &temp_array);
1199
1200 /* Create an array for lambda and fill it */
1201 check( temp_array = cpl_array_new( nlambda, CPL_TYPE_DOUBLE));
1202 for( k = 0 ; k<nlambda ; k++ ) {
1203 check( cpl_array_set_double( temp_array, k,
1204 *(list->list[i].lambda+k)));
1205 }
1206 /* Insert into table */
1207 check( cpl_table_set_array( table, XSH_REC_TABLE_COLNAME_LAMBDA, 0,
1208 temp_array));
1209 xsh_free_array( &temp_array);
1210
1211 /* images FLUX, ERRS, QUAL */
1212 check( temp_array = cpl_array_new( depth, CPL_TYPE_FLOAT));
1213 for( k = 0 ; k<depth ; k++ ) {
1214 check( cpl_array_set_float( temp_array, k,
1215 *(list->list[i].data1+k) ) ) ;
1216 }
1217 check( cpl_table_set_array( table, XSH_REC_TABLE_COLNAME_FLUX1, 0,
1218 temp_array));
1219
1220 for( k = 0 ; k<depth ; k++ ) {
1221 check( cpl_array_set_float( temp_array, k,
1222 *(list->list[i].errs1+k) ) ) ;
1223 }
1224 check( cpl_table_set_array( table, XSH_REC_TABLE_COLNAME_ERRS1, 0,
1225 temp_array));
1226 xsh_free_array( &temp_array);
1227
1228 check( temp_array = cpl_array_new( depth, CPL_TYPE_INT));
1229 for( k = 0 ; k<depth ; k++ ) {
1230 check( cpl_array_set_int( temp_array, k,
1231 *(list->list[i].qual1+k)));
1232 }
1233 check( cpl_table_set_array( table, XSH_REC_TABLE_COLNAME_QUAL1, 0,
1234 temp_array));
1235 xsh_free_array( &temp_array ) ;
1236
1237
1238 /* create fits file */
1240 check( cpl_table_save( table, list->header, NULL, filename, mode));
1241 mode = CPL_IO_EXTEND;
1242 XSH_TABLE_FREE( table);
1243 }
1244
1245 /* Create the frame */
1246 check( result = xsh_frame_product( filename, tag, CPL_FRAME_TYPE_IMAGE,
1247 CPL_FRAME_GROUP_PRODUCT, CPL_FRAME_LEVEL_FINAL));
1248
1249/*
1250 if ( is_temp == CPL_TRUE){
1251 check( cpl_frame_set_level( result, CPL_FRAME_LEVEL_TEMPORARY));
1252 xsh_add_temporary_file( filename);
1253 }
1254*/
1255 cleanup:
1256 XSH_TABLE_FREE( table);
1257 xsh_free_array( &temp_array);
1258 return result ;
1259}
1260/*---------------------------------------------------------------------------*/
1261
1262/*---------------------------------------------------------------------------*/
1275/*---------------------------------------------------------------------------*/
1277 xsh_rectify_param *rec_par, const char* pro_catg)
1278{
1279 double lambda_min, lambda_max;
1280
1281 /* check input parameters */
1282 XSH_ASSURE_NOT_NULL( rec_list);
1283 XSH_ASSURE_NOT_NULL( pre);
1284 XSH_ASSURE_NOT_NULL( rec_par);
1285
1286 /* Set header from science header */
1287 check( cpl_propertylist_append( rec_list->header, pre->data_header));
1288
1289 /* Add bin_lambda and bin_spce to property list */
1291 rec_par->rectif_bin_lambda));
1293 rec_par->rectif_bin_space));
1294
1295 check( lambda_min = xsh_rec_list_get_lambda_min( rec_list));
1296 check( lambda_max = xsh_rec_list_get_lambda_max( rec_list));
1297
1299 lambda_min)) ;
1301 lambda_max));
1302
1304 rec_list->slit_min));
1306 rec_list->slit_max));
1307 check( xsh_pfits_set_pcatg( rec_list->header, pro_catg));
1308
1309 cleanup:
1310 return;
1311}
1312/*---------------------------------------------------------------------------*/
1313
1314
1315/*---------------------------------------------------------------------------*/
1331/*---------------------------------------------------------------------------*/
1332cpl_frame* xsh_rec_list_save_table( xsh_rec_list* list, const char* filename,
1333 const char* tag, int is_temp)
1334{
1335 cpl_frame * result = NULL ;
1336 cpl_table * table = NULL;
1337 int nlambda = 0, nslit = 0, depth = 0;
1338 cpl_array * dim = NULL, * temp_array = NULL ;
1339 int i, k, order;
1340 unsigned mode = CPL_IO_DEFAULT;
1341
1342 /* check input parameters */
1343 XSH_ASSURE_NOT_NULL( list);
1344 XSH_ASSURE_NOT_NULL( filename);
1345 XSH_ASSURE_NOT_ILLEGAL( list->size > 0);
1346
1347 /* Loop over Orders, as we create one table per order */
1348 for( i = 0 ; i < list->size ; i++ ) {
1349
1350 nlambda = list->list[i].nlambda;
1351 nslit = list->list[i].nslit;
1352 depth = nlambda*nslit;
1353 order = list->list[i].order;
1354
1355 /* skip the order */
1356 if (depth == 0){
1357 continue;
1358 }
1359 check( table = cpl_table_new( 1));
1360
1361 /* create column names */
1362 check(cpl_table_new_column( table, XSH_REC_TABLE_COLNAME_ORDER,
1363 CPL_TYPE_INT));
1364 check(cpl_table_new_column( table, XSH_REC_TABLE_COLNAME_NLAMBDA,
1365 CPL_TYPE_INT));
1366 check(cpl_table_new_column( table, XSH_REC_TABLE_COLNAME_NSLIT,
1367 CPL_TYPE_INT));
1368 check(cpl_table_new_column_array( table, XSH_REC_TABLE_COLNAME_LAMBDA,
1369 CPL_TYPE_DOUBLE, nlambda));
1370 check(cpl_table_new_column_array( table, XSH_REC_TABLE_COLNAME_SLIT,
1371 CPL_TYPE_FLOAT, nslit));
1372
1373 /* Set column array dimensions */
1374 check( dim = cpl_array_new( 1, CPL_TYPE_INT)) ;
1375 cpl_array_set_int( dim, 0, nlambda);
1376 check( cpl_table_set_column_dimensions(
1377 table, XSH_REC_TABLE_COLNAME_LAMBDA, dim));
1378 cpl_array_set_int( dim, 0, nslit);
1379 check( cpl_table_set_column_dimensions( table,
1381 xsh_free_array( &dim);
1382
1383 check( dim = cpl_array_new( 2, CPL_TYPE_INT)) ;
1384 cpl_array_set_int( dim, 0, nlambda);
1385 cpl_array_set_int( dim, 1, nslit);
1386
1387 xsh_free_array( &dim);
1388
1389 /* Populate the basic columns */
1390 check( cpl_table_set_int( table, XSH_REC_TABLE_COLNAME_ORDER, 0,
1391 order));
1392 check( cpl_table_set_int( table, XSH_REC_TABLE_COLNAME_NLAMBDA, 0,
1393 nlambda));
1394 check( cpl_table_set_int( table, XSH_REC_TABLE_COLNAME_NSLIT, 0,
1395 nslit));
1396
1397 /* Create an array for slits and fill it*/
1398 check ( temp_array = cpl_array_new( nslit, CPL_TYPE_FLOAT));
1399 for( k = 0 ; k<nslit ; k++ ) {
1400 check( cpl_array_set_float( temp_array, k,
1401 *(list->list[i].slit+k)));
1402 }
1403 /* Insert into table */
1404 check( cpl_table_set_array( table, XSH_REC_TABLE_COLNAME_SLIT, 0,
1405 temp_array));
1406 xsh_free_array( &temp_array);
1407
1408 /* Create an array for lambda and fill it */
1409 check( temp_array = cpl_array_new( nlambda, CPL_TYPE_DOUBLE));
1410 for( k = 0 ; k<nlambda ; k++ ) {
1411 check( cpl_array_set_double( temp_array, k,
1412 *(list->list[i].lambda+k)));
1413 }
1414 /* Insert into table */
1415 check( cpl_table_set_array( table, XSH_REC_TABLE_COLNAME_LAMBDA, 0,
1416 temp_array));
1417 xsh_free_array( &temp_array);
1418
1419 /* images FLUX, ERRS, QUAL */
1420 /* create fits file */
1421 check( cpl_table_save( table, list->header, NULL, filename, mode));
1422 mode = CPL_IO_EXTEND;
1423 XSH_TABLE_FREE( table);
1424 }
1425
1426 /* Create the frame */
1427 check( result = xsh_frame_product( filename, tag, CPL_FRAME_TYPE_TABLE,
1428 CPL_FRAME_GROUP_PRODUCT, CPL_FRAME_LEVEL_FINAL));
1429
1430 if ( is_temp == CPL_TRUE){
1431 check( cpl_frame_set_level( result, CPL_FRAME_LEVEL_TEMPORARY));
1432 xsh_add_temporary_file( filename);
1433 }
1434
1435 cleanup:
1436 XSH_TABLE_FREE( table);
1437 xsh_free_array( &temp_array);
1438 return result ;
1439}
1440/*---------------------------------------------------------------------------*/
1441/*---------------------------------------------------------------------------*/
1451/*---------------------------------------------------------------------------*/
1452cpl_frame*
1453xsh_rec_list1D_save_as_tab(xsh_rec_list* list,const char* filename, const char* tag)
1454{
1455
1456 cpl_table * table = NULL;
1457 int nlambda, nslit, depth ;
1458 cpl_array * temp_array = NULL ;
1459 int i, k, order ;
1460 cpl_frame* result=NULL;
1461
1462 double* plambda=NULL;
1463 float* pslit=NULL;
1464
1465 float* pflux=NULL;
1466 float* perr=NULL;
1467 int* pqual=NULL;
1468 //cpl_propertylist* plist=NULL;
1469 char data_extname[20];
1470 char errs_extname[20];
1471 char qual_extname[20];
1472 unsigned mode = CPL_IO_DEFAULT;
1473 cpl_propertylist *header_data = NULL;
1474 cpl_propertylist *header_errs = NULL;
1475 cpl_propertylist *header_qual = NULL;
1476
1477 /* check input parameters */
1478 XSH_ASSURE_NOT_NULL( list);
1479 XSH_ASSURE_NOT_NULL( filename);
1480 XSH_ASSURE_NOT_ILLEGAL( list->size > 0 ) ;
1481
1482 /* Loop over Orders, as we create one table per order */
1483 for( i = 0; i < list->size ; i++ ) {
1484
1485 nlambda = list->list[i].nlambda ;
1486 nslit = list->list[i].nslit ;
1487 depth = nlambda*nslit ;
1488 order = list->list[i].order ;
1489
1490 xsh_msg_dbg_high("depth %d : %dx%d", depth, nslit, nlambda);
1491 xsh_msg("depth %d : %dx%d", depth, nslit, nlambda);
1492 /* skip the order */
1493 if (depth == 0){
1494 continue;
1495 }
1496 table = cpl_table_new(nlambda);
1497 cpl_table_new_column(table,"wave",CPL_TYPE_DOUBLE);
1498 cpl_table_new_column(table,"flux",CPL_TYPE_DOUBLE);
1499 cpl_table_new_column(table,"errs",CPL_TYPE_DOUBLE);
1500 cpl_table_new_column(table,"qual",CPL_TYPE_INT);
1501 cpl_table_fill_column_window_double(table,"wave",0,nlambda,0);
1502 cpl_table_fill_column_window_double(table,"flux",0,nlambda,0);
1503 cpl_table_fill_column_window_double(table,"errs",0,nlambda,0);
1504 cpl_table_fill_column_window_int(table,"qual",0,nlambda,0);
1505 check( header_data = cpl_propertylist_duplicate( list->header));
1506 header_errs=cpl_propertylist_new();
1507 header_qual=cpl_propertylist_new();
1508
1509
1510 check(plambda=cpl_table_get_data_double(table,"wave"));
1511 check(pflux=(float *) cpl_table_get_data_double(table,"flux"));
1512 check(perr=(float *) cpl_table_get_data_double(table,"errs"));
1513 check(pqual=cpl_table_get_data_int(table,"qual"));
1514
1515 /*
1516 for( k = 0 ; k<nslit ; k++ ) {
1517 pslit[k]= (*(list->list[i].slit+k) ) ;
1518 }
1519 */
1520 for( k = 0 ; k<nlambda ; k++ ) {
1521 plambda[k]= (*(list->list[i].lambda+k) ) ;
1522 }
1523
1524 for( k = 0 ; k<depth ; k++ ) {
1525 pflux[k]= (*(list->list[i].data1+k) ) ;
1526 perr[k]= (*(list->list[i].errs1+k) ) ;
1527 pqual[k]= (*(list->list[i].qual1+k) ) ;
1528 }
1529
1530 /* product 2D */
1531
1532 {
1533 cpl_propertylist_erase_regexp(header_data, "^CRPIX2",0);
1534 cpl_propertylist_erase_regexp(header_data, "^CRVAL2",0);
1535 cpl_propertylist_erase_regexp(header_data, "^CDELT2",0);
1536
1537 cpl_propertylist_erase_regexp(header_errs, "^CRPIX2",0);
1538 cpl_propertylist_erase_regexp(header_errs, "^CRVAL2",0);
1539 cpl_propertylist_erase_regexp(header_errs, "^CDELT2",0);
1540
1541 cpl_propertylist_erase_regexp(header_qual, "^CRPIX2",0);
1542 cpl_propertylist_erase_regexp(header_qual, "^CRVAL2",0);
1543 cpl_propertylist_erase_regexp(header_qual, "^CDELT2",0);
1544
1545 }
1546
1547
1548 sprintf(data_extname,"ORD%d_FLUX",order);
1549 sprintf(errs_extname,"ORD%d_ERRS",order);
1550 sprintf(qual_extname,"ORD%d_QUAL",order);
1551 xsh_msg_dbg_high("extname %s", data_extname);
1552
1554 check( xsh_pfits_set_extname( header_data, data_extname));
1555 check(xsh_plist_set_extra_keys(header_data,"IMAGE","DATA","RMSE",
1556 data_extname,errs_extname,qual_extname,0));
1557
1558
1560 xsh_pfits_set_extname( header_errs, errs_extname);
1561 check(xsh_plist_set_extra_keys(header_errs,"IMAGE","DATA","RMSE",
1562 data_extname,errs_extname,qual_extname,1));
1563
1565 xsh_pfits_set_extname( header_qual,qual_extname);
1566 check(xsh_plist_set_extra_keys(header_qual,"IMAGE","DATA","RMSE",
1567 data_extname,errs_extname,qual_extname,2));
1568
1569 mode = CPL_IO_EXTEND;
1570
1571 if(i==0) {
1572 cpl_table_save( table, header_data, NULL, filename, CPL_IO_DEFAULT );
1573 } else {
1574 cpl_table_save( table, header_data, NULL, filename, mode );
1575 }
1576 xsh_free_table(&table);
1577 xsh_free_propertylist( &header_data);
1578 xsh_free_propertylist( &header_errs);
1579 xsh_free_propertylist( &header_qual);
1580
1581 }
1582
1583 check(result=xsh_frame_product(filename,tag,CPL_FRAME_TYPE_IMAGE,
1584 CPL_FRAME_GROUP_PRODUCT,
1585 CPL_FRAME_LEVEL_FINAL));
1586
1587 cleanup:
1588 xsh_free_propertylist( &header_data);
1589 XSH_TABLE_FREE( table);
1590 xsh_free_array( &temp_array ) ;
1591 return result ;
1592}
1593
1594
1595/*---------------------------------------------------------------------------*/
1605/*---------------------------------------------------------------------------*/
1606cpl_frame*
1607xsh_rec_list_save2(xsh_rec_list* list,const char* filename, const char* tag)
1608{
1609
1610 cpl_table * table = NULL;
1611 int nlambda, nslit, depth ;
1612 cpl_array * temp_array = NULL ;
1613 int i, k, order ;
1614
1615 cpl_image* img_lambda=NULL;
1616 cpl_image* img_slit=NULL;
1617
1618 cpl_image* img_flux=NULL;
1619 cpl_image* img_err=NULL;
1620 cpl_image* img_qual=NULL;
1621 cpl_frame* result=NULL;
1622
1623
1624
1625 double* plambda=NULL;
1626 float* pslit=NULL;
1627
1628 float* pflux=NULL;
1629 float* perr=NULL;
1630 int* pqual=NULL;
1631 double cdelt1=0;
1632 double cdelt2=0;
1633 double crpix1=0;
1634 double crpix2=0;
1635 double crval1=0;
1636 double crval2=0;
1637 //cpl_propertylist* plist=NULL;
1638 char data_extname[20];
1639 char errs_extname[20];
1640 char qual_extname[20];
1641 unsigned mode = CPL_IO_DEFAULT;
1642 cpl_propertylist *header_data = NULL;
1643 cpl_propertylist *header_errs = NULL;
1644 cpl_propertylist *header_qual = NULL;
1645
1646 /* check input parameters */
1647 XSH_ASSURE_NOT_NULL( list);
1648 XSH_ASSURE_NOT_NULL( filename);
1649 XSH_ASSURE_NOT_ILLEGAL( list->size > 0 ) ;
1650
1651 /* Loop over Orders, as we create one table per order */
1652 for( i = 0; i < list->size ; i++ ) {
1653
1654 nlambda = list->list[i].nlambda ;
1655 nslit = list->list[i].nslit ;
1656 depth = nlambda*nslit ;
1657 order = list->list[i].order ;
1658
1659 xsh_msg_dbg_high("depth %d : %dx%d", depth, nslit, nlambda);
1660
1661 /* skip the order */
1662 if (depth == 0){
1663 continue;
1664 }
1665
1666 check( header_data = cpl_propertylist_duplicate( list->header));
1667 header_errs=cpl_propertylist_new();
1668 header_qual=cpl_propertylist_new();
1669
1670 check(img_lambda=cpl_image_new(nlambda,1,CPL_TYPE_DOUBLE));
1671 check(img_slit=cpl_image_new(nslit,1,CPL_TYPE_FLOAT));
1672 check(img_flux=cpl_image_new(nlambda,nslit,CPL_TYPE_FLOAT));
1673 check(img_err=cpl_image_new(nlambda,nslit,CPL_TYPE_FLOAT));
1674 check(img_qual=cpl_image_new(nlambda,nslit,CPL_TYPE_INT));
1675
1676 check(plambda=cpl_image_get_data_double(img_lambda));
1677 check(pslit=cpl_image_get_data_float(img_slit));
1678 check(pflux=cpl_image_get_data_float(img_flux));
1679 check(perr=cpl_image_get_data_float(img_err));
1680 check(pqual=cpl_image_get_data_int(img_qual));
1681
1682 for( k = 0 ; k<nslit ; k++ ) {
1683 pslit[k]= (*(list->list[i].slit+k) ) ;
1684 }
1685 for( k = 0 ; k<nlambda ; k++ ) {
1686 plambda[k]= (*(list->list[i].lambda+k) ) ;
1687 }
1688
1689 if (nlambda > 1){
1690 cdelt1=plambda[1]-plambda[0];
1691 crpix1=1.;
1692 crval1=plambda[0];
1693
1694 check(xsh_pfits_set_wcs1(header_data, crpix1, crval1, cdelt1));
1695 check(xsh_pfits_set_wcs1(header_errs, crpix1, crval1, cdelt1));
1696 check(xsh_pfits_set_wcs1(header_qual, crpix1, crval1, cdelt1));
1697
1698 xsh_msg_dbg_high("write axis 1 : %f %f %f", crpix1, crval1, cdelt1);
1699
1700
1701 }
1702
1703 for( k = 0 ; k<depth ; k++ ) {
1704 pflux[k]= (*(list->list[i].data1+k) ) ;
1705 perr[k]= (*(list->list[i].errs1+k) ) ;
1706 pqual[k]= (*(list->list[i].qual1+k) ) ;
1707 }
1708
1709 /* product 2D */
1710 crpix2=1.;
1711 crval2=pslit[0];
1712 if ( nslit > 1){
1713 xsh_msg_dbg_high("nslit %d", nslit);
1714 cdelt2=pslit[1]-pslit[0];
1715 xsh_pfits_set_wcs(header_data,crpix1,crval1,cdelt1,crpix2,crval2,cdelt2);
1716 xsh_pfits_set_wcs(header_errs,crpix1,crval1,cdelt1,crpix2,crval2,cdelt2);
1717 xsh_pfits_set_wcs(header_qual,crpix1,crval1,cdelt1,crpix2,crval2,cdelt2);
1718
1719 } else {
1720 cpl_propertylist_erase_regexp(header_data, "^CRPIX2",0);
1721 cpl_propertylist_erase_regexp(header_data, "^CRVAL2",0);
1722 cpl_propertylist_erase_regexp(header_data, "^CDELT2",0);
1723
1724 cpl_propertylist_erase_regexp(header_errs, "^CRPIX2",0);
1725 cpl_propertylist_erase_regexp(header_errs, "^CRVAL2",0);
1726 cpl_propertylist_erase_regexp(header_errs, "^CDELT2",0);
1727
1728 cpl_propertylist_erase_regexp(header_qual, "^CRPIX2",0);
1729 cpl_propertylist_erase_regexp(header_qual, "^CRVAL2",0);
1730 cpl_propertylist_erase_regexp(header_qual, "^CDELT2",0);
1731
1732 xsh_pfits_set_wcs1(header_data, crpix1, crval1, cdelt1);
1733 xsh_pfits_set_wcs1(header_errs, crpix1, crval1, cdelt1);
1734 xsh_pfits_set_wcs1(header_qual, crpix1, crval1, cdelt1);
1735
1736 }
1737
1738 xsh_pfits_set_extract_slit_min( header_data,list->slit_min);
1739 xsh_pfits_set_extract_slit_max( header_data,list->slit_max);
1740
1741 xsh_pfits_set_extract_slit_min( header_errs,list->slit_min);
1742 xsh_pfits_set_extract_slit_max( header_errs,list->slit_max);
1743
1744 xsh_pfits_set_extract_slit_min( header_qual,list->slit_min);
1745 xsh_pfits_set_extract_slit_max( header_qual,list->slit_max);
1746
1747 sprintf(data_extname,"ORD%d_FLUX",order);
1748 sprintf(errs_extname,"ORD%d_ERRS",order);
1749 sprintf(qual_extname,"ORD%d_QUAL",order);
1750 xsh_msg_dbg_high("extname %s", data_extname);
1751
1753 check( xsh_pfits_set_extname( header_data, data_extname));
1754 check(xsh_plist_set_extra_keys(header_data,"IMAGE","DATA","RMSE",
1755 data_extname,errs_extname,qual_extname,0));
1756
1757
1759 xsh_pfits_set_extname( header_errs, errs_extname);
1760 check(xsh_plist_set_extra_keys(header_errs,"IMAGE","DATA","RMSE",
1761 data_extname,errs_extname,qual_extname,1));
1762
1764 xsh_pfits_set_extname( header_qual,qual_extname);
1765 check(xsh_plist_set_extra_keys(header_qual,"IMAGE","DATA","RMSE",
1766 data_extname,errs_extname,qual_extname,2));
1767
1768 mode = CPL_IO_EXTEND;
1769 if ( nslit > 1){
1770 if(i==0) {
1771 cpl_image_save(img_flux,filename, CPL_BPP_IEEE_FLOAT, header_data,
1772 CPL_IO_DEFAULT);
1773 } else {
1774 cpl_image_save(img_flux,filename, CPL_BPP_IEEE_FLOAT, header_data, mode);
1775
1776 }
1777 cpl_image_save(img_err,filename, CPL_BPP_IEEE_FLOAT, header_errs, mode) ;
1778 cpl_image_save(img_qual, filename, XSH_PRE_QUAL_BPP, header_qual, mode) ;
1779
1780 } else {
1781 cpl_vector* flux1D = cpl_vector_new_from_image_row( img_flux, 1);
1782 cpl_vector* errs1D = cpl_vector_new_from_image_row( img_err, 1);
1783 cpl_vector* qual1D = cpl_vector_new_from_image_row( img_qual, 1);
1784
1785 if(i==0) {
1786 cpl_vector_save( flux1D, filename, CPL_BPP_IEEE_FLOAT, header_data,CPL_IO_DEFAULT );
1787 } else {
1788 cpl_vector_save( flux1D, filename, CPL_BPP_IEEE_FLOAT, header_data, mode);
1789 }
1790 cpl_vector_save( errs1D, filename, CPL_BPP_IEEE_FLOAT, header_errs, mode);
1791 cpl_vector_save( qual1D, filename, CPL_BPP_32_SIGNED, header_qual, mode);
1792 xsh_free_vector( &flux1D);
1793 xsh_free_vector( &errs1D);
1794 xsh_free_vector( &qual1D);
1795 }
1796
1797
1798
1799 xsh_free_image(&img_lambda);
1800 xsh_free_image(&img_slit);
1801 xsh_free_image(&img_flux);
1802 xsh_free_image(&img_err);
1803 xsh_free_image(&img_qual);
1804 xsh_free_propertylist( &header_data);
1805 xsh_free_propertylist( &header_errs);
1806 xsh_free_propertylist( &header_qual);
1807
1808 }
1809
1810 check(result=xsh_frame_product(filename,tag,CPL_FRAME_TYPE_IMAGE,
1811 CPL_FRAME_GROUP_PRODUCT,
1812 CPL_FRAME_LEVEL_FINAL));
1813
1814 cleanup:
1815 xsh_free_propertylist( &header_data);
1816 XSH_TABLE_FREE( table);
1817 xsh_free_array( &temp_array ) ;
1818 return result ;
1819}
1820
1821
1822
1823
1824
1825void xsh_rec_get_nod_kw( cpl_frame * rec_frame, double * throw,
1826 double * jitter,
1827 double * reloffset, double * cumoffset )
1828{
1829 cpl_propertylist * header ;
1830 const char *fname = NULL ;
1831 double val ;
1832
1833 XSH_ASSURE_NOT_NULL( rec_frame ) ;
1834 check( fname = cpl_frame_get_filename( rec_frame ) ) ;
1835 check( header = cpl_propertylist_load( fname, 0 ) ) ;
1836
1837 val = xsh_pfits_get_nodthrow( header ) ;
1838 if ( cpl_error_get_code() == CPL_ERROR_NONE ) {
1839 *throw = val ;
1840 }
1841 else cpl_error_reset() ;
1842
1843 val = xsh_pfits_get_nod_jitterwidth( header ) ;
1844 if ( cpl_error_get_code() == CPL_ERROR_NONE ) {
1845 *jitter = val ;
1846 }
1847 else
1848 cpl_error_reset() ;
1849
1850 val = xsh_pfits_get_nod_reloffset( header ) ;
1851 if ( cpl_error_get_code() == CPL_ERROR_NONE ) {
1852 *reloffset = val ;
1853 }
1854 else cpl_error_reset() ;
1855
1856 val = xsh_pfits_get_nod_cumoffset( header ) ;
1857 if ( cpl_error_get_code() == CPL_ERROR_NONE ) {
1858 *cumoffset = val ;
1859 }
1860 else cpl_error_reset() ;
1861
1862 cleanup:
1863 xsh_free_propertylist( &header ) ;
1864 return ;
1865}
1866
1867cpl_error_code
1869 double* smin, double* smax)
1870{
1871
1872 double nod_throw = xsh_pfits_get_nodthrow(rlist->header);
1873 int nslit = xsh_rec_list_get_nslit(rlist, 0);
1874 int hslit = round(0.5 * nod_throw / slit_step);
1875 *smax = nslit/2. + hslit;
1876 *smin = nslit/2. - hslit;
1877
1878 return cpl_error_get_code();
1879
1880}
static char mode[32]
static xsh_instrument * instrument
static float slit_step
int xsh_rec_list_get_nslit(xsh_rec_list *list, int idx)
Definition: xsh_data_rec.c:827
double * xsh_rec_list_get_lambda(xsh_rec_list *list, int idx)
cpl_error_code xsh_rec_list_set_slit_max(xsh_rec_list *list, const double val)
xsh_rec_list * xsh_rec_list_load(cpl_frame *frame, xsh_instrument *instrument)
load an rec list from a frame
Definition: xsh_data_rec.c:289
float * xsh_rec_list_get_data1(xsh_rec_list *list, int idx)
cpl_frame * xsh_rec_list_save(xsh_rec_list *list, const char *filename, const char *tag, int is_temp)
Save a rec list in a frame.
cpl_frame * xsh_rec_list_save2(xsh_rec_list *list, const char *filename, const char *tag)
save an rec list to a frame
cpl_error_code xsh_rec_get_nod_extract_slit_min_max(xsh_rec_list *rlist, const double slit_step, double *smin, double *smax)
xsh_rec_list * xsh_rec_list_create_with_size(int size, xsh_instrument *instr)
Create an empty order list.
Definition: xsh_data_rec.c:147
float * xsh_rec_list_get_errs1(xsh_rec_list *list, int idx)
cpl_propertylist * xsh_rec_list_get_header(xsh_rec_list *list)
get header of the table
Definition: xsh_data_rec.c:809
void xsh_rec_list_update_header(xsh_rec_list *rec_list, xsh_pre *pre, xsh_rectify_param *rec_par, const char *pro_catg)
Update header of rectified list writing mandatory KW.
int xsh_rec_list_get_order(xsh_rec_list *list, int idx)
Definition: xsh_data_rec.c:846
double xsh_rec_list_get_slit_max(xsh_rec_list *list)
Definition: xsh_data_rec.c:923
xsh_rec_list * xsh_rec_list_load_eso(cpl_frame *frame, xsh_instrument *instrument)
Definition: xsh_data_rec.c:407
void xsh_rec_list_set_data_size(xsh_rec_list *list, int idx, int absorder, int nlambda, int ns)
Allocate memory for the order idx of the rectify list.
Definition: xsh_data_rec.c:191
void xsh_rec_list_dump(xsh_rec_list *list, const char *fname)
Definition: xsh_data_rec.c:62
double xsh_rec_list_get_lambda_max(xsh_rec_list *list)
Definition: xsh_data_rec.c:957
cpl_frame * xsh_rec_list1D_save_as_tab(xsh_rec_list *list, const char *filename, const char *tag)
save an rec list to a frame
xsh_rec_list * xsh_rec_list_load_eso_1d(cpl_frame *frame, xsh_instrument *instrument)
Definition: xsh_data_rec.c:563
int * xsh_rec_list_get_qual1(xsh_rec_list *list, int idx)
xsh_rec_list * xsh_rec_list_duplicate(xsh_rec_list *old, xsh_instrument *instrument)
Definition: xsh_data_rec.c:226
double xsh_rec_list_get_lambda_min(xsh_rec_list *list)
Definition: xsh_data_rec.c:935
float * xsh_rec_list_get_slit(xsh_rec_list *list, int idx)
Definition: xsh_data_rec.c:884
int xsh_rec_list_get_nlambda(xsh_rec_list *list, int idx)
Definition: xsh_data_rec.c:865
cpl_frame * xsh_rec_list_frame_invert(cpl_frame *rec_frame, const char *tag, xsh_instrument *instrument)
Invert the rectified flux images of the input frame into a new frame.
Definition: xsh_data_rec.c:713
void xsh_rec_list_free(xsh_rec_list **list)
free memory associated to a rec_list
Definition: xsh_data_rec.c:760
xsh_rec_list * xsh_rec_list_create(xsh_instrument *instr)
Create an empty order list.
Definition: xsh_data_rec.c:100
double xsh_rec_list_get_slit_min(xsh_rec_list *list)
Definition: xsh_data_rec.c:903
void xsh_rec_get_nod_kw(cpl_frame *rec_frame, double *throw, double *jitter, double *reloffset, double *cumoffset)
cpl_frame * xsh_rec_list_save_table(xsh_rec_list *list, const char *filename, const char *tag, int is_temp)
Save a rec list in a frame.
cpl_error_code xsh_rec_list_set_slit_min(xsh_rec_list *list, const double val)
Definition: xsh_data_rec.c:987
#define XSH_ASSURE_NOT_ILLEGAL(cond)
Definition: xsh_error.h:107
#define check(COMMAND)
Definition: xsh_error.h:71
#define XSH_CMP_INT(A, OPERATOR, B, SUFFIX,...)
Definition: xsh_error.h:119
#define XSH_ASSURE_NOT_NULL(pointer)
Definition: xsh_error.h:99
xsh_instrument * xsh_instrument_duplicate(xsh_instrument *old)
XSH_ARM xsh_instrument_get_arm(xsh_instrument *i)
Get an arm on instrument structure.
int size
#define xsh_msg_dbg_medium(...)
Definition: xsh_msg.h:44
#define xsh_msg(...)
Print a message on info level.
Definition: xsh_msg.h:121
#define xsh_msg_dbg_low(...)
Definition: xsh_msg.h:48
#define xsh_msg_dbg_high(...)
Definition: xsh_msg.h:40
double xsh_pfits_get_crval2(const cpl_propertylist *plist)
find out the crval2
Definition: xsh_pfits.c:1926
cpl_error_code xsh_plist_set_extra_keys(cpl_propertylist *plist, const char *hduclas1, const char *hduclas2, const char *hduclas3, const char *scidata, const char *errdata, const char *qualdata, const int type)
set hdu keys
Definition: xsh_pfits.c:4250
void xsh_pfits_set_pcatg(cpl_propertylist *plist, const char *value)
Write the PCATG value.
Definition: xsh_pfits.c:1008
double xsh_pfits_get_cdelt2(const cpl_propertylist *plist)
find out the cdelt2
Definition: xsh_pfits.c:2216
void xsh_pfits_set_rectify_bin_lambda(cpl_propertylist *plist, double value)
WRITE the lambda binning.
Definition: xsh_pfits.c:3188
void xsh_pfits_set_rectify_lambda_max(cpl_propertylist *plist, double value)
WRITE the lambda max value.
Definition: xsh_pfits.c:3236
double xsh_pfits_get_nod_jitterwidth(const cpl_propertylist *plist)
Get the Jitter Box size.
Definition: xsh_pfits.c:4178
const char * xsh_pfits_get_extname(const cpl_propertylist *plist)
find out the EXTNAME
Definition: xsh_pfits.c:1707
void xsh_pfits_set_rectify_space_max(cpl_propertylist *plist, double value)
WRITE the space (slit) max value.
Definition: xsh_pfits.c:3268
void xsh_pfits_set_extname(cpl_propertylist *plist, const char *value)
Write the EXTNAME value.
Definition: xsh_pfits.c:979
double xsh_pfits_get_nodthrow(const cpl_propertylist *plist)
Get the Nod Throw value.
Definition: xsh_pfits.c:4199
cpl_error_code xsh_pfits_set_wcs(cpl_propertylist *header, const double crpix1, const double crval1, const double cdelt1, const double crpix2, const double crval2, const double cdelt2)
Definition: xsh_pfits.c:4364
void xsh_pfits_set_rectify_space_min(cpl_propertylist *plist, double value)
WRITE the space (slit) min value.
Definition: xsh_pfits.c:3252
cpl_error_code xsh_pfits_set_wcs1(cpl_propertylist *header, const double crpix1, const double crval1, const double cdelt1)
Definition: xsh_pfits.c:4307
double xsh_pfits_get_cdelt1(const cpl_propertylist *plist)
find out the cdelt1
Definition: xsh_pfits.c:2196
void xsh_pfits_set_rectify_bin_space(cpl_propertylist *plist, double value)
WRITE the space (slit) binning.
Definition: xsh_pfits.c:3204
double xsh_pfits_get_nod_reloffset(const cpl_propertylist *plist)
Get the Relative Jitter Offset.
Definition: xsh_pfits.c:4125
void xsh_pfits_set_bunit(cpl_propertylist *plist, const char *value)
Write the BUNIT value.
Definition: xsh_pfits.c:2606
void xsh_pfits_set_rectify_lambda_min(cpl_propertylist *plist, double value)
WRITE the lambda min value.
Definition: xsh_pfits.c:3220
int xsh_pfits_get_naxis1(const cpl_propertylist *plist)
find out the NAXIS1 value
Definition: xsh_pfits.c:227
double xsh_pfits_get_crval1(const cpl_propertylist *plist)
find out the crval1
Definition: xsh_pfits.c:1907
void xsh_pfits_set_extract_slit_min(cpl_propertylist *plist, double value)
WRITE the min slit for extraction.
Definition: xsh_pfits.c:2815
void xsh_pfits_set_extract_slit_max(cpl_propertylist *plist, double value)
WRITE the min slit for extraction.
Definition: xsh_pfits.c:2834
double xsh_pfits_get_nod_cumoffset(const cpl_propertylist *plist)
Get the Cumulative Jitter Offset.
Definition: xsh_pfits.c:4151
int xsh_pfits_get_naxis2(const cpl_propertylist *plist)
find out the NAXIS2 value
Definition: xsh_pfits.c:244
void xsh_free_vector(cpl_vector **v)
Deallocate a vector and set the pointer to NULL.
Definition: xsh_utils.c:2284
void xsh_free_image(cpl_image **i)
Deallocate an image and set the pointer to NULL.
Definition: xsh_utils.c:2116
void xsh_free_array(cpl_array **m)
Deallocate an array and set the pointer to NULL.
Definition: xsh_utils.c:2299
void xsh_free_table(cpl_table **t)
Deallocate a table and set the pointer to NULL.
Definition: xsh_utils.c:2133
void xsh_free_propertylist(cpl_propertylist **p)
Deallocate a property list and set the pointer to NULL.
Definition: xsh_utils.c:2179
cpl_error_code xsh_get_table_value(const cpl_table *table, const char *colname, cpl_type coltype, int i, void *result)
Read a table value from a fits table.
void xsh_add_temporary_file(const char *name)
Add temporary file to temprary files list.
Definition: xsh_utils.c:1432
XSH_INSTRCONFIG * config
cpl_propertylist * data_header
Definition: xsh_data_pre.h:66
double slit_max
Definition: xsh_data_rec.h:83
xsh_instrument * instrument
Definition: xsh_data_rec.h:88
cpl_propertylist * header
Definition: xsh_data_rec.h:89
double slit_min
Definition: xsh_data_rec.h:82
xsh_rec * list
Definition: xsh_data_rec.h:87
float * errs1
Definition: xsh_data_rec.h:71
float * slit
Definition: xsh_data_rec.h:66
int nslit
Definition: xsh_data_rec.h:65
float * data1
Definition: xsh_data_rec.h:68
int * qual1
Definition: xsh_data_rec.h:75
int order
Definition: xsh_data_rec.h:63
int nlambda
Definition: xsh_data_rec.h:64
double * lambda
Definition: xsh_data_rec.h:67
@ XSH_ARM_UVB
@ XSH_ARM_NIR
@ XSH_ARM_VIS
#define XSH_PRE_DATA_TYPE
Definition: xsh_data_pre.h:42
#define XSH_PRE_QUAL_TYPE
Definition: xsh_data_pre.h:46
#define XSH_PRE_QUAL_BPP
Definition: xsh_data_pre.h:47
#define XSH_PRE_ERRS_TYPE
Definition: xsh_data_pre.h:44
#define XSH_REC_TABLE_COLNAME_ERRS1
Definition: xsh_data_rec.h:55
#define XSH_REC_TABLE_NB_VIS_ORDERS
Definition: xsh_data_rec.h:35
#define XSH_REC_TABLE_COLNAME_SLIT
Definition: xsh_data_rec.h:47
#define XSH_REC_TABLE_COLNAME_ORDER
Definition: xsh_data_rec.h:39
#define XSH_REC_TABLE_COLNAME_NLAMBDA
Definition: xsh_data_rec.h:40
#define XSH_REC_TABLE_NB_NIR_ORDERS
Definition: xsh_data_rec.h:36
#define XSH_REC_TABLE_NB_UVB_ORDERS
Definition: xsh_data_rec.h:34
#define XSH_REC_TABLE_COLNAME_NSLIT
Definition: xsh_data_rec.h:41
#define XSH_REC_TABLE_COLNAME_QUAL1
Definition: xsh_data_rec.h:58
#define XSH_REC_TABLE_COLNAME_LAMBDA
Definition: xsh_data_rec.h:46
#define XSH_REC_TABLE_COLNAME_FLUX1
Definition: xsh_data_rec.h:52
int order
Definition: xsh_detmon_lg.c:80
cpl_frame * xsh_frame_product(const char *fname, const char *tag, cpl_frame_type type, cpl_frame_group group, cpl_frame_level level)
Creates a frame with given characteristics.
Definition: xsh_dfs.c:930
#define XSH_BUNIT_NONE_C
Definition: xsh_pfits.h:116
#define XSH_BUNIT_FLUX_REL_C
Definition: xsh_pfits.h:115
#define XSH_NEW_PROPERTYLIST(POINTER)
Definition: xsh_utils.h:70
#define XSH_CALLOC(POINTER, TYPE, SIZE)
Definition: xsh_utils.h:56
void xsh_table_get_array_double(cpl_table *table, const char *colname, double *pointer, int nb)
void xsh_table_get_array_float(cpl_table *table, const char *colname, float *pointer, int nb)
#define XSH_TABLE_FREE(TABLE)