.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Gaussian 3pm" .TH Gaussian 3pm 2024-05-12 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME PDL::Fit::Gaussian \- routines for fitting gaussians .SH DESCRIPTION .IX Header "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. .PP Gaussian fitting is something I do a lot of, so I figured it was worth putting in my special code. .PP 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. .PP .Vb 1 \& KGB 29/Oct/2002 .Ve .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 4 \& use PDL; \& use PDL::Fit::Gaussian; \& ($cen, $pk, $fwhm, $back, $err, $fit) = fitgauss1d($x, $data); \& ($pk, $fwhm, $back, $err, $fit) = fitgauss1dr($r, $data); .Ve .SH FUNCTIONS .IX Header "FUNCTIONS" .SS fitgauss1d .IX Subsection "fitgauss1d" Fit 1D Gassian to data ndarray .PP .Vb 1 \& ($cen, $pk, $fwhm, $back, $err, $fit) = fitgauss1d($x, $data); .Ve .PP .Vb 1 \& ($cen, $pk, $fwhm, $back, $err, $fit) = fitgauss1d($x, $data); .Ve .PP .Vb 3 \& 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); .Ve .PP 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. .PP SEE ALSO: \fBfitgauss1dr()\fR for fitting radial gaussians .SS fitgauss1dr .IX Subsection "fitgauss1dr" Fit 1D Gassian to radial data ndarray .PP .Vb 1 \& ($pk, $fwhm2, $back, $err, $fit) = fitgauss1dr($r, $data); .Ve .PP .Vb 1 \& ($pk, $fwhm2, $back, $err, $fit) = fitgauss1dr($r, $data); .Ve .PP .Vb 3 \& 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); .Ve .PP 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. .PP SEE ALSO: \fBfitgauss1d()\fR to fit centre as well. .SH BUGS .IX Header "BUGS" May not converge for weird data, still pretty good! .SH AUTHOR .IX Header "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.