lib/Astro/Montenbruck/RiseSet/Plarise.pm

filter: Statementstmt 97.5% 78 / 80 Branchbran 43.7% 7 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 15 / 15 Podpod 0.0% 0 / 1 totaltotal 89.2% 100 / 112 CC 10 SCAR 12.5
CC
10
Cov
89%
__ANON__
7.7
__ANON__
4.2
rst_func
1.0
CRAP 3.5
« blib/lib/Astro/Montenbruck/Utils/Theme.pm ↑ Summary lib/Astro/Montenbruck/Time/DeltaT.pm »
1 package Astro::Montenbruck::RiseSet::Plarise;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶no warnings qw/experimental/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use feature qw/switch/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 ▶use Exporter qw/import/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 ▶use Math::Trig qw/:pi deg2rad rad2deg acos/;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 3 ▶use Astro::Montenbruck::MathUtils qw/to_range/;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 3 ▶use Astro::Montenbruck::Time qw/cal2jd jd_cent/;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 3 ▶use Astro::Montenbruck::Time::Sidereal qw/ramc/;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 3 ▶use Astro::Montenbruck::RiseSet::Constants qw/:events :states/;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 3 our @EXPORT_OK = qw/rst_func/;
19 3 our $VERSION = 0.01;
20  
21 3 Readonly our $SID => 0.9972696; # Conversion sidereal/solar time
22 3 Readonly our $ZT_MIN => 0.008;
23 3 Readonly our $MAX_COUNT => 10;
24  
25 2 ▶sub _cs_phi {
Subroutine _cs_phi: called CC=1 SCAR=0.0
26 2 my $phi = shift;
27 2 my $rphi = deg2rad($phi);
28 2 cos($rphi), sin($rphi);
29 }
30  
31  
32  
33 2 ▶sub rst_func {
Subroutine rst_func: called CC=1 SCAR=0.1
Pod undocumented
34 2 my %arg = ( date => undef, phi => undef, lambda => undef, @_ );
35 2 my $jd0 = cal2jd( @{ $arg{date} } );
36 2 my $phi = $arg{phi};
37 2 my ( $cphi, $sphi ) = _cs_phi( $phi );
38  
39 2 my $lst_0h = ramc( $jd0, $arg{lambda} ) / 15;
40
41  
42 10 ▶ sub {
Subroutine __ANON__: called CC=4 SCAR=14.4
43 10 my %arg = (
44 sin_h0 => undef, # sine of altitude correction
45 get_position => undef, # function for calculation equatorial coordinates of the body
46 @_
47 );
48  
49 # Compute geocentric planetary position at 0h and 24h local time
50 10 my @ra;
51 my @de;
52 10 ($ra[$_], $de[$_]) = $arg{get_position}->($jd0 + $_) for (0..1);
53  
54 # Generate continuous right ascension values in case of jumps
55 # between 0h and 24h
56 10 ▶ $ra[1] += pi2 if $ra[0] - $ra[1] > pi;
Branch: 1 branch
BranchTrueFalseTotal
if $ra[0] - $ra[1] > "3.14159265358979" 0 10 10
57 10 ▶ $ra[0] += pi2 if $ra[0] - $ra[1] < -pi;
Branch: 1 branch
BranchTrueFalseTotal
if $ra[0] - $ra[1] < "-3.14159265358979" 0 10 10
58
59 30 ▶ sub {
Subroutine __ANON__: called CC=7 SCAR=20.4
60 30 my $event = shift;
61  
62 30 my $zt;
63 30 my $zt0 = 12.0; # Starting value 12h local time
64 30 my $state = $event;
65 30 ▶ for (my $i = 0; $i <= $MAX_COUNT; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $Astro::Montenbruck::RiseSet::Plarise::MAX_COUNT) 69 0 69
66 # Linear interpolation of planetary position
67 69 my $ra = $ra[0] + ($zt0 / 24) * ($ra[1] - $ra[0]);
68 69 my $de = $de[0] + ($zt0 / 24) * ($de[1] - $de[0]);
69 69 my $above = rad2deg($de) > 90 - $phi;
70  
71 # Compute semi-diurnal arc (in radans)
72 69 my $sda = ($arg{sin_h0} - sin($de) * $sphi) / (cos($de) * $cphi);
73 69 ▶ if (abs($sda) < 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (abs $sda < 1) { } 69 0 69
elsif ($phi > 0) { } 0 0 0
74 69 $sda = acos($sda);
75 } elsif ($phi > 0) {
76 # Test for circumpolar motion or invisibility
77 0 ▶ $state = $above ? $STATE_CIRCUMPOLAR : $STATE_NEVER_RISES;
Branch: 1 branch
BranchTrueFalseTotal
$above ? : 0 0 0
78 0 last;
79 }
80 69 my $lst = $lst_0h + $zt0 / $SID; # Sidereal time at univ. time ZT0
81 69 my $h = $lst - rad2deg($ra) / 15;
82 69 my $dtau = do {
83 69 given ($event) {
84 69 $h + rad2deg($sda) / 15 when $EVT_RISE;
85 46 $h when $EVT_TRANSIT;
86 24 $h - rad2deg($sda) / 15 when $EVT_SET;
87 }
88 };
89 69 my $dzt = $SID * (to_range($dtau + 12, 24) - 12);
90 69 $zt0 -= $dzt;
91 69 $zt = $zt0;
92 69 ▶ last if abs($dzt) <= $ZT_MIN;
Branch: 1 branch
BranchTrueFalseTotal
if abs $dzt <= $Astro::Montenbruck::RiseSet::Plarise::ZT_MIN 30 39 69
93 }
94  
95 30 ▶ return $state eq $event ? ($state, $jd0 + $zt / 24)
Branch: 1 branch
BranchTrueFalseTotal
$state eq $event ? : 30 0 30
96 : ($state, undef)
97  
98 }
99  
100 10 }
101 2 }
102  
103 3 1;
104 __END__
« blib/lib/Astro/Montenbruck/Utils/Theme.pm ↑ Summary lib/Astro/Montenbruck/Time/DeltaT.pm »