57#define XSH_MAX_SHIFT_Y 10.
63 cpl_propertylist * header )
92 for (i=0; i< (*list)->size; i++) {
96 cpl_free((*list)->list);
111 if (tilt && (*tilt) ){
112 if ((*tilt)->name != NULL) {
113 cpl_free(( *tilt)->name );
142 list->
list[idx] = line ;
162 const char* filename,
168 cpl_table* table = NULL;
169 cpl_table* ext = NULL;
170 cpl_frame * result = NULL ;
292 check(cpl_table_set_size(table,list->
size));
295 for(i=0;i<list->
size;i++){
349 for(k=0;k<
niter;k++) {
352 for(i=0;i<list->
size;i++){
353 if( fabs(pshift[i]-yshift_avg) >
kappa*yshift_std ) {
393 check(cpl_table_save(table, list->
header, NULL, filename, CPL_IO_DEFAULT));
398 CPL_FRAME_TYPE_TABLE,
399 CPL_FRAME_GROUP_PRODUCT,
400 CPL_FRAME_LEVEL_TEMPORARY));
420 double* res = NULL, *p ;
425 check( res = cpl_malloc( list->
size *
sizeof(
double) ) ) ;
426 for( p = res, i = 0 ; i<
size ; i++, p++ )
443 double* res = NULL, *p ;
448 check( res = cpl_malloc( list->
size *
sizeof(
double) ) ) ;
449 for( p = res, i = 0 ; i<
size ; i++, p++ )
466 double* res = NULL, *p ;
472 check( res = cpl_malloc( list->
size *
sizeof(
double) ) ) ;
473 for( p = res, i = 0 ; i<
size ; i++, p++ )
491 double* res = NULL, *p ;
497 check( res = cpl_malloc( list->
size *
sizeof(
double) ) ) ;
498 for( p = res, i = 0 ; i<
size ; i++, p++ )
516 double* res = NULL, *p ;
522 check( res = cpl_malloc( list->
size *
sizeof(
double) ) ) ;
523 for( p = res, i = 0 ; i<
size ; i++, p++ )
541 double* res = NULL, *p ;
546 check( res = cpl_malloc( list->
size *
sizeof(
double) ) ) ;
547 for( p = res, i = 0 ; i<
size ; i++, p++ )
564 double* res = NULL, *p ;
569 check( res = cpl_malloc( list->
size *
sizeof(
double) ) ) ;
570 for( p = res, i = 0 ; i<
size ; i++, p++ )
587 double* res = NULL, *p ;
592 check( res = cpl_malloc( list->
size *
sizeof(
double) ) ) ;
593 for( p = res, i = 0 ; i<
size ; i++, p++ )
610 int * res = NULL, *p ;
615 check( res = cpl_malloc( list->
size *
sizeof(
int) ) ) ;
616 for( p = res, i = 0 ; i<
size ; i++, p++ )
633 cpl_propertylist * res = NULL ;
658 for( i = 0 ; i<list->
size ; i++ ) {
680 lb = (*b)->wavelength;
832 cpl_propertylist * res = NULL;
855 for(i=0; i< list->
size; i++) {
856 const char* name = list->
list[i]->
name;
858 if (name == NULL) name =
"";
859 if (comment == NULL) comment =
"";
860 xsh_msg(
" Wavelength %f name %s flux %d comment %s",
879 cpl_table* table = NULL;
880 const char* tablename = NULL;
888 check( tablename = cpl_frame_get_filename(frame));
896 check(result->
size = cpl_table_get_nrow(table));
901 check(result->
header = cpl_propertylist_load(tablename, 0));
904 for(i=0;i<result->
size;i++){
905 const char* name =
"";
906 const char* comment =
"";
912 CPL_TYPE_STRING, i, &name));
914 CPL_TYPE_INT, i, &(arc->
flux)));
916 CPL_TYPE_STRING, i, &comment));
923 if (comment != NULL) {
929 result->
list[i] = arc;
933 if (cpl_error_get_code () != CPL_ERROR_NONE) {
934 xsh_error_msg(
"can't load frame %s",cpl_frame_get_filename(frame));
950 if ((*arc)->name != NULL) {
951 cpl_free((*arc)->name);
953 if ((*arc)->comment != NULL) {
954 cpl_free((*arc)->comment);
973 for (i=0; i< (*list)->size; i++) {
977 cpl_free((*list)->list);
993 for(i=0;i<list->
size;i++)
1023 cpl_table* table = NULL;
1024 cpl_frame * result = NULL ;
1061 check(cpl_table_set_size(table,list->
size));
1064 for(i=0;i<list->
size;i++){
1076 check(cpl_table_save(table, list->
header, NULL, filename, CPL_IO_DEFAULT));
1081 CPL_FRAME_TYPE_TABLE,
1082 CPL_FRAME_GROUP_PRODUCT,
1083 CPL_FRAME_LEVEL_TEMPORARY));
void xsh_arclist_lambda_sort(xsh_arclist *list)
sort arcline list by increasing lambda
void xsh_dump_arclist(xsh_arclist *list)
Dump main info about an arcline_list.
static int xsh_arclist_lambda_compare(const void *one, const void *two)
float xsh_arclist_get_wavelength(xsh_arclist *list, int idx)
get wavelength of a line in the arcline list
void xsh_arclist_clean(xsh_arclist *list)
int xsh_arclist_get_nbrejected(xsh_arclist *list)
get nb lines rejected in arcline list
void xsh_arclist_free(xsh_arclist **list)
free memory associated to a arclist
void xsh_arclist_restore(xsh_arclist *list, int idx)
restore a line from the list
int xsh_arclist_get_size(xsh_arclist *list)
get size of arcline list
void xsh_arclist_reject(xsh_arclist *list, int idx)
reject a line from the list
xsh_arclist * xsh_arclist_load(cpl_frame *frame)
load an arcline list frame in arclist structure
void xsh_arcline_free(xsh_arcline **arc)
free memory associated to a arcline
int xsh_arclist_is_rejected(xsh_arclist *list, int idx)
give if a line is rejected
cpl_propertylist * xsh_arclist_get_header(xsh_arclist *list)
get header of the table
cpl_frame * xsh_arclist_save(xsh_arclist *list, const char *filename, const char *tag)
save a arclist to a frame
double * xsh_linetilt_list_get_sigma_y(xsh_linetilt_list *list)
get the Y sigma. The returned array must be deallocated by the caller.
double * xsh_linetilt_list_get_slits(xsh_linetilt_list *list)
get the slits . The returned array must be deallocated by the caller.
void xsh_linetilt_list_free(xsh_linetilt_list **list)
free memory associated to a arclist
int xsh_linetilt_is_duplicate(xsh_linetilt_list *list, float lambda, int order)
double * xsh_linetilt_list_get_wavelengths(xsh_linetilt_list *list)
get the wavelength . The returned array must be deallocated by the caller.
xsh_linetilt * xsh_linetilt_new(void)
void xsh_linetilt_list_add(xsh_linetilt_list *list, xsh_linetilt *line, int idx)
int * xsh_linetilt_list_get_slit_index(xsh_linetilt_list *list)
get the slit_index array . The returned array must be deallocated by the caller.
cpl_propertylist * xsh_linetilt_list_get_header(xsh_linetilt_list *list)
double * xsh_linetilt_list_get_posx(xsh_linetilt_list *list)
get the X central positions. The returned array must be deallocated by the caller.
xsh_linetilt_list * xsh_linetilt_list_new(int size, cpl_propertylist *header)
cpl_frame * xsh_linetilt_list_save(xsh_linetilt_list *list, xsh_instrument *instr, const char *filename, const char *tag, const double kappa, const int niter, float exptime)
save a (ks clip clean) linetilt list to a frame
void xsh_linetilt_free(xsh_linetilt **tilt)
free memory associated to a linetilt
double * xsh_linetilt_list_get_orders(xsh_linetilt_list *list)
get the orders . The returned array must be deallocated by the caller.
double * xsh_linetilt_list_get_deltay(xsh_linetilt_list *list)
get the Y Delta. The returned array must be deallocated by the caller.
double * xsh_linetilt_list_get_pre_posy(xsh_linetilt_list *list)
get the previous Y positions. The returned array must be deallocated by the caller.
double * xsh_linetilt_list_get_posy(xsh_linetilt_list *list)
get the Y central positions. The returned array must be deallocated by the caller.
#define XSH_ASSURE_NOT_ILLEGAL(cond)
#define xsh_error_msg(...)
#define XSH_ASSURE_NOT_NULL(pointer)
#define xsh_msg(...)
Print a message on info level.
void xsh_pfits_set_pcatg(cpl_propertylist *plist, const char *value)
Write the PCATG value.
void xsh_pfits_set_qc(cpl_propertylist *plist, void *value, const char *kw, xsh_instrument *instrument)
char * xsh_stringdup(const char *s)
String duplication.
void xsh_free_table(cpl_table **t)
Deallocate a table and set the pointer to NULL.
void xsh_free_propertylist(cpl_propertylist **p)
Deallocate a property list and set the pointer to NULL.
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.
cpl_propertylist * header
cpl_propertylist * header
#define XSH_ARCLIST_TABLE_COLNAME_WAVELENGTH
#define XSH_ARCLIST_TABLE_UNIT_WAVELENGTH
#define XSH_ARCLIST_TABLE_COLNAME_NAME
#define XSH_ARCLIST_TABLE_UNIT_NAME
#define XSH_ARCLIST_TABLE_COLNAME_FLUX
#define XSH_ARCLIST_TABLE_UNIT_FLUX
#define XSH_ARCLIST_TABLE_NB_COL
#define XSH_ARCLIST_TABLE_COLNAME_COMMENT
#define XSH_ARCLIST_TABLE_UNIT_COMMENT
#define XSH_LINETILT_TABLE_COLNAME_CHISQ
#define XSH_LINETILT_TABLE_COLNAME_SHIFTY
#define XSH_LINETILT_TABLE_COLNAME_GAUSSY
#define XSH_LINETILT_TABLE_UNIT_FWHM
#define XSH_LINETILT_TABLE_COLNAME_FLUX
#define XSH_LINETILT_TABLE_UNIT_GAUSSY
#define XSH_LINETILT_TABLE_COLNAME_TILT
#define XSH_LINETILT_TABLE_COLNAME_FLAG
#define XSH_LINETILT_TABLE_UNIT_CENPOSX
#define XSH_LINETILT_TABLE_UNIT_CENPOSY
#define XSH_LINETILT_TABLE_NB_COL
#define XSH_LINETILT_TABLE_COLNAME_WAVELENGTH
#define XSH_LINETILT_TABLE_UNIT_NAME
#define XSH_LINETILT_TABLE_COLNAME_CENPOSY
#define XSH_LINETILT_TABLE_COLNAME_NAME
#define XSH_LINETILT_TABLE_UNIT_SPECRES
#define XSH_LINETILT_TABLE_COLNAME_CENPOSX
#define XSH_LINETILT_TABLE_COLNAME_SPECRES
#define XSH_LINETILT_TABLE_UNIT_CHISQ
#define XSH_LINETILT_TABLE_UNIT_ORDER
#define XSH_LINETILT_TABLE_UNIT_INTENSITY
#define XSH_LINETILT_TABLE_UNIT_TILT
#define XSH_LINETILT_TABLE_UNIT_WAVELENGTH
#define XSH_LINETILT_TABLE_COLNAME_ORDER
#define XSH_LINETILT_TABLE_UNIT_FLUX
#define XSH_LINETILT_TABLE_COLNAME_FWHM
#define XSH_LINETILT_TABLE_UNIT_FLAG
#define XSH_LINETILT_TABLE_UNIT_SHIFTY
#define XSH_LINETILT_TABLE_COLNAME_INTENSITY
#define XSH_LINETILT_TABLE_COLNAME_TILTY
#define XSH_LINETILT_TABLE_UNIT_TILTY
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.
#define XSH_GET_TAG_FROM_MODE(TAG, instr)
#define QC_WAVECAL_NLININT
#define QC_WAVECAL_DIFFYSTD
#define QC_WAVECAL_DIFFYMED
#define QC_WAVECAL_FWHMAVG
#define QC_WAVECAL_FWHMRMS
#define QC_WAVECAL_LININT_NORM
#define QC_WAVECAL_DIFFYAVG
#define XSH_FREE(POINTER)
#define XSH_CALLOC(POINTER, TYPE, SIZE)
#define XSH_TABLE_LOAD(TABLE, NAME)
#define XSH_TABLE_FREE(TABLE)