00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifdef HAVE_CONFIG_H
00027 #include <config.h>
00028 #endif
00029
00030
00037
00040
00041
00042
00043
00044 #include <math.h>
00045 #include <xsh_drl.h>
00046
00047 #include <xsh_badpixelmap.h>
00048 #include <xsh_data_pre.h>
00049 #include <xsh_data_order.h>
00050 #include <xsh_data_wavemap.h>
00051 #include <xsh_data_localization.h>
00052 #include <xsh_data_rec.h>
00053 #include <xsh_dfs.h>
00054 #include <xsh_pfits.h>
00055 #include <xsh_error.h>
00056 #include <xsh_msg.h>
00057 #include <xsh_fit.h>
00058 #include <xsh_badpixelmap.h>
00059
00060 #include <cpl.h>
00061
00062
00063
00064
00065
00066
00067
00068
00069
00081 cpl_frameset * xsh_subtract_sky_offset( cpl_frameset * object_raws,
00082 cpl_frameset * sky_raws,
00083 int nraws,
00084 xsh_instrument * instrument)
00085 {
00086 cpl_frameset *result = NULL;
00087 char arm_name[16] ;
00088 cpl_frameset * objects = NULL, * skys = NULL ;
00089 int i ;
00090
00091 XSH_ASSURE_NOT_NULL( object_raws);
00092 XSH_ASSURE_NOT_NULL( sky_raws);
00093 XSH_ASSURE_NOT_NULL( instrument);
00094
00095
00096 check( objects = xsh_order_frameset_by_date( object_raws));
00097 check( skys = xsh_order_frameset_by_date( sky_raws));
00098
00099 check( result = cpl_frameset_new());
00100 sprintf( arm_name, "%s", xsh_instrument_arm_tostring( instrument));
00101
00102
00103 for( i = 0 ; i<nraws ; i ++ ) {
00104 char a_b_name[256];
00105 cpl_frame *a = NULL, *b = NULL;
00106 cpl_frame *a_b = NULL ;
00107
00108 check(a = cpl_frameset_get_frame( objects, i));
00109 check(b = cpl_frameset_get_frame( skys, i));
00110
00111 xsh_msg( "1-st pair: OBJECT='%s'", cpl_frame_get_filename( a));
00112 xsh_msg( " SKY ='%s'", cpl_frame_get_filename( b));
00113
00114 sprintf( a_b_name ,"SKY_SUBTRACTED_OFFSET_%s_%d.fits",
00115 arm_name, i);
00116
00117 check( a_b = xsh_pre_frame_subtract( a, b, a_b_name, instrument,1));
00118
00119
00120
00121
00122 check( cpl_frameset_insert( result, a_b));
00123 }
00124
00125 xsh_msg_dbg_high( "Done OK" ) ;
00126
00127 cleanup:
00128 xsh_free_frameset( &objects);
00129 xsh_free_frameset( &skys);
00130 return result ;
00131
00132 }
00133
00134