64 const char *detectorname,
65 cpl_propertylist *header)
67 cpl_ensure_code(filename != NULL, CPL_ERROR_NULL_INPUT);
68 cpl_ensure_code(detectorname != NULL, CPL_ERROR_NULL_INPUT);
72 extname = cpl_sprintf(
"%s", detectorname);
75 extname = cpl_sprintf(
"%s_%s", name, detectorname);
78 cpl_propertylist *h = NULL;
81 h = cpl_propertylist_duplicate(header);
84 h = cpl_propertylist_new();
87 if (cpl_propertylist_has(h, MOO_PFITS_EXTNAME) == 0) {
88 moo_try_check(cpl_propertylist_append_string(h, MOO_PFITS_EXTNAME,
94 moo_try_check(cpl_mask_save(mask, filename, h, CPL_IO_EXTEND),
" ");
97 moo_try_check(cpl_propertylist_save(h, filename, CPL_IO_EXTEND),
" ");
100 cpl_propertylist_delete(h);
102 return cpl_error_get_code();
124 const char *filename,
126 const char *detectorname,
128 cpl_propertylist *header)
130 cpl_ensure_code(filename != NULL, CPL_ERROR_NULL_INPUT);
131 cpl_ensure_code(detectorname != NULL, CPL_ERROR_NULL_INPUT);
135 extname = cpl_sprintf(
"%s", detectorname);
138 extname = cpl_sprintf(
"%s_%s", name, detectorname);
140 cpl_propertylist *h = NULL;
142 if (header != NULL) {
143 h = cpl_propertylist_duplicate(header);
146 h = cpl_propertylist_new();
149 if (cpl_propertylist_has(h, MOO_PFITS_EXTNAME) == 0) {
150 moo_try_check(cpl_propertylist_append_string(h, MOO_PFITS_EXTNAME,
156 moo_try_check(cpl_image_save(image, filename, type, h, CPL_IO_EXTEND),
160 moo_try_check(cpl_propertylist_save(h, filename, CPL_IO_EXTEND),
" ");
165 cpl_propertylist_delete(h);
167 return cpl_error_get_code();
188 const char *filename,
190 const char *detectorname,
191 cpl_propertylist *header)
193 cpl_ensure_code(filename != NULL, CPL_ERROR_NULL_INPUT);
194 cpl_ensure_code(detectorname != NULL, CPL_ERROR_NULL_INPUT);
198 extname = cpl_sprintf(
"%s", detectorname);
201 extname = cpl_sprintf(
"%s_%s", name, detectorname);
204 cpl_propertylist *h = NULL;
206 if (header != NULL) {
207 h = cpl_propertylist_duplicate(header);
210 h = cpl_propertylist_new();
213 if (cpl_propertylist_has(h, MOO_PFITS_EXTNAME) == 0) {
214 moo_try_check(cpl_propertylist_append_string(h, MOO_PFITS_EXTNAME,
220 moo_try_check(cpl_table_save(table, NULL, h, filename, CPL_IO_EXTEND),
224 moo_try_check(cpl_propertylist_save(h, filename, CPL_IO_EXTEND),
" ");
227 cpl_propertylist_delete(h);
229 return cpl_error_get_code();
251 const char *filename,
253 const char *detectorname,
255 cpl_propertylist *header)
257 cpl_ensure_code(filename != NULL, CPL_ERROR_NULL_INPUT);
258 cpl_ensure_code(detectorname != NULL, CPL_ERROR_NULL_INPUT);
262 extname = cpl_sprintf(
"%s", detectorname);
265 extname = cpl_sprintf(
"%s_%s", name, detectorname);
267 cpl_propertylist *h = NULL;
269 if (header != NULL) {
270 h = cpl_propertylist_duplicate(header);
273 h = cpl_propertylist_new();
276 if (cpl_propertylist_has(h, MOO_PFITS_EXTNAME) == 0) {
277 moo_try_check(cpl_propertylist_append_string(h, MOO_PFITS_EXTNAME,
283 moo_try_check(cpl_imagelist_save(cube, filename, type, h,
288 moo_try_check(cpl_propertylist_save(h, filename, CPL_IO_EXTEND),
" ");
291 cpl_propertylist_delete(h);
293 return cpl_error_get_code();
313 const char *detectorname,
316 cpl_ensure(filename != NULL, CPL_ERROR_NULL_INPUT, NULL);
317 cpl_ensure(detectorname != NULL, CPL_ERROR_NULL_INPUT, NULL);
319 cpl_image *res = NULL;
323 extname = cpl_sprintf(
"%s", detectorname);
326 extname = cpl_sprintf(
"%s_%s", name, detectorname);
328 cpl_size extnum = cpl_fits_find_extension(filename, extname);
330 moo_try_check(res = cpl_image_load(filename, type, 0, extnum),
331 "Can't load image extension %" CPL_SIZE_FORMAT
336 cpl_msg_debug(
"moo_fits",
"Couldn't find extension %s in %s", extname,
361 const char *detectorname)
363 cpl_ensure(filename != NULL, CPL_ERROR_NULL_INPUT, NULL);
364 cpl_ensure(detectorname != NULL, CPL_ERROR_NULL_INPUT, NULL);
366 cpl_table *res = NULL;
370 extname = cpl_sprintf(
"%s", detectorname);
373 extname = cpl_sprintf(
"%s_%s", name, detectorname);
375 cpl_size extnum = cpl_fits_find_extension(filename, extname);
377 moo_try_check(res = cpl_table_load(filename, extnum, 0),
378 "Can't load table extension %" CPL_SIZE_FORMAT
383 cpl_msg_debug(
"moo_fits",
"Couldn't find extension %s in %s", extname,
408 const char *detectorname)
410 cpl_ensure(filename != NULL, CPL_ERROR_NULL_INPUT, NULL);
411 cpl_ensure(detectorname != NULL, CPL_ERROR_NULL_INPUT, NULL);
413 cpl_mask *res = NULL;
417 extname = cpl_sprintf(
"%s", detectorname);
420 extname = cpl_sprintf(
"%s_%s", name, detectorname);
422 cpl_size extnum = cpl_fits_find_extension(filename, extname);
424 moo_try_check(res = cpl_mask_load(filename, 0, extnum),
425 "Can't load mask extension %" CPL_SIZE_FORMAT
430 cpl_msg_debug(
"moo_fits",
"Couldn't find extension %s in %s", extname,
457 const char *detectorname,
460 cpl_ensure(filename != NULL, CPL_ERROR_NULL_INPUT, NULL);
461 cpl_ensure(detectorname != NULL, CPL_ERROR_NULL_INPUT, NULL);
463 cpl_imagelist *res = NULL;
467 extname = cpl_sprintf(
"%s", detectorname);
470 extname = cpl_sprintf(
"%s_%s", name, detectorname);
472 cpl_size extnum = cpl_fits_find_extension(filename, extname);
474 moo_try_check(res = cpl_imagelist_load(filename, type, extnum),
475 "Can't load image extension %" CPL_SIZE_FORMAT
480 cpl_msg_debug(
"moo_fits",
"Couldn't find extension %s in %s", extname,
488moo_fits_load_extension_header(
const char *filename,
490 const char *detectorname)
492 cpl_ensure(filename != NULL, CPL_ERROR_NULL_INPUT, NULL);
493 cpl_ensure(detectorname != NULL, CPL_ERROR_NULL_INPUT, NULL);
495 cpl_propertylist *res = NULL;
499 extname = cpl_sprintf(
"%s", detectorname);
502 extname = cpl_sprintf(
"%s_%s", name, detectorname);
504 cpl_size extnum = cpl_fits_find_extension(filename, extname);
506 moo_try_check(res = cpl_propertylist_load(filename, extnum),
507 "Can't load header extension %" CPL_SIZE_FORMAT
512 cpl_msg_debug(
"moo_fits",
"Couldn't find extension %s in %s", extname,
535 cpl_ensure_code(filename != NULL, CPL_ERROR_NULL_INPUT);
536 cpl_propertylist *h = cpl_propertylist_new();
537 moo_try_check(cpl_propertylist_save(h, filename, CPL_IO_CREATE),
" ");
540 cpl_propertylist_delete(h);
541 return cpl_error_get_code();
cpl_error_code moo_fits_write_extension_mask(cpl_mask *mask, const char *filename, const char *name, const char *detectorname, cpl_propertylist *header)
Write a mask as extension in FITS file.
cpl_error_code moo_fits_write_extension_image(cpl_image *image, const char *filename, const char *name, const char *detectorname, cpl_type type, cpl_propertylist *header)
Write an image as extension in FITS file.
cpl_error_code moo_fits_create(const char *filename)
Create a new fits file with empty propertylist.
cpl_mask * moo_fits_load_extension_mask(const char *filename, const char *name, const char *detectorname)
Load a mask from FITS file.
cpl_table * moo_fits_load_extension_table(const char *filename, const char *name, const char *detectorname)
Load a table from FITS file.
cpl_image * moo_fits_load_extension_image(const char *filename, const char *name, const char *detectorname, cpl_type type)
Load an image from FITS file.
cpl_imagelist * moo_fits_load_extension_cube(const char *filename, const char *name, const char *detectorname, cpl_type type)
Load a cube from FITS file.
cpl_error_code moo_fits_write_extension_table(cpl_table *table, const char *filename, const char *name, const char *detectorname, cpl_propertylist *header)
Write an image as extension in FITS file.
cpl_error_code moo_fits_write_extension_cube(cpl_imagelist *cube, const char *filename, const char *name, const char *detectorname, cpl_type type, cpl_propertylist *header)
Write a cube as extension in FITS file.