← Index
Performance Profile   « block view • line view • sub view »
For /wise/base/deliv/dev/bin/getfix
  Run on Thu May 20 15:30:03 2010
Reported on Thu May 20 16:25:43 2010

File/wise/base/deliv/dev/lib/perl/WISE/FITSIO/Utils.pm
Statements Executed65268868
Total Time113.217757998822 seconds

Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
29531612141.6190762.56564WISE::WCS::pix2wcs
29531612141.0062963.67543WISE::WCS::wcs2pix
12471210.352150.75214WISE::WCS::new
24940210.136510.22593WISE::WCS::yscale
24940210.133280.21611WISE::WCS::nxpix
12471110.052120.05212WISE::WCS::AUTOLOAD
00000WISE::WCS::BEGIN
00000WISE::WCS::DESTROY
00000WISE::WCS::__ANON__[:34]
00000WISE::WCS::nypix
00000WISE::WCS::xref
00000WISE::WCS::xscale
00000WISE::WCS::yref
00000main::BEGIN

LineStmts.Exclusive
Time
Avg.Code
1
234.4e-51.5e-5use strict;
# spent 15µs making 1 call to strict::import
336.1e-52.0e-5use warnings;
# spent 45µs making 1 call to warnings::import
460.000111.9e-5use 5.010;
# spent 40µs making 1 call to feature::import
5
634.6e-51.5e-5use WISE::Env (cfglib=>'/wise/base/deliv/dev/lib/perl');
# spent 547µs making 1 call to WISE::Env::import
7
8# Misc utility FITS-based objects
9
10package WISE::WCS;
11
12# Lightweight WCS package that by-passes the WISE::FITSIO overhead
13
1433.9e-51.3e-5use Astro::FITS::CFITSIO qw(:constants);
# spent 1.76ms making 1 call to Exporter::import
1530.001130.00038use Astro::WCS::LibWCS;
# spent 41µs making 1 call to Exporter::import
16
1733.0e-51.0e-5use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION $AUTOLOAD);
# spent 99µs making 1 call to vars::import
1830.001210.00040use Exporter::Lite;
# spent 39µs making 1 call to Exporter::Lite::import
1911.0e-61.0e-6$VERSION = 1.00;
2012.0e-62.0e-6@ISA = qw();
21
22124710.017841.4e-6
# spent 52.1ms within WISE::WCS::AUTOLOAD which was called 12471 times, avg 4µs/call: # 12471 times (52.1ms+0) by WISE::WCS::DESTROY at line 97, avg 4µs/call
sub AUTOLOAD {}
23
24
# spent 752ms (352+400) within WISE::WCS::new which was called 12471 times, avg 60µs/call: # 12470 times (352ms+400ms) at line 993 of /wise/base/deliv/dev/bin/getfix, avg 60µs/call # once (49µs+152µs) at line 504 of /wise/base/deliv/dev/bin/getfix
sub new {
25124710.018571.5e-6 my $this = shift;
26124710.007015.6e-7 my $hdr = shift;
27124710.014241.1e-6 my $opts = shift || {};
28124710.015691.3e-6 my $err = "*** $0/WCS/new";
29124710.006815.5e-7 warn("$err: No input header specified.\n"), return if ! $hdr;
30124710.008987.2e-7 my $class = ref($this) || $this;
31
32124710.011589.3e-7 $this = {};
33
34124710.059804.8e-6 my $yell = $this->{yell} = $opts->{warn} ? sub{warn @_} : sub{die @_};
35
36124710.020091.6e-6 if(! ref $hdr) {
37 my $file;
38 if(length($hdr) < 2880 || (length($hdr)%2880) != 0) {
39 # Assume a WCS-laden FITS image file name was passed
40 $file = $hdr;
41 my ($stat,$nhdr,$fp);
42 Astro::FITS::CFITSIO::ffopen($fp="",$file,READONLY,$stat=0);
43 $yell->("$err: Unable to open file '$file'; Stat=$stat.\n"), return
44 if ! $fp || $stat;
45 Astro::FITS::CFITSIO::fits_hdr2str($fp,1,$hdr="",$nhdr=0,$stat);
46 $yell->("$err: Unable retrieve from file '$file' (1)".
47 "; Stat=$stat.\n"), return
48 if ! $hdr || $stat;
49 ffclos($fp,$stat);
50 } else {
51 $file = "<STRING>";
52 }
53 $this->{hdrstr} = $hdr;
54 $this->{wcs} = Astro::WCS::LibWCS::wcsinit($hdr);
55 $yell->("$err: Unable to init WCS from file '$file' (1).\n"), return
56 if ! $this->{wcs};
57 } elsif(ref($hdr) =~ /fitsio/i) {
58 # It's a fitsio object, so get the header string
59 my $file = $hdr->file();
60 my $hdr2 = $hdr->hdrstr() or
61 $yell->("$err: Unable to retrieve header from '$file' (2).\n"),
62 return;
63 $hdr = $this->{hdrstr} = $hdr2;
64 $this->{wcs} = Astro::WCS::LibWCS::wcsinit($hdr);
65 $yell->("$err: Unable to init WCS from file '$file' (2).\n"), return
66 if ! $this->{wcs};
67 } else {
68 # Assume WCS keyword values passed directly (bypassing header i/o)
69 # as a hash ref
70124710.012921.0e-6 my $nx = $hdr->{nxpix} || $hdr->{npix};
71124710.008987.2e-7 my $ny = $hdr->{nypix} || $nx;
72124710.484843.9e-5 $this->{wcs} = Astro::WCS::LibWCS::wcskinit
# spent 400ms making 12471 calls to Astro::WCS::LibWCS::wcskinit, avg 32µs/call
73 ($nx,$ny,
74 $hdr->{ctype1}||'RA---SIN-SIP',
75 $hdr->{ctype2}||'DEC--SIN-SIP',
76 $hdr->{crpix1}//$hdr->{crpix}//($nx/2+0.5),
77 $hdr->{crpix2}//$hdr->{crpix1}//$hdr->{crpix}//($ny/2+0.5),
78 $hdr->{crval1}//$hdr->{lon}//$hdr->{ra},
79 $hdr->{crval2}//$hdr->{lat}//$hdr->{dec},
80 $hdr->{cd}//undef,
81 $hdr->{cdelt1}||(-($hdr->{cdelt}||0)),
82 $hdr->{cdelt2}||(-($hdr->{cdelt1}||0))||$hdr->{cdelt},
83 $hdr->{crota2}//$hdr->{crota}//(-($hdr->{pa}||0)),
84 $hdr->{equinox}||2000,
85 $hdr->{epoch}||0
86 );
87 $yell->("$err: Unable to init WCS from keywords: ",
88124710.011829.5e-7 join(", ", map {"$_=$hdr->{$_}"} keys %$hdr),
89 "\n"), return
90 if ! $this->{wcs};
91 }
92
93124710.037723.0e-6 return bless $this,$class;
94}
95
96sub DESTROY {
97124710.076046.1e-6 $_[0]->wcsfree();
# spent 52.1ms making 12471 calls to WISE::WCS::AUTOLOAD, avg 4µs/call
98}
99
100
# spent 63.7s (41.0+22.7) within WISE::WCS::wcs2pix which was called 2953161 times, avg 22µs/call: # 2909482 times (40.4s+22.3s) by main::overlap at line 1304 of /wise/base/deliv/dev/bin/getfix, avg 22µs/call # 43679 times (616ms+348ms) by main::overlap at line 1293 of /wise/base/deliv/dev/bin/getfix, avg 22µs/call
sub wcs2pix {
10129531612.342927.9e-7 my $this = shift;
10229531613.656981.2e-6 my $err = "*** $0/WCS/2pix";
10329531611.895536.4e-7 if(! ref $this) {
104 $this = $this->new(shift) or return;
105 }
10629531612.008096.8e-7 my $yell = $this->{yell};
10729531612.521628.5e-7 $yell->("$err: Bad position count; ".@_." not >0 and even.\n"), return
108 if ! @_ || (@_%2) != 0;
10929531611.627395.5e-7 my ($x,$y,$off);
11029531611.278414.3e-7 my @out;
11129531613.090331.0e-6 while(@_) {
112295316127.831259.4e-6 $this->{wcs}->wcs2pix(shift(@_),shift(@_),$x,$y,$off);
# spent 22.7s making 2953161 calls to WCSPtr::wcs2pix, avg 8µs/call
11329531614.918751.7e-6 push @out, ($x, $y);
114 }
11529531615.652201.9e-6 return wantarray ? @out : \@out;
116}
117
118
# spent 62.6s (41.6+20.9) within WISE::WCS::pix2wcs which was called 2953161 times, avg 21µs/call: # 2909482 times (41.0s+20.6s) by main::overlap at line 1304 of /wise/base/deliv/dev/bin/getfix, avg 21µs/call # 43679 times (633ms+364ms) by main::overlap at line 1293 of /wise/base/deliv/dev/bin/getfix, avg 23µs/call
sub pix2wcs {
11929531612.261947.7e-7 my $this = shift;
12029531613.589771.2e-6 my $err = "*** $0/WCS/2wcs";
12129531611.905696.5e-7 if(! ref $this) {
122 $this = $this->new(shift) or return;
123 }
12429531612.055607.0e-7 my $yell = $this->{yell};
12529531612.446878.3e-7 $yell->("$err: Bad position count; ".@_." not >0 and even.\n"), return
126 if ! @_ || (@_%2) != 0;
12729531611.592925.4e-7 my ($lon,$lat);
12829531611.307034.4e-7 my @out;
12929531613.152621.1e-6 while(@_) {
130295316126.060228.8e-6 $this->{wcs}->pix2wcs(shift(@_),shift(@_),$lon,$lat);
# spent 20.9s making 2953161 calls to WCSPtr::pix2wcs, avg 7µs/call
13129531615.093401.7e-6 push @out, ($lon,$lat);
132 }
13329531615.779832.0e-6 return wantarray ? @out : \@out;
134}
135
136sub xref {
137 my $this = shift;
138 return $this->{wcs}->xref();
139}
140
141sub yref {
142 my $this = shift;
143 return $this->{wcs}->yref();
144}
145
146sub xscale {
147 my $this = shift;
148 return $this->{wcs}->xinc();
149}
150
151
# spent 226ms (137+89.4) within WISE::WCS::yscale which was called 24940 times, avg 9µs/call: # 12470 times (69.1ms+48.6ms) by main::overlap at line 1269 of /wise/base/deliv/dev/bin/getfix, avg 9µs/call # 12470 times (67.4ms+40.8ms) by main::overlap at line 1270 of /wise/base/deliv/dev/bin/getfix, avg 9µs/call
sub yscale {
152249400.016516.6e-7 my $this = shift;
153249400.154326.2e-6 return $this->{wcs}->yinc();
# spent 89.4ms making 24940 calls to WCSPtr::yinc, avg 4µs/call
154}
155
156
# spent 216ms (133+82.8) within WISE::WCS::nxpix which was called 24940 times, avg 9µs/call: # 12470 times (67.7ms+43.3ms) by main::overlap at line 1271 of /wise/base/deliv/dev/bin/getfix, avg 9µs/call # 12470 times (65.6ms+39.6ms) by main::overlap at line 1272 of /wise/base/deliv/dev/bin/getfix, avg 8µs/call
sub nxpix {
157249400.017517.0e-7 my $this = shift;
158249400.144435.8e-6 return $this->{wcs}->nxpix();
# spent 82.8ms making 24940 calls to WCSPtr::nxpix, avg 3µs/call
159}
160
161sub nypix {
162 my $this = shift;
163 return $this->{wcs}->nypix();
164}
165
16615.0e-65.0e-61;