File Coverage

blib/lib/App/SourcePlot/Source.pm
Criterion Covered Total %
statement 155 308 50.3
branch 28 128 21.8
condition 6 12 50.0
subroutine 17 47 36.1
pod 24 38 63.1
total 230 533 43.1


line stmt bran cond sub pod time code
1             package App::SourcePlot::Source;
2              
3             =head1 NAME
4              
5             App::SourcePlot::Source - creates a observation source
6              
7             =head1 SYNOPSIS
8              
9             use App::SourcePlot::Source;
10             $src = new App::SourcePlot::Source;
11              
12             =head1 DESCRIPTION
13              
14             This class will create Source objects that will hold essential
15             information for any single source.
16              
17             It is essentially a wrapper around an Astro::Coords object to add
18             the additional information used to display a source in this
19             application.
20              
21             =cut
22              
23 2     2   64615 use 5.004;
  2         9  
  2         84  
24 2     2   12 use Carp;
  2         5  
  2         149  
25 2     2   12 use strict;
  2         9  
  2         74  
26              
27 2     2   2861 use Astro::Coords;
  2         627152  
  2         114  
28 2     2   24 use Math::Trig qw/pi/;
  2         3  
  2         129  
29 2     2   11 use DateTime;
  2         4  
  2         38  
30 2     2   2505 use DateTime::Format::Strptime;
  2         17712  
  2         9103  
