26#include "../hdrl_cat_classify.h"
27#include "../hdrl_cat_conf.h"
28#include "../hdrl_cat_table.h"
36 cpl_test_init(PACKAGE_BUGREPORT,CPL_MSG_WARNING);
39 double xpos[] = { 100., 200., 300., 400., 500., 600., 700., 800., 900., 1000.};
40 double ypos[] = { 100., 200., 300., 400., 500., 600., 700., 800., 900., 1000.};
41 double norm[] = {1000., 100., 200., 500., 550., 600., 650., 700., 750., 800.};
44 cpl_image *bkg = cpl_image_new(1024, 1024, CPL_TYPE_DOUBLE);
45 cpl_image *im = cpl_image_new(1024, 1024, CPL_TYPE_DOUBLE);
46 cpl_image *cnf = cpl_image_new(1024, 1024, CPL_TYPE_DOUBLE);
49 double norm2 = 2. * CPL_MATH_PI * sigma * sigma;
50 cpl_image_fill_noise_uniform(bkg, -10., 10.);
53 cpl_image_add_scalar(bkg, sky);
55 cpl_image_fill_noise_uniform(cnf, 99.9, 100.1);
58 for (cpl_size i = 0; i < NTEST; i++) {
59 cpl_image_fill_gaussian(im, xpos[i], ypos[i], norm[i] * norm2, sigma, sigma);
60 tot[i] = cpl_image_get_flux(im);
61 cpl_image_add(bkg, im);
70 cpl_propertylist_update_string(pl,
"CTYPE1",
"RA---TAN" );
71 cpl_propertylist_update_string(pl,
"CTYPE2",
"DEC--TAN" );
72 cpl_propertylist_update_double(pl,
"CRVAL1", 30. );
73 cpl_propertylist_update_double(pl,
"CRVAL2", 12. );
74 cpl_propertylist_update_double(pl,
"CRPIX1", 512. );
75 cpl_propertylist_update_double(pl,
"CRPIX2", 512. );
76 cpl_propertylist_update_double(pl,
"CD1_1", -1. / 3600.);
77 cpl_propertylist_update_double(pl,
"CD1_2", 0. );
78 cpl_propertylist_update_double(pl,
"CD2_1", 0. );
79 cpl_propertylist_update_double(pl,
"CD2_2", 1. / 3600.);
82 hdrl_casu_result *res = cpl_calloc(1,
sizeof(hdrl_casu_result));
83 cpl_test_eq(
hdrl_catalogue_conf(inf, inconf, 5, 1.5, 0, 5., 1, 64, 6, 3., 1.,
84 HDRL_SATURATION_INIT, res), CPL_ERROR_NONE);
85 cpl_test_nonnull(res->catalogue);
86 cpl_image_delete(res->segmentation_map);
87 cpl_image_delete(res->background);
91 cpl_test_nonnull(tab);
92 cpl_test_eq(cpl_table_get_ncol(tab), NCOLS);
93 cpl_test_eq(cpl_table_get_nrow(tab), NTEST);
95 pl = cpl_propertylist_new();
96 cpl_propertylist_append_bool(pl,
"X_coordinate", 0);
97 cpl_table_sort(tab, pl);
98 cpl_propertylist_delete(pl);
102 for (cpl_size i = 0; i < NTEST; i++) {
104 cpl_test_abs(xpos[i], cpl_table_get_double(tab,
"X_coordinate", i, &nl), 0.2);
105 cpl_test_abs(ypos[i], cpl_table_get_double(tab,
"Y_coordinate", i, &nl), 0.2);
107 double diff = fabs(cpl_table_get_double(tab,
"Aper_flux_5", i, &nl) - tot[i])
108 / cpl_table_get_double(tab,
"Aper_flux_5_err", i, &nl);
109 cpl_test_lt(diff, 1.6);
115 cpl_test_eq(
hdrl_classify(res->catalogue, 5), CPL_ERROR_NONE);
118 cpl_test_rel(cpl_propertylist_get_double(pl,
"ESO QC IMAGE_SIZE"), 4.47, 0.02);
119 cpl_test_eq( cpl_propertylist_get_bool( pl,
"ESO DRS CLASSIFD" ), 1 );
120 cpl_test_rel(cpl_propertylist_get_double(pl,
"APCOR3" ), 0.132, 0.01);
122 for (cpl_size i = 0; i < NTEST; i++) {
124 cpl_test_rel(val, -1., 0.001);
128 cpl_test_eq(
hdrl_classify(res->catalogue, 10), CPL_ERROR_NONE);
137 return cpl_test_end(0);
cpl_error_code hdrl_catalogue_conf(hdrl_casu_fits *infile, hdrl_casu_fits *conf, cpl_size ipix, double threshold, cpl_size icrowd, double rcore, cpl_size bkg_subtr, cpl_size nbsize, cpl_size cattype, double filtfwhm, double gain, double saturation, hdrl_casu_result *res)
Do source extraction.
hdrl_casu_fits * hdrl_casu_fits_wrap(cpl_image *im)
Wrap an image in a hdrl_casu_fits wrapper.
cpl_propertylist * hdrl_casu_tfits_get_ehu(hdrl_casu_tfits *p)
Get the propertylist for the extension header for a given hdrl_casu_tfits image.
void hdrl_casu_tfits_delete(hdrl_casu_tfits *p)
Free all the workspace associated with a hdrl_casu_fits object.
void hdrl_casu_fits_delete(hdrl_casu_fits *p)
Free all the workspace associated with a hdrl_casu_fits object.
cpl_table * hdrl_casu_tfits_get_table(hdrl_casu_tfits *p)
Get the CPL table from the hdrl_casu_tfits object.
cpl_propertylist * hdrl_casu_fits_get_ehu(hdrl_casu_fits *p)
Get the propertylist for the extension header for a given hdrl_casu_fits image.
cpl_error_code hdrl_classify(hdrl_casu_tfits *catalogue, double minsize)
Do star/galaxy classification.