File | /wise/base/deliv/dev/lib/perl/WISE/FITSIO/Utils.pm | Statements Executed | 65268868 | Total Time | 113.217757961735 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 | 174594 | 0.71908 | 4.1e-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 | ||||
36 | 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 | ||||
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 | 32484771 | 56.82346 | 1.7e-6 | 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(@_) { | |||
112 | $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 | |||
119 | 32484771 | 55.24590 | 1.7e-6 | 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(@_) { | |||
130 | $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 | ||||
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 | 49880 | 0.17082 | 3.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 | |||
157 | 49880 | 0.16193 | 3.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 | ||||
161 | sub nypix { | |||
162 | my $this = shift; | |||
163 | return $this->{wcs}->nypix(); | |||
164 | } | |||
165 | ||||
166 | 1 | 5.0e-6 | 5.0e-6 | 1; |