68 moo_atm* res = cpl_calloc(1,
sizeof(moo_atm));
85 cpl_ensure(frame != NULL, CPL_ERROR_NULL_INPUT, NULL);
87 const char* filename = cpl_frame_get_filename(frame);
88 cpl_ensure(filename != NULL, CPL_ERROR_NULL_INPUT,
90 cpl_errorstate prev_state = cpl_errorstate_get();
93 res->filename = cpl_strdup(filename);
94 res->primary_header = cpl_propertylist_load( filename,0);
96 cpl_size qnum = cpl_fits_find_extension(filename,
99 res->table = cpl_table_load(res->filename,qnum,0);
102 if ( !cpl_errorstate_is_equal(prev_state)){
103 cpl_msg_debug(__func__,
"Error in loading atm : %d",cpl_error_get_code());
106 cpl_errorstate_set(prev_state);
124 cpl_ensure(self!=NULL,CPL_ERROR_NULL_INPUT,NULL);
126 cpl_table* res = cpl_table_duplicate(self->table);
127 cpl_table_new_column(res, MOO_ATM_FLUX, CPL_TYPE_DOUBLE);
128 int nrow = cpl_table_get_nrow(res);
129 const double* extinction = cpl_table_get_data_double_const(
130 res,MOO_ATM_EXTINCTION);
132 for(
int i=0; i<nrow; i++){
133 double e = extinction[i];
134 double flux = pow(10,-airm*e*0.4);
135 cpl_table_set_double(res,MOO_ATM_FLUX,i,flux);
139 cpl_table_save(res,NULL,NULL,
"extinction.fits",CPL_IO_CREATE);
157 if ( self->filename != NULL){
158 cpl_free(self->filename);
160 if ( self->primary_header!= NULL){
161 cpl_propertylist_delete(self->primary_header);
163 if ( self->table != NULL){
164 cpl_table_delete(self->table);
cpl_table * moo_atm_convert_mag_to_flux(moo_atm *self, double airm)
Get the extinction table with additonal column FLUX.
moo_atm * moo_atm_load(const cpl_frame *frame)
Load a ATM frame and create a moo_atm.
moo_atm * moo_atm_new(void)
Create a new moo_atm.
void moo_atm_delete(moo_atm *self)
Delete a moo_atm.
#define MOO_ATM_EXTNAME
ATM format.