Astro-Catalog
view release on metacpan or search on metacpan
#!perl
# Astro::Catalog::Query::GSC test harness
use strict;
use Test::More tests => 159;
use Data::Dumper;
# Catalog modules need to be loaded first
BEGIN {
use_ok( "Astro::Catalog::Item");
use_ok( "Astro::Catalog");
use_ok( "Astro::Catalog::Query::GSC");
}
use Astro::Flux;
use Astro::Fluxes;
use Number::Uncertainty;
# Load the generic test code
my $p = (-d "t" ? "t/" : "");
do $p."helper.pl" or die "Error reading test functions: $!";
# Grab GSC sample from the DATA block
my @buffer = <DATA>;
chomp @buffer;
# test catalog
my $catalog_data = new Astro::Catalog();
# create a temporary object to hold stars
my $star;
# Parse data block
foreach my $line (0 .. $#buffer) {
# split each line
my @separated = split /\s+/, $buffer[$line];
# check that there is something on the line
if (defined $separated[0]) {
# create a temporary place holder object
$star = new Astro::Catalog::Item();
# ID
my $id = $separated[2];
$star->id( $id );
# RA
my $objra = "$separated[3] $separated[4] $separated[5]";
# Dec
my $objdec = "$separated[6] $separated[7] $separated[8]";
$star->coords(new Astro::Coords(
name => $id,
ra => $objra,
dec => $objdec,
units => 'sex',
type => 'J2000',
));
$star->fluxes(new Astro::Fluxes(
new Astro::Flux(
new Number::Uncertainty(
Value => $separated[10],
Error => $separated[11]),
'mag', "B")));
# Quality
my $quality = $separated[13];
$star->quality($quality);
# Field
my $field = $separated[12];
$star->field($field);
# GSC, obvious!
$star->gsc("TRUE");
# Distance
my $distance = $separated[16];
$star->distance($distance);
# Position Angle
my $pos_angle = $separated[17];
$star->posangle($pos_angle);
}
# Push the star into the catalog
$catalog_data->pushstar($star);
}
# field centre
$catalog_data->fieldcentre(
RA => '01 10 12.9',
Dec => '+60 04 35.9',
Radius => '5');
# Grab comparison from ESO/ST-ECF Archive Site
my $gsc_byname = new Astro::Catalog::Query::GSC(
RA => "01 10 12.9",
Dec => "+60 04 35.9",
Radius => '5' );
SKIP: {
print "# Connecting to ESO/ST-ECF GSC Catalogue\n";
my $catalog_byname = eval {
$gsc_byname->querydb();
};
unless (defined $catalog_byname) {
diag('Cannot connect to ESO GSC: ' . $@);
skip 'Cannot connect', 156
}
unless ($catalog_byname->sizeof() > 0) {
diag('No items retrieved from ESO GSC');
skip 'No items retrieved', 156
}
print "# Continuing tests\n";
( run in 0.605 second using v1.01-cache-2.11-cpan-5b529ec07f3 )