Main Page | Data Structures | File List | Data Fields | Globals

common.h

Go to the documentation of this file.
00001 /*
00002         peakfinder
00003         Copyright (C) 2005 Hal Finkel
00004 
00005         This program is free software; you can redistribute it and/or modify
00006         it under the terms of the GNU General Public License as published by
00007         the Free Software Foundation; either version 2 of the License, or
00008         (at your option) any later version.
00009 
00010         This program is distributed in the hope that it will be useful,
00011         but WITHOUT ANY WARRANTY; without even the implied warranty of
00012         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013         GNU General Public License for more details.
00014 
00015         You should have received a copy of the GNU General Public License
00016         along with this program; if not, write to the Free Software
00017         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00027 #ifndef PF_COMMON_H
00028 #define PF_COMMON_H
00029 
00033 #define NCHAN 4096
00034 
00038 #define MAXCALPTS 1024
00039 
00043 #define MAXUNIT 256
00044 
00048 struct pf_peak_bg {
00049         double a; 
00050         double b; 
00051         double c; 
00052         double d; 
00054         double a_err; 
00055         double b_err; 
00056         double c_err; 
00057         double d_err; 
00059         double chisq; 
00060         double chisq_dof; 
00062         int conv; 
00063 };
00064 
00068 struct pf_peak_fit {
00069         double a; 
00070         double k; 
00071         double x0; 
00072         double m; 
00074         double a_err; 
00075         double k_err; 
00076         double x0_err; 
00077         double m_err; 
00079         double chisq; 
00080         double chisq_dof; 
00082         int conv; 
00083 };
00084 
00088 struct pf_peak {
00089         int num; 
00091         int lbin; 
00092         int cbin; 
00093         int rbin; 
00095         struct pf_peak_bg bg; 
00096         struct pf_peak_fit fit; 
00098         double center; 
00099         double width; 
00101         double lbound; 
00102         double rbound; 
00104         double bglbound; 
00105         double bgrbound; 
00107         double area; 
00108         double height; 
00109 };
00110 
00114 struct pf_cal_fit {
00115         char unit[MAXUNIT]; 
00117         double a; 
00118         double b; 
00119         double c; 
00121         double a_err; 
00122         double b_err; 
00123         double c_err; 
00125         double chisq; 
00126         double chisq_dof; 
00128         int conv; 
00130         int valid; 
00131 };
00132 
00136 struct pf_cal_pt {
00137         int num; 
00138         double pt; 
00139         double ri; 
00140 };
00141 
00145 struct pf_cal_pts {
00146         char unit[MAXUNIT]; 
00148         int npts; 
00149         struct pf_cal_pt pts[MAXCALPTS]; 
00150         struct pf_cal_pt* pts_by_value[MAXCALPTS]; 
00151         struct pf_cal_pt* pts_by_ri[MAXCALPTS]; 
00152 };
00153 
00157 struct pf_data {
00158         double data_raw[NCHAN]; 
00159         double data_norm[NCHAN]; 
00161         double max_raw; 
00162         double min_raw; 
00163         double max_norm; 
00164         double min_norm; 
00166         int total_counts; 
00167         double total_chisq; 
00169         int data_bg[NCHAN]; 
00171         int npeaks; 
00172         struct pf_peak peaks[NCHAN]; 
00173         struct pf_peak* peaks_by_number[NCHAN]; 
00174         struct pf_peak* peaks_by_height[NCHAN]; 
00175         struct pf_peak* peaks_by_area[NCHAN]; 
00176 };
00177 
00181 struct pf_plot_params {
00182         double xstart; 
00183         double xend; 
00185         int xstartcal; 
00186         int xendcal; 
00188         int peak; 
00190         char* fn; 
00191         char* dev; 
00193         double rot; 
00194         int norm; 
00195         int rescale; 
00196         int cal; 
00197         int marked; 
00198         int annot; 
00199 };
00200 
00204 enum pf_peak_sort {
00205         sort_number, 
00206         sort_height, 
00207         sort_area 
00208 };
00209 
00215 int pf_parse_command(char* command);
00216 
00223 int pf_loaddata(char* fn, struct pf_data* d);
00224 
00233 double pf_chanwindowavg(double* data, int ds, int ci, int ac);
00234 
00241 void pf_plotdata(struct pf_data* d, struct pf_plot_params* p, struct pf_cal_fit* cal);
00242 
00249 void pf_plotpeak(struct pf_data* d, struct pf_plot_params* p, struct pf_cal_fit* cal);
00250 
00258 int pf_printdata(struct pf_data* d, char* fn, int norm);
00259 
00267 int pf_printpeaks(struct pf_data* d, char* fn, enum pf_peak_sort srt);
00268 
00277 int pf_printpeak(struct pf_data* d, struct pf_cal_fit* cal, int peak, char* fn);
00278 
00286 int pf_printcal(struct pf_data* d, struct pf_cal_fit* f, char* fn);
00287 
00292 void pf_fitpeaks(struct pf_data* d);
00293 
00298 void pf_prunepeaks(struct pf_data* d);
00299 
00307 double pf_bgfunc(struct pf_data* d, int peak, double x);
00308 
00316 double pf_peakfunc(struct pf_data* d, int peak, double x);
00317 
00325 double pf_fitfunc(struct pf_data* d, int peak, double x);
00326 
00334 int pf_calibrate(struct pf_data* d, struct pf_cal_fit* f, char* fn);
00335 
00342 double pf_calfunc(struct pf_cal_fit* f, double ch);
00343 
00344 #endif
00345 

Generated on Sun Feb 20 17:46:14 2005 for peakfinder-0.1 by  doxygen 1.3.9.1