File: gauss.t

package info (click to toggle)
pdl 1%3A2.4.7%2Bdfsg-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 10,128 kB
  • ctags: 5,821
  • sloc: perl: 26,328; fortran: 13,113; ansic: 9,378; makefile: 71; sh: 50; sed: 6
file content (49 lines) | stat: -rw-r--r-- 1,676 bytes parent folder | download | duplicates (7)
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
# Test routine for PDL::Fit::Gaussian module

use PDL;
use PDL::Fit::Gaussian;


print "1..2\n";

kill INT,$$  if $ENV{UNDER_DEBUGGER}; # Useful for debugging.

$count=1;
sub ok {
        my $no = $count++ ;
        my $result = shift ;
        print "not " unless $result ;
        print "ok $no\n" ;
}
sub nint{int($_[0]->at+0.5)};

$g1 = pdl qw[ 2.1990459  1.9464173  2.1565406  2.1672124  2.2701938   
1.82992   1.914893  2.1466146  1.8822749  2.0293979  2.0101469   2.210302 
2.6183602  4.3191846  7.8333737  11.525845  13.069404  11.364827  7.2853706 
4.3667506  2.2601078  2.0051197   1.802916  2.1735853  1.7985277  1.9498281 
1.7745239  1.7534224  2.6137111  1.8443813  2.0064845  2.1981632  2.0572412 
1.8928303  2.0703847  2.0121833  1.9967828  2.3846479  1.8907906  2.1486651];

$g2 = pdl qw[  13.013418  11.397573  7.4494489  4.5594057  2.5728955 
2.0687907  2.1953927  2.2819689  1.7046446  2.3276816  2.0130417    1.72691 
1.8260466  2.0842572  2.2455532  1.9223378   1.695866  1.5893454  1.9787549 
1.6941413  1.8576307  2.3780392  2.2588472  2.2080773  1.8754143   2.019966 
1.9363813  2.1414206  2.0062853  2.0867273  2.0158617  1.6481802  1.9686077 
2.2979197  2.2963699  2.1171346  1.8859732  2.1277667  2.0716804  1.9251175];


my ($xc, $pk, $fwhm, $back, $err, $fit) = fitgauss1d(xvals($g1), $g1);


#points $g1; hold; line $fit; rel;

ok( nint($xc)==16 && nint($pk)==11 && nint($fwhm)==4 && nint($back)==2
  && nint($err)==0 && sum(abs($g1-$fit))<10);

($pk, $fwhm, $back, $err, $fit) = fitgauss1dr(xvals($g2),$g2);

#points $g2; hold; line $fit; rel;

ok(nint($pk)==11 && nint($fwhm)==4 && nint($back)==2
  && nint($err)==0 && sum(abs($g2-$fit))<10);