31              
32             our $VERSION = '1.23';
33              
34             my $locateBug = 0;
35              
36             =head1 PUBLIC METHODS
37              
38             These are the methods avaliable in this class:
39              
40             =over 4
41              
42             =item new
43              
44             Create a new Source object.
45              
46             $obs = new App::SourcePlot::Source($planet);
47             $obs = new App::SourcePlot::Source($name, $RA, $DEC, $Epoc);
48              
49             Or using an Astro::Coords object.
50              
51             $coords = new Astro::Coords(...);
52             $obs = new App::SourcePlot::Source($coords);
53              
54             =cut
55              
56             sub new {
57 1020 50   1020 1 8449374 print "Creating a new observation Source object\n" if $locateBug;
58              
59 1020         2389 my $proto = shift;
60 1020   33     8229 my $class = ref($proto) || $proto;
61              
62 1020         6677 my $self = {}; # Anon hash
63              
64 1020         4099 bless($self, $class);
65 1020 50       3391 print "New observation Source object has been blessed: $self\n" if $locateBug;
66              
67 1020         5540 $self->configure(@_);
68              
69 1020         4263 $self->active(1);
70              
71 1020 50       2463 print "Object created\n" if $locateBug;
72              
73 1020         3195 return $self;
74             }
75              
76              
77             sub configure {
78 1020     1020 0 1665 my $self = shift;
79              
80             # Special case: empty source object.
81 1020 50       3048 unless (@_) {
82 0         0 $self->coords(new Astro::Coords());
83 0         0 return;
84             }
85              
86 1020         1975 my $name = shift;
87              
88 1020 50       9703 if (UNIVERSAL::isa($name, 'Astro::Coords')) {
    50          
89 0         0 $self->coords($name);
90             }
91             elsif (@_) {
92 1020 50       3243 print "Passed in paramaters are being entered\n" if $locateBug;
93 1020         2877 my ($ra, $dec, $epoc, undef) = @_;
94              
95             # Prevent Astro::Coords guessing between radians and degrees.
96 1020 50 33     7293 my $unit = ($ra =~ /:/ or $dec =~ /:/)
97             ? 'sexagesimal'
98             : 'degrees';
99              
100 1020 100       4759 if ($epoc eq 'RJ') {
    50          
    0          
    0          
101 527 50       5158 $self->coords(new Astro::Coords(
102             name => $name,
103             ra => ($unit eq 'degrees') ? ($ra * 15) : $ra,
104             dec => $dec,
105             type => 'J2000',
106             units => $unit,
107             ));
108             }
109             elsif ($epoc eq 'RB') {
110 493 50       4967 $self->coords(new Astro::Coords(
111             name => $name,
112             ra => ($unit eq 'degrees') ? ($ra * 15) : $ra,
113             dec => $dec,
114             type => 'B1950',
115             units => $unit,
116             ));
117             }
118             elsif ($epoc eq 'GA') {
119 0         0 $self->coords(new Astro::Coords(
120             name => $name,
121             long => $ra,
122             lat => $dec,
123             type => 'galactic',
124             units => $unit,
125             ));
126             }
127             elsif ($epoc eq 'AZ') {
128 0         0 $self->coords(new Astro::Coords(
129             name => $name,
130             az => $ra,
131             el => $dec,
132             units => $unit,
133             ));
134             }
135             else {
136 0         0 die "App::SourcePlot::Source unknown epoc " . $epoc .
137             " for source " . $name;
138             }
139             }
140             else {
141 0         0 $self->coords(new Astro::Coords(
142             planet => $name
143             ));
144             }
145             }
146              
147             ############################################################
148             # Common data manipulation functions
149             #
150             =item name
151              
152             returns and sets the name of the source
153              
154             $name = $obs->name();
155             $obs->name('Mars');
156              
157             =cut
158              
159             sub name {
160 0     0 0 0 my $self = shift;
161 0         0 return $self->coords()->name(@_);
162             }
163              
164             =item coords
165              
166             Set or return the corresponding Astro::Coords object.
167              
168             =cut
169              
170             sub coords {
171 3980     3980 1 474143 my ($self, $coords, undef) = @_;
172 3980 100       15651 if (defined $coords) {
173 1020 50       4848 die unless UNIVERSAL::isa($coords, 'Astro::Coords');
174 1020         3010 $self->{'COORDS'} = $coords;
175             }
176 3980         10527 return $self->{'COORDS'};
177             }
178              
179             =item active
180              
181             returns and sets whether the source is active
182              
183             $on = $obs->active();
184             $obs->active(0);
185              
186             =cut
187              
188             sub active {
189 1020     1020 1 1798 my $self = shift;
190 1020 50       3632 $self->{ACTIVE} = shift if @_;
191 1020 50       3901 return $self->{ACTIVE} if defined $self->{ACTIVE};
192 0         0 return '';
193             }
194              
195             =item color
196              
197             returns and sets the source color
198              
199             $col = $obs->color();
200             $obs->color('black');
201              
202             =cut
203              
204             sub color {
205 0     0 1 0 my $self = shift;
206 0 0       0 $self->{COLOR} = shift if @_;
207 0 0       0 return $self->{COLOR} if defined $self->{COLOR};
208 0         0 return '';
209             }
210              
211             =item lineWidth
212              
213             returns and sets the sources thickness
214              
215             $LW = $obs->lineWidth();
216             $obs->lineWidth(2);
217              
218             =cut
219              
220             sub lineWidth {
221 0     0 1 0 my $self = shift;
222 0 0       0 $self->{LINEWIDTH} = shift if @_;
223 0 0       0 return $self->{LINEWIDTH} if defined $self->{LINEWIDTH};
224 0         0 return 1;
225             }
226              
227             =item index
228              
229             returns and sets the sources window index
230              
231             $index = $obs->index();
232             $obs->index(1234);
233              
234             =cut
235              
236             sub index {
237 0     0 1 0 my $self = shift;
238 0 0       0 $self->{INDEX} = shift if @_;
239 0 0       0 return $self->{INDEX} if defined $self->{INDEX};
240 0         0 return -1;
241             }
242              
243             =item ra
244              
245             Returns the RA of the source, or other coordinate type
246             in systems other than RJ / RB.
247              
248             $ra = $obs->ra();
249              
250             =cut
251              
252             sub ra {
253 0     0 1 0 my $self = shift;
254 0 0       0 if (@_) {
255 0         0 die 'App::SourcePlot::Source cannot change ra';
256             }
257 0         0 my $native_method = $self->coords()->native();
258 0         0 my ($ra, undef) = $self->coords()->$native_method();
259 0 0       0 return sprintf('%.4f', $ra->degrees()) if $self->epoc() eq 'GA';
260 0         0 return $ra->in_format('sexagesimal');
261             }
262              
263             =item dec
264              
265             Returns the declination of the source, or other coordinate
266             type in systems other than RJ / RB.
267              
268             $dec = $obs->dec();
269              
270             =cut
271              
272             sub dec {
273 0     0 1 0 my $self = shift;
274 0 0       0 if (@_) {
275 0         0 die 'App::SourcePlot::Source cannot change dec';
276             }
277 0         0 my $native_method = $self->coords()->native();
278 0         0 my (undef, $dec) = $self->coords()->$native_method();
279 0 0       0 return sprintf('% .4f', $dec->degrees()) if $self->epoc() eq 'GA';
280 0         0 return $dec->in_format('sexagesimal');
281             }
282              
283             =item ra2000
284              
285             returns the ra of the source in J2000 in radians
286              
287             $ra2000 = $obs->ra2000();
288              
289             =cut
290              
291             sub ra2000 {
292 0     0 1 0 my $self = shift;
293 0 0       0 if (@_) {
294 0         0 die 'App::SourcePlot::Source cannot change ra2000';
295             }
296 0         0 return $self->coords()->ra(format => 'r');
297             }
298              
299             =item dec2000
300              
301             returns dec of the source in J2000 in radians
302              
303             $dec2000 = $obs->dec2000();
304              
305             =cut
306              
307             sub dec2000 {
308 0     0 1 0 my $self = shift;
309 0 0       0 if (@_) {
310 0         0 die 'App::SourcePlot::Source cannot change dec';
311             }
312 0         0 return $self->coords()->dec(format => 'r');
313             }
314              
315             =item epoc
316              
317             returns the epoch of the source
318              
319             $epoc = $obs->epoc();
320              
321             =cut
322              
323             sub epoc {
324 0     0 1 0 my $self = shift;
325 0         0 my $native_method = $self->coords()->native;
326              
327 0 0       0 return 'RJ' if $native_method eq 'radec';
328 0 0       0 return 'RB' if $native_method eq 'radec1950';
329 0 0       0 return 'GA' if $native_method eq 'glonglat';
330 0 0       0 return 'AZ' if $native_method eq 'azel';
331 0         0 return '??';
332             }
333              
334             =item elevation
335              
336             returns the current elevation of the source at the ut time
337             in degrees
338              
339             $ele = $obs->elevation();
340              
341             =cut
342              
343             sub elevation {
344 0     0 1 0 my $self = shift;
345 0 0       0 if (@_) {
346 0         0 die 'App::SourcePlot::Source cannot set elevation';
347             }
348 0         0 return $self->coords()->el(format => 'd');
349             }
350              
351             =item is_blank
352              
353             Returns true if the source information is "blank". This is the
354             default state for an object constructed with no arguments,
355             and is represented by the Astro::Coords default type -- a
356             Calibration object.
357              
358             =cut
359              
360             sub is_blank {
361 0     0 1 0 my $self = shift;
362              
363 0         0 return $self->coords()->type() eq 'CAL';
364             }
365              
366             =item NameX
367              
368             returns and sets the current x position of name label
369              
370             $x = $obs->NameX();
371             $obs->NameX(6.5);
372              
373             =cut
374              
375             sub NameX {
376 0     0 1 0 my $self = shift;
377 0 0       0 $self->{NAMEX} = shift if @_;
378 0 0       0 return $self->{NAMEX} if defined $self->{NAMEX};
379 0         0 return '';
380             }
381              
382             =item NameY
383              
384             returns and sets the current y position of name label
385              
386             $y = $obs->NameY();
387             $obs->NameY(6.5);
388              
389             =cut
390              
391             sub NameY {
392 0     0 1 0 my $self = shift;
393 0 0       0 $self->{NAMEY} = shift if @_;
394 0 0       0 return $self->{NAMEY} if defined $self->{NAMEY};
395 0         0 return '';
396             }
397              
398             =item AzElOffsets
399              
400             returns the amount in the current system to offset to draw the
401             Elevation and Azimuth axes
402              
403             ($elex, $eley, $azx, $azy) = $obs->AzElOffsets();
404             $obs->AzElOffsets(.5, 4, .3, 2);
405              
406             =cut
407              
408             sub AzElOffsets {
409 0     0 1 0 my $self = shift;
410 0 0       0 if (@_) {
411 0         0 $self->{ELEX} = shift;
412 0         0 $self->{ELEY} = shift;
413 0         0 $self->{AZX} = shift;
414 0         0 $self->{AZY} = shift;
415             }
416 0 0       0 return ($self->{ELEX}, $self->{ELEY}, $self->{AZX}, $self->{AZY}) if defined $self->{ELEX};
417 0         0 return (undef, undef, undef, undef);
418             }
419              
420             =item timeDotX
421              
422             returns and sets the current position of the time dot on
423             the x axis
424              
425             $x = $obs->timeDotX();
426             $obs->timeDotX('15.122');
427              
428             =cut
429              
430             sub timeDotX {
431 0     0 1 0 my $self = shift;
432 0 0       0 $self->{TIMEDOTX} = shift if @_;
433 0 0       0 return $self->{TIMEDOTX} if defined $self->{TIMEDOTX};
434 0         0 return '';
435             }
436              
437             =item timeDotY
438              
439             returns and sets the current position of the time dot on
440             the y axis
441              
442             $y = $obs->timeDotY();
443             $obs->timeDotY('15.122');
444              
445             =cut
446              
447             sub timeDotY {
448 0     0 1 0 my $self = shift;
449 0 0       0 $self->{TIMEDOTY} = shift if @_;
450 0 0       0 return $self->{TIMEDOTY} if defined $self->{TIMEDOTY};
451 0         0 return '';
452             }
453              
454             =item time_ele_points
455              
456             These functions return an array of comparative points for different
457             characteristics of this source. The avaliable comparisons are:
458              
459             time_ele_points - time vs elevation
460             time_az_points - time vs azimuth
461             time_pa_points - time vs parallactic angle
462             ele_time_points - elevation vs time
463             ele_az_points - elevation vs azimuth
464             ele_pa_points - elevation vs parallactic angle
465             az_time_points - azimuth vs time
466             az_ele_points - azimuth vs azimuth
467             az_pa_points - azimuth vs parallactic angle
468             pa_time_points - parallactic angle vs time
469             pa_ele_points - parallactic angle vs elevation
470             pa_az_points - parallactic angle vs azimuth
471            
472             Example syntax:
473              
474             @time_ele_points = $obs->time_ele_points();
475              
476             =cut
477              
478             sub time_ele_points {
479 20     20 1 2574 my $self = shift;
480 20 50       78 return @{$self->{TIME_ELE_POINTS}} if defined $self->{TIME_ELE_POINTS};
  20         1852  
481 0         0 return ();
482             }
483              
484             sub time_az_points {
485 0     0 0 0 my $self = shift;
486 0 0       0 return @{$self->{TIME_AZ_POINTS}} if defined $self->{TIME_AZ_POINTS};
  0         0  
487 0         0 return ();
488             }
489              
490             sub time_pa_points {
491 0     0 0 0 my $self = shift;
492 0 0       0 return @{$self->{TIME_PA_POINTS}} if defined $self->{TIME_PA_POINTS};
  0         0  
493 0         0 return ();
494             }
495              
496             sub ele_time_points {
497 0     0 0 0 my $self = shift;
498 0 0       0 return @{$self->{ELE_TIME_POINTS}} if defined $self->{ELE_TIME_POINTS};
  0         0  
499 0         0 return ();
500             }
501              
502             sub ele_az_points {
503 0     0 0 0 my $self = shift;
504 0 0       0 return @{$self->{ELE_AZ_POINTS}} if defined $self->{ELE_AZ_POINTS};
  0         0  
505 0         0 return ();
506             }
507              
508             sub ele_pa_points {
509 0     0 0 0 my $self = shift;
510 0 0       0 return @{$self->{ELE_PA_POINTS}} if defined $self->{ELE_PA_POINTS};
  0         0  
511 0         0 return ();
512             }
513              
514             sub az_time_points {
515 0     0 0 0 my $self = shift;
516 0 0       0 return @{$self->{AZ_TIME_POINTS}} if defined $self->{AZ_TIME_POINTS};
  0         0  
517 0         0 return ();
518             }
519              
520             sub az_ele_points {
521 0     0 0 0 my $self = shift;
522 0 0       0 return @{$self->{AZ_ELE_POINTS}} if defined $self->{AZ_ELE_POINTS};
  0         0  
523 0         0 return ();
524             }
525              
526             sub az_pa_points {
527 20     20 0 239 my $self = shift;
528 20 50       94 return @{$self->{AZ_PA_POINTS}} if defined $self->{AZ_PA_POINTS};
  20         1179  
529 0         0 return ();
530             }
531              
532             sub pa_time_points {
533 0     0 0 0 my $self = shift;
534 0 0       0 return @{$self->{PA_TIME_POINTS}} if defined $self->{PA_TIME_POINTS};
  0         0  
535 0         0 return ();
536             }
537              
538             sub pa_ele_points {
539 0     0 0 0 my $self = shift;
540 0 0       0 return @{$self->{PA_ELE_POINTS}} if defined $self->{PA_ELE_POINTS};
  0         0  
541 0         0 return ();
542             }
543              
544             sub pa_az_points {
545 0     0 0 0 my $self = shift;
546 0 0       0 return @{$self->{PA_AZ_POINTS}} if defined $self->{PA_AZ_POINTS};
  0         0  
547 0         0 return ();
548             }
549              
550             ############################################################
551             # Some needed methods - not calculations but info gluers
552             #
553             =item dispLine
554              
555             returns the line to display - presentation use
556              
557             $line = $obs->dispLine();
558              
559             =cut
560              
561             sub dispLine {
562 0     0 0 0 my $self = shift;
563 0         0 my $line;
564 0 0       0 unless (UNIVERSAL::isa($self->coords(), 'Astro::Coords::Planet')) {
565 0         0 $line = sprintf(' %-4d %-16s %-12s %-13s %-4s',
566             ($self->index() + 1), $self->name(),
567             $self->ra(), $self->dec(), $self->epoc());
568             }
569             else {
570 0         0 $line = sprintf(' %-4d %-16s Planet',
571             ($self->index() + 1),
572             ucfirst($self->name()));
573             }
574 0         0 return $line;
575             }
576              
577             =item copy
578              
579             returns a copy of this object
580              
581             $cp = $obs->copy();
582              
583             =cut
584              
585             sub copy {
586 0     0 1 0 my $self = shift;
587 0         0 my $source = $self->new($self->coords());
588 0         0 return $source;
589             }
590              
591             =item calcPoints
592              
593             Calculations the Elevation, Azimeth, etc. points
594             $MW is the main window widget. Required for
595             progress bar
596              
597             $obs->calcPoints($date, $time, $num_points, $MW, $tel);
598              
599             =cut
600              
601             sub calcPoints {
602 20     20 1 130 my $self = shift;
603 20         36 my $DATE = shift;
604 20         39 my $TIME = shift;
605 20         34 my $numPoints = shift;
606 20         198 my $MW = shift;
607 20         31 my $tel = shift;
608 20         25 my $timeBug = 0;
609              
610 20         68 my $coords = $self->coords();
611 20         96 $coords->telescope($tel);
612 20         957 my $dt_save = $coords->datetime();
613              
614 20         23816 $DATE =~ s/\/$//;
615              
616 20         195 my $strp = new DateTime::Format::Strptime(
617             pattern => '%Y/%m/%d %H:%M:%S',
618             time_zone => 'UTC',
619             on_error => 'croak');
620              
621 20         10597 my $dt = $strp->parse_datetime($DATE . ' ' . $TIME);
622              
623 20         22428 my $dt_running = $dt->clone();
624              
625 20 50       344 my $tlen = @{$self->{TIME_ELE_POINTS}} if defined $self->{TIME_ELE_POINTS};
  0         0  
626 20 50 33     68 if (defined $tlen && $tlen > 0) {
627 0         0 return;
628             }
629              
630 20         354 $dt_running->subtract(hours => 2);
631 20         16242 my $lst_prev = undef;
632              
633 20         95 for (my $h = 0; $h < $numPoints; $h ++) {
634 1940         1384989 $MW->update;
635 1940         8173 my ($lst, $ele, $az, $pa, undef) = $self->_calcPoint($dt_running);
636              
637 1940 100 100     955031 if (defined $lst_prev and $lst < $lst_prev) {
638 870         1469 $lst += 2 * pi;
639              
640             # Allow a second wrap around in case LST is just under 2 pi at the
641             # start (eg on March 5th at JCMT with (default) 1:30:00 center time.
642             # This is necessary because we generate points over a full day,
643             # and then convert to LST so there is always one wrap-around, with
644             # a potential for a second for certain date / location /center time
645             # configurations!
646 870 50       2671 if ($lst < $lst_prev) {
647 0         0 $lst += 2 * pi;
648             }
649             }
650 1940         2969 $lst_prev = $lst;
651              
652 1940         2457 push (@{$self->{TIME_ELE_POINTS}}, $lst);
  1940         6169  
653 1940         2629 push (@{$self->{TIME_ELE_POINTS}}, $ele);
  1940         4605  
654              
655 1940         2792 push (@{$self->{TIME_AZ_POINTS}}, $lst);
  1940         5339  
656 1940         2453 push (@{$self->{TIME_AZ_POINTS}}, $az);
  1940         4135  
657              
658 1940         2881 push (@{$self->{TIME_PA_POINTS}}, $lst);
  1940         4998  
659 1940         2465 push (@{$self->{TIME_PA_POINTS}}, $pa);
  1940         3731  
660              
661 1940         2542 push (@{$self->{ELE_TIME_POINTS}}, $ele);
  1940         3715  
662 1940         2749 push (@{$self->{ELE_TIME_POINTS}}, $lst);
  1940         4394  
663              
664 1940         2415 push (@{$self->{ELE_AZ_POINTS}}, $ele);
  1940         3875  
665 1940         2431 push (@{$self->{ELE_AZ_POINTS}}, $az);
  1940         3764  
666              
667 1940         2317 push (@{$self->{ELE_PA_POINTS}}, $ele);
  1940         5001  
668 1940         2417 push (@{$self->{ELE_PA_POINTS}}, $pa);
  1940         3598  
669              
670 1940         2046 push (@{$self->{AZ_TIME_POINTS}}, $az);
  1940         3882  
671 1940         2426 push (@{$self->{AZ_TIME_POINTS}}, $lst);
  1940         3550  
672              
673 1940         1968 push (@{$self->{AZ_ELE_POINTS}}, $az);
  1940         4411  
674 1940         2617 push (@{$self->{AZ_ELE_POINTS}}, $ele);
  1940         3443  
675              
676 1940         2368 push (@{$self->{AZ_PA_POINTS}}, $az);
  1940         4107  
677 1940         2973 push (@{$self->{AZ_PA_POINTS}}, $pa);
  1940         3372  
678              
679 1940         2280 push (@{$self->{PA_TIME_POINTS}}, $pa);
  1940         4084  
680 1940         2584 push (@{$self->{PA_TIME_POINTS}}, $lst);
  1940         4112  
681              
682 1940         2757 push (@{$self->{PA_ELE_POINTS}}, $pa);
  1940         4155  
683 1940         2316 push (@{$self->{PA_ELE_POINTS}}, $ele);
  1940         3853  
684              
685 1940         2047 push (@{$self->{PA_AZ_POINTS}}, $pa);
  1940         3627  
686 1940         2153 push (@{$self->{PA_AZ_POINTS}}, $az);
  1940         3369  
687              
688 1940         10550 $dt_running->add(seconds => 24 * 3600 / ($numPoints - 1));
689             }
690              
691 20         11542 $coords->datetime($dt_save);
692             }
693              
694             =item calcPoint
695              
696             Returns the time in decimal, elevation, azimuth, and parallactic angle
697             for a given source at a particular time and date.
698              
699             ($lst, $ele, $az, $pa) = $obs->calcPoint($date, $time, $tel);
700              
701             =cut
702              
703             sub calcPoint {
704 1000     1000 1 6425 my $self = shift;
705 1000         2646 my $DATE = shift;
706 1000         1337 my $TIME = shift;
707 1000         2016 my $tel = shift;
708              
709 1000         5791 $DATE =~ s/\/$//;
710              
711 1000         25700 my $strp = new DateTime::Format::Strptime(
712             pattern => '%Y/%m/%d %H:%M:%S',
713             time_zone => 'UTC',
714             on_error => 'croak');
715              
716 1000         617841 my $dt = $strp->parse_datetime($DATE . ' ' . $TIME);
717              
718 1000         1157908 $dt->add(hours => 10);
719              
720 1000         727870 return $self->_calcPoint($dt, $tel);
721             }
722              
723             sub _calcPoint {
724 2940     2940   5525 my $self = shift;
725 2940         5304 my $dt = shift;
726 2940         4675 my $tel = shift;
727              
728 2940         9740 my $coords = $self->coords();
729 2940 50       17322 $coords->datetime($dt) if defined $dt;
730 2940 100       365680 $coords->telescope($tel) if defined $tel;
731              
732 2940         74150 my $pa = $coords->pa(format => 'r');
733 2940         5900905 my ($elex, $eley) = _axis_direction($pa, 0, 30);
734 2940         11638 my ($azx, $azy) = _axis_direction($pa, 30, 0);
735              
736 2940         12946 return ($coords->_lst()->radians(),
737             $coords->el(format => 'd'),
738             $coords->az(format => 'd'),
739             $coords->pa(format => 'd'),
740             $elex, $eley, $azx, $azy);
741             }
742              
743             # Based on the AzToRa function from the old
744             # Astro::Instrument::SCUBA::Array module
745             # by Casey Best (University of Victoria).
746             sub _axis_direction {
747 5880     5880   8412 my $pa = shift;
748 5880         8514 my $daz = shift;
749 5880         7801 my $del = shift;
750              
751 5880         24302 my $x = -$daz * cos($pa) + $del * sin($pa);
752 5880         13372 my $y = $daz * sin($pa) + $del * cos($pa);
753 5880         18887 return ($x, $y);
754             }
755              
756              
757             =item erasePoints
758              
759             Erases all of the plotting points. Needed when new coords put in.
760              
761             $obs->erasePoints();
762              
763             =cut
764              
765             sub erasePoints {
766 0     0 1   my $self = shift;
767 0           $self->{TIME_ELE_POINTS} = ();
768 0           $self->{TIME_AZ_POINTS} = ();
769 0           $self->{TIME_PA_POINTS} = ();
770 0           $self->{ELE_TIME_POINTS} = ();
771 0           $self->{ELE_AZ_POINTS} = ();
772 0           $self->{ELE_PA_POINTS} = ();
773 0           $self->{AZ_TIME_POINTS} = ();
774 0           $self->{AZ_ELE_POINTS} = ();
775 0           $self->{AZ_PA_POINTS} = ();
776 0           $self->{PA_TIME_POINTS} = ();
777 0           $self->{PA_ELE_POINTS} = ();
778 0           $self->{PA_AZ_POINTS} = ();
779 0           $self->{TIMEDOTX} = undef;
780 0           $self->{TIMEDOTY} = undef;
781             }
782              
783             =item eraseTimeDot
784              
785             Erases the time dot coordinates
786              
787             $obs->eraseTimeDot();
788              
789             =cut
790              
791             sub eraseTimeDot {
792 0     0 1   my $self = shift;
793 0           $self->{TIMEDOTX} = undef;
794 0           $self->{TIMEDOTY} = undef;
795             }
796              
797             =back
798              
799             =head1 AUTHOR
800              
801             Casey Best
802              
803             =head1 COPYRIGHT
804              
805             Copyright (C) 2012-2014 Science and Technology Facilities Council.
806             Copyright (C) 1998, 1999 Particle Physics and Astronomy Research
807             Council. All Rights Reserved.
808              
809             This program is free software; you can redistribute it and/or modify
810             it under the terms of the GNU General Public License as published by
811             the Free Software Foundation; either version 3 of the License, or
812             (at your option) any later version.
813              
814             This program is distributed in the hope that it will be useful,but
815             WITHOUT ANY WARRANTY; without even the implied warranty of
816             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
817             General Public License for more details.
818              
819             You should have received a copy of the GNU General Public License
820             along with this program. If not, see .
821              
822             =cut
823              
824             1;