projects/barrel/
brl_find511.pro
pro mygauss() and function brl_find511() ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ evaluate gaussian + linear model for use with curvefit() model is f(x) = a[0]*exp(-((x-a[1])/a[2])^2) + a[3]x + a[4] INPUT: x is where the model is to be evaluated a is the current list of 5 parameter values; these must be initialized by the caller OUTPUT: f is evaluated as a linear+gaussian model pder is a list of 5 partial derivatives of f wrt a WARNING: for speed, no checks for foolish function evaluation requests. Caller is responsible! For instance, if one sets a[2]=0 or (x-a[1])/a[2]=1000 for some x, expect error msgs and/or nonsense output.
+ find the slow spectrum bin value of the 511 line INPUT: slo list of 256 slow spectrum count rates (counts/second) the slo list should not be normalized by bin widths OUTPUT: bin value for the 511 peak (usually not an integer) -1 on failure (511 peak not found) OPTIONS: offset=offset low bdy for 511 search region (default is 100) err=err 1-sigma uncertainties for each slo value; this should be should be a list of sqrt(# of counts)/(integration time in seconds) ACTION: limit the search to a reasonable part of the entire spectrum. Fit a line to the two endpoints of the search region, and subtract off the line. Then find the midpoint position of the list of values exceeding 50% of the max residual. That becomes a start guess for the peak location, modeled by a line+Gaussian. Amplitude and width are hard-coded typical values. Fit model to data and get best fit peak location. If the fit looks good, return its position; else return -1 to signal failure. HISTORY: first version working 31Dec2012/mm FUTURE: might need to adjust testing for valid 511 peak EXAMPLE: peak = brl_find511(spec, offset=95) peak = brl_find511(spec, err=sigmas)
Routines
Routines from brl_find511.pro
Routine details
File attributes
Modification date: | Tue Oct 21 13:53:32 2014 |
Lines: | 63 |