Astro-Coord-ECI-TLE-Iridium

 view release on metacpan or  search on metacpan

t/tle_flare.t  view on Meta::CPAN

package main;

use 5.006002;

use strict;
use warnings;

use Test::More 0.88;

BEGIN {
    eval {
	require Time::Local;
	Time::Local->import();
	1;
    } or do {
	plan skip_all => 'Can not load Time::Local';
	exit;
    };
}

use Astro::Coord::ECI;
use Astro::Coord::ECI::TLE qw{ :constants };
use Astro::Coord::ECI::TLE::Iridium;
use Astro::Coord::ECI::Utils qw{ deg2rad PARSEC rad2deg SECSPERDAY };

use lib qw{ inc };

use My::Module::Test qw{ magnitude };

my $sta = Astro::Coord::ECI->new(
    name => 'Greenwich Observatory',
)->geodetic(
    deg2rad( 51.4772 ),
    0,
    2 / 1000,
);

Astro::Coord::ECI::TLE->status( add => 88888, iridium => '+',
    'Fake Iridium' );

# The following TLE is from
#
# SPACETRACK REPORT NO. 3
#
# Models for Propagation of
# NORAD Element Sets
#
# Felix R. Hoots
# Ronald L. Roerich
#
# December 1980
#
# Package Compiled by
# TS Kelso
#
# 31 December 1988
#
# obtained from http://celestrak.com/

# There is no need to call Astro::Coord::ECI::TLE::Set->aggregate()
# because we know we have exactly one data set.

my ( $tle ) = Astro::Coord::ECI::TLE->parse( <<'EOD' );
1 88888U          80275.98708465  .00073094  13844-3  66816-4 0    8
2 88888  72.8435 115.9689 0086731  52.6988 110.5714 16.05824518  105
EOD

$tle->set( zone => 0 );

ok $tle->can_flare(), 'Body 88888 can flare (not really, but ...)';

my @flare;

note 'Flares over explicit location';

if (
    eval {
	@flare = $tle->flare(
	    $sta,
	    timegm( 0, 0, 0, 13, 9, 80 ),
	    timegm( 0, 0, 0, 14, 9, 80 ),
	);
	1;
    }
) {
    ok @flare == 2, 'Found 2 flares as seen from Greenwich'
	or diag "Found @{[ scalar @flare ]} flares from Greenwich";
} else {
    fail "Error in flare() method: $@";
}

is format_flare( $flare[0] ), <<'EOD', 'Flare 1';
1980/10/13 05:43:26  29.9  48.1   412.9 -0.4 1 am
EOD

magnitude( $tle, $sta, $flare[0]{time},
    -0.4, 'Compute magnitude at time of flare 1' );

is format_flare( $flare[1] ), <<'EOD', 'Flare 2';
1980/10/13 14:58:33  42.8 204.9   393.0 -3.0 1 day
EOD

magnitude( $tle, $sta, $flare[1]{time},



( run in 1.425 second using v1.01-cache-2.11-cpan-b16cb0d3907 )