.\" Automatically generated by Pod::Man 4.14 (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 .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . 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 "2023-06-17" "perl v5.36.0" "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, \&\s-1FWHM.\s0 The background is \s-1NOT\s0 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 \s-1FWHM\s0 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 \&\s-1SEE ALSO:\s0 \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, \&\s-1FWHM.\s0 Centre is assumed to be X=0 (i.e. start of ndarray). The background is \s-1NOT\s0 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 \s-1FWHM\s0 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 \&\s-1SEE ALSO:\s0 \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 \&\s-1COPYING\s0 in the \s-1PDL\s0 distribution. If this file is separated from the \&\s-1PDL\s0 distribution, the copyright notice should be included in the file.