59#define MODULE_ID "XSH_DETECT_LINE_FILE"
65 cpl_propertylist_append_double(plist,
XSH_EXPTIME,10.);
66 cpl_propertylist_append_double(plist,
XSH_RON,1.);
67 cpl_propertylist_append_double(plist,
XSH_CONAD,1.);
71 cpl_propertylist_append_double(plist,
XSH_PSZX,15.);
72 cpl_propertylist_append_double(plist,
XSH_PSZY,15.);
75 cpl_propertylist_append_int(plist,
XSH_CHIP_NY,2048);
78 return cpl_error_get_code();
81#define PI_NUMB (3.1415926535897932384626433832795)
89int main(
int argc,
char** argv)
96 cpl_image* image = NULL;
97 cpl_image* gauss = NULL;
98 cpl_image* img_err = NULL;
99 cpl_image* img_line = NULL;
113 int size=1+2*(gauss_sx+gauss_sy);
122 cpl_frame* frm_raw=NULL;
123 cpl_frame* frm_line=NULL;
125 const char* name_out=
"line.fits";
128 cpl_propertylist* plist=NULL;
129 const char* name_line = NULL;
134 cpl_msg_set_level( CPL_MSG_DEBUG);
139 nb_frames = argc - optind;
140 if ( nb_frames == 1 ) {
141 name_line = argv[optind];
144 xsh_msg(
"********** NOT ENOUGH INPUT FRAMES **********" ) ;
149 img_line = cpl_image_load(name_line,CPL_TYPE_DOUBLE,0,0);
150 sx=cpl_image_get_size_x(img_line);
151 sy=cpl_image_get_size_y(img_line);
157 plist=cpl_propertylist_new();
161 check(cpl_image_save(img_line,name_out,
162 CPL_BPP_IEEE_FLOAT,plist,CPL_IO_DEFAULT));
167 CPL_FRAME_TYPE_IMAGE,
169 CPL_FRAME_LEVEL_FINAL));
172 img_err=cpl_image_new(sx,sy,CPL_TYPE_DOUBLE);
173 cpl_image_add_scalar(img_err,1.);
177 cpl_array* parameters=cpl_array_new(7, CPL_TYPE_DOUBLE);
178 cpl_array* err_params=cpl_array_new(7, CPL_TYPE_DOUBLE);
179 cpl_array* fit_params=cpl_array_new(7, CPL_TYPE_INT);
182 for (i = 0; i < 7; i++)
183 cpl_array_set(fit_params, i, 1);
187 cpl_matrix* covariance=NULL;
188 cpl_matrix* phys_cov=NULL;
204 check(cpl_fit_image_gaussian(img_line, img_err, xpos, ypos,
size,
size,
205 parameters,err_params,fit_params,
206 &rms,&red_chisq,&covariance,
207 &major,&minor,&angle,&phys_cov));
221 back=cpl_array_get(parameters,0,NULL);
222 norm=cpl_array_get(parameters,1,NULL);
223 rho=cpl_array_get(parameters,2,NULL);
225 cen_x=cpl_array_get(parameters,3,NULL);
226 cen_y=cpl_array_get(parameters,4,NULL);
227 sig_x=cpl_array_get(parameters,5,NULL);
228 sig_y=cpl_array_get(parameters,6,NULL);
229 fwhm_x=sig_x*CPL_MATH_FWHM_SIG;
230 fwhm_y=sig_y*CPL_MATH_FWHM_SIG;
232 double sig_xy=sig_x*sig_x;
233 double sig_x2=sig_x*sig_x;
234 double sig_y2=sig_y*sig_y;
236 double theta=0.5*atan( 2.*rho * (sig_xy) / (sig_x2 - sig_y2) );
237 double a=sig_xy*sqrt( 2.*(1.-rho2) * cos(2.*theta)/(sig_x2+sig_y2) * cos(2.*theta) + sig_y2 - sig_x2);
238 double b=sig_xy*sqrt( 2.*(1.-rho2) * cos(2.*theta)/(sig_x2+sig_y2) * cos(2.*theta) - sig_y2 + sig_x2);
240 xsh_msg(
"%s R: [%f,%f], Back: %f Norm: %f Sigma: [%f,%f] FWHM [%f,%f] theta,a,b: [%f(%f),%f,%f]",
241 name_line,cen_x,cen_y,back,norm,sig_x,sig_y,fwhm_x,fwhm_y,theta,theta*180./
PI_NUMB,a,b);
283 if (cpl_error_get_code() != CPL_ERROR_NONE) {
int main()
Unit test of xsh_bspline_interpol.
static xsh_instrument * instrument
#define xsh_error_dump(level)
void xsh_instrument_set_arm(xsh_instrument *i, XSH_ARM arm)
Set an arm on instrument structure.
xsh_instrument * xsh_instrument_new(void)
create new instrument structure
#define xsh_msg(...)
Print a message on info level.
void xsh_free_image(cpl_image **i)
Deallocate an image and set the pointer to NULL.
void xsh_free_frame(cpl_frame **f)
Deallocate a frame and set the pointer to NULL.
int xsh_debug_level_set(int level)
set debug level
void xsh_free_propertylist(cpl_propertylist **p)
Deallocate a property list and set the pointer to NULL.
#define TESTS_INIT(DRL_ID)
cpl_frame * xsh_frame_product(const char *fname, const char *tag, cpl_frame_type type, cpl_frame_group group, cpl_frame_level level)
Creates a frame with given characteristics.