Astro-satpass
view release on metacpan or search on metacpan
lib/Astro/Coord/ECI/TLE.pm view on Meta::CPAN
=cut
sub is_deep {
return $_[0]->{&TLE_INIT}{TLE_isdeep}
if exists $_[0]->{&TLE_INIT}{TLE_isdeep};
return ($_[0]->{&TLE_INIT}{TLE_isdeep} = $_[0]->period () >= 13500);
}
=item $boolean = $tle->is_model_attribute ($name);
This method returns true if the named attribute is an attribute of
the model - i.e. it came from the TLE data and actually affects the
model computations. It is really for the benefit of
Astro::Coord::ECI::TLE::Set, so that class can determine how its
set() method should handle the attribute.
=cut
sub is_model_attribute { return $model_attrib{$_[1]} }
=item $boolean = $tle->is_valid_model ($model_name);
This method returns true if the given name is the name of an orbital
model, and false otherwise.
Actually, in the spirit of UNIVERSAL::can, it returns a reference to
the code if the model exists, and undef otherwise.
This is really for the benefit of Astro::Coord::ECI::TLE::Set, so it
knows it needs to select the correct member object before running the
model.
This method can be called as a static method, or even as a subroutine.
=cut
{ # Begin local symbol block
my %valid = map {$_ => __PACKAGE__->can ($_)}
qw{model model4 model4r model8 null sdp4 sdp8 sgp sgp4 sgp4r sgp8};
#>>> NOTE WELL
#>>> If a model is added, the period method must change
#>>> as well, to calculate using the new model. I really
#>>> ought to do all this with code attributes.
sub is_valid_model {
return $valid{$_[1]}
}
} # End local symbol block
=item $mag = $tle->magnitude( $station );
This method returns the magnitude of the body as seen from the given
station. If no C<$station> is specified, the object's C<'station'>
attribute is used. If that is not set, and exception is thrown.
This is calculated from the C<'intrinsic_magnitude'> attribute, the
distance from the station to the satellite, and the fraction of the
satellite illuminated. The formula is from Mike McCants.
We return C<undef> if the C<'intrinsic_magnitude'> or C<'illum'>
attributes are C<undef>, or if the illuminating body is below the
horizon as seen from the satellite.
After this method returns the time set in the station attribute should
be considered undefined. In fact, it will be set to the same time as the
invocant if a defined magnitude was returned. But if C<undef> was
returned, the station's time may not have been changed.
Some very desultory investigation of International Space Station
magnitude predictions suggests that this method produces magnitude
estimates about half a magnitude less bright than Heavens Above.
=cut
sub magnitude {
my ( $self, $sta ) = __default_station( @_ );
# If we have no standard magnitude, just return undef.
defined( my $std_mag = $self->get( 'intrinsic_magnitude' ) )
or return undef; ## no critic (ProhibitExplicitReturnUndef)
# If we have no illuminating body for some reason, we also have to
# just return undef.
my $illum = $self->get( 'illum' )
or return undef; ## no critic (ProhibitExplicitReturnUndef)
# Pick up the time.
my $time = $self->universal();
# If the illuminating body is below the horizon, we return undef.
$self->illuminated()
or return undef; ## no critic (ProhibitExplicitReturnUndef)
# Compute the range amd the elevation.
my ( undef, $elev, $range ) = $sta->universal( $time )->azel( $self );
# If the satellite is below the horizon, just return undef
$elev < 0
and return undef; ## no critic (ProhibitExplicitReturnUndef)
# Adjust the magnitude if the illuminating body is not the Sun.
my $mag_adj = $illum->isa( 'Astro::Coord::ECI::Sun' ) ? 0 :
$illum->magnitude() - Astro::Coord::ECI::Sun->MEAN_MAGNITUDE();
# Compute the fraction of the satellite illuminated.
my $frac_illum = ( 1 + cos( $self->angle( $illum, $sta ) ) ) / 2;
# Finally we get to McCants' algorithm
return $std_mag + $mag_adj - 15.75 +
2.5 * log( $range ** 2 / $frac_illum ) / log( 10 );
}
=item Astro::Coord::ECI::TLE->magnitude_table( command => arguments ...)
This method maintains the internal magnitude table, which is used by the
parse() method to fill in magnitudes, since they are not normally
available from the usual sources. The first argument determines what is
( run in 2.346 seconds using v1.01-cache-2.11-cpan-5c0b1e786e0 )