Debian Codegraph @

GENERATED/PDL/Fit/Gaussian.pm

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