68 moo_bpm *res = cpl_calloc(1,
sizeof(moo_bpm));
89 cpl_propertylist *header)
91 cpl_ensure_code(ntas >= 1 && ntas <= 2, CPL_ERROR_ILLEGAL_INPUT);
92 cpl_ensure_code(self != NULL, CPL_ERROR_NULL_INPUT);
93 cpl_ensure_code(header != NULL, CPL_ERROR_NULL_INPUT);
95 self->data[(ntas - 1) * 3 + type] = data;
96 self->data_header[(ntas - 1) * 3 + type] = header;
98 return CPL_ERROR_NONE;
118 cpl_ensure_code(self != NULL, CPL_ERROR_NULL_INPUT);
119 cpl_ensure_code(self->filename != NULL, CPL_ERROR_NULL_INPUT);
120 cpl_error_code status = CPL_ERROR_NONE;
121 cpl_errorstate prev_state = cpl_errorstate_get();
122 cpl_propertylist *header = cpl_propertylist_new();
123 char *extname = NULL;
126 cpl_propertylist_append_string(header, MOO_PFITS_EXTNAME, extname);
130 cpl_image_save(img, self->filename, CPL_TYPE_INT, header,
134 cpl_propertylist_save(header, self->filename, CPL_IO_EXTEND);
138 if (!cpl_errorstate_is_equal(prev_state)) {
139 cpl_msg_error(
"moo_bpm",
"Error for adding data to %s %s (%s)",
140 self->filename, extname,
141 cpl_error_get_message_default(cpl_error_get_code()));
142 status = cpl_error_get_code();
160 cpl_ensure_code(a != NULL, CPL_ERROR_NULL_INPUT);
161 cpl_ensure_code(b != NULL, CPL_ERROR_NULL_INPUT);
163 cpl_error_code status = CPL_ERROR_NONE;
164 for (
int i = 0; i < 6; i++) {
165 cpl_image *im1 = a->data[i];
166 cpl_image *im2 = b->data[i];
167 if (im1 != NULL && im2 != NULL) {
168 status = cpl_image_or(im1, NULL, im2);
189 cpl_propertylist_save(self->primary_header, filename, CPL_IO_CREATE);
190 for (
int i = 0; i < 2; i++) {
191 for (
int j = 0; j < 3; j++) {
194 "QUAL", extname, CPL_TYPE_INT,
195 self->data_header[i * 3 + j]);
217 if (self->primary_header != NULL) {
218 cpl_propertylist_delete(self->primary_header);
220 for (i = 0; i < 6; i++) {
221 if (self->data[i] != NULL) {
222 cpl_image_delete(self->data[i]);
224 if (self->data_header[i] != NULL) {
225 cpl_propertylist_delete(self->data_header[i]);
228 cpl_free(self->filename);
void moo_bpm_save(moo_bpm *self, const char *filename)
Save a moo_bpm to a FITS file.
cpl_error_code moo_bpm_set_data(moo_bpm *self, moo_detector_type type, int ntas, cpl_image *data, cpl_propertylist *header)
set bpm data for relevant extension
cpl_error_code moo_bpm_merge(moo_bpm *a, moo_bpm *b)
Merge to moo_bpm structure in the first.
void moo_bpm_delete(moo_bpm *self)
Delete a moo_bpm.
cpl_error_code moo_bpm_add_data(moo_bpm *self, cpl_image *img, moo_detector_type type, int ntas)
Add CPL_IMAGE extension to BPM filename and update moo_bpm structure.
moo_bpm * moo_bpm_new(void)
Create a new moo_bpm.
const char * moo_detector_get_extname(moo_detector_type type, int ntas)
Get the extension name of a detector.
enum _moo_detector_type_ moo_detector_type
The type code type.
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.