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