32 #include <fors_identify.h>
33 #include <fors_setting.h>
34 #include <fors_data.h>
36 #include <fors_utils.h>
37 #include <fors_instrument.h>
38 #include <fors_std_cat.h>
40 #include <test_simulate.h>
53 cpl_frame_delete(raw_frame); \
54 cpl_frameset_delete(cat_frames); \
55 cpl_frame_delete(phot_table); \
56 fors_setting_delete(&setting); \
57 cpl_parameterlist_delete(parameters); \
58 fors_identify_method_delete(&im); \
59 fors_std_star_list_delete(&cat, fors_std_star_delete); \
60 fors_std_star_list_delete(&cat, fors_std_star_delete); \
61 fors_star_list_delete(&stars, fors_star_delete); \
62 fors_star_list_delete(&stars_id, fors_star_delete); \
63 cpl_propertylist_delete(raw_header); raw_header = NULL; \
72 identify_method *im = NULL;
73 cpl_parameterlist *parameters = cpl_parameterlist_new();
74 const char *
const context =
"test";
75 fors_star_list *stars = NULL;
76 fors_star_list *stars_id = NULL;
77 fors_std_star_list *cat = NULL;
79 cpl_frame *raw_frame = NULL;
80 cpl_frame *phot_table = NULL;
81 cpl_propertylist *raw_header = NULL;
82 double color_term, dcolor_term;
83 double ext_coeff, dext_coeff;
87 cpl_frameset *cat_frames = cpl_frameset_new();
88 cpl_frameset_insert(cat_frames,
create_std_cat(
"identify_std_cat.fits",
90 CPL_FRAME_GROUP_CALIB));
96 assure( !cpl_error_get_code(),
return,
97 "Could not get identification parameters");
100 STANDARD_IMG, CPL_FRAME_GROUP_RAW);
103 PHOT_TABLE, CPL_FRAME_GROUP_CALIB);
107 fors_phot_table_load(phot_table, setting,
108 &color_term, &dcolor_term,
109 &ext_coeff, &dext_coeff,
113 band = fors_instrument_filterband_get_by_setting(setting);
114 cat = fors_std_cat_load(cat_frames, band, 0, color_term, dcolor_term);
115 assure( !cpl_error_get_code(),
return, NULL );
117 raw_header = cpl_propertylist_load(cpl_frame_get_filename(raw_frame), 0);
118 assure( !cpl_error_get_code(),
return, NULL );
119 fors_std_star_list_apply_wcs(cat, raw_header);
120 assure( !cpl_error_get_code(),
return, NULL );
122 stars = fors_star_list_new();
123 stars_id = fors_star_list_new();
132 double offsety = -100;
133 double semi_major = 1.0;
134 double semi_minor = 1.0;
136 double orientation = 0;
137 double stellarity = 1.0;
139 for (s = fors_std_star_list_first(cat);
141 s = fors_std_star_list_next(cat)) {
157 double temp = source->pixel->x;
158 source->pixel->x = source->pixel->y;
159 source->pixel->y = -temp;
166 fors_star_list_insert(stars, source);
170 source_id->id = fors_std_star_duplicate(s);
171 fors_star_list_insert(stars_id, source_id);
188 for (star = fors_star_list_first(stars);
190 star = fors_star_list_next(stars))
192 if (star->id != NULL) {
197 fors_star_list *input =
202 test_eq( fors_star_list_size(input), 1 );
204 fors_star *input1 = fors_star_list_first(input);
206 test( fors_std_star_equal(star->id, input1->id) );
234 for (star = fors_star_list_first(stars);
236 star = fors_star_list_next(stars)) {
238 double temp = star->pixel->x;
239 star->pixel->x = star->pixel->y;
240 star->pixel->y = temp;
243 if (star->id != NULL) {
244 fors_std_star_delete_const(&(star->id));
251 cpl_msg_severity before = cpl_msg_get_level();
252 cpl_msg_set_level(CPL_MSG_ERROR);
256 cpl_msg_set_level(before);
262 for (star = fors_star_list_first(stars);
264 star = fors_star_list_next(stars)) {
266 test( star->id == NULL );
double fors_rand_gauss(void)
Pseudo-random gaussian distributed number.
fors_setting * fors_setting_new(const cpl_frame *raw)
Create setting from FITS header.
static void test_identify(void)
Test identification.
identify_method * fors_identify_method_new(const cpl_parameterlist *parameters, const char *context)
Get id method from parameter list.
bool fors_star_equal(const fors_star *s, const fors_star *t)
Test for equality.
void fors_star_delete(fors_star **star)
Delete object and set pointer to NULL.
cpl_frame * create_std_cat(const char *filename, const char *tag, cpl_frame_group group)
Create standard star catalogue.
fors_star * fors_star_new(double x, double y, double fwhm, double smajor, double sminor, double orientation, double m, double dm, double si)
Constructor.
int main(void)
Test of identification module.
fors_star * fors_star_duplicate(const fors_star *star)
Copy constructor.
cpl_frame * create_phot_table(const char *filename, const char *tag, cpl_frame_group group)
Create photometry table.
void fors_parameterlist_set_defaults(cpl_parameterlist *parlist)
Set unset parameters to default value.
void fors_identify(fors_star_list *stars, fors_std_star_list *cat, const identify_method *im, cpl_image **histogram)
Identify sources.
cpl_frame * create_standard(const char *filename, const char *tag, cpl_frame_group group)
Create standard star image.
void fors_identify_define_parameters(cpl_parameterlist *parameters, const char *context)
Define recipe parameters.