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