22#include "../hdrl_cat_classify.h"
23#include "../hdrl_cat_conf.h"
24#include "../hdrl_cat_table.h"
32 cpl_test_init(PACKAGE_BUGREPORT,CPL_MSG_WARNING);
35 double xpos[] = { 100., 200., 300., 400., 500., 600., 700., 800., 900., 1000.};
36 double ypos[] = { 100., 200., 300., 400., 500., 600., 700., 800., 900., 1000.};
37 double norm[] = {1000., 100., 200., 500., 550., 600., 650., 700., 750., 800.};
40 cpl_image *bkg = cpl_image_new(1024, 1024, CPL_TYPE_DOUBLE);
41 cpl_image *im = cpl_image_new(1024, 1024, CPL_TYPE_DOUBLE);
42 cpl_image *cnf = cpl_image_new(1024, 1024, CPL_TYPE_DOUBLE);
45 double norm2 = 2. * CPL_MATH_PI * sigma * sigma;
46 cpl_image_fill_noise_uniform(bkg, -10., 10.);
49 cpl_image_add_scalar(bkg, sky);
51 cpl_image_fill_noise_uniform(cnf, 99.9, 100.1);
54 for (cpl_size i = 0; i < NTEST; i++) {
55 cpl_image_fill_gaussian(im, xpos[i], ypos[i], norm[i] * norm2, sigma, sigma);
56 tot[i] = cpl_image_get_flux(im);
57 cpl_image_add(bkg, im);
66 cpl_propertylist_update_string(pl,
"CTYPE1",
"RA---TAN" );
67 cpl_propertylist_update_string(pl,
"CTYPE2",
"DEC--TAN" );
68 cpl_propertylist_update_double(pl,
"CRVAL1", 30. );
69 cpl_propertylist_update_double(pl,
"CRVAL2", 12. );
70 cpl_propertylist_update_double(pl,
"CRPIX1", 512. );
71 cpl_propertylist_update_double(pl,
"CRPIX2", 512. );
72 cpl_propertylist_update_double(pl,
"CD1_1", -1. / 3600.);
73 cpl_propertylist_update_double(pl,
"CD1_2", 0. );
74 cpl_propertylist_update_double(pl,
"CD2_1", 0. );
75 cpl_propertylist_update_double(pl,
"CD2_2", 1. / 3600.);
78 hdrl_casu_result *res = cpl_calloc(1,
sizeof(hdrl_casu_result));
79 cpl_test_eq(
hdrl_catalogue_conf(inf, inconf, 5, 1.5, 0, 5., 1, 64, 6, 3., 1.,
80 HDRL_SATURATION_INIT, res), CPL_ERROR_NONE);
81 cpl_test_nonnull(res->catalogue);
82 cpl_image_delete(res->segmentation_map);
83 cpl_image_delete(res->background);
87 cpl_test_nonnull(tab);
88 cpl_test_eq(cpl_table_get_ncol(tab), NCOLS);
89 cpl_test_eq(cpl_table_get_nrow(tab), NTEST);
91 pl = cpl_propertylist_new();
92 cpl_propertylist_append_bool(pl,
"X_coordinate", 0);
93 cpl_table_sort(tab, pl);
94 cpl_propertylist_delete(pl);
98 for (cpl_size i = 0; i < NTEST; i++) {
100 cpl_test_abs(xpos[i], cpl_table_get_double(tab,
"X_coordinate", i, &nl), 0.2);
101 cpl_test_abs(ypos[i], cpl_table_get_double(tab,
"Y_coordinate", i, &nl), 0.2);
103 double diff = fabs(cpl_table_get_double(tab,
"Aper_flux_5", i, &nl) - tot[i])
104 / cpl_table_get_double(tab,
"Aper_flux_5_err", i, &nl);
105 cpl_test_lt(diff, 1.6);
111 cpl_test_eq(
hdrl_classify(res->catalogue, 5), CPL_ERROR_NONE);
114 cpl_test_rel(cpl_propertylist_get_double(pl,
"ESO QC IMAGE_SIZE"), 4.47, 0.02);
115 cpl_test_eq( cpl_propertylist_get_bool( pl,
"ESO DRS CLASSIFD" ), 1 );
116 cpl_test_rel(cpl_propertylist_get_double(pl,
"APCOR3" ), 0.132, 0.01);
118 for (cpl_size i = 0; i < NTEST; i++) {
120 cpl_test_rel(val, -1., 0.001);
124 cpl_test_eq(
hdrl_classify(res->catalogue, 10), CPL_ERROR_NONE);
133 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.