22#include "../hdrl_cat_casu.h"
23#include "../hdrl_cat_table.h"
32 cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING);
34 double xpos[] = { 100., 200., 300., 400., 500., 600., 700., 800., 900., 1000.};
35 double ypos[] = { 100., 200., 300., 400., 500., 600., 700., 800., 900., 1000.};
36 double norm[] = {1000., 100., 200., 500., 550., 600., 650., 700., 750., 800.};
39 hdrl_casu_result *res = cpl_calloc(1,
sizeof(hdrl_casu_result));
40 cpl_test_eq(
hdrl_casu_catalogue(NULL, NULL, NULL, 5, 1.5, 1, 3.5, 1, 64, 6, 1., 2.,
41 HDRL_SATURATION_INIT, res), CPL_ERROR_NULL_INPUT);
42 cpl_test_error(CPL_ERROR_NULL_INPUT);
43 cpl_test_null( res->catalogue);
44 cpl_image_delete( res->segmentation_map);
45 cpl_image_delete( res->background);
50 cpl_table *test_table = NULL;
51 cpl_propertylist *test_ehu = NULL;
53 cpl_test_null(test_tinf);
54 test_table = cpl_table_new(10);
56 cpl_test_nonnull(test_tinf);
58 test_table = cpl_table_new(10);
59 test_ehu = cpl_propertylist_new();
61 cpl_test_nonnull(test_tinf);
66 cpl_image *bkg = cpl_image_new(1024, 1024, CPL_TYPE_DOUBLE);
67 cpl_image *im = cpl_image_new(1024, 1024, CPL_TYPE_DOUBLE);
68 cpl_image *cnf = cpl_image_new(1024, 1024, CPL_TYPE_DOUBLE);
71 double norm2 = 2. * CPL_MATH_PI * sigma * sigma;
72 cpl_image_fill_noise_uniform(bkg, -10., 10.);
75 cpl_image_add_scalar(bkg, sky);
77 cpl_image_fill_noise_uniform(cnf, 99.9, 100.1);
80 for (cpl_size i = 0; i < NTEST; i++) {
81 cpl_image_fill_gaussian(im, xpos[i], ypos[i], norm[i] * norm2, sigma, sigma);
82 tot[i] = cpl_image_get_flux(im);
83 cpl_image_add(bkg, im);
92 cpl_propertylist_update_string(pl,
"CTYPE1",
"RA---TAN" );
93 cpl_propertylist_update_string(pl,
"CTYPE2",
"DEC--TAN" );
94 cpl_propertylist_update_double(pl,
"CRVAL1", 30. );
95 cpl_propertylist_update_double(pl,
"CRVAL2", 12. );
96 cpl_propertylist_update_double(pl,
"CRPIX1", 512. );
97 cpl_propertylist_update_double(pl,
"CRPIX2", 512. );
98 cpl_propertylist_update_double(pl,
"CD1_1", -1. / 3600.);
99 cpl_propertylist_update_double(pl,
"CD1_2", 0. );
100 cpl_propertylist_update_double(pl,
"CD2_1", 0. );
101 cpl_propertylist_update_double(pl,
"CD2_2", 1. / 3600.);
102 cpl_propertylist_update_int( pl,
"NAXIS1", 1024 );
103 cpl_propertylist_update_int( pl,
"NAXIS2", 1024 );
104 cpl_wcs *wcs = cpl_wcs_new_from_propertylist(pl);
107 res = cpl_calloc(1,
sizeof(*res));
108 cpl_test_eq(
hdrl_casu_catalogue(inf, inconf, wcs, 5, 1.5, 0, 5., 1, 64, 6, 3., 1.,
109 HDRL_SATURATION_INIT, res), CPL_ERROR_NONE);
110 cpl_test_nonnull(res->catalogue);
115 cpl_image_delete(res->segmentation_map);
116 cpl_image_delete(res->background);
120 cpl_test_nonnull(tab);
121 cpl_test_eq(cpl_table_get_ncol(tab), NCOLS);
122 cpl_test_eq(cpl_table_get_nrow(tab), NTEST);
124 pl = cpl_propertylist_new();
125 cpl_propertylist_append_bool(pl,
"X_coordinate", 0);
126 cpl_table_sort(tab, pl);
127 cpl_propertylist_delete(pl);
131 for (cpl_size i = 0; i < NTEST; i++) {
133 cpl_test_abs(xpos[i], cpl_table_get_double(tab,
"X_coordinate", i, &nl), 0.2);
134 cpl_test_abs(ypos[i], cpl_table_get_double(tab,
"Y_coordinate", i, &nl), 0.2);
136 double diff = fabs( cpl_table_get_double(tab,
"Aper_flux_5", i, &nl) - tot[i])
137 / cpl_table_get_double(tab,
"Aper_flux_5_err", i, &nl);
138 cpl_test_lt(diff, 1.6);
139 cpl_test_eq( cpl_table_get_double(tab,
"Classification", i, &nl), -1.);
144 cpl_test_rel( cpl_propertylist_get_double(pl,
"ESO QC IMAGE_SIZE") / 2.355, sigma, 0.1);
150 return cpl_test_end(0);
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.
hdrl_casu_tfits * hdrl_casu_tfits_wrap(cpl_table *tab, cpl_propertylist *ehu)
Wrap an table in a hdrl_casu_tfits wrapper.
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_casu_catalogue(hdrl_casu_fits *infile, hdrl_casu_fits *conf, const cpl_wcs *wcs, cpl_size ipix, double threshold, cpl_size icrowd, double rcore, cpl_size bkg_subtr, cpl_size nbsize, hdrl_catalogue_options cattype, double filtfwhm, double gainloc, double saturation, hdrl_casu_result *res)
Generate object catalogues from input images.