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