36 #include "crires_recipe.h"
42 #define RECIPE_STRING "crires_util_genypos"
48 static int crires_util_genypos_save(cpl_table *,
const cpl_parameterlist *,
51 static char crires_util_genypos_description[] =
52 "This recipe is used to generate the FITS table with the Y positions.\n"
53 "The sof file contains the names of the input ASCII file\n"
54 "tagged with "CRIRES_UTIL_GENYPOS_RAW
".\n"
55 "The ASCII file must contain two columns:\n"
58 "The ASCII file is in the catalogs/ directory of the CRIRES distribution.\n"
59 "This recipe produces 1 file:\n"
60 "First product: the table with the positions.\n"
61 " (PRO TYPE = "CRIRES_PROTYPE_YPOS
")\n" ;
63 CRIRES_RECIPE_DEFINE(crires_util_genypos, 0,
64 "Generate Y Positions FITS table",
65 crires_util_genypos_description) ;
85 static int crires_util_genypos(
86 cpl_frameset * framelist,
87 const cpl_parameterlist * parlist)
89 cpl_bivector * bivec ;
92 cpl_bivector * bivec_fill ;
93 double * pbivec_fill_x ;
94 double * pbivec_fill_y ;
95 cpl_frame * cur_frame ;
96 int nvals, nb_new_vals ;
102 if (crires_dfs_set_groups(framelist, NULL)) {
103 cpl_msg_error(__func__,
"Cannot identify RAW and CALIB frames") ;
108 cur_frame = cpl_frameset_get_position(framelist, 0) ;
109 if ((bivec=cpl_bivector_read(cpl_frame_get_filename(cur_frame)))==NULL) {
110 cpl_msg_error(__func__,
"Cannot load the file in the bivector") ;
113 nvals = cpl_bivector_get_size(bivec) ;
116 tab = cpl_table_new(nvals) ;
117 cpl_table_wrap_double(tab, cpl_bivector_get_x_data(bivec),
119 cpl_table_wrap_double(tab, cpl_bivector_get_y_data(bivec),
120 CRIRES_COL_DETPOSY) ;
123 cpl_msg_info(__func__,
"Saving the table with %d rows", nvals) ;
124 if (crires_util_genypos_save(tab, parlist, framelist) == -1) {
125 cpl_msg_error(__func__,
"Cannot write the table") ;
126 cpl_bivector_delete(bivec) ;
127 cpl_table_unwrap(tab, CRIRES_CHIP_NB) ;
128 cpl_table_unwrap(tab, CRIRES_COL_DETPOSY) ;
129 cpl_table_delete(tab) ;
132 cpl_bivector_delete(bivec) ;
133 cpl_table_unwrap(tab, CRIRES_CHIP_NB) ;
134 cpl_table_unwrap(tab, CRIRES_COL_DETPOSY) ;
135 cpl_table_delete(tab) ;
148 static int crires_util_genypos_save(
149 cpl_table * out_table,
150 const cpl_parameterlist * parlist,
153 cpl_propertylist * plist ;
155 plist = cpl_propertylist_new();
156 cpl_propertylist_append_string(plist,
"INSTRUME",
"CRIRES") ;
157 cpl_propertylist_append_string(plist, CPL_DFS_PRO_CATG,
158 CRIRES_CALPRO_THAR_POS) ;
159 cpl_propertylist_append_string(plist, CPL_DFS_PRO_TYPE,
160 CRIRES_PROTYPE_YPOS) ;
162 if (cpl_dfs_save_table(set, NULL, parlist, set, NULL, out_table,
163 NULL,
"crires_util_genypos", plist, NULL,
164 PACKAGE
"/" PACKAGE_VERSION,
165 "crires_util_genypos.fits") != CPL_ERROR_NONE) {
166 cpl_msg_error(__func__,
"Cannot save the table") ;
169 cpl_propertylist_delete(plist) ;