90 cpl_propertylist *pl = NULL;
92 if ( pre_3d != NULL && *pre_3d != NULL) {
93 img = (*pre_3d)->data;
95 img = (*pre_3d)->errs;
97 img = (*pre_3d)->qual;
100 pl = (*pre_3d)->data_header;
102 pl = (*pre_3d)->errs_header;
104 pl = (*pre_3d)->qual_header;
133 assure (
nx > 0 &&
ny > 0 && nz > 0, CPL_ERROR_ILLEGAL_INPUT,
134 "Illegal image size: %dx%dx%d",
nx,
ny, nz );
150 if (cpl_error_get_code () != CPL_ERROR_NONE) {
171 const char *filename = NULL;
173 cpl_propertylist * data_header = NULL;
179 check ( filename = cpl_frame_get_filename (frame));
185 check(result->
group = cpl_frame_get_group(frame));
192 check_msg (data_header = cpl_propertylist_load (filename, extension),
193 "Cannot read the FITS header from '%s' extension %d",
194 filename, extension);
204 "Error loading image from %s extension 0", filename);
208 "Cannot read the FITS header from '%s' extension 1",filename);
212 "Error loading image from %s extension 1", filename);
215 "Cannot read the FITS header from '%s' extension 2",filename);
219 "Error loading image from %s extension 2", filename);
222 if (cpl_error_get_code () != CPL_ERROR_NONE) {
223 xsh_error_msg(
"can't load frame %s",cpl_frame_get_filename(frame));
350 cpl_propertylist * header,
358 cpl_imagelist* cube = NULL;
360 register float* base = NULL;
362 cube = cpl_imagelist_new();
365 for (k = 0; k < naxis3; k++) {
367 cpl_image* plane = cpl_image_wrap_float(naxis1, naxis2, base);
368 cpl_imagelist_set(cube, cpl_image_duplicate(plane), k);
369 base += naxis1 * naxis2;
370 cpl_image_unwrap(plane);
374 cpl_imagelist_save(cube, fname, CPL_BPP_IEEE_FLOAT, header,
mode);
377 return cpl_error_get_code();
394 cpl_propertylist * header,
402 cpl_imagelist* cube = NULL;
404 register int* base = NULL;
406 cube = cpl_imagelist_new();
409 for (k = 0; k < naxis3; k++) {
411 cpl_image* plane = cpl_image_wrap_int(naxis1, naxis2, base);
412 cpl_imagelist_set(cube, cpl_image_duplicate(plane), k);
413 base += naxis1 * naxis2;
414 cpl_image_unwrap(plane);
417 cpl_imagelist_save(cube, fname, CPL_BPP_32_SIGNED, header,
mode);
419 return cpl_error_get_code();
434 cpl_frame * product_frame = NULL;
442 "Could not save data to %s extension 0", filename);
445 "Could not save errs to %s extension 1", filename);
448 "Could not save qual to %s extension 2", filename);
450 product_frame = cpl_frame_new ();
453 check( cpl_frame_set_filename (product_frame, filename) ) ;
454 check( cpl_frame_set_type (product_frame, CPL_FRAME_TYPE_IMAGE) ) ;
464 if (cpl_error_get_code () != CPL_ERROR_NONE) {
466 product_frame = NULL;
468 return product_frame;
int xsh_image_3d_get_size_x(xsh_image_3d *img_3d)
int xsh_image_3d_get_size_y(xsh_image_3d *img_3d)
int xsh_image_3d_get_size_z(xsh_image_3d *img_3d)
void xsh_image_3d_free(xsh_image_3d **img_3d)
xsh_image_3d * xsh_image_3d_new(int nx, int ny, int nz, cpl_type type)
xsh_image_3d * xsh_image_3d_load(const char *filename, cpl_type type, int xtnum)
xsh_image_3d * xsh_pre_3d_get_errs(xsh_pre_3d *pre_3d)
Get errs.
void xsh_pre_3d_free(xsh_pre_3d **pre_3d)
static void xsh_pre_3d_init(xsh_pre_3d *pre, cpl_propertylist *header)
Fill the XSH_PRE structure from FITS header file.
static cpl_error_code xsh_cube_3d_save_float(xsh_image_3d *img_3d, const char *fname, cpl_propertylist *header, unsigned mode)
int xsh_pre_3d_get_nx(const xsh_pre_3d *pre)
Get nx of pre_3d structure.
xsh_pre_3d * xsh_pre_3d_load(cpl_frame *frame)
Load a xsh_pre_3d structure from a frame.
int xsh_pre_3d_get_nz(const xsh_pre_3d *pre)
Get nz of pre_3d structure.
cpl_frame * xsh_pre_3d_save(const xsh_pre_3d *pre, const char *filename, int temp)
Save PRE_3D on disk.
xsh_pre_3d * xsh_pre_3d_new(int nx, int ny, int nz)
Create new PRE image.
int xsh_pre_3d_get_ny(const xsh_pre_3d *pre)
Get ny of pre_3d structure.
xsh_image_3d * xsh_pre_3d_get_qual(xsh_pre_3d *pre_3d)
Get qual.
static cpl_error_code xsh_cube_3d_save_int(xsh_image_3d *img_3d, const char *fname, cpl_propertylist *header, unsigned mode)
xsh_image_3d * xsh_pre_3d_get_data(xsh_pre_3d *pre_3d)
Get data.
#define XSH_ASSURE_NOT_ILLEGAL(cond)
#define assure(CONDITION, ERROR_CODE,...)
#define check_msg(COMMAND,...)
#define xsh_error_msg(...)
#define XSH_ASSURE_NOT_NULL(pointer)
#define xsh_msg_dbg_medium(...)
int xsh_pfits_get_naxis3(const cpl_propertylist *plist)
find out the NAXIS3 value
int xsh_pfits_get_naxis1(const cpl_propertylist *plist)
find out the NAXIS1 value
int xsh_pfits_get_naxis2(const cpl_propertylist *plist)
find out the NAXIS2 value
void xsh_free_frame(cpl_frame **f)
Deallocate a frame and set the pointer to NULL.
void xsh_free_propertylist(cpl_propertylist **p)
Deallocate a property list and set the pointer to NULL.
void xsh_free_imagelist(cpl_imagelist **i)
Deallocate an image list and set the pointer to NULL.
cpl_propertylist * data_header
cpl_propertylist * errs_header
cpl_propertylist * qual_header
#define XSH_PRE_DATA_TYPE
#define XSH_PRE_QUAL_TYPE
#define XSH_PRE_ERRS_TYPE
#define XSH_FREE(POINTER)
#define XSH_CALLOC(POINTER, TYPE, SIZE)