File | /wise/base/static/lib/perl5/site_perl/5.10.0/x86_64-linux-thread-multi/PGPLOT.pm | Statements Executed | 12 | Total Time | 0.000305 seconds |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine | |
---|---|---|---|---|---|---|
19 | 3 | 2 | 0.09969 | 0.09969 | PGPLOT:: | pgscr (xsub) |
2 | 1 | 2 | 0.03968 | 0.03968 | PGPLOT:: | pgbeg (xsub) |
34 | 6 | 2 | 0.02044 | 0.02044 | PGPLOT:: | pgptext (xsub) |
699 | 1 | 2 | 0.01845 | 0.01845 | PGPLOT:: | pgdraw (xsub) |
21 | 2 | 2 | 0.00974 | 0.00974 | PGPLOT:: | pgpt (xsub) |
2 | 1 | 2 | 0.00164 | 0.00164 | PGPLOT:: | pgpap (xsub) |
2 | 1 | 2 | 0.00034 | 0.00034 | PGPLOT:: | bootstrap (xsub) |
52 | 1 | 2 | 0.00032 | 0.00032 | PGPLOT:: | pgmove (xsub) |
33 | 5 | 2 | 0.00017 | 0.00017 | PGPLOT:: | pgsci (xsub) |
26 | 7 | 2 | 0.00011 | 0.00011 | PGPLOT:: | pgsch (xsub) |
3 | 2 | 2 | 7.6e-5 | 7.6e-5 | PGPLOT:: | pgqtxt (xsub) |
3 | 2 | 2 | 3.9e-5 | 3.9e-5 | PGPLOT:: | pgstbg (xsub) |
2 | 1 | 2 | 2.4e-5 | 2.4e-5 | PGPLOT:: | pgswin (xsub) |
3 | 2 | 2 | 2.3e-5 | 2.3e-5 | PGPLOT:: | pgqwin (xsub) |
3 | 2 | 2 | 1.9e-5 | 1.9e-5 | PGPLOT:: | pgsclp (xsub) |
2 | 1 | 2 | 1.9e-5 | 1.9e-5 | PGPLOT:: | pgsvp (xsub) |
2 | 1 | 2 | 1.4e-5 | 1.4e-5 | PGPLOT:: | pgqcs (xsub) |
2 | 1 | 2 | 1.2e-5 | 1.2e-5 | PGPLOT:: | pgqvp (xsub) |
0 | 0 | 0 | 0 | 0 | PGPLOT:: | BEGIN |
Line | Stmts. | Exclusive Time | Avg. | Code |
---|---|---|---|---|
1 | ||||
2 | package PGPLOT; | |||
3 | ||||
4 | # Module to allow calling of PGPLOT from Perl | |||
5 | # | |||
6 | # Karl Glazebrook [email: kgb@aaoepp.aao.gov.au] | |||
7 | # | |||
8 | # WWW info: http://www.aao.gov.au/local/www/kgb/pgperl/ | |||
9 | ||||
10 | 1 | 1.0e-6 | 1.0e-6 | $VERSION="2.19"; |
11 | ||||
12 | 3 | 2.9e-5 | 9.7e-6 | use Exporter; # spent 51µs making 1 call to Exporter::import |
13 | 3 | 0.00019 | 6.4e-5 | use DynaLoader; # spent 5µs making 1 call to import |
14 | ||||
15 | 1 | 1.0e-5 | 1.0e-5 | @ISA = qw(Exporter DynaLoader); |
16 | 1 | 3.1e-5 | 3.1e-5 | @EXPORT = qw( pgarro pgask pgaxis pgband pgbbuf pgbeg pgbegin pgbin pgbox |
17 | pgcirc pgclos pgconb pgconf pgconl pgcons pgcont pgconx pgctab pgcurs pgcurse pgdraw | |||
18 | pgebuf pgend pgenv pgeras pgerrb pgerr1 pgerrx pgerry pgetxt pgfunt pgfunx | |||
19 | pgfuny pggray pghi2d pghist pgiden pgimag pglab pglabel pglcur pgldev | |||
20 | pglen pgline pgmove pgmtxt pgmtext pgncur pgncurse pgnumb pgolin pgopen pgpage | |||
21 | pgadvance pgpanl pgpap pgpaper pgpixl pgpnts pgpoly pgpt pgpt1 pgpoint pgptxt | |||
22 | pgptext pgqah pgqcf pgqch pgqci pgqclp pgqcir pgqcol pgqcr pgqcs pgqdt pgqfs pgqhs | |||
23 | pgqid pgqinf pgqitf pgqls pgqlw pgqndt pgqpos pgqtbg pgqtxt pgqvp pgqvsz pgqwin | |||
24 | pgrect pgrnd pgrnge pgsah pgsave pgunsa pgscf pgsch pgsci pgscir pgsclp pgscr | |||
25 | pgscrl pgscrn pgsfs pgshls pgshs pgsitf pgslct pgsls pgslw pgstbg pgsubp pgsvp | |||
26 | pgvport pgswin pgwindow pgtbox pgtick pgtext pgupdt pgvect pgvsiz pgvsize | |||
27 | pgvstd pgvstand pgwedg pgwnad ); | |||
28 | ||||
29 | 2 | 1.6e-5 | 8.0e-6 | if($^O =~ /mswin32/i) { # spent 4.32ms making 1 call to DynaLoader::bootstrap |
30 | local $DynaLoader::dl_dlext = 'xs.dll'; | |||
31 | bootstrap PGPLOT $VERSION; | |||
32 | } | |||
33 | ||||
34 | else {bootstrap PGPLOT $VERSION} | |||
35 | ||||
36 | # Exit with OK status | |||
37 | ||||
38 | 1 | 2.7e-5 | 2.7e-5 | 1; |
39 | ||||
40 | __DATA__ | |||
41 | ||||
42 | =head1 NAME | |||
43 | ||||
44 | PGPLOT - allow subroutines in the PGPLOT graphics library to be called from Perl. | |||
45 | ||||
46 | =head1 SYNOPSIS | |||
47 | ||||
48 | use PGPLOT; | |||
49 | ||||
50 | pgbegin(0,"/xserve",1,1); | |||
51 | pgenv(1,10,1,10,0,0); | |||
52 | pglabel('X','Y','My plot'); | |||
53 | pgpoint(7,[2..8],[2..8],17); | |||
54 | ||||
55 | # etc... | |||
56 | ||||
57 | pgend; | |||
58 | ||||
59 | =head1 DESCRIPTION | |||
60 | ||||
61 | Originally developed in the olden days of Perl4 (when it was known | |||
62 | as 'pgperl' due to the necessity of making a special perl executable) | |||
63 | PGPLOT is now a dynamically loadable perl module which interfaces | |||
64 | to the FORTRAN graphics library of the same name. | |||
65 | ||||
66 | PGPLOT, originally developed as a FORTRAN library, is now available with | |||
67 | C bindings (which the Perl module uses), though a FORTRAN compiler is | |||
68 | still required to build it. | |||
69 | ||||
70 | For every PGPLOT C/FORTRAN function the module provides an equivalent | |||
71 | Perl function with the same arguments. Thus the user of the module should | |||
72 | refer to the PGPLOT manual to learn all about how to use PGPLOT and for | |||
73 | the complete list of available functions. This manual comes with the | |||
74 | PGPLOT distribution and is also available at the WWW address: | |||
75 | ||||
76 | http://astro.caltech.edu/~tjp/pgplot/ | |||
77 | ||||
78 | Also refer to the extensive set of test scripts (C<test*.p>) included | |||
79 | in the module distribution for examples of usage of all kinds of | |||
80 | PGPLOT routines. | |||
81 | ||||
82 | How the FORTRAN/C function calls map on to Perl calls is detailed below. | |||
83 | ||||
84 | ||||
85 | =head2 ARGUMENT MAPPING - SIMPLE NUMBERS AND ARRAYS | |||
86 | ||||
87 | This is more or less as you might expect - use Perl scalars | |||
88 | and Perl arrays in place of FORTRAN/C variables and arrays. | |||
89 | ||||
90 | Any FORTRAN REAL/INTEGER/CHARACTER* scalar variable maps to a | |||
91 | Perl scalar (Perl doesn't care about the differences between | |||
92 | strings and numbers and ints and floats). | |||
93 | ||||
94 | Thus you can say: | |||
95 | ||||
96 | To draw a line to point (42,$x): | |||
97 | ||||
98 | pgdraw(42,$x); | |||
99 | ||||
100 | To plot 10 points with data in Perl arrays C<@x> and C<@y> with plot symbol | |||
101 | no. 17. Note the Perl arrays are passed by reference: | |||
102 | ||||
103 | pgpoint(10, \@x, \@y, 17); | |||
104 | ||||
105 | You can also use the old Perl4 style: | |||
106 | ||||
107 | pgpoint(10, *x, *y, 17); | |||
108 | ||||
109 | but this is deprecated in Perl5. | |||
110 | ||||
111 | Label the axes: | |||
112 | ||||
113 | pglabel("X axis", "Data units", $label); | |||
114 | ||||
115 | Draw ONE point, see how when C<N=1> C<pgpoint()> can take a scalar as well as | |||
116 | a array argument: | |||
117 | ||||
118 | pgpoint(1, $x, $y, 17); | |||
119 | ||||
120 | ||||
121 | =head2 ARGUMENT MAPPING - IMAGES AND 2D ARRAYS | |||
122 | ||||
123 | Many of the PGPLOT commands (e.g. C<pggray>) take 2D arrays as | |||
124 | arguments. Several schemes are provided to allow efficient use | |||
125 | from Perl: | |||
126 | ||||
127 | =over 4 | |||
128 | ||||
129 | =item 1. | |||
130 | ||||
131 | Simply pass a reference to a 2D array, e.g: | |||
132 | ||||
133 | # Create 2D array | |||
134 | ||||
135 | $x=[]; | |||
136 | for($i=0; $i<128; $i++) { | |||
137 | for($j=0; $j<128; $j++) { | |||
138 | $$x[$i][$j] = sqrt($i*$j); | |||
139 | } | |||
140 | } | |||
141 | pggray( $x, 128, 128, ...); | |||
142 | ||||
143 | =item 2. | |||
144 | ||||
145 | Pass a reference to a 1D array: | |||
146 | ||||
147 | @x=(); | |||
148 | for($i=0; $i<128; $i++) { | |||
149 | for($j=0; $j<128; $j++) { | |||
150 | $x[$i][$j] = sqrt($i*$j); | |||
151 | } | |||
152 | } | |||
153 | pggray( \@x, 128, 128, ...); | |||
154 | ||||
155 | Here @x is a 1D array of 1D arrays. (Confused? - see perldata(1)). | |||
156 | Alternatively @x could be a flat 1D array with 128x128 elements, 2D | |||
157 | routines such as C<pggray()> etc. are programmed to do the right thing | |||
158 | as long as the number of elements match. | |||
159 | ||||
160 | =item 3. | |||
161 | ||||
162 | If your image data is packed in raw binary form into a character string | |||
163 | you can simply pass the raw string. e.g.: | |||
164 | ||||
165 | read(IMG, $img, 32768); | |||
166 | pggray($img, $xsize, $ysize, ...); | |||
167 | ||||
168 | Here the C<read()> function reads the binary data from a file and the | |||
169 | C<pggray()> function displays it as a grey-scale image. | |||
170 | ||||
171 | This saves unpacking the image data in to a potentially very large 2D | |||
172 | perl array. However the types must match. The string must be packed as a | |||
173 | C<"f*"> for example to use C<pggray>. This is intended as a short-cut for | |||
174 | sophisticated users. Even more sophisticated users will want to download | |||
175 | the C<PDL> module which provides a wealth of functions for manipulating | |||
176 | binary data. | |||
177 | ||||
178 | ||||
179 | PLEASE NOTE: As PGPLOT is a Fortran library it expects it's images to be | |||
180 | be stored in row order. Thus a 1D list is interpreted as a sequence of | |||
181 | rows end to end. Perl is similar to C in that 2D arrays are arrays of | |||
182 | pointers thus images end up stored in column order. | |||
183 | ||||
184 | Thus using perl multidimensional arrays the coordinate ($i,$j) should be | |||
185 | stored in $img[$j][$i] for things to work as expected, e.g: | |||
186 | ||||
187 | $img = []; | |||
188 | for $j (0..$nx-1) for $i (0..$ny-1) { | |||
189 | $$img[$j][$i] = whatever(); | |||
190 | }} | |||
191 | pggray($$img, $nx, $ny, ...); | |||
192 | ||||
193 | Also PGPLOT displays coordinate (0,0) at the bottom left (this is | |||
194 | natural as the subroutine library was written by an astronomer!). | |||
195 | ||||
196 | ||||
197 | =back | |||
198 | ||||
199 | =head2 ARGUMENT MAPPING - FUNCTION NAMES | |||
200 | ||||
201 | Some PGPLOT functions (e.g. C<pgfunx>) take functions as callback | |||
202 | arguments. In Perl simply pass a subroutine reference or a name, | |||
203 | e.g.: | |||
204 | ||||
205 | # Anonymous code reference: | |||
206 | ||||
207 | pgfunx(sub{ sqrt($_[0]) }, 500, 0, 10, 0); | |||
208 | ||||
209 | # Pass by ref: | |||
210 | ||||
211 | sub foo { | |||
212 | my $x=shift; | |||
213 | return sin(4*$x); | |||
214 | } | |||
215 | ||||
216 | pgfuny(\&foo, 360, 0, 2*$pi, 0); | |||
217 | ||||
218 | # Pass by name: | |||
219 | ||||
220 | pgfuny("foo", 360, 0, 2*$pi, 0); | |||
221 | ||||
222 | ||||
223 | =head2 ARGUMENT MAPPING - GENERAL HANDLING OF BINARY DATA | |||
224 | ||||
225 | In addition to the implicit rules mentioned above PGPLOT now provides | |||
226 | a scheme for explictly handling binary data in all routines. | |||
227 | ||||
228 | If your scalar variable (e.g. C<$x>) holds binary data (i.e. 'packed') | |||
229 | then simply pass PGPLOT a reference to it (e.g. C<\$x>). Thus one can | |||
230 | say: | |||
231 | ||||
232 | read(MYDATA, $wavelens, $n*4); | |||
233 | read(MYDATA, $spectrum, $n*4); | |||
234 | pgline($n, \$wavelens, \$spectrum); | |||
235 | ||||
236 | This is very efficient as we can be sure the data never gets copied | |||
237 | and will always be interpreted as binary. | |||
238 | ||||
239 | Again see the C<PDL> module for sophisticated manipulation of | |||
240 | binary data. C<PDL> takes great advantage of these facilities. | |||
241 | ||||
242 | Be VERY careful binary data is of the right size or your segments | |||
243 | might get violated. | |||
244 | ||||
# spent 336µs within PGPLOT::bootstrap which was called
# once (336µs+0) by DynaLoader::bootstrap at line 226 of /opt/wise/lib/perl5/5.10.0/x86_64-linux-thread-multi/DynaLoader.pm | ||||
# spent 39.7ms within PGPLOT::pgbeg which was called
# once (39.7ms+0) by WISE::PgAitoff::make_aitoff at line 211 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm | ||||
# spent 18.5ms within PGPLOT::pgdraw which was called 698 times, avg 26µs/call:
# 698 times (18.5ms+0) by WISE::PgAitoff::versplot at line 1072 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm, avg 26µs/call | ||||
# spent 318µs within PGPLOT::pgmove which was called 51 times, avg 6µs/call:
# 51 times (318µs+0) by WISE::PgAitoff::versplot at line 1071 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm, avg 6µs/call | ||||
# spent 1.65ms within PGPLOT::pgpap which was called
# once (1.65ms+0) by WISE::PgAitoff::make_aitoff at line 215 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm | ||||
# spent 9.74ms within PGPLOT::pgpt which was called 20 times, avg 487µs/call:
# 10 times (9.47ms+0) by WISE::PgAitoff::make_aitoff at line 331 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm, avg 947µs/call
# 10 times (265µs+0) by WISE::PgAitoff::color_key at line 586 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm, avg 26µs/call | ||||
# spent 20.4ms within PGPLOT::pgptext which was called 33 times, avg 619µs/call:
# 19 times (790µs+0) by WISE::PgAitoff::number at line 1063 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm, avg 42µs/call
# 10 times (355µs+0) by WISE::PgAitoff::color_key at line 589 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm, avg 36µs/call
# once (19.1ms+0) by WISE::PgAitoff::color_key at line 562 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm
# once (74µs+0) by WISE::PgAitoff::label_aitoff at line 940 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm
# once (70µs+0) by WISE::PgAitoff::label_aitoff at line 938 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm
# once (67µs+0) by WISE::PgAitoff::label_aitoff at line 939 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm | ||||
# spent 14µs within PGPLOT::pgqcs which was called
# once (14µs+0) by WISE::PgAitoff::color_key at line 548 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm | ||||
# spent 76µs within PGPLOT::pgqtxt which was called 2 times, avg 38µs/call:
# once (44µs+0) by WISE::PgAitoff::make_aitoff at line 252 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm
# once (32µs+0) by WISE::PgAitoff::label_aitoff at line 935 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm | ||||
# spent 12µs within PGPLOT::pgqvp which was called
# once (12µs+0) by WISE::PgAitoff::color_key at line 542 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm | ||||
# spent 23µs within PGPLOT::pgqwin which was called 2 times, avg 12µs/call:
# once (13µs+0) by WISE::PgAitoff::color_key at line 544 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm
# once (10µs+0) by WISE::PgAitoff::label_aitoff at line 925 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm | ||||
# spent 112µs within PGPLOT::pgsch which was called 25 times, avg 4µs/call:
# 10 times (35µs+0) by WISE::PgAitoff::color_key at line 585 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm, avg 3µs/call
# 10 times (29µs+0) by WISE::PgAitoff::color_key at line 588 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm, avg 3µs/call
# once (15µs+0) by WISE::PgAitoff::make_aitoff at line 251 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm
# once (14µs+0) by WISE::PgAitoff::make_aitoff at line 308 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm
# once (9µs+0) by WISE::PgAitoff::label_aitoff at line 931 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm
# once (5µs+0) by WISE::PgAitoff::color_key at line 546 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm
# once (5µs+0) by WISE::PgAitoff::color_key at line 561 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm | ||||
# spent 168µs within PGPLOT::pgsci which was called 32 times, avg 5µs/call:
# 10 times (54µs+0) by WISE::PgAitoff::make_aitoff at line 321 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm, avg 5µs/call
# 10 times (45µs+0) by WISE::PgAitoff::color_key at line 584 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm, avg 4µs/call
# 10 times (43µs+0) by WISE::PgAitoff::color_key at line 587 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm, avg 4µs/call
# once (15µs+0) by WISE::PgAitoff::label_aitoff at line 930 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm
# once (11µs+0) by WISE::PgAitoff::color_key at line 560 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm | ||||
# spent 19µs within PGPLOT::pgsclp which was called 2 times, avg 10µs/call:
# once (11µs+0) by WISE::PgAitoff::color_key at line 556 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm
# once (8µs+0) by WISE::PgAitoff::color_key at line 593 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm | ||||
# spent 99.7ms within PGPLOT::pgscr which was called 18 times, avg 5.54ms/call:
# 16 times (77µs+0) by WISE::PgAitoff::make_aitoff at line 238 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm, avg 5µs/call
# once (97.7ms+0) by WISE::PgAitoff::make_aitoff at line 230 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm
# once (1.93ms+0) by WISE::PgAitoff::make_aitoff at line 231 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm | ||||
# spent 39µs within PGPLOT::pgstbg which was called 2 times, avg 20µs/call:
# once (34µs+0) by WISE::PgAitoff::make_aitoff at line 311 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm
# once (5µs+0) by WISE::PgAitoff::label_aitoff at line 932 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm | ||||
# spent 19µs within PGPLOT::pgsvp which was called
# once (19µs+0) by WISE::PgAitoff::make_aitoff at line 244 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm | ||||
# spent 24µs within PGPLOT::pgswin which was called
# once (24µs+0) by WISE::PgAitoff::make_aitoff at line 247 of /wise/base/deliv/dev/lib/perl/WISE/PgAitoff.pm |