blib/lib/PDL/Fit/Gaussian.pm

filter: Statementstmt 100% 18 / 18 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 21 / 21 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/PDL/Constants.pm ↑ Summary blib/lib/PDL/Lite.pm »
1  
2 #
3 # GENERATED WITH PDL::PP! Don't modify!
4 #
5 package PDL::Fit::Gaussian;
6  
7 1 @EXPORT_OK = qw( PDL::PP fitgauss1d PDL::PP fitgauss1dr );
8 1 %EXPORT_TAGS = (Func=>[@EXPORT_OK]);
9  
10 1 ▶use PDL::Core;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use PDL::Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use DynaLoader;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14  
15  
16
17 1 @ISA = ( 'PDL::Exporter','DynaLoader' );
18 1 push @PDL::Core::PP, __PACKAGE__;
19 1 bootstrap PDL::Fit::Gaussian ;
20  
21  
22  
23  
24 =head1 NAME
25  
26 PDL::Fit::Gaussian - routines for fitting gaussians
27  
28 =head1 DESCRIPTION
29  
30  
31 This module contains some custom gaussian fitting routines.
32 These were developed in collaboration with Alison Offer,
33 they do a reasonably robust job and are quite useful.
34  
35 Gaussian fitting is something I do a lot of, so I figured
36 it was worth putting in my special code.
37  
38 Note it is not clear to me that this code is fully debugged. The reason
39 I say that is because I tried using the internal linear eqn solving
40 C routines called elsewhere and they were giving erroneous results.
41 So steal from this code with caution! However it does give good fits to
42 reasonable looking gaussians and tests show correct parameters.
43
44 KGB 29/Oct/2002
45  
46 =head1 SYNOPSIS
47  
48 use PDL;
49 use PDL::Fit::Gaussian;
50 ($cen, $pk, $fwhm, $back, $err, $fit) = fitgauss1d($x, $data);
51 ($pk, $fwhm, $back, $err, $fit) = fitgauss1dr($r, $data);
52  
53 =head1 FUNCTIONS
54  
55 =head2 fitgauss1d
56  
57 =for ref
58  
59 Fit 1D Gassian to data piddle
60  
61 =for example
62  
63 ($cen, $pk, $fwhm, $back, $err, $fit) = fitgauss1d($x, $data);
64  
65 =for usage
66  
67 ($cen, $pk, $fwhm, $back, $err, $fit) = fitgauss1d($x, $data);
68  
69 =for signature
70  
71 xval(n); data(n); [o]xcentre();[o]peak_ht(); [o]fwhm();
72 [o]background();int [o]err(); [o]datafit(n);
73 [t]sig(n); [t]xtmp(n); [t]ytmp(n); [t]yytmp(n); [t]rtmp(n);
74  
75 Fits a 1D Gaussian robustly free parameters are the centre, peak height,
76 FWHM. The background is NOT fit, because I find this is generally
77 unreliable, rather a median is determined in the 'outer' 10% of
78 pixels (i.e. those at the start/end of the data piddle). The initial
79 estimate of the FWHM is the length of the piddle/3, so it might fail
80 if the piddle is too long. (This is non-robust anyway). Most data
81 does just fine and this is a good default gaussian fitter.
82  
83 SEE ALSO: fitgauss1dr() for fitting radial gaussians
84  
85 =head2 fitgauss1dr
86  
87 =for ref
88  
89 Fit 1D Gassian to radial data piddle
90  
91 =for example
92  
93 ($pk, $fwhm2, $back, $err, $fit) = fitgauss1dr($r, $data);
94  
95 =for usage
96  
97 ($pk, $fwhm2, $back, $err, $fit) = fitgauss1dr($r, $data);
98  
99 =for signature
100  
101 xval(n); data(n); [o]peak_ht(); [o]fwhm();
102 [o]background();int [o]err(); [o]datafit(n);
103 [t]sig(n); [t]xtmp(n); [t]ytmp(n); [t]yytmp(n); [t]rtmp(n);
104  
105 Fits a 1D radial Gaussian robustly free parameters are the peak height,
106 FWHM. Centre is assumed to be X=0 (i.e. start of piddle).
107 The background is NOT fit, because I find this is generally
108 unreliable, rather a median is determined in the 'outer' 10% of
109 pixels (i.e. those at the end of the data piddle). The initial
110 estimate of the FWHM is the length of the piddle/3, so it might fail
111 if the piddle is too long. (This is non-robust anyway). Most data
112 does just fine and this is a good default gaussian fitter.
113  
114 SEE ALSO: fitgauss1d() to fit centre as well.
115  
116 =cut
117  
118  
119  
120  
121  
122  
123  
124  
125  
126 1 *fitgauss1d = \&PDL::fitgauss1d;
127  
128  
129  
130  
131  
132 1 *fitgauss1dr = \&PDL::fitgauss1dr;
133  
134  
135  
136  
137 1 1; # OK
138  
139  
140  
141  
142 =head1 BUGS
143  
144 May not converge for weird data, still pretty good!
145  
146 =head1 AUTHOR
147  
148 This file copyright (C) 1999, Karl Glazebrook (kgb@aaoepp.aao.gov.au),
149 Gaussian fitting code by Alison Offer
150 (aro@aaocbn.aao.gov.au). All rights reserved. There
151 is no warranty. You are allowed to redistribute this software /
152 documentation under certain conditions. For details, see the file
153 COPYING in the PDL distribution. If this file is separated from the
154 PDL distribution, the copyright notice should be included in the file.
155  
156  
157 =cut
158  
159  
160  
161 ;
162  
163  
164  
165 # Exit with OK status
166  
167 1 1;
168  
169
« blib/lib/PDL/Constants.pm ↑ Summary blib/lib/PDL/Lite.pm »