Astro-Catalog
view release on metacpan or search on metacpan
#!perl
# Astro::Catalog::Query::MPC test harness
use strict;
use Test::More tests => 202;
use Data::Dumper;
use Astro::Flux;
use Astro::Fluxes;
use Number::Uncertainty;
# Catalog modules need to be loaded first
BEGIN {
use_ok( "Astro::Catalog::Item");
use_ok( "Astro::Catalog");
use_ok( "Astro::Catalog::Query::MPC");
}
# Load the generic test code
my $p = (-d "t" ? "t/" : "");
do $p."helper.pl" or die "Error reading test functions: $!";
# Grab MPC sample from the DATA block
my @buffer = <DATA>;
chomp @buffer;
# test catalog
my $catalog_data = new Astro::Catalog();
my $epoch = 2004.16427554485;
# create a temporary object to hold stars
my $star;
# Parse data block
foreach my $line (0 .. $#buffer) {
my ($name, $ra, $dec, $vmag, $raoff, $decoff, $pm_ra, $pm_dec, $orbit,
$comment) = unpack("A24A11A10A6A7A7A7A7A6A*", $buffer[$line]);
if (defined $ra) {
$star = new Astro::Catalog::Item();
$name =~ s/^\s+//;
$star->id( $name );
$vmag =~ s/^\s+//;
$star->fluxes(new Astro::Fluxes(new Astro::Flux(
new Number::Uncertainty(Value => $vmag),
'mag', "V")));
$comment =~ s/^\s+//;
$star->comment($comment);
# Deal with the coordinates. RA and Dec are almost in the
# right format (need to replace separating spaces with colons).
$ra =~ s/^\s+//;
$ra =~ s/ /:/g;
$dec =~ s/^\s+//;
$dec =~ s/ /:/g;
my $coords = new Astro::Coords(
name => $name,
ra => $ra,
dec => $dec,
type => 'J2000',
epoch => $epoch,
);
$star->coords($coords);
# Push the star onto the catalog.
$catalog_data->pushstar( $star );
}
}
# field centre
$catalog_data->fieldcentre(
RA => '07 13 42',
Dec => '-14 02 00',
Radius => '300');
# Grab comparison from ESO/ST-ECF Archive Site
my $mpc_byname = new Astro::Catalog::Query::MPC(
RA => "07 13 42",
Dec => "-14 02 00",
Radmax => '300',
Year => 2004,
Month => 03,
Day => 1.87,
);
print "# Connecting to MPC Minor Planet Checker\n";
my $catalog_byname;
eval {$catalog_byname = $mpc_byname->querydb()};
SKIP: {
diag($@) if $@;
skip "Cannot connect to MPC website", 199 if $@;
skip "No asteroids returned from MPC", 199 if ($catalog_byname->sizeof() == 0);
print "# Continuing tests\n";
# check sizes
print "# DAT has " . $catalog_data->sizeof() . " stars\n";
print "# NET has " . $catalog_byname->sizeof() . " stars\n";
# Compare catalogs
compare_mpc_catalog($catalog_byname, $catalog_data);
}
( run in 0.632 second using v1.01-cache-2.11-cpan-5a3173703d6 )