File | /wise/base/deliv/dev/lib/perl/WISE/FITSIO/Utils.pm | Statements Executed | 65268868 | Total Time | 113.217757998822 seconds |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine | |
---|---|---|---|---|---|---|
2953161 | 2 | 1 | 41.61907 | 62.56564 | WISE::WCS:: | pix2wcs |
2953161 | 2 | 1 | 41.00629 | 63.67543 | WISE::WCS:: | wcs2pix |
12471 | 2 | 1 | 0.35215 | 0.75214 | WISE::WCS:: | new |
24940 | 2 | 1 | 0.13651 | 0.22593 | WISE::WCS:: | yscale |
24940 | 2 | 1 | 0.13328 | 0.21611 | WISE::WCS:: | nxpix |
12471 | 1 | 1 | 0.05212 | 0.05212 | WISE::WCS:: | AUTOLOAD |
0 | 0 | 0 | 0 | 0 | WISE::WCS:: | BEGIN |
0 | 0 | 0 | 0 | 0 | WISE::WCS:: | DESTROY |
0 | 0 | 0 | 0 | 0 | WISE::WCS:: | __ANON__[:34] |
0 | 0 | 0 | 0 | 0 | WISE::WCS:: | nypix |
0 | 0 | 0 | 0 | 0 | WISE::WCS:: | xref |
0 | 0 | 0 | 0 | 0 | WISE::WCS:: | xscale |
0 | 0 | 0 | 0 | 0 | WISE::WCS:: | yref |
0 | 0 | 0 | 0 | 0 | main:: | BEGIN |
Line | Stmts. | Exclusive Time | Avg. | Code |
---|---|---|---|---|
1 | ||||
2 | 3 | 4.4e-5 | 1.5e-5 | use strict; # spent 15µs making 1 call to strict::import |
3 | 3 | 6.1e-5 | 2.0e-5 | use warnings; # spent 45µs making 1 call to warnings::import |
4 | 6 | 0.00011 | 1.9e-5 | use 5.010; # spent 40µs making 1 call to feature::import |
5 | ||||
6 | 3 | 4.6e-5 | 1.5e-5 | use 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 | ||||
10 | package WISE::WCS; | |||
11 | ||||
12 | # Lightweight WCS package that by-passes the WISE::FITSIO overhead | |||
13 | ||||
14 | 3 | 3.9e-5 | 1.3e-5 | use Astro::FITS::CFITSIO qw(:constants); # spent 1.76ms making 1 call to Exporter::import |
15 | 3 | 0.00113 | 0.00038 | use Astro::WCS::LibWCS; # spent 41µs making 1 call to Exporter::import |
16 | ||||
17 | 3 | 3.0e-5 | 1.0e-5 | use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION $AUTOLOAD); # spent 99µs making 1 call to vars::import |
18 | 3 | 0.00121 | 0.00040 | use Exporter::Lite; # spent 39µs making 1 call to Exporter::Lite::import |
19 | 1 | 1.0e-6 | 1.0e-6 | $VERSION = 1.00; |
20 | 1 | 2.0e-6 | 2.0e-6 | @ISA = qw(); |
21 | ||||
22 | 12471 | 0.01784 | 1.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 |
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 | |||
25 | 12471 | 0.01857 | 1.5e-6 | my $this = shift; |
26 | 12471 | 0.00701 | 5.6e-7 | my $hdr = shift; |
27 | 12471 | 0.01424 | 1.1e-6 | my $opts = shift || {}; |
28 | 12471 | 0.01569 | 1.3e-6 | my $err = "*** $0/WCS/new"; |
29 | 12471 | 0.00681 | 5.5e-7 | warn("$err: No input header specified.\n"), return if ! $hdr; |
30 | 12471 | 0.00898 | 7.2e-7 | my $class = ref($this) || $this; |
31 | ||||
32 | 12471 | 0.01158 | 9.3e-7 | $this = {}; |
33 | ||||
34 | 12471 | 0.05980 | 4.8e-6 | my $yell = $this->{yell} = $opts->{warn} ? sub{warn @_} : sub{die @_}; |
35 | ||||
36 | 12471 | 0.02009 | 1.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 | |||
70 | 12471 | 0.01292 | 1.0e-6 | my $nx = $hdr->{nxpix} || $hdr->{npix}; |
71 | 12471 | 0.00898 | 7.2e-7 | my $ny = $hdr->{nypix} || $nx; |
72 | 12471 | 0.48484 | 3.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: ", | |||
88 | 12471 | 0.01182 | 9.5e-7 | join(", ", map {"$_=$hdr->{$_}"} keys %$hdr), |
89 | "\n"), return | |||
90 | if ! $this->{wcs}; | |||
91 | } | |||
92 | ||||
93 | 12471 | 0.03772 | 3.0e-6 | return bless $this,$class; |
94 | } | |||
95 | ||||
96 | sub DESTROY { | |||
97 | 12471 | 0.07604 | 6.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 | |||
101 | 2953161 | 2.34292 | 7.9e-7 | my $this = shift; |
102 | 2953161 | 3.65698 | 1.2e-6 | my $err = "*** $0/WCS/2pix"; |
103 | 2953161 | 1.89553 | 6.4e-7 | if(! ref $this) { |
104 | $this = $this->new(shift) or return; | |||
105 | } | |||
106 | 2953161 | 2.00809 | 6.8e-7 | my $yell = $this->{yell}; |
107 | 2953161 | 2.52162 | 8.5e-7 | $yell->("$err: Bad position count; ".@_." not >0 and even.\n"), return |
108 | if ! @_ || (@_%2) != 0; | |||
109 | 2953161 | 1.62739 | 5.5e-7 | my ($x,$y,$off); |
110 | 2953161 | 1.27841 | 4.3e-7 | my @out; |
111 | 2953161 | 3.09033 | 1.0e-6 | while(@_) { |
112 | 2953161 | 27.83125 | 9.4e-6 | $this->{wcs}->wcs2pix(shift(@_),shift(@_),$x,$y,$off); # spent 22.7s making 2953161 calls to WCSPtr::wcs2pix, avg 8µs/call |
113 | 2953161 | 4.91875 | 1.7e-6 | push @out, ($x, $y); |
114 | } | |||
115 | 2953161 | 5.65220 | 1.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 | |||
119 | 2953161 | 2.26194 | 7.7e-7 | my $this = shift; |
120 | 2953161 | 3.58977 | 1.2e-6 | my $err = "*** $0/WCS/2wcs"; |
121 | 2953161 | 1.90569 | 6.5e-7 | if(! ref $this) { |
122 | $this = $this->new(shift) or return; | |||
123 | } | |||
124 | 2953161 | 2.05560 | 7.0e-7 | my $yell = $this->{yell}; |
125 | 2953161 | 2.44687 | 8.3e-7 | $yell->("$err: Bad position count; ".@_." not >0 and even.\n"), return |
126 | if ! @_ || (@_%2) != 0; | |||
127 | 2953161 | 1.59292 | 5.4e-7 | my ($lon,$lat); |
128 | 2953161 | 1.30703 | 4.4e-7 | my @out; |
129 | 2953161 | 3.15262 | 1.1e-6 | while(@_) { |
130 | 2953161 | 26.06022 | 8.8e-6 | $this->{wcs}->pix2wcs(shift(@_),shift(@_),$lon,$lat); # spent 20.9s making 2953161 calls to WCSPtr::pix2wcs, avg 7µs/call |
131 | 2953161 | 5.09340 | 1.7e-6 | push @out, ($lon,$lat); |
132 | } | |||
133 | 2953161 | 5.77983 | 2.0e-6 | return wantarray ? @out : \@out; |
134 | } | |||
135 | ||||
136 | sub xref { | |||
137 | my $this = shift; | |||
138 | return $this->{wcs}->xref(); | |||
139 | } | |||
140 | ||||
141 | sub yref { | |||
142 | my $this = shift; | |||
143 | return $this->{wcs}->yref(); | |||
144 | } | |||
145 | ||||
146 | sub 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 | |||
152 | 24940 | 0.01651 | 6.6e-7 | my $this = shift; |
153 | 24940 | 0.15432 | 6.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 | |||
157 | 24940 | 0.01751 | 7.0e-7 | my $this = shift; |
158 | 24940 | 0.14443 | 5.8e-6 | return $this->{wcs}->nxpix(); # spent 82.8ms making 24940 calls to WCSPtr::nxpix, avg 3µs/call |
159 | } | |||
160 | ||||
161 | sub nypix { | |||
162 | my $this = shift; | |||
163 | return $this->{wcs}->nypix(); | |||
164 | } | |||
165 | ||||
166 | 1 | 5.0e-6 | 5.0e-6 | 1; |