67#define MODULE_ID "XSH_LOCALIZE_IFU"
83 {
"cut-snr-up", required_argument, 0,
SNR_UP_OPT},
87 {
"deg", required_argument, 0,
DEG_OPT},
95 puts(
"Unitary test of xsh_localize_ifu");
96 puts(
"Usage: test_xsh_localize_ifu [options] DATA_FILE");
99 puts(
" --help : What you see" ) ;
100 puts(
" --smooth-hsize= : Half size of median smooth filter");
101 puts(
" --nscales= : Number of scales");
102 puts(
" --HF-skip= : Number of skipping High Frequency");
103 puts(
" --cut-sigma-low= : Gaussian fits of the cross-dispersion profile whose FWHM is lower than this value are rejected.[0.05]");
104 puts(
" --cut-sigma-up = : Gaussian fits of the cross-dispersion profile whose FWHM is upper than this value are rejected.[0.95]");
105 puts(
" --cut-snr-low= : Gaussian fits of the cross-dispersion profile whose SNR is lower than this value are rejected.[0.05]");
106 puts(
" --cut-snr-up= : Gaussian fits of the cross-dispersion profile whose SNR is upper than this value are rejected.0.95]");
107 puts(
" --box-hsize= : Half size of running chunk box");
108 puts(
" --slit-min= : Maximum slit in arcsec [-6.0]");
109 puts(
" --slit-max= : Minimum slit in arcsec [6.0]");
110 puts(
" --deg = : Minimum slit in arcsec [2]");
111 puts(
" --skymask=<file> : Sky mask file");
112 puts(
"\nInput Files" ) ;
113 puts(
"DATA_FILE : Merge 2D frame");
119 int *smooth_hsize,
int *nscales,
int *HF_skip,
120 double *sigma_low,
double *sigma_up,
double *snr_low,
double *snr_up,
121 int *box_hsize,
double *slitmin,
double *slitmax,
int *deg,
char **skymask_name)
124 int option_index = 0;
126 while (( opt = getopt_long (argc, argv,
127 "cut-sigma:smooth-hsize:nscales:HF-skip:deg",
132 *smooth_hsize = atoi(optarg);
135 *nscales = atoi(optarg);
138 *HF_skip = atoi(optarg);
141 *sigma_low = atof( optarg);
144 *sigma_up = atof( optarg);
147 *snr_low = atof( optarg);
150 *snr_up = atof( optarg);
153 *box_hsize = atoi( optarg);
156 *slitmin = atof( optarg);
159 *slitmax = atof( optarg);
162 *deg = atoi( optarg);
165 *skymask_name = optarg;
175int main(
int argc,
char **argv)
181 int smooth_hsize = 2;
183 const char *file_name = NULL;
184 cpl_frame *merge2d_frame = NULL;
185 cpl_frame *result = NULL;
186 char result_name[256];
188 cpl_table *result_tab = NULL;
190 double *wave_result_data = NULL;
191 double *slit_result_data = NULL;
192 FILE *result_file = NULL;
194 double sigma_low = 0.05;
195 double sigma_up = 0.95;
196 double snr_low = 0.05;
197 double snr_up = 0.95;
205 char * skymask_name = NULL;
206 cpl_frame *skymask_frame = NULL;
208 cpl_propertylist *plist = NULL;
211 const char* tag = NULL;
219 cpl_msg_set_level(CPL_MSG_DEBUG);
223 HandleOptions( argc, argv, &smooth_hsize, &nscales, &HF_skip,
224 &sigma_low, &sigma_up, &snr_low, &snr_up,
225 &box_hsize, &slitmin, &slitmax, °, &skymask_name);
227 if ( (argc - optind) > 0 ) {
228 file_name = argv[optind];
235 check( plist = cpl_propertylist_load( file_name, 0));
241 xsh_msg(
"File : %s ", file_name);
243 xsh_msg(
"SMOOTH_HSIZE : %d ", smooth_hsize);
244 xsh_msg(
"NSCALES : %d ", nscales);
245 xsh_msg(
"HF_SKIP : %d ", HF_skip);
246 xsh_msg(
"SIGMA : [%f %f]", sigma_low, sigma_up);
247 xsh_msg(
"SNR : [%f %f]", snr_low, snr_up);
248 xsh_msg(
"BOX HSIZE: %d", box_hsize);
249 xsh_msg(
"SLIT MIN: %f", slitmin);
250 xsh_msg(
"SLIT MAX: %f", slitmax);
253 xsh_msg(
"SKYMASK : %s", skymask_name);
261 if ( strstr( file_name,
"CEN") != NULL){
262 sprintf( result_name,
"decomp_CEN.fits");
264 else if ( strstr( file_name,
"UP") != NULL){
265 sprintf( result_name,
"decomp_UP.fits");
267 else if ( strstr( file_name,
"DOWN") != NULL){
268 sprintf( result_name,
"decomp_DOWN.fits");
271 sprintf( result_name,
"decomp.fits");
275 skymask_frame, smooth_hsize, nscales,
276 HF_skip, result_name, sigma_low, sigma_up,
277 snr_low, snr_up, slitmin, slitmax, deg, box_hsize,
instrument));
279 xsh_msg(
"Produce file %s", result_name);
282 check( wave_result_data = cpl_table_get_data_double( result_tab,
284 check( slit_result_data = cpl_table_get_data_double( result_tab,
286 result_size = cpl_table_get_nrow( result_tab);
288 result_file = fopen(
"LOCALIZE_IFU.reg",
"w+");
290 fprintf( result_file,
"# Region file format: DS9 version 4.0\n");
292 fprintf( result_file,
"#yellow center\n");
293 fprintf( result_file,
"global color=red font=\"helvetica 4 normal\"select=1 highlite=1 edit=1 move=1 delete=1 include=1 fixed=0 source=1\n");
294 fprintf( result_file,
"wcs\n");
296 for( i=0; i< result_size; i++){
299 wave = wave_result_data[i];
300 slit = slit_result_data[i];
302 fprintf( result_file,
"point(%f,%f)\n #point=cross color=yellow font=\"helvetica 4 normal\"\n", wave, slit);
305 fclose( result_file);
307 xsh_msg(
"Produce ds9 region file LOCALIZE_IFU.reg");
309 if (cpl_error_get_code() != CPL_ERROR_NONE) {
int main()
Unit test of xsh_bspline_interpol.
static void HandleOptions(int argc, char **argv, int *smooth_hsize, int *nscales, int *HF_skip, double *sigma_low, double *sigma_up, double *snr_low, double *snr_up, int *box_hsize, double *slitmin, double *slitmax, int *deg, char **skymask_name)
static struct option long_options[]
static xsh_instrument * instrument
#define xsh_error_dump(level)
void xsh_instrument_free(xsh_instrument **instrument)
free an instrument structure
cpl_frame * xsh_localize_ifu_slitlet(cpl_frame *merge2d_slitlet, cpl_frame *skymask_frame, int smooth_hsize, int nscales, int HF_skip, const char *resname, double cut_sigma_low, double cut_sigma_up, double cut_snr_low, double cut_snr_up, double slit_min, double slit_max, int deg, int box_hsize, xsh_instrument *instr)
Localize center of object on a merge 2D IFU slitlet.
#define xsh_msg(...)
Print a message on info level.
XSH_ARM xsh_pfits_get_arm(const cpl_propertylist *plist)
void xsh_free_frame(cpl_frame **f)
Deallocate a frame and set the pointer to NULL.
int xsh_debug_level_set(int level)
set debug level
void xsh_free_propertylist(cpl_propertylist **p)
Deallocate a property list and set the pointer to NULL.
#define TESTS_XSH_INSTRUMENT_CREATE(instr, mode, arm, lamp, recipe)
#define TESTS_XSH_FRAME_CREATE(frame, tag, name)
#define TESTS_INIT(DRL_ID)
#define XSH_GET_TAG_FROM_ARM(TAG, instr)
#define XSH_SKY_LINE_LIST
#define XSH_OBJPOS_COLNAME_SLIT
#define XSH_OBJPOS_COLNAME_WAVELENGTH
#define XSH_TABLE_LOAD(TABLE, NAME)
#define XSH_TABLE_FREE(TABLE)