"Fossies" - the Fresh Open Source Software Archive

Member "PDL-2.080/GENERATED/PDL/Fit/Gaussian.pm" (28 May 2022, 4053 Bytes) of package /linux/misc/PDL-2.080.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Gaussian.pm" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.079_vs_2.080.

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