32#include <hdrl_utils.h>
33#include <hdrl_resample.h>
34#include <hdrl_resample.c>
35#include <hdrl_random.h>
37#define omp_get_max_threads() 1
55#define RECIPE_NAME "hdrldemo_resample"
58#define HDRL_DELTA_COMPARE_VALUE_ABS CPL_MAX(HDRL_EPS_DATA, HDRL_EPS_ERROR) * 4.
60#define HDRL_EPS_TEST HDRL_EPS_DATA
62#define DRIZZLE_DOWN_SCALING_FACTOR_X 0.8
63#define DRIZZLE_DOWN_SCALING_FACTOR_Y 0.8
64#define DRIZZLE_DOWN_SCALING_FACTOR_Z 0.8
65#define RENKA_CRITICAL_RADIUS 1.25
66#define LANCZOS_KERNEL_SIZE 2
67#define LOOP_DISTANCE 1.0
69#define HDRL_FLUX_ADU 100
72#define HDRL_SCALE_Z 500
73#define HDRL_CD11 -3.47222e-05
76#define HDRL_CD22 3.47222e-05
81#define HDRL_CD33 2.45e-10*HDRL_SCALE_Z
83#define HDRL_CDELT1 fabs(HDRL_CD11)
84#define HDRL_CDELT2 fabs(HDRL_CD22)
85#define HDRL_CDELT3 fabs(HDRL_CD33)
87#define HDRL_CRPIX1 33.5
88#define HDRL_CRPIX2 33.5
91#define HDRL_CRVAL1 48.0706
92#define HDRL_CRVAL2 -20.6219
93#define HDRL_CRVAL3 1.9283e-06
96#define HDRL_DEC -20.621
97#define HDRL_RA_MIN 48.069416667
98#define HDRL_RA_MAX 48.0718125
99#define HDRL_DEC_MIN -20.6229925
100#define HDRL_DEC_MAX -20.620708611
102#define HDRL_LAMBDA_MIN 1.9283e-06
103#define HDRL_LAMBDA_MAX 2.47146e-06
106#define HDRL_SIZE_X 50
107#define HDRL_SIZE_Y 50
118hdrl_resample_util_hdrl_image_create(cpl_image* data, cpl_image* error,
121 cpl_mask* mask = cpl_mask_threshold_image_create(bpm, 0, INT_MAX);
122 cpl_image_reject_from_mask(data, mask);
123 cpl_mask_delete(mask);
136static cpl_error_code test_hdrl_resample_compute2D_multiple(
void)
141 cpl_image * img_data = cpl_image_new(9, 9, CPL_TYPE_DOUBLE);
142 cpl_image * img_bpm = cpl_image_new(9, 9, CPL_TYPE_INT);
145 cpl_image_add_scalar(img_bpm, 1.);
148 cpl_image_set(img_data, 4, 4, 48.);
149 cpl_image_set(img_data, 5, 4, 48.);
150 cpl_image_set(img_data, 6, 4, 48.);
151 cpl_image_set(img_data, 4, 5, 48.);
152 cpl_image_set(img_data, 5, 5, 48.);
153 cpl_image_set(img_data, 6, 5, 48.);
154 cpl_image_set(img_data, 4, 6, 48.);
155 cpl_image_set(img_data, 5, 6, 48.);
156 cpl_image_set(img_data, 6, 6, 48.);
158 cpl_image_add_scalar(img_data, 1.0);
159 cpl_image * img_error=cpl_image_power_create(img_data, 0.5);
162 cpl_image_set(img_bpm, 4, 4, 0);
163 cpl_image_set(img_bpm, 5, 4, 0);
164 cpl_image_set(img_bpm, 6, 4, 0);
165 cpl_image_set(img_bpm, 4, 5, 0);
166 cpl_image_set(img_bpm, 5, 5, 0);
167 cpl_image_set(img_bpm, 6, 5, 0);
168 cpl_image_set(img_bpm, 4, 6, 0);
169 cpl_image_set(img_bpm, 5, 6, 0);
170 cpl_image_set(img_bpm, 6, 6, 0);
173 cpl_propertylist* plist = cpl_propertylist_new();
175 cpl_propertylist_append_int(plist,
"NAXIS" , 2);
176 cpl_propertylist_append_int(plist,
"NAXIS1" , 9);
177 cpl_propertylist_append_int(plist,
"NAXIS2" , 9);
178 cpl_propertylist_append_double(plist,
"CD1_1" , -0.01 );
179 cpl_propertylist_append_double(plist,
"CD1_2" , 0. );
180 cpl_propertylist_append_double(plist,
"CD2_1" , 0. );
181 cpl_propertylist_append_double(plist,
"CD2_2" , 0.01 );
182 cpl_propertylist_append_double(plist,
"CRPIX1" , 4.5 );
183 cpl_propertylist_append_double(plist,
"CRPIX2" , 4.5 );
184 cpl_propertylist_append_double(plist,
"CRVAL1" , 359.8 );
185 cpl_propertylist_append_double(plist,
"CRVAL2" , 10.0 );
186 cpl_propertylist_append_string(plist,
"CTYPE1" ,
"RA---TAN");
187 cpl_propertylist_append_string(plist,
"CTYPE2" ,
"DEC--TAN");
188 cpl_propertylist_append_string(plist,
"CUNIT1" ,
"deg" );
189 cpl_propertylist_append_string(plist,
"CUNIT2" ,
"deg" );
191 hdrl_random_state * rastate = hdrl_random_state_new(1, NULL);
192 hdrl_random_state * decstate = hdrl_random_state_new(1, NULL);
199 hima = hdrl_resample_util_hdrl_image_create(img_data, img_error, img_bpm);
200 const cpl_size iterations = 500;
201 for (cpl_size i = 0; i < iterations; i++) {
202 double rarandom = hdrl_random_uniform_double(rastate, 0., 360.);
203 double decrandom = hdrl_random_uniform_double(decstate, -89., 89.);
204 cpl_msg_info(cpl_func,
"ra-random: %g, dec-random: %g ", rarandom,
206 cpl_propertylist_update_double(plist,
"CRVAL1" , rarandom);
207 cpl_propertylist_update_double(plist,
"CRVAL2" , decrandom);
208 cpl_wcs * wcs = cpl_wcs_new_from_propertylist(plist);
213 hdrl_parameter *aParams_outputgrid = NULL;
217 hdrl_resample_result *result = NULL;
218 hdrl_parameter *aParams_method = NULL;
227 cpl_test_error(CPL_ERROR_NONE);
229 5, 5, &rej), 49., 1e-6);
231 5, 5, &rej), 7., 0.05);
247 cpl_test_error(CPL_ERROR_NONE);
249 5, 5, &rej), 49., 1e-6);
251 5, 5, &rej), 7., 0.001);
267 cpl_test_error(CPL_ERROR_NONE);
269 5, 5, &rej), 49., 1e-6);
271 5, 5, &rej), 7., 0.3);
287 cpl_test_error(CPL_ERROR_NONE);
289 5, 5, &rej), 49., 1e-6);
291 5, 5, &rej), 7., 0.02);
308 cpl_test_error(CPL_ERROR_NONE);
310 5, 5, &rej), 49., 1e-6);
312 5, 5, &rej), 7., 0.01);
327 cpl_test_error(CPL_ERROR_NONE);
329 5, 5, &rej), 49., 1e-6);
331 5, 5, &rej), 7., 0.00001);
343 cpl_table_delete(table);
351 cpl_propertylist_update_double(plist,
"CRVAL1" , 0.01);
352 cpl_propertylist_update_double(plist,
"CRVAL2" , 20.1);
355 cpl_propertylist_update_double(plist,
"CD1_1" , cos(45) );
356 cpl_propertylist_update_double(plist,
"CD1_2" , -sin(45) );
357 cpl_propertylist_update_double(plist,
"CD2_1" , sin(45) );
358 cpl_propertylist_update_double(plist,
"CD2_2" , cos(45) );
361 cpl_wcs * wcs = cpl_wcs_new_from_propertylist(plist);
364 hima = hdrl_resample_util_hdrl_image_create(img_data, img_error, img_bpm);
369 hdrl_parameter *aParams_outputgrid = NULL;
374 hdrl_resample_result *result = NULL;
376 hdrl_parameter *aParams_method = NULL;
383 cpl_test_error(CPL_ERROR_NONE);
385 5, 5, &rej), 49., 1e-6);
387 5, 5, &rej), 7., 0.3);
394 cpl_image_save(img_data,
"image_orig.fits", CPL_TYPE_FLOAT, plist,
397 cpl_image_save(img_error,
"image_orig.fits", CPL_TYPE_FLOAT, plist,
400 cpl_image_save(img_bpm,
"image_orig.fits", CPL_TYPE_INT, plist,
404 CPL_TYPE_FLOAT, result->header, CPL_IO_CREATE);
406 CPL_TYPE_FLOAT, result->header, CPL_IO_EXTEND);
408 result->header, CPL_IO_EXTEND);
411 hdrl_resample_wcs_print(wcs);
414 wcs = cpl_wcs_new_from_propertylist(result->header);
415 hdrl_resample_wcs_print(wcs);
420 cpl_table_delete(table);
426 cpl_propertylist_delete(plist);
427 cpl_image_delete(img_data);
428 cpl_image_delete(img_error);
429 cpl_image_delete(img_bpm);
430 hdrl_random_state_delete(rastate);
431 hdrl_random_state_delete(decstate);
433 cpl_test_error(CPL_ERROR_NONE);
434 return cpl_error_get_code();
437static hdrl_imagelist*
438hdrl_resample_util_hdrl_imagelist_create(cpl_imagelist* dlist,
439 cpl_imagelist* elist, cpl_imagelist* qlist) {
441 cpl_ensure(dlist != NULL, CPL_ERROR_NULL_INPUT, NULL);
442 cpl_size size = cpl_imagelist_get_size(dlist);
444 for(cpl_size k = 0; k < size; k++) {
445 cpl_image* data = cpl_imagelist_get(dlist, k);
447 cpl_image* qual = cpl_imagelist_get(qlist, k);
451 cpl_mask* mask = cpl_mask_threshold_image_create(qual, 0, INT_MAX);
453 cpl_image_reject_from_mask(data, mask);
454 cpl_mask_delete(mask);
455 cpl_imagelist_set(dlist, data, k);
469static cpl_error_code test_hdrl_resample_compute3D_multiple(
void)
471 cpl_test_error(CPL_ERROR_NONE);
472 cpl_imagelist * imglist_data = cpl_imagelist_new();
473 cpl_imagelist * imglist_error = cpl_imagelist_new();
474 cpl_imagelist * imglist_bpm = cpl_imagelist_new();
475 cpl_test_error(CPL_ERROR_NONE);
479 cpl_test_error(CPL_ERROR_NONE);
480 for (cpl_size var = 0; var <99 ; ++var) {
481 cpl_image * data = cpl_image_new(9, 9, CPL_TYPE_DOUBLE);
482 cpl_image * bpm = cpl_image_new(9, 9, CPL_TYPE_INT);
484 cpl_image_add_scalar(bpm, 1.);
487 cpl_image_set(data, 4, 4, var + 1.);
488 cpl_image_set(data, 5, 4, var + 1.);
489 cpl_image_set(data, 6, 4, var + 1.);
490 cpl_image_set(data, 4, 5, var + 1.);
491 cpl_image_set(data, 5, 5, var + 1.);
492 cpl_image_set(data, 6, 5, var + 1.);
493 cpl_image_set(data, 4, 6, var + 1.);
494 cpl_image_set(data, 5, 6, var + 1.);
495 cpl_image_set(data, 6, 6, var + 1.);
496 cpl_image * errors=cpl_image_power_create(data, 0.5);
499 cpl_image_set(bpm, 4, 4, 0);
500 cpl_image_set(bpm, 5, 4, 0);
501 cpl_image_set(bpm, 6, 4, 0);
502 cpl_image_set(bpm, 4, 5, 0);
503 cpl_image_set(bpm, 5, 5, 0);
504 cpl_image_set(bpm, 6, 5, 0);
505 cpl_image_set(bpm, 4, 6, 0);
506 cpl_image_set(bpm, 5, 6, 0);
507 cpl_image_set(bpm, 6, 6, 0);
509 cpl_imagelist_set(imglist_data, data, var);
510 cpl_imagelist_set(imglist_error, errors, var);
511 cpl_imagelist_set(imglist_bpm, bpm, var);
514 cpl_image_set(data, 4, 4, 99. - var);
515 cpl_image_set(data, 5, 4, 99. - var);
516 cpl_image_set(data, 6, 4, 99. - var);
517 cpl_image_set(data, 4, 5, 99. - var);
518 cpl_image_set(data, 5, 5, 99. - var);
519 cpl_image_set(data, 6, 5, 99. - var);
520 cpl_image_set(data, 4, 6, 99. - var);
521 cpl_image_set(data, 5, 6, 99. - var);
522 cpl_image_set(data, 6, 6, 99. - var);
523 cpl_image * errors=cpl_image_power_create(data, 0.5);
526 cpl_image_set(bpm, 4, 4, 0);
527 cpl_image_set(bpm, 5, 4, 0);
528 cpl_image_set(bpm, 6, 4, 0);
529 cpl_image_set(bpm, 4, 5, 0);
530 cpl_image_set(bpm, 5, 5, 0);
531 cpl_image_set(bpm, 6, 5, 0);
532 cpl_image_set(bpm, 4, 6, 0);
533 cpl_image_set(bpm, 5, 6, 0);
534 cpl_image_set(bpm, 6, 6, 0);
536 cpl_imagelist_set(imglist_data, data, var);
537 cpl_imagelist_set(imglist_error, errors, var);
538 cpl_imagelist_set(imglist_bpm, bpm, var);
541 cpl_test_error(CPL_ERROR_NONE);
544 cpl_propertylist* plist = cpl_propertylist_new();
546 cpl_propertylist_append_int(plist,
"NAXIS" , 3 );
547 cpl_propertylist_append_int(plist,
"NAXIS1" , 9 );
548 cpl_propertylist_append_int(plist,
"NAXIS2" , 9 );
549 cpl_propertylist_append_int(plist,
"NAXIS3" , 99 );
550 cpl_propertylist_append_double(plist,
"CD1_1" , -0.01 );
551 cpl_propertylist_append_double(plist,
"CD1_2" , 0. );
552 cpl_propertylist_append_double(plist,
"CD2_1" , 0. );
553 cpl_propertylist_append_double(plist,
"CD2_2" , 0.01 );
554 cpl_propertylist_append_double(plist,
"CRPIX1" , 4.5 );
555 cpl_propertylist_append_double(plist,
"CRPIX2" , 4.5 );
556 cpl_propertylist_append_double(plist,
"CRVAL1" , 48.0 );
557 cpl_propertylist_append_double(plist,
"CRVAL2" , -20.0 );
558 cpl_propertylist_append_string(plist,
"CTYPE1" ,
"RA---TAN");
559 cpl_propertylist_append_string(plist,
"CTYPE2" ,
"DEC--TAN");
560 cpl_propertylist_append_string(plist,
"CUNIT1" ,
"deg" );
561 cpl_propertylist_append_string(plist,
"CUNIT2" ,
"deg" );
562 cpl_propertylist_append_double(plist,
"CD1_3" , 0. );
563 cpl_propertylist_append_double(plist,
"CD2_3" , 0. );
564 cpl_propertylist_append_double(plist,
"CD3_1" , 0. );
565 cpl_propertylist_append_double(plist,
"CD3_2" , 0. );
566 cpl_propertylist_append_double(plist,
"CD3_3" , 1.0 );
567 cpl_propertylist_append_double(plist,
"CRPIX3" , 1.0 );
568 cpl_propertylist_append_double(plist,
"CRVAL3" , 1.0 );
569 cpl_propertylist_append_string(plist,
"CTYPE3" ,
"WAVE" );
570 cpl_propertylist_append_string(plist,
"CUNIT3" ,
"m" );
571 cpl_test_error(CPL_ERROR_NONE);
573 hdrl_random_state * rastate = hdrl_random_state_new(1, NULL);
574 hdrl_random_state * decstate = hdrl_random_state_new(1, NULL);
578 hdrl_imagelist* hlist =
579 hdrl_resample_util_hdrl_imagelist_create(imglist_data,
580 imglist_error, imglist_bpm);
581 const cpl_size iterations = 20;
582 for (cpl_size i = 0; i < iterations; i++) {
583 double rarandom = hdrl_random_uniform_double(rastate, 0., 360.);
584 double decrandom = hdrl_random_uniform_double(decstate, -89., 89.);
585 cpl_msg_info(cpl_func,
"ra-random: %g, dec-random: %g ", rarandom,
587 cpl_propertylist_update_double(plist,
"CRVAL1" , rarandom);
588 cpl_propertylist_update_double(plist,
"CRVAL2" , decrandom);
589 cpl_wcs * wcs = cpl_wcs_new_from_propertylist(plist);
590 cpl_test_error(CPL_ERROR_NONE);
594 cpl_test_error(CPL_ERROR_NONE);
595 hdrl_parameter *aParams_outputgrid = NULL;
599 cpl_test_nonnull(aParams_outputgrid);
600 cpl_test_error(CPL_ERROR_NONE);
602 hdrl_resample_result *result = NULL;
603 hdrl_parameter *aParams_method = NULL;
612 cpl_test_error(CPL_ERROR_NONE);
614 5, 5, &rej), 49., 1e-6);
616 5, 5, &rej), 7., 0.05);
633 cpl_test_error(CPL_ERROR_NONE);
635 5, 5, &rej), 49., 1e-6);
637 5, 5, &rej), 7., 0.001);
653 cpl_test_error(CPL_ERROR_NONE);
655 5, 5, &rej), 49., 1e-6);
657 5, 5, &rej), 7., 0.3);
673 cpl_test_error(CPL_ERROR_NONE);
675 5, 5, &rej), 49., 1e-6);
677 5, 5, &rej), 7., 0.02);
694 cpl_test_error(CPL_ERROR_NONE);
696 5, 5, &rej), 49., 1e-6);
698 5, 5, &rej), 7., 0.01);
713 cpl_test_error(CPL_ERROR_NONE);
715 5, 5, &rej), 49., 1e-6);
717 5, 5, &rej), 7., 0.00001);
729 cpl_table_delete(table);
737 cpl_propertylist_update_double(plist,
"CRVAL1" , 0.03);
738 cpl_propertylist_update_double(plist,
"CRVAL2" , 0.1);
739 cpl_wcs * wcs = cpl_wcs_new_from_propertylist(plist);
744 hdrl_parameter *aParams_outputgrid = NULL;
748 cpl_test_nonnull(aParams_outputgrid);
749 cpl_test_error(CPL_ERROR_NONE);
751 hdrl_resample_result *result = NULL;
752 hdrl_parameter *aParams_method = NULL;
759 cpl_test_error(CPL_ERROR_NONE);
761 5, 5, &rej), 49., 1e-6);
763 5, 5, &rej), 7., 0.05);
769 cpl_test_error(CPL_ERROR_NONE);
771 cpl_propertylist_save(plist,
"cube_orig.fits", CPL_IO_CREATE);
772 cpl_imagelist_save(imglist_data,
"cube_orig.fits", CPL_TYPE_FLOAT, plist,
774 cpl_imagelist_save(imglist_bpm,
"cube_orig.fits", CPL_TYPE_INT, plist,
776 cpl_imagelist_save(imglist_error,
"cube_orig.fits", CPL_TYPE_FLOAT,
777 plist, CPL_IO_EXTEND);
781 cpl_propertylist_save(plist,
"cube_resampled.fits", CPL_IO_CREATE);
782 cpl_test_error(CPL_ERROR_NONE);
784 cpl_imagelist * ilistdata = cpl_imagelist_new();
785 cpl_imagelist * ilisterrors = cpl_imagelist_new();
786 cpl_imagelist * ilistbpm = cpl_imagelist_new();
789 for (cpl_size i = 0; i < planes; i++) {
794 cpl_imagelist_set(ilistbpm, bpm, i);
798 cpl_imagelist_save(ilistdata,
"cube_resampled.fits", CPL_TYPE_FLOAT,
799 result->header, CPL_IO_EXTEND);
800 cpl_imagelist_save(ilistbpm,
"cube_resampled.fits", CPL_TYPE_INT,
801 result->header, CPL_IO_EXTEND);
802 cpl_imagelist_save(ilisterrors,
"cube_resampled.fits", CPL_TYPE_FLOAT,
803 result->header, CPL_IO_EXTEND);
806 cpl_imagelist_delete(ilistdata);
807 cpl_imagelist_delete(ilisterrors);
808 cpl_imagelist_delete(ilistbpm);
811 hdrl_resample_wcs_print(wcs);
813 wcs = cpl_wcs_new_from_propertylist(result->header);
814 hdrl_resample_wcs_print(wcs);
817 cpl_propertylist_delete(plist);
818 cpl_imagelist_delete(imglist_data);
819 cpl_imagelist_delete(imglist_error);
820 cpl_imagelist_delete(imglist_bpm);
821 hdrl_random_state_delete(rastate);
822 hdrl_random_state_delete(decstate);
827 cpl_table_delete(table);
830 return cpl_error_get_code();
864static cpl_propertylist*
865hdrl_resample_util_crea_header_image(
const int naxis,
const int sx,
const int sy,
866 const double ra,
const double dec,
867 const double cd11,
const double cd12,
868 const double cd21,
const double cd22,
869 const double crpix1,
const double crpix2,
870 const double crval1,
const double crval2,
871 const double cdelt1,
const double cdelt2,
872 const char* ctype1,
const char* ctype2,
873 const char* cunit1,
const char* cunit2)
875 cpl_propertylist* plist = cpl_propertylist_new();
876 cpl_propertylist_append_int(plist,
"NAXIS", naxis);
878 cpl_propertylist_append_int(plist,
"NAXIS1", sx);
879 cpl_propertylist_append_int(plist,
"NAXIS2", sy);
881 cpl_propertylist_append_double(plist,
"RA", ra);
882 cpl_propertylist_append_double(plist,
"DEC", dec);
884 cpl_propertylist_append_double(plist,
"CRPIX1", crpix1);
885 cpl_propertylist_append_double(plist,
"CRPIX2", crpix2);
887 cpl_propertylist_append_double(plist,
"CRVAL1", crval1);
888 cpl_propertylist_append_double(plist,
"CRVAL2", crval2);
890 cpl_propertylist_append_double(plist,
"CDELT1", cdelt1);
891 cpl_propertylist_append_double(plist,
"CDELT2", cdelt2);
893 cpl_propertylist_append_string(plist,
"CTYPE1", ctype1);
894 cpl_propertylist_append_string(plist,
"CTYPE2", ctype2);
896 cpl_propertylist_append_string(plist,
"CUNIT1", cunit1);
897 cpl_propertylist_append_string(plist,
"CUNIT2", cunit2);
899 cpl_propertylist_append_double(plist,
"CD1_1", cd11);
900 cpl_propertylist_append_double(plist,
"CD1_2", cd12);
901 cpl_propertylist_append_double(plist,
"CD2_1", cd21);
902 cpl_propertylist_append_double(plist,
"CD2_2", cd22);
905 cpl_image* ima = cpl_image_new(sx, sy, CPL_TYPE_INT);
906 cpl_image_add_scalar(ima, 1);
908 cpl_image_save(ima,
"ima.fits", CPL_TYPE_INT, plist, CPL_IO_DEFAULT);
909 cpl_image_delete(ima);
910 cpl_propertylist_delete(plist);
911 plist = cpl_propertylist_load(
"ima.fits", 0);
912 cpl_test_error(CPL_ERROR_NONE);
962static cpl_propertylist*
963hdrl_resample_crea_header_cube(
const int naxis,
964 const int sx,
const int sy,
const int sz,
965 const double ra,
const double dec,
966 const double cd11,
const double cd12,
967 const double cd21,
const double cd22,
968 const double cd13,
const double cd31,
969 const double cd23,
const double cd32,
971 const double crpix1,
const double crpix2,
const double crpix3,
972 const double crval1,
const double crval2,
const double crval3,
973 const double cdelt1,
const double cdelt2,
const double cdelt3,
974 const char* ctype1,
const char* ctype2,
const char* ctype3,
975 const char* cunit1,
const char* cunit2,
const char* cunit3)
978 cpl_propertylist* plist =
979 hdrl_resample_util_crea_header_image(naxis, sx, sy, ra, dec,
980 cd11, cd12, cd21, cd22, crpix1, crpix2,
981 crval1, crval2, cdelt1, cdelt2, ctype1,
982 ctype2, cunit1, cunit2);
985 cpl_propertylist_update_int(plist,
"NAXIS", naxis);
987 cpl_propertylist_append_int(plist,
"NAXIS3", sz);
989 cpl_propertylist_append_double(plist,
"CRVAL3", crval3);
990 cpl_propertylist_append_double(plist,
"CRPIX3", crpix3);
991 cpl_propertylist_append_double(plist,
"CDELT3", cdelt3);
992 cpl_propertylist_append_string(plist,
"CTYPE3", ctype3);
993 cpl_propertylist_append_string(plist,
"CUNIT3", cunit3);
995 cpl_propertylist_append_double(plist,
"CD1_3", cd13);
996 cpl_propertylist_append_double(plist,
"CD3_1", cd31);
997 cpl_propertylist_append_double(plist,
"CD2_3", cd23);
998 cpl_propertylist_append_double(plist,
"CD3_2", cd32);
999 cpl_propertylist_append_double(plist,
"CD3_3", cd33);
1003 cpl_image* ima = cpl_image_new(sx, sy, CPL_TYPE_INT);
1004 cpl_image_add_scalar(ima, 1);
1005 cpl_imagelist* iml = cpl_imagelist_new();
1006 for(
int i = 0; i< sz;i++) {
1007 cpl_imagelist_set(iml, ima, i);
1010 cpl_imagelist_save(iml,
"iml.fits", CPL_TYPE_INT, plist, CPL_IO_DEFAULT);
1011 cpl_imagelist_delete(iml);
1012 cpl_propertylist_delete(plist);
1013 plist = cpl_propertylist_load(
"iml.fits", 0);
1014 cpl_test_error(CPL_ERROR_NONE);
1021static cpl_error_code
1022test_invalid_input_hdrl_resample_weight_function_renka(
void){
1030 cpl_test_abs(hdrl_resample_weight_function_renka(r, r_c), FLT_MAX, HDRL_EPS_TEST);
1031 cpl_test_error(CPL_ERROR_NONE);
1036 cpl_test_abs(hdrl_resample_weight_function_renka(r, r_c), DBL_MIN, HDRL_EPS_TEST);
1037 cpl_test_error(CPL_ERROR_NONE);
1042 cpl_test_abs(hdrl_resample_weight_function_renka(r, r_c), DBL_MIN, HDRL_EPS_TEST);
1043 cpl_test_error(CPL_ERROR_NONE);
1044 return cpl_error_get_code();
1046static cpl_error_code
1047test_hdrl_resample_weight_function_renka(
void)
1054 test_invalid_input_hdrl_resample_weight_function_renka();
1061 res = 0.0277777777777777762;
1062 cpl_test_abs(hdrl_resample_weight_function_renka(r, r_c), res, HDRL_EPS_TEST);
1064 cpl_test_error(CPL_ERROR_NONE);
1066 return cpl_error_get_code();
1073static cpl_error_code
1074test_hdrl_resample_weight_function_drizzle(
void)
1076 double x_in, y_in, z_in;
1077 double x_out, y_out, z_out;
1081 x_in = 2, y_in = 2, z_in = 2;
1082 dx = 1, dy = 1, dz = 1;
1083 x_out = 1, y_out = 1, z_out = 1;
1084 double res = 0.015625;
1085 hdrl_resample_weight_function_drizzle(x_in, y_in, z_in, x_out, y_out, z_out,
1087 cpl_test_error(CPL_ERROR_NONE);
1089 cpl_test_abs(hdrl_resample_weight_function_drizzle(x_in, y_in, z_in,
1090 x_out, y_out, z_out, dx, dy, dz),res,HDRL_EPS_TEST);
1093 x_in = 3, y_in = 3, z_in = 3;
1094 dx = 1, dy = 1, dz = 1;
1095 x_out = 2, y_out = 2, z_out = 2;
1097 hdrl_resample_weight_function_drizzle(x_in, y_in, z_in, x_out, y_out, z_out,
1099 cpl_test_error(CPL_ERROR_NONE);
1100 cpl_test_abs(hdrl_resample_weight_function_drizzle(x_in, y_in, z_in,
1101 x_out, y_out, z_out, dx, dy, dz),res,HDRL_EPS_TEST);
1104 x_in = 2, y_in = 2, z_in = 2;
1105 dx = 10, dy = 10, dz = 10;
1106 x_out = 1, y_out = 1, z_out = 1;
1108 cpl_test_abs(hdrl_resample_weight_function_drizzle(x_in, y_in, z_in,
1109 x_out, y_out, z_out, dx, dy, dz),res,HDRL_EPS_TEST);
1111 cpl_test_error(CPL_ERROR_NONE);
1113 return cpl_error_get_code();
1119static cpl_error_code
1120test_hdrl_resample_weight_function_linear(
void)
1124 cpl_test_abs(hdrl_resample_weight_function_linear(0), FLT_MAX, HDRL_EPS_TEST);
1125 cpl_test_error(CPL_ERROR_NONE);
1129 cpl_test_abs(hdrl_resample_weight_function_linear(2), 0.5, HDRL_EPS_TEST);
1130 cpl_test_error(CPL_ERROR_NONE);
1133 return cpl_error_get_code();
1139static cpl_error_code
1140test_hdrl_resample_weight_function_quadratic(
void)
1144 cpl_test_abs(hdrl_resample_weight_function_quadratic(0), FLT_MAX, HDRL_EPS_TEST);
1145 cpl_test_error(CPL_ERROR_NONE);
1149 cpl_test_abs(hdrl_resample_weight_function_quadratic(4), 0.25, HDRL_EPS_TEST);
1150 cpl_test_error(CPL_ERROR_NONE);
1153 return cpl_error_get_code();
1159static cpl_error_code
1160test_hdrl_resample_weight_function_sinc(
void)
1167 cpl_test_abs(hdrl_resample_weight_function_sinc(DBL_EPSILON), 1., HDRL_EPS_TEST);
1168 cpl_test_error(CPL_ERROR_NONE);
1173 res = 0.900316316157106056;
1174 cpl_test_abs(hdrl_resample_weight_function_sinc(r), res, HDRL_EPS_TEST);
1175 cpl_test_error(CPL_ERROR_NONE);
1177 return cpl_error_get_code();
1183static cpl_error_code
1184test_hdrl_resample_weight_function_lanczos(
void)
1190 unsigned int ld = 4;
1191 unsigned int lks = 2;
1195 cpl_test_abs(hdrl_resample_weight_function_lanczos(5., dy, dz, ld, lks), 0., HDRL_EPS_TEST);
1196 cpl_test_abs(hdrl_resample_weight_function_lanczos(dx, 5., dz, ld, lks), 0., HDRL_EPS_TEST);
1197 cpl_test_abs(hdrl_resample_weight_function_lanczos(dx, dy, 5., ld, lks), 0., HDRL_EPS_TEST);
1198 cpl_test_error(CPL_ERROR_NONE);
1201 double res = 4.32283142061004719e-50;
1202 cpl_test_abs(hdrl_resample_weight_function_lanczos(dx, dy, dz, ld, lks), res, HDRL_EPS_TEST);
1203 cpl_test_error(CPL_ERROR_NONE);
1205 return cpl_error_get_code();
1212hdrl_resample_util_crea_image_dice_5(
const cpl_size sx,
const cpl_size sy,
1216 cpl_image * image = cpl_image_new(sx, sy, CPL_TYPE_DOUBLE);
1217 cpl_image * dice = cpl_image_new(sx, sy, CPL_TYPE_DOUBLE);
1218 cpl_image_add_scalar(image,value);
1220 cpl_size xc = 0.5 * sx;
1221 cpl_size yc = 0.5 * sy;
1224 cpl_size xl = 0.25 * sx;
1225 cpl_size yl = 0.25 * sy;
1226 cpl_size xh = 0.75 * sx;
1227 cpl_size yh = 0.75 * sy;
1228 double flux_point=2.*value;
1229 cpl_image_fill_window(dice, xc - dx, yc - dy, xc + dx, yc + dy, flux_point);
1230 cpl_image_fill_window(dice, xl - dx, yl - dy, xl + dx, yl + dy, flux_point);
1231 cpl_image_fill_window(dice, xl - dx, yh - dy, xl + dx, yh + dy, flux_point);
1232 cpl_image_fill_window(dice, xh - dx, yh - dy, xh + dx, yh + dy, flux_point);
1233 cpl_image_fill_window(dice, xh - dx, yl - dy, xh + dx, yl + dy, flux_point);
1234 cpl_image_add(image,dice);
1236 cpl_image_delete(dice);
1237 cpl_test_error(CPL_ERROR_NONE);
1255static hdrl_parameter *
1256hdrl_resample_util_methodparam_create (
1257 const int loop_distance,
1258 const double critical_radius_renka,
1259 const int kernel_size_lanczos,
1260 const double pix_frac_drizzle_x,
1261 const double pix_frac_drizzle_y,
1262 const double pix_frac_drizzle_l,
1263 const int resample_method,
1264 const cpl_boolean use_errorweights
1267 hdrl_parameter *aParams_method = NULL;
1270 switch(resample_method) {
1271 case HDRL_RESAMPLE_METHOD_NEAREST:
1275 case HDRL_RESAMPLE_METHOD_RENKA:
1278 critical_radius_renka);
1280 case HDRL_RESAMPLE_METHOD_LINEAR:
1284 case HDRL_RESAMPLE_METHOD_QUADRATIC:
1288 case HDRL_RESAMPLE_METHOD_DRIZZLE:
1293 pix_frac_drizzle_l);
1295 case HDRL_RESAMPLE_METHOD_LANCZOS:
1298 kernel_size_lanczos);
1303 kernel_size_lanczos);
1304 cpl_msg_warning (cpl_func,
1305 "You set an unsupported method! Default to LANCZOS");
1309 cpl_test_error(CPL_ERROR_NONE);
1310 return aParams_method;
1323hdrl_resample_util_wcs_create_example_params(
void)
1326 cpl_propertylist* p = cpl_propertylist_new();
1328 cpl_propertylist_append_int(p,
"NAXIS", 2);
1329 cpl_propertylist_append_int(p,
"NAXIS1", 512);
1330 cpl_propertylist_append_int(p,
"NAXIS2", 512);
1331 cpl_propertylist_append_double(p,
"CRPIX1", 256.);
1334 cpl_propertylist_append_double(p,
"CD1_1", -0.003);
1335 cpl_propertylist_append_string(p,
"CTYPE1",
"RA---TAN");
1336 cpl_propertylist_append_double(p,
"CRVAL1", 45.83);
1337 cpl_propertylist_append_string(p,
"CUNIT1",
"deg");
1339 cpl_propertylist_append_double(p,
"CRPIX2", 257.);
1340 cpl_propertylist_append_double(p,
"CD2_2", 0.003);
1341 cpl_propertylist_append_string(p,
"CTYPE2",
"DEC--TAN");
1342 cpl_propertylist_append_double(p,
"CRVAL2", 63.57);
1343 cpl_propertylist_append_string(p,
"CUNIT2",
"deg");
1346 cpl_propertylist_append_double(p,
"CD1_2", 0.);
1347 cpl_propertylist_append_double(p,
"CD2_1", 0.);
1350 cpl_propertylist_append_double(p,
"RA", 45.83);
1351 cpl_propertylist_append_double(p,
"DEC", 63.57);
1353 cpl_wcs* wcs = cpl_wcs_new_from_propertylist(p);
1354 cpl_propertylist_delete(p);
1355 cpl_test_error(CPL_ERROR_NONE);
1366hdrl_resample_util_crea_wcs_2d(
void)
1368 cpl_propertylist* plist = NULL;
1370 int sx = HDRL_SIZE_X;
1371 int sy = HDRL_SIZE_Y;
1376 double cd11 = HDRL_CD11;
1377 double cd22 = HDRL_CD22;
1378 double cd12 = HDRL_CD12;
1379 double cd21 = HDRL_CD21;
1380 const double crpix1 = HDRL_CRPIX1;
1381 const double crpix2 = HDRL_CRPIX2;
1382 const double crval1 = HDRL_CRVAL1;
1383 const double crval2 = HDRL_CRVAL2;
1384 const double cdelt1 = HDRL_CDELT1;
1385 const double cdelt2 = HDRL_CDELT2;
1386 const char* cunit1 =
"";
1387 const char* cunit2 =
"";
1388 const char* ctype1 =
"pix";
1389 const char* ctype2 =
"pix";
1391 plist = hdrl_resample_util_crea_header_image(naxis, sx, sy, ra, dec,
1392 cd11, cd12, cd21, cd22, crpix1,
1393 crpix2, crval1, crval2,
1394 cdelt1, cdelt2, ctype1, ctype2,
1396 cpl_test_error(CPL_ERROR_NONE);
1398 cpl_wcs* wcs = cpl_wcs_new_from_propertylist(plist);
1399 cpl_test_nonnull(wcs);
1400 cpl_test_error(CPL_ERROR_NONE);
1401 cpl_propertylist_delete(plist);
1412hdrl_resample_util_crea_wcs_3d(
void)
1415 cpl_propertylist* plist = NULL;
1416 int sx = HDRL_SIZE_X;
1417 int sy = HDRL_SIZE_Y;
1422 double cd11 = HDRL_CD11;
1423 double cd22 = HDRL_CD22;
1424 double cd12 = HDRL_CD12;
1425 double cd21 = HDRL_CD21;
1426 const double crpix1 = HDRL_CRPIX1;
1427 const double crpix2 = HDRL_CRPIX2;
1428 const double crval1 = HDRL_CRVAL1;
1429 const double crval2 = HDRL_CRVAL2;
1430 const double cdelt1 = HDRL_CDELT1;
1431 const double cdelt2 = HDRL_CDELT2;
1432 const char* cunit1 =
"deg";
1433 const char* cunit2 =
"deg";
1434 const char* ctype1 =
"RA---TAN";
1435 const char* ctype2 =
"DEC--TAN";
1437 int sz = HDRL_SIZE_Z;
1438 double cd13 = HDRL_CD13;
1439 double cd31 = HDRL_CD31;
1440 double cd23 = HDRL_CD23;
1441 double cd32 = HDRL_CD32;
1442 double cd33 = HDRL_CD33;
1443 const double crpix3 = HDRL_CRPIX3;
1444 const double crval3 = HDRL_CRVAL3;
1445 const double cdelt3 = HDRL_CDELT3;
1446 const char* cunit3 =
"m";
1447 const char* ctype3 =
"WAV";
1449 cpl_test_error(CPL_ERROR_NONE);
1450 cpl_propertylist_delete(plist);
1451 cpl_test_error(CPL_ERROR_NONE);
1452 plist = hdrl_resample_crea_header_cube(naxis, sx, sy, sz, ra, dec,
1453 cd11, cd12, cd21, cd22, cd13, cd31,
1455 crpix1, crpix2, crpix3,
1456 crval1, crval2, crval3,
1457 cdelt1, cdelt2, cdelt3,
1458 ctype1, ctype2, ctype3,
1459 cunit1, cunit2, cunit3);
1460 cpl_test_error(CPL_ERROR_NONE);
1462 cpl_wcs* wcs = cpl_wcs_new_from_propertylist(plist);
1463 cpl_test_nonnull(wcs);
1464 cpl_test_error(CPL_ERROR_NONE);
1465 cpl_propertylist_delete(plist);
1470CPL_DIAG_PRAGMA_PUSH_IGN(-Wunused-function);
1477static cpl_error_code
1478test_resample_wcs_as_muse(
void)
1490 const double kLimitPPl = FLT_EPSILON * 2.88;
1499 cpl_test_error(CPL_ERROR_NONE);
1500 cpl_wcs* wcs = hdrl_resample_util_wcs_create_example_params();
1501 cpl_test_nonnull(wcs);
1505 hdrl_parameter* hpar =
1508 cpl_test_nonnull(hpar);
1509 hdrl_resample_outgrid_parameter * par = (hdrl_resample_outgrid_parameter *) hpar;
1510 cpl_test_nonnull(par);
1513 cpl_errorstate state = cpl_errorstate_get();
1514 cpl_test_error(CPL_ERROR_NONE);
1516 cpl_test(hdrl_resample_wcs_projplane_from_celestial(par, 47.503264, 62.795111,
1517 &x, &y) == CPL_ERROR_NONE);
1518 cpl_test_error(CPL_ERROR_NONE);
1519 cpl_test(fabs(x - 0.765000) < kLimitPPl && fabs(y - (-0.765000)) < kLimitPPl);
1520 cpl_msg_debug(__func__,
"SE corner: %f,%f (%e,%e <? %e", x, y, x - 0.765000,
1521 y - (-0.765000), kLimitPPl);
1522 cpl_test(hdrl_resample_wcs_projplane_from_celestial(par, 47.595581, 64.324332,
1523 &x, &y) == CPL_ERROR_NONE);
1524 cpl_test(fabs(x - 0.765000) < kLimitPPl && fabs(y - 0.765000) < kLimitPPl);
1525 cpl_msg_debug(__func__,
"NE corner: %f,%f (%e,%e <? %e", x, y, x - 0.765000,
1526 y - 0.765000, kLimitPPl);
1527 cpl_test(hdrl_resample_wcs_projplane_from_celestial(par, 44.064419, 64.324332,
1528 &x, &y) == CPL_ERROR_NONE);
1529 cpl_test(fabs(x - (-0.765000)) < kLimitPPl && fabs(y - 0.765000) < kLimitPPl);
1530 cpl_msg_debug(__func__,
"NW corner: %f,%f (%e,%e <? %e", x, y, x - (-0.765000),
1531 y - 0.765000, kLimitPPl);
1532 state = cpl_errorstate_get();
1533 cpl_test(hdrl_resample_wcs_projplane_from_celestial(NULL, 1., 1., &v1, &v2)
1534 == CPL_ERROR_NULL_INPUT);
1535 cpl_test(hdrl_resample_wcs_projplane_from_celestial(par, 1., 1., NULL, &v2)
1536 == CPL_ERROR_NULL_INPUT);
1537 cpl_test(hdrl_resample_wcs_projplane_from_celestial(par, 1., 1., &v1, NULL)
1538 == CPL_ERROR_NULL_INPUT);
1539 cpl_errorstate_set(state);
1541 cpl_test_error(CPL_ERROR_NONE);
1542 cpl_test(hdrl_resample_wcs_projplane_from_celestial(par, 1., 1., &v1, &v2)
1544 cpl_test_error(CPL_ERROR_NONE);
1545 cpl_errorstate_set(state);
1547 cpl_wcs_delete(wcs);
1549 cpl_test_error(CPL_ERROR_NONE);
1550 return cpl_error_get_code();
1560static cpl_error_code
1561test_hdrl_resample_image_to_table(
void)
1564 cpl_table* tab = NULL;
1565 cpl_image* data = NULL;
1566 cpl_image* error = NULL;
1567 cpl_image* quality = NULL;
1568 cpl_wcs* wcs = NULL;
1572 cpl_test_error(CPL_ERROR_NULL_INPUT);
1576 int sx = HDRL_SIZE_X;
1577 int sy = HDRL_SIZE_Y;
1578 double value = HDRL_FLUX_ADU;
1580 data = cpl_image_new(sx, sy, CPL_TYPE_DOUBLE);
1581 cpl_image_add_scalar(data, value);
1583 error = cpl_image_power_create(data, 0.5);
1584 quality = cpl_image_new(sx, sy, CPL_TYPE_INT);
1588 const double cd11 = -3.47222e-05;
1589 const double cd22 = 3.47222e-05;
1590 const double cd12 = 0;
1591 const double cd21 = 0;
1592 const double crpix1 = 33.5;
1593 const double crpix2 = 33.5;
1594 const double crval1 = 48.0718057375143246;
1595 const double crval2 = -20.6230284673176705;
1596 const double cdelt1 = 0;
1597 const double cdelt2 = 0;
1598 const char* cunit1 =
"deg";
1599 const char* cunit2 =
"deg";
1600 const char* ctype1 =
"RA---TAN";
1601 const char* ctype2 =
"DEC--TAN";
1603 cpl_propertylist* plist =
1604 hdrl_resample_util_crea_header_image(naxis, sx, sy, ra, dec,
1605 cd11, cd12, cd21, cd22,
1606 crpix1, crpix2, crval1, crval2,
1607 cdelt1, cdelt2, ctype1, ctype2,
1610 wcs = cpl_wcs_new_from_propertylist(plist);
1611 cpl_test_nonnull(wcs);
1612 hdrl_image* hima = hdrl_resample_util_hdrl_image_create(data, error, quality);
1614 cpl_test_error(CPL_ERROR_NONE);
1617 cpl_test_eq(1, cpl_table_has_column(tab, HDRL_RESAMPLE_TABLE_RA));
1618 cpl_test_eq(1, cpl_table_has_column(tab, HDRL_RESAMPLE_TABLE_DEC));
1619 cpl_test_eq(1, cpl_table_has_column(tab, HDRL_RESAMPLE_TABLE_LAMBDA));
1620 cpl_test_eq(1, cpl_table_has_column(tab, HDRL_RESAMPLE_TABLE_BPM));
1621 cpl_test_eq(1, cpl_table_has_column(tab, HDRL_RESAMPLE_TABLE_ERRORS));
1623 double* ptablambda = cpl_table_get_data_double(tab, HDRL_RESAMPLE_TABLE_LAMBDA);
1624 double* ptabdata = cpl_table_get_data_double(tab, HDRL_RESAMPLE_TABLE_DATA);
1625 int* ptabbpm = cpl_table_get_data_int(tab, HDRL_RESAMPLE_TABLE_BPM);
1626 double* ptaberr = cpl_table_get_data_double(tab, HDRL_RESAMPLE_TABLE_ERRORS);
1628 cpl_test_abs(0, ptablambda[0], HDRL_EPS_TEST);
1629 cpl_test_abs(HDRL_FLUX_ADU, ptabdata[0], HDRL_EPS_TEST);
1630 cpl_test_abs(0, ptabbpm[0], HDRL_EPS_TEST);
1631 cpl_test_abs(10, ptaberr[0], HDRL_EPS_TEST);
1634 cpl_table_delete(tab);
1635 cpl_image_delete(data);
1636 cpl_image_delete(error);
1637 cpl_image_delete(quality);
1639 cpl_propertylist_delete(plist);
1640 cpl_wcs_delete(wcs);
1641 cpl_test_error(CPL_ERROR_NONE);
1642 return cpl_error_get_code();
1650static cpl_error_code
1651test_hdrl_resample_imagelist_to_table(
void)
1654 cpl_table* tab = NULL;
1655 cpl_imagelist* ilist = NULL;
1656 cpl_imagelist* elist = NULL;
1657 cpl_imagelist* qlist = NULL;
1658 cpl_image* data = NULL;
1659 cpl_image* error = NULL;
1660 cpl_image* quality = NULL;
1661 cpl_wcs* wcs = NULL;
1665 cpl_test_error(CPL_ERROR_NULL_INPUT);
1671 double value = HDRL_FLUX_ADU;
1673 data = cpl_image_new(sx, sy, CPL_TYPE_DOUBLE);
1674 cpl_image_add_scalar(data, value);
1676 error = cpl_image_power_create(data, 0.5);
1677 quality = cpl_image_new(sx, sy, CPL_TYPE_INT);
1681 const double cd11 = -3.47222e-05;
1682 const double cd22 = 3.47222e-05;
1683 const double cd12 = 0;
1684 const double cd21 = 0;
1685 const double crpix1 = 33.5;
1686 const double crpix2 = 33.5;
1687 const double crval1 = 48.0706;
1688 const double crval2 = -20.6219;
1689 const double cdelt1 = 0;
1690 const double cdelt2 = 0;
1691 const char* cunit1 =
"deg";
1692 const char* cunit2 =
"deg";
1693 const char* ctype1 =
"RA---TAN";
1694 const char* ctype2 =
"DEC--TAN";
1700 double cd33 = 2.45e-10;
1701 const double crpix3 = 1;
1702 const double crval3 = 1.9283e-06;
1703 const double cdelt3 = 0.1;
1704 const char* cunit3 =
"m";
1705 const char* ctype3 =
"WAVE";
1707 cpl_test_error(CPL_ERROR_NONE);
1708 cpl_propertylist* plist =
1709 hdrl_resample_crea_header_cube(naxis, sx, sy, sz, ra, dec,
1710 cd11, cd12, cd21, cd22,
1711 cd13, cd31, cd23, cd32, cd33,
1712 crpix1, crpix2, crpix3,
1713 crval1, crval2, crval3,
1714 cdelt1, cdelt2, cdelt3,
1715 ctype1, ctype2, ctype3,
1716 cunit1, cunit2, cunit3);
1718 ilist = cpl_imagelist_new();
1719 elist = cpl_imagelist_new();
1720 qlist = cpl_imagelist_new();
1722 cpl_imagelist_set(ilist, data, 0);
1723 cpl_imagelist_set(elist, error, 0);
1724 cpl_imagelist_set(qlist, quality, 0);
1726 wcs = cpl_wcs_new_from_propertylist(plist);
1727 cpl_test_nonnull(wcs);
1728 cpl_test_error(CPL_ERROR_NONE);
1729 hdrl_imagelist* hlist = hdrl_resample_util_hdrl_imagelist_create(ilist, elist,
1732 cpl_test_error(CPL_ERROR_NONE);
1735 cpl_test_eq(1, cpl_table_has_column(tab, HDRL_RESAMPLE_TABLE_RA));
1736 cpl_test_eq(1, cpl_table_has_column(tab, HDRL_RESAMPLE_TABLE_DEC));
1737 cpl_test_eq(1, cpl_table_has_column(tab, HDRL_RESAMPLE_TABLE_LAMBDA));
1738 cpl_test_eq(1, cpl_table_has_column(tab, HDRL_RESAMPLE_TABLE_BPM));
1739 cpl_test_eq(1, cpl_table_has_column(tab, HDRL_RESAMPLE_TABLE_ERRORS));
1743 double* ptablambda = cpl_table_get_data_double(tab, HDRL_RESAMPLE_TABLE_LAMBDA);
1744 double* ptabdata = cpl_table_get_data_double(tab, HDRL_RESAMPLE_TABLE_DATA);
1745 int* ptabbpm = cpl_table_get_data_int(tab, HDRL_RESAMPLE_TABLE_BPM);
1746 double* ptaberr = cpl_table_get_data_double(tab, HDRL_RESAMPLE_TABLE_ERRORS);
1749 cpl_test_abs(0, ptablambda[0], HDRL_EPS_TEST);
1750 cpl_test_abs(HDRL_FLUX_ADU, ptabdata[0], HDRL_EPS_TEST);
1751 cpl_test_abs(0, ptabbpm[0], HDRL_EPS_TEST);
1752 cpl_test_abs(10, ptaberr[0], HDRL_EPS_TEST);
1755 cpl_imagelist_delete(ilist);
1756 cpl_imagelist_delete(elist);
1757 cpl_imagelist_delete(qlist);
1759 cpl_table_delete(tab);
1760 cpl_propertylist_delete(plist);
1761 cpl_wcs_delete(wcs);
1762 cpl_test_error(CPL_ERROR_NONE);
1763 return cpl_error_get_code();
1771static cpl_error_code
1772test_hdrl_wcs_to_propertylist(
void) {
1774 cpl_propertylist* plist = NULL;
1775 cpl_wcs* wcs = NULL;
1776 cpl_boolean only2d = CPL_TRUE;
1779 hdrl_wcs_to_propertylist(NULL, plist, only2d);
1780 cpl_test_error(CPL_ERROR_NULL_INPUT);
1782 hdrl_wcs_to_propertylist(wcs, NULL, only2d);
1783 cpl_test_error(CPL_ERROR_NULL_INPUT);
1786 wcs = hdrl_resample_util_crea_wcs_2d();
1787 cpl_test_error(CPL_ERROR_NONE);
1788 plist = cpl_propertylist_new();
1789 hdrl_wcs_to_propertylist(wcs, plist, only2d);
1790 cpl_test_error(CPL_ERROR_NONE);
1792 cpl_wcs_delete(wcs);
1793 wcs = hdrl_resample_util_crea_wcs_3d();
1794 cpl_test_error(CPL_ERROR_NONE);
1796 hdrl_wcs_to_propertylist(wcs, plist, !only2d);
1797 cpl_test_error(CPL_ERROR_NONE);
1800 const cpl_array *crval = cpl_wcs_get_crval(wcs);
1801 const cpl_array *crpix = cpl_wcs_get_crpix(wcs);
1802 const cpl_array *ctype = cpl_wcs_get_ctype(wcs);
1803 const cpl_array *cunit = cpl_wcs_get_cunit(wcs);
1804 const cpl_matrix *cd = cpl_wcs_get_cd(wcs);
1805 int naxis_out = cpl_wcs_get_image_naxis(wcs);
1808 int sx = HDRL_SIZE_X;
1809 int sz = HDRL_SIZE_Z;
1810 cpl_test_eq(naxis, naxis_out);
1813 for (
int i = 0; i < naxis_out; i++) {
1815 char * buf = cpl_sprintf(
"NAXIS%d", i + 1);
1818 cpl_test_eq(sx, cpl_propertylist_get_int(plist, buf));
1820 cpl_test_eq(sz, cpl_propertylist_get_int(plist, buf));
1827 cpl_test_abs(cpl_propertylist_get_double(plist,
"CRVAL1"),
1828 cpl_array_get_double(crval, 0, &err), HDRL_EPS_TEST);
1830 cpl_test_abs(cpl_propertylist_get_double(plist,
"CRVAL2"),
1831 cpl_array_get_double(crval, 1, &err), HDRL_EPS_TEST);
1833 cpl_test_abs(cpl_propertylist_get_double(plist,
"CRVAL3"),
1834 cpl_array_get_double(crval, 2, &err), HDRL_EPS_TEST);
1837 cpl_test_abs(cpl_propertylist_get_double(plist,
"CRPIX1"),
1838 cpl_array_get_double(crpix, 0, &err), HDRL_EPS_TEST);
1840 cpl_test_abs(cpl_propertylist_get_double(plist,
"CRPIX2"),
1841 cpl_array_get_double(crpix, 1, &err), HDRL_EPS_TEST);
1843 cpl_test_abs(cpl_propertylist_get_double(plist,
"CRPIX3"),
1844 cpl_array_get_double(crpix, 2, &err), HDRL_EPS_TEST);
1847 const char* string_val = NULL;
1848 const char* string_chk = NULL;
1850 string_val = cpl_propertylist_get_string(plist,
"CTYPE1");
1851 string_chk = cpl_array_get_string(ctype, 0);
1852 cpl_test_eq(0, strcmp(string_val,string_chk));
1854 string_val = cpl_propertylist_get_string(plist,
"CTYPE2");
1855 string_chk = cpl_array_get_string(ctype, 1);
1856 cpl_test_eq(0, strcmp(string_val,string_chk));
1858 string_val = cpl_propertylist_get_string(plist,
"CTYPE3");
1859 string_chk = cpl_array_get_string(ctype, 2);
1860 cpl_test_eq(0, strcmp(string_val,string_chk));
1863 string_val = cpl_propertylist_get_string(plist,
"CUNIT1");
1864 string_chk = cpl_array_get_string(cunit, 0);
1865 cpl_test_eq(0, strcmp(string_val,string_chk));
1867 string_val = cpl_propertylist_get_string(plist,
"CUNIT2");
1868 string_chk = cpl_array_get_string(cunit, 1);
1869 cpl_test_eq(0, strcmp(string_val,string_chk));
1871 string_val = cpl_propertylist_get_string(plist,
"CUNIT3");
1872 string_chk = cpl_array_get_string(cunit, 2);
1873 cpl_test_eq(0, strcmp(string_val,string_chk));
1876 double cd11 = 1, cd22 = 1, cd33 = 0.1;
1877 double cd12 = 0, cd21 = 0, cd13 = 0, cd31 = 0, cd23 = 0, cd32 = 0;
1879 cd11 = cpl_matrix_get(cd, 0, 0);
1880 cd12 = cpl_matrix_get(cd, 0, 1);
1881 cd21 = cpl_matrix_get(cd, 1, 0);
1882 cd22 = cpl_matrix_get(cd, 1, 1);
1883 cd13 = cpl_matrix_get(cd, 0, 2);
1884 cd31 = cpl_matrix_get(cd, 2, 0);
1885 cd23 = cpl_matrix_get(cd, 1, 2);
1886 cd32 = cpl_matrix_get(cd, 2, 1);
1887 cd33 = cpl_matrix_get(cd, 2, 2);
1889 cpl_test_abs(cd11, cpl_propertylist_get_double(plist,
"CD1_1"), HDRL_EPS_TEST);
1890 cpl_test_abs(cd12, cpl_propertylist_get_double(plist,
"CD1_2"), HDRL_EPS_TEST);
1891 cpl_test_abs(cd21, cpl_propertylist_get_double(plist,
"CD2_1"), HDRL_EPS_TEST);
1892 cpl_test_abs(cd22, cpl_propertylist_get_double(plist,
"CD2_2"), HDRL_EPS_TEST);
1893 cpl_test_abs(cd13, cpl_propertylist_get_double(plist,
"CD1_3"), HDRL_EPS_TEST);
1894 cpl_test_abs(cd31, cpl_propertylist_get_double(plist,
"CD3_1"), HDRL_EPS_TEST);
1895 cpl_test_abs(cd23, cpl_propertylist_get_double(plist,
"CD2_3"), HDRL_EPS_TEST);
1896 cpl_test_abs(cd32, cpl_propertylist_get_double(plist,
"CD3_2"), HDRL_EPS_TEST);
1897 cpl_test_abs(cd33, cpl_propertylist_get_double(plist,
"CD3_3"), HDRL_EPS_TEST);
1899 cpl_propertylist_delete(plist);
1900 cpl_wcs_delete(wcs);
1901 cpl_test_error(CPL_ERROR_NONE);
1902 return cpl_error_get_code();
1905static cpl_error_code
1906test_resample_invalid_input_outgrid_param(
1907 const double delta_ra,
1908 const double delta_dec,
1909 const double delta_lambda,
1910 const double ra_min,
1911 const double ra_max,
1912 const double dec_min,
1913 const double dec_max,
1914 const double lambda_min,
1915 const double lambda_max,
1916 const double field_margin) {
1918 hdrl_parameter* pErr = NULL;
1921 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
1922 cpl_test_null(pErr);
1925 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
1926 cpl_test_null(pErr);
1929 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
1930 cpl_test_null(pErr);
1933 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
1934 cpl_test_null(pErr);
1937 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
1938 cpl_test_null(pErr);
1942 dec_min, dec_max, field_margin);
1943 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
1944 cpl_test_null(pErr);
1948 dec_min, dec_max, field_margin);
1949 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
1950 cpl_test_null(pErr);
1953 ra_max, dec_min, dec_max, field_margin);
1954 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
1955 cpl_test_null(pErr);
1958 -1, dec_min, dec_max, field_margin);
1959 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
1960 cpl_test_null(pErr);
1963 2, 1, dec_min, dec_max, field_margin);
1964 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
1965 cpl_test_null(pErr);
1968 ra_min, ra_max, 2, 1, field_margin);
1969 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
1970 cpl_test_null(pErr);
1973 ra_min, ra_max, dec_min, dec_max, -1);
1974 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
1975 cpl_test_null(pErr);
1978 delta_lambda, -1, ra_max,
1979 dec_min, dec_max, lambda_min,
1980 lambda_max,field_margin);
1981 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
1982 cpl_test_null(pErr);
1985 delta_lambda, ra_min, -1,
1986 dec_min, dec_max, lambda_min,
1987 lambda_max,field_margin);
1988 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
1989 cpl_test_null(pErr);
1992 delta_lambda, 2, 1, dec_min,
1993 dec_max, lambda_min,
1994 lambda_max,field_margin);
1995 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
1996 cpl_test_null(pErr);
1999 delta_lambda, ra_min, ra_max,
2001 lambda_max,field_margin);
2002 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
2003 cpl_test_null(pErr);
2006 delta_lambda, ra_min, ra_max,
2007 dec_min, dec_max, -1,
2008 lambda_max,field_margin);
2009 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
2010 cpl_test_null(pErr);
2013 delta_lambda, ra_min, ra_max,
2014 dec_min, dec_max, lambda_min,
2016 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
2017 cpl_test_null(pErr);
2020 delta_lambda, ra_min, ra_max,
2021 dec_min, dec_max, 2,
2023 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
2024 cpl_test_null(pErr);
2027 delta_lambda, ra_min, ra_max,
2028 dec_min, dec_max, lambda_min,
2030 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
2031 cpl_test_null(pErr);
2033 return cpl_error_get_code();
2041static cpl_error_code
2042test_resample_outgrid_param(
void) {
2044 const double delta_ra = 0.1;
2045 const double delta_dec = 0.2;
2046 const double delta_lambda = 0.001;
2048 hdrl_resample_outgrid_parameter * aParams_outputgrid =
2049 cpl_calloc (1,
sizeof(hdrl_resample_outgrid_parameter));
2051 aParams_outputgrid->delta_ra = delta_ra;
2052 aParams_outputgrid->delta_dec = delta_dec;
2053 aParams_outputgrid->delta_lambda = delta_lambda;
2054 aParams_outputgrid->wcs = hdrl_resample_util_crea_wcs_2d();
2056 double ra_min = HDRL_RA_MIN;
2057 double ra_max = HDRL_RA_MIN;
2058 double dec_min = HDRL_DEC_MIN;
2059 double dec_max = HDRL_DEC_MIN;
2060 double lambda_min = HDRL_LAMBDA_MIN;
2061 double lambda_max = HDRL_LAMBDA_MIN;
2062 double field_margin = 5;
2063 aParams_outputgrid->dec_min = dec_min;
2064 aParams_outputgrid->dec_max = dec_max;
2065 aParams_outputgrid->ra_min = ra_min;
2066 aParams_outputgrid->ra_max = ra_max;
2067 aParams_outputgrid->lambda_min = lambda_min;
2068 aParams_outputgrid->lambda_max = lambda_max;
2069 hdrl_parameter* pErr = NULL;
2070 cpl_wcs_delete((cpl_wcs *)aParams_outputgrid->wcs);
2073 test_resample_invalid_input_outgrid_param(delta_ra, delta_dec, delta_lambda,
2074 ra_min, ra_max, dec_min, dec_max, lambda_min, lambda_max, field_margin);
2078 cpl_test_error(CPL_ERROR_NONE);
2079 cpl_test_nonnull(pErr);
2081 cpl_test_error(CPL_ERROR_NONE);
2084 cpl_test_error(CPL_ERROR_NONE);
2088 cpl_test_error(CPL_ERROR_NONE);
2089 cpl_test_nonnull(pErr);
2091 cpl_test_error(CPL_ERROR_NONE);
2094 cpl_test_error(CPL_ERROR_NONE);
2100 dec_min, dec_max, field_margin);
2101 cpl_test_error(CPL_ERROR_NONE);
2102 cpl_test_nonnull(pErr);
2104 cpl_test_error(CPL_ERROR_NONE);
2107 cpl_test_error(CPL_ERROR_NONE);
2112 delta_lambda, ra_min, ra_max,
2113 dec_min, dec_max, lambda_min,
2114 lambda_max,field_margin);
2115 cpl_test_error(CPL_ERROR_NONE);
2116 cpl_test_nonnull(pErr);
2119 cpl_test_error(CPL_ERROR_NONE);
2122 cpl_test_error(CPL_ERROR_NONE);
2125 cpl_free(aParams_outputgrid);
2127 return cpl_error_get_code();
2135static cpl_error_code
2136test_hdrl_resample_parameter_create_nearest(
void) {
2138 hdrl_parameter *pErr;
2141 cpl_test_error(CPL_ERROR_NONE);
2142 cpl_test_nonnull(pErr);
2146 cpl_test_nonnull(p);
2149 cpl_test_error(CPL_ERROR_NONE);
2152 cpl_test_error(CPL_ERROR_NONE);
2156 return cpl_error_get_code();
2164static cpl_error_code
2165test_hdrl_resample_parameter_create_lanczos(
void) {
2167 const double loop_distance = 2;
2168 const int kernel_size = 2;
2169 cpl_boolean use_errorweights= CPL_TRUE;
2170 hdrl_parameter *pErr;
2173 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
2176 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
2177 cpl_test_null(pErr);
2178 cpl_test_error(CPL_ERROR_NONE);
2184 cpl_test_error(CPL_ERROR_NONE);
2185 cpl_test_nonnull(p);
2188 cpl_test_error(CPL_ERROR_NONE);
2191 cpl_test_error(CPL_ERROR_NONE);
2195 return cpl_error_get_code();
2203static cpl_error_code
2204test_hdrl_resample_parameter_create_linear(
void) {
2206 const double loop_distance = 2;
2207 cpl_boolean use_errorweights= CPL_TRUE;
2209 hdrl_parameter *pErr;
2212 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
2213 cpl_test_null(pErr);
2218 cpl_test_error(CPL_ERROR_NONE);
2219 cpl_test_nonnull(p);
2222 cpl_test_error(CPL_ERROR_NONE);
2225 cpl_test_error(CPL_ERROR_NONE);
2229 return cpl_error_get_code();
2237static cpl_error_code
2238test_hdrl_resample_parameter_create_quadratic(
void) {
2240 const double loop_distance = 2;
2241 cpl_boolean use_errorweights= CPL_TRUE;
2242 hdrl_parameter *pErr;
2246 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
2247 cpl_test_null(pErr);
2252 cpl_test_error(CPL_ERROR_NONE);
2253 cpl_test_nonnull(p);
2256 cpl_test_error(CPL_ERROR_NONE);
2259 cpl_test_error(CPL_ERROR_NONE);
2263 return cpl_error_get_code();
2271static cpl_error_code
2272test_hdrl_resample_parameter_create_renka(
void) {
2274 const double loop_distance = 2;
2275 const double critical_radius_renka = 3;
2276 cpl_boolean use_errorweights= CPL_TRUE;
2277 hdrl_parameter *pErr;
2281 critical_radius_renka);
2282 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
2283 cpl_test_null(pErr);
2286 use_errorweights, -1);
2287 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
2288 cpl_test_null(pErr);
2293 critical_radius_renka);
2296 cpl_test_error(CPL_ERROR_NONE);
2299 cpl_test_error(CPL_ERROR_NONE);
2303 return cpl_error_get_code();
2305static cpl_error_code
2306test_invalid_input_hdrl_resample_parameter_create_drizzle(
2307 const double loop_distance,
2308 const double pix_frac_drizzle_x,
2309 const double pix_frac_drizzle_y,
2310 const double pix_frac_drizzle_lambda,
2311 cpl_boolean use_errorweights
2314 hdrl_parameter *pErr;
2320 pix_frac_drizzle_lambda);
2321 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
2322 cpl_test_null(pErr);
2327 pix_frac_drizzle_lambda);
2328 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
2329 cpl_test_null(pErr);
2334 pix_frac_drizzle_lambda);
2335 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
2336 cpl_test_null(pErr);
2342 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
2343 cpl_test_null(pErr);
2345 return cpl_error_get_code();
2353static cpl_error_code
2354test_hdrl_resample_parameter_create_drizzle(
void) {
2356 const double loop_distance = 2;
2357 const double pix_frac_drizzle_x = 0.8;
2358 const double pix_frac_drizzle_y = 0.8;
2359 const double pix_frac_drizzle_lambda = 1;
2360 cpl_boolean use_errorweights= CPL_TRUE;
2363 test_invalid_input_hdrl_resample_parameter_create_drizzle(loop_distance,
2364 pix_frac_drizzle_x, pix_frac_drizzle_y, pix_frac_drizzle_lambda,
2372 pix_frac_drizzle_lambda);
2375 cpl_test_error(CPL_ERROR_NONE);
2378 cpl_test_error(CPL_ERROR_NONE);
2382 return cpl_error_get_code();
2390static cpl_error_code
2391test_resample_parameters(
void) {
2393 test_resample_outgrid_param();
2394 cpl_test_error(CPL_ERROR_NONE);
2396 test_hdrl_resample_parameter_create_nearest();
2397 cpl_test_error(CPL_ERROR_NONE);
2399 test_hdrl_resample_parameter_create_lanczos();
2400 cpl_test_error(CPL_ERROR_NONE);
2402 test_hdrl_resample_parameter_create_linear();
2403 cpl_test_error(CPL_ERROR_NONE);
2405 test_hdrl_resample_parameter_create_quadratic();
2406 cpl_test_error(CPL_ERROR_NONE);
2408 test_hdrl_resample_parameter_create_renka();
2409 cpl_test_error(CPL_ERROR_NONE);
2411 test_hdrl_resample_parameter_create_drizzle();
2412 cpl_test_error(CPL_ERROR_NONE);
2414 return cpl_error_get_code();
2422static cpl_error_code
2423test_hdrl_resample_parameter_create_outgrid2D(
void){
2424 const double delta_ra = 0.1;
2425 const double delta_dec = 0.1;
2426 hdrl_parameter *pErr;
2430 cpl_test_error(CPL_ERROR_NONE);
2431 cpl_test_nonnull(pErr);
2434 cpl_test_error(CPL_ERROR_NONE);
2437 cpl_test_error(CPL_ERROR_NONE);
2439 return cpl_error_get_code();
2447static cpl_error_code
2448test_hdrl_resample_parameter_create_outgrid3D(
void){
2449 const double delta_ra = 0.1;
2450 const double delta_dec = 0.1;
2451 const double delta_lambda = 0.1;
2452 hdrl_parameter *pErr;
2458 cpl_test_error(CPL_ERROR_NONE);
2459 cpl_test_nonnull(pErr);
2462 cpl_test_error(CPL_ERROR_NONE);
2465 cpl_test_error(CPL_ERROR_NONE);
2467 return cpl_error_get_code();
2470static cpl_error_code
2471test_invalid_input_hdrl_resample_parameter_create_outgrid2D_userdef(
2472 const double delta_ra,
2473 const double delta_dec,
2474 const double ra_min,
2475 const double ra_max,
2476 const double dec_min,
2477 const double dec_max,
2478 const double fieldmargin
2481 hdrl_parameter *pErr;
2488 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
2489 cpl_test_null(pErr);
2495 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
2496 cpl_test_null(pErr);
2502 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
2503 cpl_test_null(pErr);
2505 return cpl_error_get_code();
2513static cpl_error_code
2514test_hdrl_resample_parameter_create_outgrid2D_userdef(
void){
2515 const double delta_ra = 0.1;
2516 const double delta_dec = 0.1;
2517 const double ra_min = 1;
2518 const double ra_max = 2;
2519 const double dec_min = 0;
2520 const double dec_max = 1;
2521 double fieldmargin = 5;
2522 hdrl_parameter *pErr;
2525 test_invalid_input_hdrl_resample_parameter_create_outgrid2D_userdef(delta_ra,
2527 ra_min, ra_max, dec_min, dec_max, fieldmargin);
2533 cpl_test_error(CPL_ERROR_NONE);
2534 cpl_test_nonnull(pErr);
2537 cpl_test_error(CPL_ERROR_NONE);
2540 cpl_test_error(CPL_ERROR_NONE);
2542 return cpl_error_get_code();
2544static cpl_error_code
2545test_invalid_input_hdrl_resample_parameter_create_outgrid3D_userdef(
2546 const double delta_ra,
2547 const double delta_dec,
2548 const double delta_lambda,
2549 const double ra_min,
2550 const double ra_max,
2551 const double dec_min,
2552 const double dec_max,
2553 const double lambda_min,
2554 const double lambda_max,
2555 const double fieldmargin
2557 hdrl_parameter *pErr;
2564 lambda_min, lambda_max,
2566 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
2567 cpl_test_null(pErr);
2573 lambda_min, lambda_max,
2575 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
2576 cpl_test_null(pErr);
2584 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
2585 cpl_test_null(pErr);
2591 lambda_min, lambda_max,
2593 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
2594 cpl_test_null(pErr);
2596 return cpl_error_get_code();
2604static cpl_error_code
2605test_hdrl_resample_parameter_create_outgrid3D_userdef(
void){
2606 const double delta_ra = 0.1;
2607 const double delta_dec = 0.1;
2608 const double delta_lambda = 0.1;
2609 const double ra_min = 1;
2610 const double ra_max = 2;
2611 const double dec_min = 0;
2612 const double dec_max = 1;
2613 const double lambda_min = 500;
2614 const double lambda_max = 550;
2616 double fieldmargin = 5;
2617 hdrl_parameter *pErr;
2620 test_invalid_input_hdrl_resample_parameter_create_outgrid3D_userdef(delta_ra,
2621 delta_dec, delta_lambda, ra_min, ra_max, dec_min, dec_max, lambda_min,
2622 lambda_max, fieldmargin);
2628 lambda_min, lambda_max,
2630 cpl_test_error(CPL_ERROR_NONE);
2631 cpl_test_nonnull(pErr);
2634 cpl_test_error(CPL_ERROR_NONE);
2637 cpl_test_error(CPL_ERROR_NONE);
2640 return cpl_error_get_code();
2648static cpl_error_code
2649test_hdrl_resample_wcs_print(
void){
2651 cpl_wcs* wcs = NULL;
2654 hdrl_resample_wcs_print(NULL);
2655 cpl_test_error(CPL_ERROR_NULL_INPUT);
2658 wcs = hdrl_resample_util_crea_wcs_3d();
2659 hdrl_resample_wcs_print(wcs);
2660 cpl_test_error(CPL_ERROR_NONE);
2661 cpl_wcs_delete(wcs);
2664 wcs = hdrl_resample_util_crea_wcs_2d();
2665 hdrl_resample_wcs_print(wcs);
2666 cpl_test_error(CPL_ERROR_NONE);
2667 cpl_wcs_delete(wcs);
2669 return cpl_error_get_code();
2678static cpl_error_code
2679hdrl_resample_util_fill_outputgrid(hdrl_resample_outgrid_parameter * aParams_outputgrid)
2682 cpl_wcs* wcs = hdrl_resample_util_crea_wcs_2d();
2683 cpl_test_nonnull(wcs);
2685 aParams_outputgrid->wcs = wcs;
2688 cpl_boolean recalc_limits = aParams_outputgrid->recalc_limits;
2690 if (recalc_limits == CPL_TRUE) {
2692 aParams_outputgrid->ra_min = HDRL_RA_MIN;
2693 aParams_outputgrid->ra_max = HDRL_RA_MAX;
2694 aParams_outputgrid->dec_min = HDRL_DEC_MIN;
2695 aParams_outputgrid->dec_max = HDRL_DEC_MAX;
2696 aParams_outputgrid->lambda_min = HDRL_LAMBDA_MIN;
2697 aParams_outputgrid->lambda_max = HDRL_LAMBDA_MAX;
2699 cpl_test_error(CPL_ERROR_NONE);
2700 return cpl_error_get_code();
2709static cpl_error_code
2710test_hdrl_resample_outgrid_parameter_print(
void){
2713 hdrl_resample_outgrid_parameter_print(NULL);
2714 cpl_test_error(CPL_ERROR_NULL_INPUT);
2716 hdrl_parameter * outputgrid =
2719 hdrl_resample_outgrid_parameter *aParams_outputgrid =
2720 (hdrl_resample_outgrid_parameter *) outputgrid;
2722 cpl_test_nonnull(aParams_outputgrid);
2725 hdrl_resample_util_fill_outputgrid(aParams_outputgrid);
2726 cpl_test_error(CPL_ERROR_NONE);
2729 hdrl_resample_outgrid_parameter_print(aParams_outputgrid);
2730 cpl_test_error(CPL_ERROR_NONE);
2732 cpl_wcs_delete((cpl_wcs *)aParams_outputgrid->wcs);
2733 cpl_free(aParams_outputgrid);
2735 return cpl_error_get_code();
2743static cpl_error_code
2744test_hdrl_resample_method_parameter_print(
void){
2747 hdrl_resample_method_parameter_print(NULL);
2748 cpl_test_error(CPL_ERROR_NULL_INPUT);
2751 hdrl_resample_method_parameter * pwrong =
2752 (hdrl_resample_method_parameter *) wrong;
2753 cpl_test_nonnull(pwrong);
2754 hdrl_resample_method_parameter_print(pwrong);
2755 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
2760 hdrl_resample_method_parameter * p =
2761 (hdrl_resample_method_parameter *) method;
2762 cpl_test_nonnull(p);
2764 hdrl_resample_method_parameter_print(p);
2765 cpl_test_error(CPL_ERROR_NONE);
2768 return cpl_error_get_code();
2776static cpl_error_code
2777test_hdrl_wcs_xy_to_radec(
void) {
2785 hdrl_wcs_xy_to_radec(NULL, x, y, &ra, &dec);
2786 cpl_test_error(CPL_ERROR_NULL_INPUT);
2788 cpl_wcs* wcs = hdrl_resample_util_crea_wcs_2d();
2789 cpl_test_nonnull(wcs);
2791 hdrl_wcs_xy_to_radec(wcs, x, y, NULL, &dec);
2792 cpl_test_error(CPL_ERROR_NULL_INPUT);
2794 hdrl_wcs_xy_to_radec(wcs, x, y, &ra, NULL);
2795 cpl_test_error(CPL_ERROR_NULL_INPUT);
2798 hdrl_wcs_xy_to_radec(wcs, x, y, &ra, &dec);
2799 cpl_test_error(CPL_ERROR_NONE);
2800 cpl_msg_warning(cpl_func,
"ra: %20.18g",ra);
2801 cpl_msg_warning(cpl_func,
"dec: %20.18g",dec);
2802 cpl_test_abs(48.0716937492999961, ra, HDRL_EPS_TEST);
2803 cpl_test_abs(-20.6229937493000008, dec, HDRL_EPS_TEST);
2805 cpl_wcs_delete(wcs);
2806 cpl_test_error(CPL_ERROR_NONE);
2807 return cpl_error_get_code();
2815static cpl_error_code
2816test_hdrl_resample_pfits_get(
void) {
2818 cpl_wcs* wcs = hdrl_resample_util_crea_wcs_3d();
2819 cpl_test_nonnull(wcs);
2820 cpl_propertylist* header = cpl_propertylist_new();
2821 hdrl_wcs_to_propertylist(wcs, header, CPL_FALSE);
2822 cpl_test_nonnull(header);
2828 crpix = hdrl_resample_pfits_get_crpix(NULL, 1);
2829 cpl_test_error(CPL_ERROR_NULL_INPUT);
2830 cpl_test_abs(crpix, 0, HDRL_EPS_TEST);
2832 crval = hdrl_resample_pfits_get_crval(NULL, 1);
2833 cpl_test_error(CPL_ERROR_NULL_INPUT);
2834 cpl_test_abs(crval, 0, HDRL_EPS_TEST);
2836 cd = hdrl_resample_pfits_get_cd(NULL, 1, 1);
2837 cpl_test_error(CPL_ERROR_NULL_INPUT);
2838 cpl_test_abs(cd, 0, HDRL_EPS_TEST);
2841 cpl_test_abs(HDRL_CRPIX1,hdrl_resample_pfits_get_crpix(header, 1), HDRL_EPS_TEST);
2842 cpl_test_abs(HDRL_CRPIX2,hdrl_resample_pfits_get_crpix(header, 2), HDRL_EPS_TEST);
2843 cpl_test_abs(HDRL_CRPIX3,hdrl_resample_pfits_get_crpix(header, 3), HDRL_EPS_TEST);
2845 cpl_test_abs(HDRL_CRVAL1,hdrl_resample_pfits_get_crval(header, 1), HDRL_EPS_TEST);
2846 cpl_test_abs(HDRL_CRVAL2,hdrl_resample_pfits_get_crval(header, 2), HDRL_EPS_TEST);
2847 cpl_test_abs(HDRL_CRVAL3,hdrl_resample_pfits_get_crval(header, 3), HDRL_EPS_TEST);
2849 cpl_test_abs(HDRL_CD11,hdrl_resample_pfits_get_cd(header, 1, 1), HDRL_EPS_TEST);
2850 cpl_test_abs(HDRL_CD12,hdrl_resample_pfits_get_cd(header, 1, 2), HDRL_EPS_TEST);
2851 cpl_test_abs(HDRL_CD21,hdrl_resample_pfits_get_cd(header, 2, 1), HDRL_EPS_TEST);
2852 cpl_test_abs(HDRL_CD22,hdrl_resample_pfits_get_cd(header, 2, 2), HDRL_EPS_TEST);
2854 cpl_test_abs(HDRL_CD13,hdrl_resample_pfits_get_cd(header, 1, 3), HDRL_EPS_TEST);
2855 cpl_test_abs(HDRL_CD31,hdrl_resample_pfits_get_cd(header, 3, 1), HDRL_EPS_TEST);
2856 cpl_test_abs(HDRL_CD23,hdrl_resample_pfits_get_cd(header, 2, 3), HDRL_EPS_TEST);
2857 cpl_test_abs(HDRL_CD32,hdrl_resample_pfits_get_cd(header, 3, 1), HDRL_EPS_TEST);
2858 cpl_test_abs(HDRL_CD33,hdrl_resample_pfits_get_cd(header, 3, 3), HDRL_EPS_TEST);
2860 cpl_propertylist_delete(header);
2861 cpl_wcs_delete(wcs);
2862 cpl_test_error(CPL_ERROR_NONE);
2863 return cpl_error_get_code();
2871static cpl_error_code
2872test_hdrl_resample_smallwcs_new(
void){
2874 cpl_wcs* wcs = hdrl_resample_util_crea_wcs_3d();
2875 cpl_test_nonnull(wcs);
2876 cpl_propertylist* header = cpl_propertylist_new();
2877 hdrl_wcs_to_propertylist(wcs, header, CPL_FALSE);
2878 cpl_test_nonnull(header);
2881 hdrl_resample_smallwcs* swcs = NULL;
2882 swcs = hdrl_resample_smallwcs_new(NULL);
2883 cpl_test_error(CPL_ERROR_NULL_INPUT);
2884 cpl_test_null(swcs);
2887 swcs = hdrl_resample_smallwcs_new(header);
2888 cpl_test_nonnull(swcs);
2889 cpl_test_error(CPL_ERROR_NONE);
2890 cpl_test_nonnull(swcs);
2892 cpl_test_rel(swcs->cd11, HDRL_CD11, HDRL_EPS_TEST);
2893 cpl_test_rel(swcs->cd22, HDRL_CD22, HDRL_EPS_TEST);
2894 cpl_test_rel(swcs->cd12, HDRL_CD12, HDRL_EPS_TEST);
2895 cpl_test_rel(swcs->cd21, HDRL_CD21, HDRL_EPS_TEST);
2896 cpl_test_rel(swcs->crpix1, HDRL_CRPIX1, HDRL_EPS_TEST);
2897 cpl_test_rel(swcs->crpix2, HDRL_CRPIX2, HDRL_EPS_TEST);
2898 cpl_test_rel(swcs->crval1, HDRL_CRVAL1, HDRL_EPS_TEST);
2899 cpl_test_rel(swcs->crval2, HDRL_CRVAL2, HDRL_EPS_TEST);
2902 cpl_propertylist_erase(header,
"CRPIX1");
2903 swcs = hdrl_resample_smallwcs_new(header);
2904 cpl_test_nonnull(swcs);
2905 cpl_test_error(CPL_ERROR_NONE);
2906 cpl_test_nonnull(swcs);
2907 cpl_test_rel(swcs->crpix1, 0., HDRL_EPS_TEST);
2910 cpl_propertylist_erase(header,
"CD1_1");
2911 swcs = hdrl_resample_smallwcs_new(header);
2912 cpl_test_nonnull(swcs);
2913 cpl_test_error(CPL_ERROR_SINGULAR_MATRIX);
2916 cpl_propertylist_erase_regexp(header,
"CD?_?", 0);
2917 swcs = hdrl_resample_smallwcs_new(header);
2918 cpl_test_nonnull(swcs);
2919 cpl_test_error(CPL_ERROR_NONE);
2920 cpl_test_nonnull(swcs);
2921 cpl_test_rel(swcs->crpix1, 0., HDRL_EPS_TEST);
2924 cpl_wcs_delete(wcs);
2925 cpl_propertylist_delete(header);
2926 cpl_test_error(CPL_ERROR_NONE);
2927 return cpl_error_get_code();
2935static hdrl_resample_pixgrid*
2936hdrl_resample_util_pixgrid_new(
void) {
2938 cpl_size aSizeX = 10;
2939 cpl_size aSizeY = 10;
2940 cpl_size aSizeZ = 10;
2941 unsigned short aNMaps = 10;
2944 hdrl_resample_pixgrid *aGrid =
2945 hdrl_resample_pixgrid_new(aSizeX, aSizeY, aSizeZ, aNMaps);
2955static cpl_error_code
2956test_hdrl_resample_pixgrid_delete(
void) {
2959 hdrl_resample_pixgrid_delete(NULL);
2963 hdrl_resample_pixgrid *aGrid = hdrl_resample_util_pixgrid_new();
2964 cpl_test_nonnull(aGrid);
2966 hdrl_resample_pixgrid_delete(aGrid);
2967 cpl_test_error(CPL_ERROR_NONE);
2969 return cpl_error_get_code();
2978hdrl_resample_util_crea_pixel_table()
2980 cpl_wcs* wcs = hdrl_resample_util_crea_wcs_3d();
2981 cpl_imagelist* ilist = NULL;
2982 cpl_imagelist* elist = NULL;
2984 ilist = cpl_imagelist_new();
2985 elist = cpl_imagelist_new();
2986 cpl_image* simul = hdrl_resample_util_crea_image_dice_5(HDRL_SIZE_X, HDRL_SIZE_X,
2988 cpl_image* errs = cpl_image_duplicate(simul);
2989 cpl_image_power(errs, 0.5);
2990 cpl_imagelist_set(ilist, simul, 0);
2991 cpl_imagelist_set(elist, errs, 0);
2992 hdrl_imagelist* hlist = hdrl_resample_util_hdrl_imagelist_create(ilist,
2996 cpl_imagelist_delete(ilist);
2997 cpl_imagelist_delete(elist);
3000 cpl_wcs_delete(wcs);
3001 cpl_test_error(CPL_ERROR_NONE);
3014static cpl_error_code
3015test_hdrl_resample_compute_method(hdrl_resample_method aMethod,
3016 cpl_boolean use_errorweights) {
3018 const double delta_ra = HDRL_CDELT1;
3019 const double delta_dec = HDRL_CDELT2;
3020 const double delta_lambda = HDRL_CDELT3;
3021 const double ramin = HDRL_RA_MIN;
3022 const double ramax = HDRL_RA_MAX;
3023 const double decmin = HDRL_DEC_MIN;
3024 const double decmax = HDRL_DEC_MAX;
3025 const double lambmin = HDRL_LAMBDA_MIN;
3026 const double lambmax = HDRL_LAMBDA_MAX;
3028 cpl_wcs* wcs = hdrl_resample_util_crea_wcs_3d();
3030 cpl_table* pixel_table = hdrl_resample_util_crea_pixel_table();
3032 hdrl_parameter * aParams_method =
3033 hdrl_resample_util_methodparam_create (
3035 RENKA_CRITICAL_RADIUS,
3036 LANCZOS_KERNEL_SIZE,
3037 DRIZZLE_DOWN_SCALING_FACTOR_X,
3038 DRIZZLE_DOWN_SCALING_FACTOR_Y,
3039 DRIZZLE_DOWN_SCALING_FACTOR_Z,
3040 aMethod, use_errorweights);
3042 hdrl_parameter* aParams_outputgrid =
3044 delta_lambda, ramin, ramax, decmin, decmax, lambmin, lambmax, 0.);
3048 int sx = HDRL_SIZE_X, sy = HDRL_SIZE_Z, sz = HDRL_SIZE_Z;
3049 cpl_image* ima = cpl_image_new(sx, sy, CPL_TYPE_INT);
3050 cpl_image_add_scalar(ima, 1);
3051 cpl_imagelist* iml = cpl_imagelist_new();
3052 for(
int i = 0; i< sz;i++) {
3053 cpl_imagelist_set(iml, ima, i);
3055 hdrl_imagelist* hlist = hdrl_resample_util_hdrl_imagelist_create(iml,
3059 cpl_imagelist_delete(iml);
3062 cpl_test_error(CPL_ERROR_NONE);
3063 cpl_test_nonnull(ResTable);
3064 cpl_test_nonnull(aParams_method);
3065 cpl_test_nonnull(aParams_outputgrid);
3066 cpl_test_nonnull(wcs);
3067 hdrl_resample_result *cube =
3070 cpl_test_nonnull(cube);
3071 cpl_test_error(CPL_ERROR_NONE);
3077 aParams_outputgrid =
3084 cpl_test_nonnull(cube);
3085 cpl_test_error(CPL_ERROR_NONE);
3089 aParams_outputgrid =
3098 cpl_test_nonnull(cube);
3099 cpl_test_error(CPL_ERROR_NONE);
3103 cpl_table_delete(ResTable);
3104 cpl_wcs_delete(wcs);
3105 cpl_table_delete(pixel_table);
3108 return cpl_error_get_code();
3116static cpl_error_code
3117test_hdrl_resample_compute(
void) {
3119 test_hdrl_resample_compute_method(HDRL_RESAMPLE_METHOD_NEAREST, CPL_TRUE);
3120 cpl_test_error(CPL_ERROR_NONE);
3121 test_hdrl_resample_compute_method(HDRL_RESAMPLE_METHOD_RENKA, CPL_TRUE);
3122 cpl_test_error(CPL_ERROR_NONE);
3123 test_hdrl_resample_compute_method(HDRL_RESAMPLE_METHOD_LINEAR, CPL_TRUE);
3124 cpl_test_error(CPL_ERROR_NONE);
3125 test_hdrl_resample_compute_method(HDRL_RESAMPLE_METHOD_QUADRATIC, CPL_TRUE);
3126 cpl_test_error(CPL_ERROR_NONE);
3127 test_hdrl_resample_compute_method(HDRL_RESAMPLE_METHOD_DRIZZLE, CPL_TRUE);
3128 cpl_test_error(CPL_ERROR_NONE);
3129 test_hdrl_resample_compute_method(HDRL_RESAMPLE_METHOD_LANCZOS, CPL_TRUE);
3130 cpl_test_error(CPL_ERROR_NONE);
3131 test_hdrl_resample_compute_method(HDRL_RESAMPLE_METHOD_NONE, CPL_TRUE);
3132 cpl_test_error(CPL_ERROR_NONE);
3133 test_hdrl_resample_compute_method(HDRL_RESAMPLE_METHOD_LINEAR, CPL_FALSE);
3134 cpl_test_error(CPL_ERROR_NONE);
3136 return cpl_error_get_code();
3144static cpl_error_code
3145test_hdrl_resample_wcs_projplane_from_celestial(
void) {
3147 hdrl_parameter * outputgrid =
3150 hdrl_resample_outgrid_parameter *pogrid =
3151 (hdrl_resample_outgrid_parameter *) outputgrid;
3153 double ra = HDRL_RA;
3154 double dec = HDRL_DEC;
3155 double x_out = HDRL_RA;
3156 double y_out = HDRL_DEC;
3159 hdrl_resample_wcs_projplane_from_celestial(NULL, ra, dec, &x_out, &y_out);
3160 cpl_test_error(CPL_ERROR_NULL_INPUT);
3163 hdrl_resample_util_fill_outputgrid(pogrid);
3164 hdrl_resample_wcs_projplane_from_celestial(pogrid, ra, dec, &x_out, &y_out);
3165 cpl_test_error(CPL_ERROR_NONE);
3166 cpl_test_abs(x_out, -0.000561558354797, HDRL_DELTA_COMPARE_VALUE_ABS);
3167 cpl_test_abs(y_out, 0.000899999036676, HDRL_DELTA_COMPARE_VALUE_ABS);
3169 cpl_wcs_delete((cpl_wcs *)pogrid->wcs);
3171 cpl_test_error(CPL_ERROR_NONE);
3172 return cpl_error_get_code();
3181static cpl_error_code
3182test_hdrl_resample_wcs_pixel_from_celestial_fast(
void){
3184 double ra = HDRL_RA;
3185 double dec = HDRL_DEC;
3186 double x_out = HDRL_RA;
3187 double y_out = HDRL_DEC;
3189 hdrl_resample_wcs_pixel_from_celestial_fast(NULL, ra, dec, &x_out, &y_out);
3190 cpl_wcs* wcs = hdrl_resample_util_crea_wcs_3d();
3191 cpl_test_nonnull(wcs);
3192 cpl_propertylist* header = cpl_propertylist_new();
3193 hdrl_wcs_to_propertylist(wcs, header, CPL_FALSE);
3194 cpl_test_nonnull(header);
3196 hdrl_resample_smallwcs * swcs = hdrl_resample_smallwcs_new(header);
3197 cpl_test_nonnull(swcs);
3199 hdrl_resample_wcs_pixel_from_celestial_fast(swcs, ra, dec, &x_out, &y_out);
3200 cpl_test_error(CPL_ERROR_NONE);
3206 cpl_test_rel(x_out, -163.82544787203, 1.e-11);
3207 cpl_test_rel(y_out, 1518.66596649235, 1.e-11);
3210 cpl_wcs_delete(wcs);
3211 cpl_propertylist_delete(header);
3212 cpl_test_error(CPL_ERROR_NONE);
3213 return cpl_error_get_code();
3222static cpl_error_code
3223test_hdrl_resample_compute_size(
void){
3225 hdrl_parameter * outputgrid =
3228 hdrl_resample_outgrid_parameter *pogrid =
3229 (hdrl_resample_outgrid_parameter *) outputgrid;
3234 hdrl_resample_compute_size(NULL, &x, &y, &z);
3235 cpl_test_error(CPL_ERROR_NULL_INPUT);
3238 hdrl_resample_util_fill_outputgrid(pogrid);
3239 hdrl_resample_compute_size(pogrid, &x, &y, &z);
3240 cpl_test_error(CPL_ERROR_NONE);
3242 cpl_test_eq(x, 225);
3243 cpl_test_eq(y, 229);
3246 cpl_wcs_delete((cpl_wcs *)pogrid->wcs);
3248 cpl_test_error(CPL_ERROR_NONE);
3249 return cpl_error_get_code();
3257static cpl_error_code
3258test_hdrl_resample_pixgrid_add(
void){
3260 hdrl_resample_pixgrid *aGrid = hdrl_resample_util_pixgrid_new();
3261 cpl_test_nonnull(aGrid);
3263 cpl_size aIndex = 1;
3265 unsigned short aXIdx = 1;
3268 hdrl_resample_pixgrid_add(NULL, aIndex, aRow, aXIdx);
3269 hdrl_resample_pixgrid_add(aGrid, -1, aRow, aXIdx);
3272 hdrl_resample_pixgrid_add(aGrid, aIndex, aRow, aXIdx);
3274 cpl_test_error(CPL_ERROR_NONE);
3276 hdrl_resample_pixgrid_delete(aGrid);
3277 cpl_test_error(CPL_ERROR_NONE);
3279 return cpl_error_get_code();
3287static cpl_error_code
3288test_hdrl_resample_pixgrid_get_count(
void){
3289 cpl_size aIndex = 1;
3291 hdrl_resample_pixgrid_get_count(NULL, aIndex);
3293 hdrl_resample_pixgrid *aGrid = hdrl_resample_util_pixgrid_new();
3294 cpl_test_nonnull(aGrid);
3296 hdrl_resample_pixgrid_get_count(aGrid, -1);
3299 cpl_size n = hdrl_resample_pixgrid_get_count(aGrid, aIndex);
3301 cpl_test_rel(n, 0, HDRL_EPS_TEST);
3303 hdrl_resample_pixgrid_delete(aGrid);
3304 cpl_test_error(CPL_ERROR_NONE);
3305 return cpl_error_get_code();
3314static cpl_error_code
3315test_hdrl_resample_pixgrid_get_index(
void)
3320 cpl_boolean aAllowOutside = CPL_TRUE;
3322 hdrl_resample_pixgrid *aGrid = hdrl_resample_util_pixgrid_new();
3323 cpl_test_nonnull(aGrid);
3324 cpl_msg_warning(cpl_func,
"x: %lld",aGrid->nx);
3325 cpl_msg_warning(cpl_func,
"y: %lld",aGrid->ny);
3326 cpl_msg_warning(cpl_func,
"z: %lld",aGrid->nz);
3330 index = hdrl_resample_pixgrid_get_index(NULL, x, y, z, aAllowOutside);
3331 cpl_test_eq(index, -1);
3332 index = hdrl_resample_pixgrid_get_index(aGrid, -1, y, z, CPL_FALSE);
3333 cpl_test_eq(index, -1);
3334 index = hdrl_resample_pixgrid_get_index(aGrid, x, -1, z, CPL_FALSE);
3335 cpl_test_eq(index, -1);
3336 index = hdrl_resample_pixgrid_get_index(aGrid, x, y, -1, CPL_FALSE);
3337 cpl_test_eq(index, -1);
3339 index = hdrl_resample_pixgrid_get_index(aGrid, aGrid->nx+1, y, z, CPL_FALSE);
3340 cpl_test_eq(index, -1);
3341 index = hdrl_resample_pixgrid_get_index(aGrid, x, aGrid->ny+1, z, CPL_FALSE);
3342 cpl_test_eq(index, -1);
3343 index = hdrl_resample_pixgrid_get_index(aGrid, x, y, aGrid->nz+1, CPL_FALSE);
3344 cpl_test_eq(index, -1);
3346 index = hdrl_resample_pixgrid_get_index(aGrid, aGrid->nx + 1, y, z, CPL_TRUE);
3347 cpl_test_eq(index, 119);
3348 index = hdrl_resample_pixgrid_get_index(aGrid, x, aGrid->ny + 1, z, CPL_TRUE);
3349 cpl_test_eq(index, 191);
3350 index = hdrl_resample_pixgrid_get_index(aGrid, x, y, aGrid->nz + 1, CPL_TRUE);
3351 cpl_test_eq(index, 911);
3354 cpl_size index_res = 111;
3355 cpl_msg_warning(cpl_func,
"index: %lld",
3356 hdrl_resample_pixgrid_get_index(aGrid, x, y, z, aAllowOutside));
3357 index = hdrl_resample_pixgrid_get_index(aGrid, x, y, z, aAllowOutside);
3358 cpl_test_eq(index_res, index);
3360 hdrl_resample_pixgrid_delete(aGrid);
3361 cpl_test_error(CPL_ERROR_NONE);
3362 return cpl_error_get_code();
3370static cpl_error_code
3371test_hdrl_resample_pixgrid_new(
void) {
3375 unsigned short aNMaps = 1;
3376 hdrl_resample_pixgrid * pGrid = NULL;
3379 pGrid = hdrl_resample_pixgrid_new(-1, y, z, aNMaps);
3380 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
3381 cpl_test_null(pGrid);
3383 pGrid = hdrl_resample_pixgrid_new(x, -1, z, aNMaps);
3384 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
3385 cpl_test_null(pGrid);
3387 pGrid = hdrl_resample_pixgrid_new(x, y, -1, aNMaps);
3388 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
3389 cpl_test_null(pGrid);
3391 pGrid = hdrl_resample_pixgrid_new(x, y, z, 0);
3392 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
3393 cpl_test_null(pGrid);
3396 pGrid = hdrl_resample_pixgrid_new(x, y, z, aNMaps);
3397 cpl_test_error(CPL_ERROR_NONE);
3398 cpl_test_nonnull(pGrid);
3400 hdrl_resample_pixgrid_delete(pGrid);
3401 return cpl_error_get_code();
3409static cpl_error_code
3410test_hdrl_resample_pixgrid_create(
void) {
3415 cpl_table* pixel_table = NULL;
3416 cpl_wcs* wcs = hdrl_resample_util_crea_wcs_3d();
3417 cpl_test_nonnull(wcs);
3418 cpl_propertylist* header = cpl_propertylist_new();
3419 hdrl_wcs_to_propertylist(wcs, header, CPL_FALSE);
3420 hdrl_resample_pixgrid * pGrid= NULL;
3423 pixel_table = cpl_table_new(0);
3424 pGrid = hdrl_resample_pixgrid_create(pixel_table, header, x, y, z);
3425 cpl_test_error(CPL_ERROR_NULL_INPUT);
3426 cpl_test_null(pGrid);
3427 cpl_table_delete(pixel_table);
3429 pixel_table = cpl_table_new(1);
3430 pGrid = hdrl_resample_pixgrid_create(pixel_table, header, x, y, z);
3431 cpl_test_error(CPL_ERROR_DATA_NOT_FOUND);
3432 cpl_test_null(pGrid);
3433 cpl_table_delete(pixel_table);
3435 pixel_table = hdrl_resample_util_crea_pixel_table();
3438 pGrid = hdrl_resample_pixgrid_create(pixel_table, NULL, x, y, z);
3439 cpl_test_error(CPL_ERROR_NULL_INPUT);
3440 cpl_test_null(pGrid);
3442 pGrid = hdrl_resample_pixgrid_create(pixel_table, header, -1, y, z);
3443 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
3444 cpl_test_null(pGrid);
3446 pGrid = hdrl_resample_pixgrid_create(pixel_table, header, x, -1, z);
3447 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
3448 cpl_test_null(pGrid);
3450 pGrid = hdrl_resample_pixgrid_create(pixel_table, header, x, y, -1);
3451 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
3452 cpl_test_null(pGrid);
3455 pGrid = hdrl_resample_pixgrid_create(pixel_table, header, x, y, z);
3456 cpl_test_error(CPL_ERROR_NONE);
3457 cpl_test_nonnull(pGrid);
3458 hdrl_resample_pixgrid_delete(pGrid);
3460 cpl_table_unselect_row(pixel_table, 1);
3461 pGrid = hdrl_resample_pixgrid_create(pixel_table, header, x, y, z);
3462 cpl_test_error(CPL_ERROR_NONE);
3463 cpl_test_nonnull(pGrid);
3465 cpl_wcs_delete(wcs);
3466 cpl_table_delete(pixel_table);
3467 cpl_propertylist_delete(header);
3468 hdrl_resample_pixgrid_delete(pGrid);
3469 return cpl_error_get_code();
3477static cpl_error_code
3478test_hdrl_resample_wcs_get_scales(
void) {
3482 hdrl_parameter * outputgrid =
3485 hdrl_resample_outgrid_parameter *pogrid =
3486 (hdrl_resample_outgrid_parameter *) outputgrid;
3487 hdrl_resample_util_fill_outputgrid(pogrid);
3490 hdrl_resample_method_parameter * p =
3491 (hdrl_resample_method_parameter *) method;
3492 cpl_test_nonnull(p);
3495 hdrl_resample_wcs_get_scales(NULL, &aXScale, &aYScale);
3496 cpl_test_error(CPL_ERROR_NULL_INPUT);
3498 hdrl_resample_wcs_get_scales(pogrid, NULL, &aYScale);
3499 cpl_test_error(CPL_ERROR_NULL_INPUT);
3501 hdrl_resample_wcs_get_scales(pogrid, &aXScale, NULL);
3502 cpl_test_error(CPL_ERROR_NULL_INPUT);
3505 hdrl_resample_wcs_get_scales(pogrid, &aXScale, &aYScale);
3506 cpl_msg_warning(cpl_func,
"x: %16.10g",aXScale);
3507 cpl_msg_warning(cpl_func,
"y: %16.10g",aYScale);
3508 cpl_test_error(CPL_ERROR_NONE);
3510 cpl_wcs_delete((cpl_wcs *)pogrid->wcs);
3513 return cpl_error_get_code();
3521static cpl_error_code
3522test_hdrl_resample_create_table(
void){
3524 const cpl_size size = 10;
3525 cpl_table* tab = NULL;
3528 hdrl_resample_create_table(NULL, size);
3529 cpl_test_error(CPL_ERROR_NULL_INPUT);
3531 hdrl_resample_create_table(&tab, -1);
3532 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
3535 hdrl_resample_create_table(&tab, size);
3536 cpl_test_error(CPL_ERROR_NONE);
3538 cpl_table_delete(tab);
3539 return cpl_error_get_code();
3547static cpl_error_code
3548test_hdrl_resample_pixgrid_get_rows(
void) {
3550 cpl_size aIndex = 1;
3551 hdrl_resample_pixgrid *aGrid = NULL;
3555 unsigned short aNMaps = 1;
3558 hdrl_resample_pixgrid_get_rows(NULL, aIndex);
3559 cpl_test_error(CPL_ERROR_NULL_INPUT);
3561 aGrid = hdrl_resample_pixgrid_new(x, y, z, aNMaps);
3562 cpl_test_error(CPL_ERROR_NONE);
3563 cpl_test_nonnull(aGrid);
3565 hdrl_resample_pixgrid_get_rows(aGrid, -1);
3566 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
3569 hdrl_resample_pixgrid_get_rows(aGrid, aIndex);
3570 cpl_test_error(CPL_ERROR_NONE);
3571 hdrl_resample_pixgrid_delete(aGrid);
3573 return cpl_error_get_code();
3581static cpl_error_code
3582test_hdrl_resample_cube_nearest(
void){
3584 cpl_table *ResTable = NULL;
3585 const cpl_size size = 10;
3589 unsigned short aNMaps = 1;
3592 hdrl_resample_create_table(&ResTable, size);
3595 hdrl_resample_pixgrid *aGrid = hdrl_resample_pixgrid_new(x, y, z, aNMaps);
3598 hdrl_parameter * outputgrid =
3600 HDRL_CDELT2, HDRL_CDELT3,
3601 HDRL_RA_MIN, HDRL_RA_MAX, HDRL_DEC_MIN, HDRL_DEC_MAX,
3602 HDRL_LAMBDA_MIN, HDRL_LAMBDA_MAX,5.);
3605 hdrl_resample_method aMethod = HDRL_RESAMPLE_METHOD_DRIZZLE;
3606 cpl_boolean use_errorweights = CPL_TRUE;
3607 hdrl_parameter * aParams_method =
3608 hdrl_resample_util_methodparam_create (
3610 RENKA_CRITICAL_RADIUS,
3611 LANCZOS_KERNEL_SIZE,
3612 DRIZZLE_DOWN_SCALING_FACTOR_X,
3613 DRIZZLE_DOWN_SCALING_FACTOR_Y,
3614 DRIZZLE_DOWN_SCALING_FACTOR_Z,
3615 aMethod, use_errorweights);
3616 hdrl_resample_outgrid_parameter *aParams_outputgrid =
3617 (hdrl_resample_outgrid_parameter *) outputgrid;
3618 hdrl_resample_util_fill_outputgrid(aParams_outputgrid);
3619 cpl_wcs_delete((cpl_wcs *)aParams_outputgrid->wcs);
3620 aParams_outputgrid->wcs = hdrl_resample_util_crea_wcs_3d();
3624 aParams_outputgrid->wcs);
3627 hdrl_resample_cube_nearest(NULL, ResTable, aGrid, aParams_outputgrid);
3628 cpl_test_error(CPL_ERROR_NULL_INPUT);
3630 hdrl_resample_cube_nearest(cube, NULL, aGrid, aParams_outputgrid);
3631 cpl_test_error(CPL_ERROR_NULL_INPUT);
3633 hdrl_resample_cube_nearest(cube, ResTable, NULL, aParams_outputgrid);
3634 cpl_test_error(CPL_ERROR_NULL_INPUT);
3636 hdrl_resample_cube_nearest(cube, ResTable, aGrid, NULL);
3637 cpl_test_error(CPL_ERROR_NULL_INPUT);
3640 hdrl_resample_cube_nearest(cube, ResTable, aGrid,aParams_outputgrid);
3641 cpl_test_error(CPL_ERROR_NONE);
3644 cpl_wcs_delete((cpl_wcs *)aParams_outputgrid->wcs);
3645 hdrl_resample_pixgrid_delete(aGrid);
3646 cpl_table_delete(ResTable);
3650 return cpl_error_get_code();
3658static cpl_error_code
3659test_hdrl_resample_cube_weighted(
void) {
3661 cpl_table *ResTable = NULL;
3662 const cpl_size size = 10;
3666 unsigned short aNMaps = 1;
3669 hdrl_resample_create_table(&ResTable, size);
3672 hdrl_resample_pixgrid *aGrid = hdrl_resample_pixgrid_new(x, y, z, aNMaps);
3675 hdrl_parameter * outputgrid =
3677 HDRL_CDELT2, HDRL_CDELT3,
3678 HDRL_RA_MIN, HDRL_RA_MAX, HDRL_DEC_MIN, HDRL_DEC_MAX,
3679 HDRL_LAMBDA_MIN, HDRL_LAMBDA_MAX,5.);
3682 hdrl_resample_method aMethod = HDRL_RESAMPLE_METHOD_DRIZZLE;
3683 cpl_boolean use_errorweights = CPL_TRUE;
3684 hdrl_parameter * aParams_method =
3685 hdrl_resample_util_methodparam_create (
3687 RENKA_CRITICAL_RADIUS,
3688 LANCZOS_KERNEL_SIZE,
3689 DRIZZLE_DOWN_SCALING_FACTOR_X,
3690 DRIZZLE_DOWN_SCALING_FACTOR_Y,
3691 DRIZZLE_DOWN_SCALING_FACTOR_Z,
3692 aMethod, use_errorweights);
3693 hdrl_resample_outgrid_parameter *aParams_outputgrid =
3694 (hdrl_resample_outgrid_parameter *) outputgrid;
3695 hdrl_resample_util_fill_outputgrid(aParams_outputgrid);
3696 cpl_wcs_delete((cpl_wcs *)aParams_outputgrid->wcs);
3697 aParams_outputgrid->wcs = hdrl_resample_util_crea_wcs_3d();
3699 hdrl_resample_method_parameter * mp =
3700 (hdrl_resample_method_parameter *) aParams_method;
3701 cpl_test_nonnull(mp);
3704 aParams_outputgrid->wcs);
3707 hdrl_resample_cube_weighted(NULL, ResTable, aGrid, mp,
3708 aParams_outputgrid);
3709 cpl_test_error(CPL_ERROR_NULL_INPUT);
3711 hdrl_resample_cube_weighted(cube, NULL, aGrid, mp,
3712 aParams_outputgrid);
3713 cpl_test_error(CPL_ERROR_NULL_INPUT);
3715 hdrl_resample_cube_weighted(cube, ResTable, NULL, mp,
3716 aParams_outputgrid);
3717 cpl_test_error(CPL_ERROR_NULL_INPUT);
3719 hdrl_resample_cube_weighted(cube, ResTable, aGrid, NULL,
3720 aParams_outputgrid);
3721 cpl_test_error(CPL_ERROR_NULL_INPUT);
3723 hdrl_resample_cube_weighted(cube, ResTable, aGrid, mp,
3725 cpl_test_error(CPL_ERROR_NULL_INPUT);
3728 hdrl_resample_cube_weighted(cube, ResTable, aGrid, mp,
3729 aParams_outputgrid);
3730 cpl_test_error(CPL_ERROR_NONE);
3732 mp->loop_distance = -1;
3733 mp->lanczos_kernel_size = 0;
3734 hdrl_resample_cube_weighted(cube, ResTable, aGrid, mp,
3735 aParams_outputgrid);
3736 cpl_test_error(CPL_ERROR_NONE);
3739 cpl_wcs_delete((cpl_wcs *)aParams_outputgrid->wcs);
3740 hdrl_resample_pixgrid_delete(aGrid);
3741 cpl_table_delete(ResTable);
3746 return cpl_error_get_code();
3754static cpl_error_code
3755test_hdrl_resample_cube(
void) {
3756 cpl_table *ResTable = NULL;
3757 const cpl_size size = 10;
3760 hdrl_resample_create_table(&ResTable, size);
3763 hdrl_resample_pixgrid *aGrid = NULL;
3765 hdrl_parameter * outputgrid =
3767 HDRL_CDELT2, HDRL_CDELT3,
3768 HDRL_RA_MIN, HDRL_RA_MAX, HDRL_DEC_MIN, HDRL_DEC_MAX,
3769 HDRL_LAMBDA_MIN, HDRL_LAMBDA_MAX,5.);
3772 hdrl_resample_method aMethod = HDRL_RESAMPLE_METHOD_DRIZZLE;
3773 cpl_boolean use_errorweights = CPL_TRUE;
3774 hdrl_parameter * aParams_method =
3775 hdrl_resample_util_methodparam_create (
3777 RENKA_CRITICAL_RADIUS,
3778 LANCZOS_KERNEL_SIZE,
3779 DRIZZLE_DOWN_SCALING_FACTOR_X,
3780 DRIZZLE_DOWN_SCALING_FACTOR_Y,
3781 DRIZZLE_DOWN_SCALING_FACTOR_Z,
3782 aMethod, use_errorweights);
3783 hdrl_resample_outgrid_parameter *aParams_outputgrid =
3784 (hdrl_resample_outgrid_parameter *) outputgrid;
3785 hdrl_resample_util_fill_outputgrid(aParams_outputgrid);
3786 cpl_wcs_delete((cpl_wcs *)aParams_outputgrid->wcs);
3787 aParams_outputgrid->wcs = hdrl_resample_util_crea_wcs_3d();
3789 hdrl_resample_method_parameter * mp =
3790 (hdrl_resample_method_parameter *) aParams_method;
3791 cpl_test_nonnull(mp);
3793 hdrl_resample_cube(NULL, mp, aParams_outputgrid, &aGrid);
3794 cpl_test_error(CPL_ERROR_NULL_INPUT);
3796 hdrl_resample_cube(ResTable, NULL, aParams_outputgrid, &aGrid);
3797 cpl_test_error(CPL_ERROR_NULL_INPUT);
3799 hdrl_resample_cube(ResTable, mp, NULL, &aGrid);
3800 cpl_test_error(CPL_ERROR_NULL_INPUT);
3802 hdrl_resample_cube(ResTable, mp, aParams_outputgrid, NULL);
3803 cpl_test_error(CPL_ERROR_NULL_INPUT);
3806 hdrl_resample_result * cube = hdrl_resample_cube(ResTable, mp, aParams_outputgrid, &aGrid);
3807 cpl_test_error(CPL_ERROR_NONE);
3809 hdrl_resample_pixgrid_delete(aGrid);
3813 cube = hdrl_resample_cube(ResTable, mp, aParams_outputgrid, &aGrid);
3814 cpl_test_error(CPL_ERROR_UNSUPPORTED_MODE);
3816 cpl_table_delete(ResTable);
3817 hdrl_resample_pixgrid_delete(aGrid);
3820 ResTable = cpl_table_new(0);
3821 cube = hdrl_resample_cube(ResTable, mp, aParams_outputgrid, &aGrid);
3822 cpl_test_error(CPL_ERROR_DATA_NOT_FOUND);
3825 cpl_wcs_delete((cpl_wcs *)aParams_outputgrid->wcs);
3826 hdrl_resample_pixgrid_delete(aGrid);
3827 cpl_table_delete(ResTable);
3832 cpl_test_error(CPL_ERROR_NONE);
3833 return cpl_error_get_code();
3841static cpl_error_code
3842test_hdrl_resampling_set_outputgrid(
void)
3844 int xsize = HDRL_SIZE_X;
3845 int ysize = HDRL_SIZE_Y;
3846 int zsize = HDRL_SIZE_Z;
3848 cpl_table *ResTable = NULL;
3849 const cpl_size size = 10;
3852 hdrl_resample_create_table(&ResTable, size);
3855 hdrl_resample_pixgrid *aGrid = NULL;
3858 hdrl_parameter * outputgrid =
3860 HDRL_CDELT2, HDRL_CDELT3,
3861 HDRL_RA_MIN, HDRL_RA_MAX, HDRL_DEC_MIN, HDRL_DEC_MAX,
3862 HDRL_LAMBDA_MIN, HDRL_LAMBDA_MAX,5.);
3865 hdrl_resample_method aMethod = HDRL_RESAMPLE_METHOD_DRIZZLE;
3866 cpl_boolean use_errorweights = CPL_TRUE;
3867 hdrl_parameter * aParams_method =
3868 hdrl_resample_util_methodparam_create (
3870 RENKA_CRITICAL_RADIUS,
3871 LANCZOS_KERNEL_SIZE,
3872 DRIZZLE_DOWN_SCALING_FACTOR_X,
3873 DRIZZLE_DOWN_SCALING_FACTOR_Y,
3874 DRIZZLE_DOWN_SCALING_FACTOR_Z,
3875 aMethod, use_errorweights);
3876 hdrl_resample_outgrid_parameter *aParams_outputgrid =
3877 (hdrl_resample_outgrid_parameter *) outputgrid;
3878 hdrl_resample_util_fill_outputgrid(aParams_outputgrid);
3879 cpl_wcs_delete((cpl_wcs *)aParams_outputgrid->wcs);
3880 aParams_outputgrid->wcs = hdrl_resample_util_crea_wcs_3d();
3882 hdrl_resample_method_parameter * mp =
3883 (hdrl_resample_method_parameter *) aParams_method;
3884 cpl_test_nonnull(mp);
3886 hdrl_resample_result * cube = hdrl_resample_cube(ResTable, mp,
3887 aParams_outputgrid, &aGrid);
3890 hdrl_resampling_set_outputgrid (-1, ysize, zsize, cube, aParams_outputgrid);
3891 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
3893 hdrl_resampling_set_outputgrid (xsize, -1, zsize, cube, aParams_outputgrid);
3894 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
3896 hdrl_resampling_set_outputgrid (xsize, ysize, -1, cube, aParams_outputgrid);
3897 cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
3899 hdrl_resampling_set_outputgrid (xsize, ysize, zsize, NULL, aParams_outputgrid);
3900 cpl_test_error(CPL_ERROR_NULL_INPUT);
3902 hdrl_resampling_set_outputgrid (xsize, ysize, zsize, cube, NULL);
3903 cpl_test_error(CPL_ERROR_NULL_INPUT);
3909 cpl_propertylist_delete(cube->header);
3911 hdrl_resampling_set_outputgrid (xsize, ysize, zsize, cube, aParams_outputgrid);
3912 cpl_test_error(CPL_ERROR_NONE);
3914 cpl_wcs_delete((cpl_wcs *)aParams_outputgrid->wcs);
3915 hdrl_resample_pixgrid_delete(aGrid);
3916 cpl_table_delete(ResTable);
3920 cpl_test_error(CPL_ERROR_NONE);
3921 return cpl_error_get_code();
3923static cpl_error_code
3924test_hdrl_resample_inputtable_verify(
void)
3926 cpl_table* tab = NULL;
3927 hdrl_resample_inputtable_verify(NULL);
3928 cpl_test_error(CPL_ERROR_NULL_INPUT);
3931 tab= cpl_table_new(1);
3932 cpl_table_new_column(tab, HDRL_RESAMPLE_TABLE_RA, CPL_TYPE_DOUBLE);
3933 hdrl_resample_inputtable_verify(tab);
3934 cpl_test_error(CPL_ERROR_INCOMPATIBLE_INPUT);
3936 cpl_table_new_column(tab, HDRL_RESAMPLE_TABLE_DEC, CPL_TYPE_DOUBLE);
3937 hdrl_resample_inputtable_verify(tab);
3938 cpl_test_error(CPL_ERROR_INCOMPATIBLE_INPUT);
3940 cpl_table_new_column(tab, HDRL_RESAMPLE_TABLE_LAMBDA, CPL_TYPE_DOUBLE);
3941 hdrl_resample_inputtable_verify(tab);
3942 cpl_test_error(CPL_ERROR_INCOMPATIBLE_INPUT);
3944 cpl_table_new_column(tab, HDRL_RESAMPLE_TABLE_BPM, CPL_TYPE_INT);
3945 hdrl_resample_inputtable_verify(tab);
3946 cpl_test_error(CPL_ERROR_INCOMPATIBLE_INPUT);
3948 cpl_table_new_column(tab, HDRL_RESAMPLE_TABLE_ERRORS, CPL_TYPE_DOUBLE);
3949 hdrl_resample_inputtable_verify(tab);
3950 cpl_test_error(CPL_ERROR_INCOMPATIBLE_INPUT);
3952 cpl_table_new_column(tab, HDRL_RESAMPLE_TABLE_DATA, CPL_TYPE_DOUBLE);
3953 hdrl_resample_inputtable_verify(tab);
3954 cpl_test_error(CPL_ERROR_NONE);
3955 cpl_table_delete(tab);
3958 tab= cpl_table_new(1);
3959 cpl_table_new_column(tab, HDRL_RESAMPLE_TABLE_RA, CPL_TYPE_INT);
3960 hdrl_resample_inputtable_verify(tab);
3961 cpl_test_error(CPL_ERROR_INCOMPATIBLE_INPUT);
3962 cpl_table_erase_column(tab, HDRL_RESAMPLE_TABLE_RA);
3963 cpl_table_new_column(tab, HDRL_RESAMPLE_TABLE_RA, CPL_TYPE_DOUBLE);
3965 cpl_table_new_column(tab, HDRL_RESAMPLE_TABLE_DEC, CPL_TYPE_INT);
3966 hdrl_resample_inputtable_verify(tab);
3967 cpl_test_error(CPL_ERROR_INCOMPATIBLE_INPUT);
3968 cpl_table_erase_column(tab, HDRL_RESAMPLE_TABLE_DEC);
3969 cpl_table_new_column(tab, HDRL_RESAMPLE_TABLE_DEC, CPL_TYPE_DOUBLE);
3971 cpl_table_new_column(tab, HDRL_RESAMPLE_TABLE_LAMBDA, CPL_TYPE_INT);
3972 hdrl_resample_inputtable_verify(tab);
3973 cpl_test_error(CPL_ERROR_INCOMPATIBLE_INPUT);
3974 cpl_table_erase_column(tab, HDRL_RESAMPLE_TABLE_LAMBDA);
3975 cpl_table_new_column(tab, HDRL_RESAMPLE_TABLE_LAMBDA, CPL_TYPE_DOUBLE);
3977 cpl_table_new_column(tab, HDRL_RESAMPLE_TABLE_BPM, CPL_TYPE_DOUBLE);
3978 hdrl_resample_inputtable_verify(tab);
3979 cpl_test_error(CPL_ERROR_INCOMPATIBLE_INPUT);
3980 cpl_table_erase_column(tab, HDRL_RESAMPLE_TABLE_BPM);
3981 cpl_table_new_column(tab, HDRL_RESAMPLE_TABLE_BPM, CPL_TYPE_INT);
3983 cpl_table_new_column(tab, HDRL_RESAMPLE_TABLE_ERRORS, CPL_TYPE_INT);
3984 hdrl_resample_inputtable_verify(tab);
3985 cpl_test_error(CPL_ERROR_INCOMPATIBLE_INPUT);
3986 cpl_table_erase_column(tab, HDRL_RESAMPLE_TABLE_ERRORS);
3987 cpl_table_new_column(tab, HDRL_RESAMPLE_TABLE_ERRORS, CPL_TYPE_DOUBLE);
3989 cpl_table_new_column(tab, HDRL_RESAMPLE_TABLE_DATA, CPL_TYPE_INT);
3990 hdrl_resample_inputtable_verify(tab);
3991 cpl_test_error(CPL_ERROR_INCOMPATIBLE_INPUT);
3992 cpl_table_erase_column(tab, HDRL_RESAMPLE_TABLE_DATA);
3993 cpl_table_new_column(tab, HDRL_RESAMPLE_TABLE_DATA, CPL_TYPE_DOUBLE);
3994 hdrl_resample_inputtable_verify(tab);
3995 cpl_test_error(CPL_ERROR_NONE);
3997 cpl_table_delete(tab);
3998 return cpl_error_get_code();
4004static cpl_propertylist*
4005hdrl_resample_util_header_create(
const int sx,
const int sy,
4006 const double dx,
const double dy)
4009 cpl_propertylist* plist = cpl_propertylist_new();
4010 cpl_propertylist_append_bool(plist,
"SIMPLE", CPL_TRUE);
4011 cpl_propertylist_append_int(plist,
"NAXIS", 2);
4012 cpl_propertylist_append_int(plist,
"NAXIS1", sx);
4013 cpl_propertylist_append_int(plist,
"NAXIS2", sy);
4014 cpl_propertylist_append_bool(plist,
"EXTEND", CPL_TRUE);
4015 cpl_propertylist_append_double(plist,
"CRPIX1", 0.5 * sx);
4016 cpl_propertylist_append_double(plist,
"CRPIX2", 0.5 * sy);
4017 cpl_propertylist_append_double(plist,
"CRVAL1", 0.5 * sx);
4018 cpl_propertylist_append_double(plist,
"CRVAL2", 0.5 * sy);
4019 cpl_propertylist_append_double(plist,
"CDELT1", dx );
4020 cpl_propertylist_append_double(plist,
"CDELT2", dy );
4021 cpl_propertylist_append_double(plist,
"CD1_1", -dx );
4022 cpl_propertylist_append_double(plist,
"CD1_2", 0. );
4023 cpl_propertylist_append_double(plist,
"CD2_1", 0. );
4024 cpl_propertylist_append_double(plist,
"CD2_2", dy );
4025 cpl_propertylist_append_string(plist,
"CTYPE1",
"PIXEL");
4026 cpl_propertylist_append_string(plist,
"CTYPE2",
"PIXEL");
4027 cpl_propertylist_append_string(plist,
"CUNIT1",
"PIXEL");
4028 cpl_propertylist_append_string(plist,
"CUNIT2",
"PIXEL");
4037hdrl_resample_util_crea_image_uniform(
const cpl_size sx,
const cpl_size sy,
4041 cpl_image * image = cpl_image_new(sx, sy, CPL_TYPE_DOUBLE);
4042 cpl_image_add_scalar(image,value);
4047hdrldemo_get_resampled_pix_value(
const char* type,
const double pix_value,
4048 const double outlier, cpl_boolean is_bad,
4049 hdrl_resample_method aMethod)
4051 cpl_size sx = HDRL_SIZE_X;
4052 cpl_size sy = HDRL_SIZE_X;
4053 cpl_size xc = 0.5 * sx;
4054 cpl_size yc = 0.5 * sy;
4056 const double value = pix_value;
4057 const double dx = 0.01;
4058 const double dy = 0.01;
4059 cpl_image* simul = NULL;
4060 cpl_image* errs = NULL;
4062 cpl_test_error(CPL_ERROR_NONE);
4063 if(strcmp(type,
"uniform") == 0) {
4064 simul = hdrl_resample_util_crea_image_uniform(sx, sy, value);
4066 simul = hdrl_resample_util_crea_image_dice_5(sx, sy, value);
4068 cpl_test_error(CPL_ERROR_NONE);
4072 cpl_image_set(simul, xc, yc, outlier);
4073 fname = cpl_sprintf(
"cube_and_bp.fits");
4075 fname = cpl_sprintf(
"cube_not_bp.fits");
4078 cpl_test_error(CPL_ERROR_NONE);
4079 errs = cpl_image_duplicate(simul);
4080 cpl_image_power(errs, 0.5);
4083 cpl_propertylist* plist = NULL;
4084 plist = hdrl_resample_util_header_create(sx, sy, dx, dy);
4085 cpl_image_save(simul,
"image.fits", CPL_TYPE_DOUBLE,plist,CPL_IO_DEFAULT);
4086 cpl_propertylist_delete(plist);
4087 plist = cpl_propertylist_load(
"image.fits",0);
4088 cpl_wcs *wcs = cpl_wcs_new_from_propertylist(plist);
4089 cpl_test_nonnull(wcs);
4090 cpl_test_error(CPL_ERROR_NONE);
4093 cpl_imagelist* ilist = NULL;
4094 cpl_imagelist* elist = NULL;
4095 ilist = cpl_imagelist_new();
4096 elist = cpl_imagelist_new();
4098 cpl_imagelist_set(ilist, simul, 0);
4099 cpl_imagelist_set(elist, errs, 0);
4100 cpl_table* pixel_table = NULL;
4101 hdrl_imagelist* hlist = NULL;
4102 if( is_bad == CPL_TRUE) {
4103 cpl_image* qual = cpl_image_new(sx, sy, CPL_TYPE_INT);
4104 cpl_image_set(qual, xc, yc, 1);
4105 cpl_imagelist* qlist = cpl_imagelist_new();
4106 cpl_imagelist_set(qlist, qual, 0);
4109 cpl_imagelist_delete(qlist);
4114 cpl_imagelist_delete(ilist);
4115 cpl_imagelist_delete(elist);
4118 cpl_frameset* frameset = cpl_frameset_new();
4121 cpl_msg_info(cpl_func,
"start resample");
4123 cpl_test_error(CPL_ERROR_NONE);
4124 cpl_wcs_delete(wcs);
4125 cpl_propertylist* p = cpl_propertylist_new();
4126 cpl_propertylist_append_string(p,
"CTYPE1",
"RA---TAN");
4127 cpl_propertylist_append_string(p,
"CTYPE2",
"DEC--TAN");
4128 cpl_propertylist_append_double(p,
"CRVAL1", 0.);
4129 cpl_propertylist_append_double(p,
"CRVAL2", 0.);
4130 cpl_propertylist_append_double(p,
"CRPIX1", xc);
4131 cpl_propertylist_append_double(p,
"CRPIX2", yc);
4132 cpl_propertylist_append_double(p,
"CD1_1", -dx);
4133 cpl_propertylist_append_double(p,
"CD1_2", 0.1);
4134 cpl_propertylist_append_double(p,
"CD2_1", 0.1);
4135 cpl_propertylist_append_double(p,
"CD2_2", dy);
4136 wcs = cpl_wcs_new_from_propertylist(p);
4137 cpl_test_nonnull(wcs);
4138 cpl_propertylist_delete(p);
4140 const double ramin = xc - 0.5*sx*dx;
4141 const double ramax = xc + 0.5*sx*dx;
4142 const double decmin = yc - 0.5*sy*dy;
4143 const double decmax = yc + 0.5*sy*dy;
4144 const double lambmin = 550;
4145 const double lambmax = 551;
4146 const double dlambda = 1;
4148 hdrl_parameter* aParams_outputgrid =
4150 ramin, ramax, decmin, decmax, lambmin, lambmax, 5.);
4152 cpl_boolean use_errorweights = CPL_FALSE;
4153 hdrl_parameter * aParams_method =
4154 hdrl_resample_util_methodparam_create (
4156 RENKA_CRITICAL_RADIUS,
4157 LANCZOS_KERNEL_SIZE,
4158 DRIZZLE_DOWN_SCALING_FACTOR_X,
4159 DRIZZLE_DOWN_SCALING_FACTOR_Y,
4160 DRIZZLE_DOWN_SCALING_FACTOR_Z,
4161 aMethod, use_errorweights);
4163 hdrl_resample_result *cube = NULL;
4165 cpl_test_error(CPL_ERROR_NONE);
4167 hdrl_imagelist* himlist = cube->himlist;
4172 cpl_size rpix = 0.5 * rsy * rsx + rsx;
4174 double pix_ref = data[rpix];
4175 cpl_test_error(CPL_ERROR_NONE);
4176 cpl_test_error(CPL_ERROR_NONE);
4179 cpl_free(aParams_method);
4180 cpl_wcs_delete(wcs);
4182 cpl_table_delete(pixel_table);
4184 cpl_frameset_delete(frameset);
4185 cpl_propertylist_delete(plist);
4189static cpl_error_code
4190test_resample_image_dice(hdrl_resample_method aMethod)
4198 cpl_test_error(CPL_ERROR_NONE);
4200 hdrldemo_get_resampled_pix_value(
"uniform", HDRL_FLUX_ADU, 1000., CPL_FALSE,
4203 double check_value =
4204 hdrldemo_get_resampled_pix_value(
"uniform", HDRL_FLUX_ADU, 100000., CPL_TRUE,
4207 cpl_test_abs(check_value, ref_value, HDRL_EPS_TEST);
4216 return cpl_error_get_code();
4219static hdrl_resample_result *
4220hdrl_resample_util_get_resampled_pix_cube(
const char* type,
const double pix_value,
4221 const double outlier, cpl_boolean is_bad,
const char* suffix)
4223 cpl_size sx = HDRL_SIZE_X;
4224 cpl_size sy = HDRL_SIZE_Y;
4225 cpl_size xc = 0.5 * sx;
4226 cpl_size yc = 0.5 * sy;
4227 const double value = pix_value;
4228 const double dx = 0.01;
4229 const double dy = 0.01;
4230 cpl_image* simul = NULL;
4231 cpl_image* errs = NULL;
4233 cpl_test_error(CPL_ERROR_NONE);
4234 if(strcmp(type,
"uniform") == 0) {
4235 simul = hdrl_resample_util_crea_image_uniform(sx, sy, value);
4237 simul = hdrl_resample_util_crea_image_dice_5(sx, sy, value);
4239 cpl_test_error(CPL_ERROR_NONE);
4243 cpl_msg_warning(cpl_func,
"is bad");
4244 cpl_image_set(simul, xc, yc, outlier);
4245 bname = cpl_sprintf(
"%s_%s.fits",
"cube_and_bp",suffix);
4247 cpl_msg_warning(cpl_func,
"is not bad");
4248 bname = cpl_sprintf(
"%s_%s.fits",
"cube_not_bp",suffix);
4250 cpl_test_error(CPL_ERROR_NONE);
4252 errs = cpl_image_duplicate(simul);
4253 cpl_image_power(errs, 0.5);
4256 cpl_propertylist* plist = NULL;
4257 plist = hdrl_resample_util_header_create(sx, sy, dx, dy);
4258 cpl_image_save(simul,
"image.fits", CPL_TYPE_DOUBLE,plist,CPL_IO_DEFAULT);
4259 cpl_propertylist_delete(plist);
4260 plist = cpl_propertylist_load(
"image.fits",0);
4261 cpl_wcs *wcs = cpl_wcs_new_from_propertylist(plist);
4262 cpl_test_nonnull(wcs);
4265 cpl_imagelist* ilist = NULL;
4266 cpl_imagelist* elist = NULL;
4267 cpl_table* pixel_table = NULL;
4268 ilist = cpl_imagelist_new();
4269 elist = cpl_imagelist_new();
4270 cpl_imagelist_set(ilist, simul, 0);
4271 cpl_imagelist_set(elist, errs, 0);
4272 cpl_test_error(CPL_ERROR_NONE);
4273 cpl_imagelist_save(ilist,bname, CPL_TYPE_DOUBLE, NULL, CPL_IO_DEFAULT);
4274 cpl_imagelist_save(elist,bname, CPL_TYPE_DOUBLE, NULL, CPL_IO_EXTEND);
4275 cpl_test_error(CPL_ERROR_NONE);
4276 hdrl_imagelist* hlist;
4277 if( is_bad == CPL_TRUE) {
4278 cpl_image* qual = cpl_image_new(sx, sy, CPL_TYPE_INT);
4279 cpl_image_set(qual, xc, yc, 1);
4280 cpl_imagelist* qlist = cpl_imagelist_new();
4281 cpl_imagelist_set(qlist, qual, 0);
4282 cpl_imagelist_save(qlist,bname, CPL_TYPE_INT, NULL, CPL_IO_EXTEND);
4285 cpl_imagelist_delete(qlist);
4290 cpl_test_error(CPL_ERROR_NONE);
4292 cpl_imagelist_delete(ilist);
4293 cpl_imagelist_delete(elist);
4296 cpl_frameset* frameset = cpl_frameset_new();
4299 cpl_msg_info(cpl_func,
"start resample");
4300 const double ramin = xc - 0.5*sx*dx;
4301 const double ramax = xc + 0.5*sx*dx;
4302 const double decmin = yc - 0.5*sy*dy;
4303 const double decmax = yc + 0.5*sy*dy;
4304 const double lambmin = 550;
4305 const double lambmax = 551;
4306 const double dlambda = 1;
4307 cpl_wcs_delete(wcs);
4308 cpl_propertylist* p = cpl_propertylist_new();
4309 cpl_propertylist_append_string(p,
"CTYPE1",
"RA---TAN");
4310 cpl_propertylist_append_string(p,
"CTYPE2",
"DEC--TAN");
4311 cpl_propertylist_append_double(p,
"CRVAL1", 0.);
4312 cpl_propertylist_append_double(p,
"CRVAL2", 0.);
4313 cpl_propertylist_append_double(p,
"CRPIX1", xc);
4314 cpl_propertylist_append_double(p,
"CRPIX2", yc);
4315 cpl_propertylist_append_double(p,
"CD1_1", -dx);
4316 cpl_propertylist_append_double(p,
"CD1_2", 0.);
4317 cpl_propertylist_append_double(p,
"CD2_1", 0.);
4318 cpl_propertylist_append_double(p,
"CD2_2", dy);
4319 wcs = cpl_wcs_new_from_propertylist(p);
4320 cpl_propertylist_delete(p);
4322 hdrl_parameter* aParams_outputgrid =
4324 ramin, ramax, decmin, decmax, lambmin, lambmax, 5.);
4326 cpl_boolean use_errorweights = CPL_FALSE;
4328 hdrl_resample_method aMethod = HDRL_RESAMPLE_METHOD_QUADRATIC;
4329 hdrl_parameter * aParams_method =
4330 hdrl_resample_util_methodparam_create (
4332 RENKA_CRITICAL_RADIUS,
4333 LANCZOS_KERNEL_SIZE,
4334 DRIZZLE_DOWN_SCALING_FACTOR_X,
4335 DRIZZLE_DOWN_SCALING_FACTOR_Y,
4336 DRIZZLE_DOWN_SCALING_FACTOR_Z,
4337 aMethod, use_errorweights);
4339 hdrl_resample_result *cube = NULL;
4341 aParams_outputgrid, wcs);
4343 cpl_msg_info(cpl_func,
"end resample");
4345 cpl_table_delete(pixel_table);
4346 cpl_wcs_delete(wcs);
4349 cpl_frameset_delete(frameset);
4350 cpl_propertylist_delete(plist);
4355static cpl_error_code
4356test_resample_image_with_outlier(
void)
4358 cpl_test_error(CPL_ERROR_NONE);
4360 hdrl_resample_result *cube1 =
4361 hdrl_resample_util_get_resampled_pix_cube(
"uniform", HDRL_FLUX_ADU, 1000., CPL_FALSE,
"one");
4364 hdrl_resample_result *cube2 =
4365 hdrl_resample_util_get_resampled_pix_cube(
"uniform", HDRL_FLUX_ADU, 100000., CPL_FALSE,
"two");
4371 cpl_image_save(diff,
"diff.fits",CPL_TYPE_DOUBLE,NULL,CPL_IO_DEFAULT);
4372 cpl_test_error(CPL_ERROR_NONE);
4374 cpl_test_abs(0,cpl_image_get_mean(diff), HDRL_EPS_TEST);
4375 cpl_test_abs(0,cpl_image_get_stdev(diff), HDRL_EPS_TEST);
4376 cpl_test_abs(0,cpl_image_get_min(diff), HDRL_EPS_TEST);
4377 cpl_test_abs(0,cpl_image_get_max(diff), HDRL_EPS_TEST);
4382 cpl_test_error(CPL_ERROR_NONE);
4383 return cpl_error_get_code();
4393 cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING);
4395 test_resample_wcs_as_muse();
4396 test_hdrl_resample_wcs_print();
4397 test_hdrl_resample_outgrid_parameter_print();
4398 test_hdrl_resample_method_parameter_print();
4399 test_hdrl_wcs_xy_to_radec();
4400 test_hdrl_resample_pfits_get();
4401 test_hdrl_resample_smallwcs_new();
4402 test_hdrl_resample_pixgrid_delete();
4403 test_hdrl_resample_compute();
4405 test_resample_parameters();
4406 test_hdrl_wcs_to_propertylist();
4407 test_hdrl_resample_image_to_table();
4408 test_hdrl_resample_imagelist_to_table();
4409 test_hdrl_resample_parameter_create_outgrid2D();
4410 test_hdrl_resample_parameter_create_outgrid3D();
4411 test_hdrl_resample_parameter_create_outgrid2D_userdef();
4412 test_hdrl_resample_parameter_create_outgrid3D_userdef();
4414 test_hdrl_resample_weight_function_renka();
4415 test_hdrl_resample_weight_function_linear();
4416 test_hdrl_resample_weight_function_quadratic();
4417 test_hdrl_resample_weight_function_sinc();
4418 test_hdrl_resample_weight_function_lanczos();
4419 test_hdrl_resample_weight_function_drizzle();
4421 test_hdrl_resample_wcs_projplane_from_celestial();
4422 test_hdrl_resample_wcs_pixel_from_celestial_fast();
4423 test_hdrl_resample_compute_size();
4424 test_hdrl_resample_pixgrid_add();
4425 test_hdrl_resample_pixgrid_get_count();
4426 test_hdrl_resample_pixgrid_get_index();
4427 test_hdrl_resample_pixgrid_new();
4429 test_hdrl_resample_wcs_get_scales();
4430 test_hdrl_resample_create_table();
4431 test_hdrl_resample_pixgrid_get_rows();
4432 test_hdrl_resample_pixgrid_create();
4433 test_hdrl_resample_cube_nearest();
4434 test_hdrl_resample_cube_weighted();
4435 test_hdrl_resample_cube();
4437 test_hdrl_resampling_set_outputgrid();
4438 test_hdrl_resample_compute2D_multiple();
4439 test_hdrl_resample_compute3D_multiple();
4440 test_hdrl_resample_inputtable_verify();
4442 test_resample_image_dice(HDRL_RESAMPLE_METHOD_LINEAR);
4443 test_resample_image_dice(HDRL_RESAMPLE_METHOD_QUADRATIC);
4444 test_resample_image_dice(HDRL_RESAMPLE_METHOD_NEAREST);
4445 test_resample_image_dice(HDRL_RESAMPLE_METHOD_RENKA);
4446 test_resample_image_dice(HDRL_RESAMPLE_METHOD_DRIZZLE);
4447 test_resample_image_dice(HDRL_RESAMPLE_METHOD_LANCZOS);
4449 test_resample_image_with_outlier();
4450 return cpl_test_end(0);
hdrl_image * hdrl_image_sub_image_create(const hdrl_image *self, const hdrl_image *other)
Subtract two images.
cpl_mask * hdrl_image_get_mask(hdrl_image *himg)
get cpl bad pixel mask from image
cpl_image * hdrl_image_get_error(hdrl_image *himg)
get error as cpl image
const cpl_mask * hdrl_image_get_mask_const(const hdrl_image *himg)
get cpl bad pixel mask from image
const cpl_image * hdrl_image_get_error_const(const hdrl_image *himg)
get error as cpl image
hdrl_image * hdrl_image_create(const cpl_image *image, const cpl_image *error)
create a new hdrl_image from to existing images by copying them
cpl_image * hdrl_image_get_image(hdrl_image *himg)
get data as cpl image
const cpl_image * hdrl_image_get_image_const(const hdrl_image *himg)
get data as cpl image
void hdrl_image_delete(hdrl_image *himg)
delete hdrl_image
cpl_size hdrl_imagelist_get_size_y(const hdrl_imagelist *himlist)
Get number of rows of images in the imagelist.
hdrl_imagelist * hdrl_imagelist_create(cpl_imagelist *imlist, cpl_imagelist *errlist)
Create an hdrl_imagelist out of 2 cpl_imagelist.
void hdrl_imagelist_delete(hdrl_imagelist *himlist)
Free all memory used by a hdrl_imagelist object including the images.
const hdrl_image * hdrl_imagelist_get_const(const hdrl_imagelist *himlist, cpl_size inum)
Get an image from a list of images.
cpl_size hdrl_imagelist_get_size(const hdrl_imagelist *himlist)
Get the number of images in the imagelist.
cpl_size hdrl_imagelist_get_size_x(const hdrl_imagelist *himlist)
Get number of colums of images in the imagelist.
hdrl_image * hdrl_imagelist_get(const hdrl_imagelist *himlist, cpl_size inum)
Get an image from a list of images.
void hdrl_parameter_destroy(hdrl_parameter *obj)
deep delete of a parameter
void hdrl_parameter_delete(hdrl_parameter *obj)
shallow delete of a parameter
hdrl_parameter * hdrl_resample_parameter_create_nearest(void)
Creates a resample nearest neighbor hdrl parameter object. The algorithm does not use any weighting f...
cpl_error_code hdrl_resample_parameter_method_verify(const hdrl_parameter *hp)
verify parameters have proper values
int hdrl_resample_parameter_method_check(const hdrl_parameter *self)
check method is of proper type
hdrl_parameter * hdrl_resample_parameter_create_renka(const int loop_distance, cpl_boolean use_errorweights, const double critical_radius)
Creates a resample renka hdrl parameter object. The algorithm uses a modified Shepard-like distance w...
hdrl_parameter * hdrl_resample_parameter_create_lanczos(const int loop_distance, cpl_boolean use_errorweights, const int kernel_size)
Creates a resample Lanczos hdrl parameter object. The algorithm uses a restricted SINC distance weigh...
hdrl_parameter * hdrl_resample_parameter_create_drizzle(const int loop_distance, cpl_boolean use_errorweights, const double pix_frac_x, const double pix_frac_y, const double pix_frac_lambda)
Creates a resample drizzle hdrl parameter object. The algorithm uses a drizzle-like distance weightin...
hdrl_parameter * hdrl_resample_parameter_create_quadratic(const int loop_distance, cpl_boolean use_errorweights)
Creates a resample quadratic hdrl parameter object. The algorithm uses a quadratic inverse distance w...
hdrl_parameter * hdrl_resample_parameter_create_linear(const int loop_distance, cpl_boolean use_errorweights)
Creates a resample linear hdrl parameter object. The algorithm uses a linear inverse distance weighti...
hdrl_parameter * hdrl_resample_parameter_create_outgrid3D(const double delta_ra, const double delta_dec, const double delta_lambda)
Creates a resample_outgrid hdrl parameter object for a 3 dimensional interpolation,...
hdrl_parameter * hdrl_resample_parameter_create_outgrid3D_userdef(const double delta_ra, const double delta_dec, const double delta_lambda, const double ra_min, const double ra_max, const double dec_min, const double dec_max, const double lambda_min, const double lambda_max, const double fieldmargin)
Creates a resample_outgrid hdrl parameter object for a 3 dimensional interpolation,...
int hdrl_resample_parameter_outgrid_check(const hdrl_parameter *self)
check method is of proper type
hdrl_parameter * hdrl_resample_parameter_create_outgrid2D(const double delta_ra, const double delta_dec)
Creates a resample_outgrid hdrl parameter object for a 2 dimensional interpolation,...
hdrl_parameter * hdrl_resample_parameter_create_outgrid2D_userdef(const double delta_ra, const double delta_dec, const double ra_min, const double ra_max, const double dec_min, const double dec_max, const double fieldmargin)
Creates a resample_outgrid hdrl parameter object for a 2 dimensional interpolation,...
cpl_error_code hdrl_resample_parameter_outgrid_verify(const hdrl_parameter *hp)
verify parameters have proper values
hdrl_resample_result * hdrl_resample_compute(const cpl_table *ResTable, hdrl_parameter *method, hdrl_parameter *outputgrid, const cpl_wcs *wcs)
High level resampling function.
void hdrl_resample_result_delete(hdrl_resample_result *aCube)
Deallocates the memory associated to a hdrl_resample_result object.
cpl_table * hdrl_resample_image_to_table(const hdrl_image *hima, const cpl_wcs *wcs)
Convert a hdrl image into a cpl table that can be given as input to hdrl_resample_compute()
cpl_table * hdrl_resample_imagelist_to_table(const hdrl_imagelist *himlist, const cpl_wcs *wcs)
Convert a hdrl imagelist into a cpl table that can be given as input to hdrl_resample_compute().