37#include <casu_utils.h>
40#include "vircam_utils.h"
41#include "vircam_dfs.h"
42#include "vircam_mods.h"
46static int vircam_matchstds_create(cpl_plugin *);
47static int vircam_matchstds_exec(cpl_plugin *);
48static int vircam_matchstds_destroy(cpl_plugin *);
49static int vircam_matchstds_test(cpl_parameterlist *, cpl_frameset *);
50static int vircam_matchstds_save(cpl_frameset *framelist,
51 cpl_parameterlist *parlist);
52static void vircam_matchstds_init(
void);
53static void vircam_matchstds_tidy(
void);
61} vircam_matchstds_config;
74static cpl_frame *product_frame = NULL;
76static char vircam_matchstds_description[] =
77"vircam_matchstds -- VIRCAM recipe to test vircam_matchstds.\n\n"
78"Match a catalogue with a table of standards\n\n"
79"The program accepts the following files in the SOF:\n\n"
81" -----------------------------------------------------------------------\n"
82" %-21s An input catalogue of objects extracted from an image\n"
83" %-21s An input catalogue of standard stars\n"
140int cpl_plugin_get_info(cpl_pluginlist *list) {
141 cpl_recipe *recipe = cpl_calloc(1,
sizeof(*recipe));
142 cpl_plugin *plugin = &recipe->interface;
143 char alldesc[SZ_ALLDESC];
144 (void)snprintf(alldesc,SZ_ALLDESC,vircam_matchstds_description,
145 VIRCAM_CAL_OBJCAT,VIRCAM_CAL_STDTAB);
147 cpl_plugin_init(plugin,
149 VIRCAM_BINARY_VERSION,
150 CPL_PLUGIN_TYPE_RECIPE,
152 "VIRCAM catalogue and standards matching test recipe [test]",
157 vircam_matchstds_create,
158 vircam_matchstds_exec,
159 vircam_matchstds_destroy);
161 cpl_pluginlist_append(list,plugin);
177static int vircam_matchstds_create(cpl_plugin *plugin) {
183 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
184 recipe = (cpl_recipe *)plugin;
190 recipe->parameters = cpl_parameterlist_new();
194 p = cpl_parameter_new_range(
"vircam.vircam_matchstds.extenum",
196 "Extension number to be done, 0 == all",
197 "vircam.vircam_matchstds",1,0,16);
198 cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,
"ext");
199 cpl_parameterlist_append(recipe->parameters,p);
214static int vircam_matchstds_exec(cpl_plugin *plugin) {
219 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
220 recipe = (cpl_recipe *)plugin;
224 return(vircam_matchstds_test(recipe->parameters,recipe->frames));
235static int vircam_matchstds_destroy(cpl_plugin *plugin) {
240 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
241 recipe = (cpl_recipe *)plugin;
245 cpl_parameterlist_delete(recipe->parameters);
258static int vircam_matchstds_test(cpl_parameterlist *parlist,
259 cpl_frameset *framelist) {
260 const char *fctid=
"vircam_matchstds";
262 int jst,jfn,status,j;
267 if (framelist == NULL || cpl_frameset_get_size(framelist) <= 0) {
268 cpl_msg_error(fctid,
"Input framelist NULL or has no input data");
274 vircam_matchstds_init();
278 p = cpl_parameterlist_find(parlist,
"vircam.vircam_matchstds.extenum");
279 vircam_matchstds_config.extenum = cpl_parameter_get_int(p);
284 cpl_msg_error(fctid,
"Cannot identify RAW and CALIB frames");
285 vircam_matchstds_tidy();
293 cpl_msg_error(fctid,
"Cannot labelise the input frames");
294 vircam_matchstds_tidy();
298 VIRCAM_CAL_OBJCAT)) == NULL) {
299 cpl_msg_info(fctid,
"No object catalogue found -- cannot continue");
300 vircam_matchstds_tidy();
304 VIRCAM_CAL_STDTAB)) == NULL) {
305 cpl_msg_info(fctid,
"No standards catalogue found -- cannot continue");
306 vircam_matchstds_tidy();
315 (
const cpl_frame *)ps.cat,&jst,&jfn);
316 if (jst == -1 || jfn == -1) {
317 cpl_msg_error(fctid,
"Unable to continue");
318 vircam_matchstds_tidy();
325 for (j = jst; j <= jfn; j++) {
326 isfirst = (j == jst);
332 if (ps.stdsf == NULL || ps.catf == NULL) {
335 cpl_msg_info(fctid,
"No matching possible");
341 cpl_msg_info(fctid,
"Doing the matching for extension %" CPL_SIZE_FORMAT,
345 &(ps.outtab),&status);
346 if (status != CASU_OK) {
347 cpl_msg_info(fctid,
"No matching done");
353 cpl_msg_info(fctid,
"Saving results for extension %" CPL_SIZE_FORMAT,
355 if (vircam_matchstds_save(framelist,parlist) != 0)
356 cpl_msg_info(fctid,
"No matching saved");
363 freetable(ps.outtab);
365 vircam_matchstds_tidy();
378static int vircam_matchstds_save(cpl_frameset *framelist,
379 cpl_parameterlist *parlist) {
380 const char *recipeid =
"vircam_matchstds";
381 const char *fctid =
"vircam_matchstds_save";
382 const char *outfile =
"matchstds.fits";
383 cpl_propertylist *plist,*elist;
391 product_frame = cpl_frame_new();
392 cpl_frame_set_filename(product_frame,outfile);
393 cpl_frame_set_tag(product_frame,VIRCAM_PRO_MSTDTAB);
394 cpl_frame_set_type(product_frame,CPL_FRAME_TYPE_TABLE);
395 cpl_frame_set_group(product_frame,CPL_FRAME_GROUP_PRODUCT);
396 cpl_frame_set_level(product_frame,CPL_FRAME_LEVEL_FINAL);
402 parlist,(
char *)recipeid,
403 "?Dictionary?",NULL,0);
409 parlist,(
char *)recipeid,
410 "?Dictionary?",NULL);
414 if (cpl_table_save(ps.outtab,plist,elist,outfile,CPL_IO_DEFAULT)
416 cpl_msg_error(fctid,
"Cannot save product table");
417 cpl_frame_delete(product_frame);
420 cpl_frameset_insert(framelist,product_frame);
430 parlist,(
char *)recipeid,
431 "?Dictionary?",NULL);
435 if (cpl_table_save(ps.outtab,NULL,elist,outfile,CPL_IO_EXTEND)
437 cpl_msg_error(fctid,
"Cannot save product table");
452static void vircam_matchstds_init(
void) {
468static void vircam_matchstds_tidy(
void) {
469 freespace(ps.labels);
474 freetable(ps.outtab);
int casu_matchstds(cpl_table *objtab, cpl_table *stdstab, float srad, cpl_table **outtab, int *status)
Match object and standard star tables by their xy coordinates.
cpl_propertylist * casu_tfits_get_ehu(casu_tfits *p)
casu_tfits * casu_tfits_load(cpl_frame *table, int nexten)
cpl_propertylist * casu_tfits_get_phu(casu_tfits *p)
cpl_table * casu_tfits_get_table(casu_tfits *p)
int casu_compare_tags(const cpl_frame *frame1, const cpl_frame *frame2)
Compare input tags.
cpl_frame * casu_frameset_subgroup_1(cpl_frameset *frameset, cpl_size *labels, cpl_size nlab, const char *tag)
Extract a frame of a given label from a frameset.
int vircam_dfs_set_groups(cpl_frameset *set)
void vircam_dfs_set_product_primary_header(cpl_propertylist *plist, cpl_frame *frame, cpl_frameset *frameset, cpl_parameterlist *parlist, char *recipeid, const char *dict, cpl_frame *inherit, int synch)
void vircam_dfs_set_product_exten_header(cpl_propertylist *plist, cpl_frame *frame, cpl_frameset *frameset, cpl_parameterlist *parlist, char *recipeid, const char *dict, cpl_frame *inherit)
const char * vircam_get_license(void)
void vircam_exten_range(int inexten, const cpl_frame *fr, int *out1, int *out2)