00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifdef HAVE_CONFIG_H
00030 # include <config.h>
00031 #endif
00032
00033
00034
00035
00036
00037 #include "sinfo_utl_spectrum_divide_by_blackbody.h"
00038
00039 #include <sinfo_spectrum_ops.h>
00040 #include "sinfo_key_names.h"
00041 #include "sinfo_error.h"
00042 #include "sinfo_utils_wrappers.h"
00043 #include "sinfo_msg.h"
00044
00045
00046
00047
00048
00049
00050
00059
00060
00061
00062
00063
00070
00071 int sinfo_utl_spectrum_divide_by_blackbody(
00072 cpl_parameterlist * parlist,
00073 cpl_frameset * framelist)
00074 {
00075 cpl_parameter * param =NULL;
00076 const char * name_i =NULL;
00077 const char * name_o =NULL;
00078
00079 double temp=0 ;
00080
00081 cpl_frame * frm_spct=NULL ;
00082
00083 cpl_propertylist * plist=NULL ;
00084
00085
00086 cpl_frame * product_frame=NULL;
00087 cpl_image * bb_img=NULL;
00088 cpl_image * image_o=NULL;
00089 cpl_image * image_i=NULL;
00090
00091 Vector* bb=NULL;
00092
00093
00094
00095
00096 name_o = "out_ima.fits";
00097
00098
00099
00100 check_nomsg(param = cpl_parameterlist_find(parlist,
00101 "sinfoni.sinfo_utl_spectrum_divide_by_blackbody.temperature"));
00102 check_nomsg(temp = cpl_parameter_get_double(param));
00103
00104
00105 check(frm_spct = cpl_frameset_find(framelist,
00106 SI_UTL_SPECTRUM_DIVIDE_BY_BLACKBODY_SPECTRUM),
00107 "SOF does not have a file tagged as %s",
00108 SI_UTL_SPECTRUM_DIVIDE_BY_BLACKBODY_SPECTRUM);
00109
00110 check(plist=cpl_propertylist_load(cpl_frame_get_filename(frm_spct),
00111 0),"Cannot read the FITS header") ;
00112
00113
00114
00115 check_nomsg(name_i = cpl_frame_get_filename(frm_spct));
00116 check_nomsg(image_i= cpl_image_load((char*)name_i, CPL_TYPE_FLOAT,0,0));
00117 cknull_nomsg(bb= sinfo_new_blackbody_spectrum ((char*)name_i, temp));
00118 cknull_nomsg(bb_img = sinfo_new_vector_to_image(bb));
00119 cknull_nomsg(image_o = sinfo_new_div_image_by_spectrum (image_i,bb_img));
00120
00121
00122
00123
00124
00125 check_nomsg(product_frame = cpl_frame_new());
00126 check_nomsg(cpl_frame_set_filename(product_frame, name_o)) ;
00127 check_nomsg(cpl_frame_set_tag(product_frame,
00128 SI_UTL_SPECTRUM_DIVIDE_BY_BLACKBODY_PROSPECTRUM));
00129 check_nomsg(cpl_frame_set_type(product_frame, CPL_FRAME_TYPE_IMAGE));
00130 check_nomsg(cpl_frame_set_group(product_frame, CPL_FRAME_GROUP_PRODUCT));
00131 check_nomsg(cpl_frame_set_level(product_frame, CPL_FRAME_LEVEL_FINAL));
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142 check(cpl_image_save(image_o, name_o, CPL_BPP_DEFAULT, plist,
00143 CPL_IO_DEFAULT),"Could not save product");
00144
00145
00146 check_nomsg(cpl_frameset_insert(framelist, product_frame));
00147
00148 cleanup:
00149
00150 sinfo_free_propertylist(&plist) ;
00151 sinfo_free_image(&image_i);
00152 sinfo_free_image(&image_o);
00153 sinfo_free_image(&bb_img);
00154
00155
00156
00157 if (cpl_error_get_code())
00158 return -1 ;
00159 else
00160 return 0 ;
00161 }