1Gaussian(3) User Contributed Perl Documentation Gaussian(3)
2
3
4
6 PDL::Fit::Gaussian - routines for fitting gaussians
7
9 This module contains some custom gaussian fitting routines. These were
10 developed in collaboration with Alison Offer, they do a reasonably
11 robust job and are quite useful.
12
13 Gaussian fitting is something I do a lot of, so I figured it was worth
14 putting in my special code.
15
16 Note this code is also used in the Karma package.
17
18 Note it is not clear to me that this code is fully debugged. The reason
19 I say that is because I tried using the internal linear eqn solving C
20 routines called elsewhere and they were giving erroneous results. So
21 steal from this code with caution! However it does give good fits to
22 reasonable looking gaussians and tests show correct parameters.
23
24 KGB 29/Oct/2002
25
27 use PDL;
28 use PDL::Fit::Gaussian;
29 ($cen, $pk, $fwhm, $back, $err, $fit) = fitgauss1d($x, $data);
30 ($pk, $fwhm, $back, $err, $fit) = fitgauss1dr($r, $data);
31
33 fitgauss1d
34 Fit 1D Gassian to data piddle
35
36 ($cen, $pk, $fwhm, $back, $err, $fit) = fitgauss1d($x, $data);
37
38 ($cen, $pk, $fwhm, $back, $err, $fit) = fitgauss1d($x, $data);
39
40 xval(n); data(n); [o]xcentre();[o]peak_ht(); [o]fwhm();
41 [o]background();int [o]err(); [o]datafit(n); [t]sig(n); [t]xtmp(n);
42 [t]ytmp(n); [t]yytmp(n); [t]rtmp(n);
43
44 Fits a 1D Gaussian robustly free parameters are the centre, peak
45 height, FWHM. The background is NOT fit, because I find this is
46 generally unreliable, rather a median is determined in the 'outer' 10%
47 of pixels (i.e. those at the start/end of the data piddle). The initial
48 estimate of the FWHM is the length of the piddle/3, so it might fail if
49 the piddle is too long. (This is non-robust anyway). Most data does
50 just fine and this is a good default gaussian fitter.
51
52 SEE ALSO: fitgauss1dr() for fitting radial gaussians
53
54 fitgauss1dr
55 Fit 1D Gassian to radial data piddle
56
57 ($pk, $fwhm2, $back, $err, $fit) = fitgauss1dr($r, $data);
58
59 ($pk, $fwhm2, $back, $err, $fit) = fitgauss1dr($r, $data);
60
61 xval(n); data(n); [o]peak_ht(); [o]fwhm(); [o]background();int
62 [o]err(); [o]datafit(n); [t]sig(n); [t]xtmp(n); [t]ytmp(n);
63 [t]yytmp(n); [t]rtmp(n);
64
65 Fits a 1D radial Gaussian robustly free parameters are the peak height,
66 FWHM. Centre is assumed to be X=0 (i.e. start of piddle). The
67 background is NOT fit, because I find this is generally unreliable,
68 rather a median is determined in the 'outer' 10% of pixels (i.e. those
69 at the end of the data piddle). The initial estimate of the FWHM is the
70 length of the piddle/3, so it might fail if the piddle is too long.
71 (This is non-robust anyway). Most data does just fine and this is a
72 good default gaussian fitter.
73
74 SEE ALSO: fitgauss1d() to fit centre as well.
75
77 May not converge for weird data, still pretty good!
78
80 This file copyright (C) 1999, Karl Glazebrook (kgb@aaoepp.aao.gov.au),
81 Gaussian fitting code by Alison Offer (aro@aaocbn.aao.gov.au). All
82 rights reserved. There is no warranty. You are allowed to redistribute
83 this software / documentation under certain conditions. For details,
84 see the file COPYING in the PDL distribution. If this file is separated
85 from the PDL distribution, the copyright notice should be included in
86 the file.
87
88
89
90perl v5.12.3 2011-03-31 Gaussian(3)