← 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:31 2010

File/wise/base/deliv/dev/lib/perl/WISE/FITSIO/Utils.pm
Statements Executed65268868
Total Time113.217758002741 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 {
251247100.200511.6e-6 my $this = shift;
26 my $hdr = shift;
27 my $opts = shift || {};
28 my $err = "*** $0/WCS/new";
29 warn("$err: No input header specified.\n"), return if ! $hdr;
30 my $class = ref($this) || $this;
31
32 $this = {};
33
34 my $yell = $this->{yell} = $opts->{warn} ? sub{warn @_} : sub{die @_};
35
36498840.518571.0e-5 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
70 my $nx = $hdr->{nxpix} || $hdr->{npix};
71 my $ny = $hdr->{nypix} || $nx;
72 $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: ",
88 join(", ", map {"$_=$hdr->{$_}"} keys %$hdr),
89 "\n"), return
90 if ! $this->{wcs};
91 }
92
93 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 {
1012657844924.073469.1e-7 my $this = shift;
102 my $err = "*** $0/WCS/2pix";
103 if(! ref $this) {
104 $this = $this->new(shift) or return;
105 }
106 my $yell = $this->{yell};
107 $yell->("$err: Bad position count; ".@_." not >0 and even.\n"), return
108 if ! @_ || (@_%2) != 0;
109 my ($x,$y,$off);
110 my @out;
111 while(@_) {
112590632232.750005.5e-6 $this->{wcs}->wcs2pix(shift(@_),shift(@_),$x,$y,$off);
# spent 22.7s making 2953161 calls to WCSPtr::wcs2pix, avg 8µs/call
113 push @out, ($x, $y);
114 }
115 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 {
1192657844924.092279.1e-7 my $this = shift;
120 my $err = "*** $0/WCS/2wcs";
121 if(! ref $this) {
122 $this = $this->new(shift) or return;
123 }
124 my $yell = $this->{yell};
125 $yell->("$err: Bad position count; ".@_." not >0 and even.\n"), return
126 if ! @_ || (@_%2) != 0;
127 my ($lon,$lat);
128 my @out;
129 while(@_) {
130590632231.153635.3e-6 $this->{wcs}->pix2wcs(shift(@_),shift(@_),$lon,$lat);
# spent 20.9s making 2953161 calls to WCSPtr::pix2wcs, avg 7µs/call
131 push @out, ($lon,$lat);
132 }
133 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 {
152498800.170823.4e-6 my $this = shift;
153 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 {
157498800.161933.2e-6 my $this = shift;
158 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;