Astro-Catalog
view release on metacpan or search on metacpan
lib/Astro/Catalog/Query/GSC.pm view on Meta::CPAN
package Astro::Catalog::Query::GSC;
=head1 NAME
Astro::Catalog::Query::GSC - A query request to the GSC Catalog
=head1 SYNOPSIS
$gsc = new Astro::Catalog::Query::GSC(
RA => $ra,
Dec => $dec,
Radius => $radius,
Bright => $magbright,
Faint => $magfaint,
Sort => $sort_type,
Nout => $number_out );
my $catalog = $gsc->querydb();
=head1 DESCRIPTION
The module is an object orientated interface to the online Guide Star
catalogue at the ESO/ST-ECF archive site.
Stores information about an prospective GSC query and allows the query to
be made, returning an Astro::Catalog::GSC::Catalog object.
The object will by default pick up the proxy information from the HTTP_PROXY
and NO_PROXY environment variables, see the LWP::UserAgent documentation for
details.
See L<Astro::Catalog::BaseQuery> for the catalog-independent methods.
=cut
use strict;
use warnings;
use base qw/Astro::Catalog::Transport::REST/;
use File::Spec;
use Carp;
use Astro::Catalog;
use Astro::Catalog::Item;
use Astro::Flux;
use Astro::Fluxes;
use Number::Uncertainty;
our $VERSION = '4.38';
=begin __PRIVATE_METHODS__
=head2 Private methods
These methods are for internal use only.
=over 4
=item B<_default_remote_host>
=cut
sub _default_remote_host {
return "archive.eso.org";
}
=item B<_default_url_path>
=cut
sub _default_url_path {
return "gsc/gsc?";
}
=item B<_get_allowed_options>
Returns a hash with keys, being the internal options supported
by this subclass, and values being the key name actually required
by the remote system (and to be included in the query).
=cut
sub _get_allowed_options {
my $self = shift;
return (
ra => 'ra',
dec => 'dec',
object => 'object',
radmax => 'radmax',
magbright => 'magbright',
magfaint => 'magfaint',
sort => 'sort',
nout => 'nout',
format => 'format',
catalogue => 'catalogue',
epoch => 'epoch',
chart => 'chart',
multi => 'multi',
);
}
=item B<_get_default_options>
Get the default query state.
=cut
lib/Astro/Catalog/Query/GSC.pm view on Meta::CPAN
# loop round the returned buffer and stuff the contents into star objects
foreach $line (0 ... $#buffer) {
# Parse field centre
# RA
if (lc($buffer[$line]) =~ "<td>ra:") {
$_ = lc($buffer[$line]);
my ($ra) = /^\s*<td>ra:\s+(.*)<\/td>/;
$field{RA} = $ra;
}
# Dec
if (lc($buffer[$line]) =~ "<td>dec:") {
$_ = lc($buffer[$line]);
my ($dec) = /^\s+<td>dec:\s+(.*)<\/td>/;
$field{Dec} = $dec;
}
# Radius
if (lc($buffer[$line]) =~ "search radius:") {
$_ = lc($buffer[$line+1]);
my ($radius) = />\s+(.*)\s\w/;
$field{Radius} = $radius;
}
$catalog->fieldcentre(%field);
# Parse list of objects
if (lc($buffer[$line]) =~ "<pre>") {
# reached the catalog block, loop through until </pre> reached
$counter = $line + 2;
until (lc($buffer[$counter+1]) =~ "</pre>") {
# split each line
my @separated = split /\s+/, $buffer[$counter];
# 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(
ra => $objra,
dec => $objdec,
units => 'sex',
type => 'J2000',
name => $id,
),
);
$star->fluxes(new Astro::Fluxes(new Astro::Flux(
new Number::Uncertainty(
Value => $separated[10],
Error => $separated[11]),
'mag', "B")));
# Quality
my $quality = $separated[13];
$quality = 1 if $quality == 3; # 3 == non-stellar
$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->pushstar($star);
# increment counter
$counter = $counter + 1;
}
# reset $line to correct place
$line = $counter;
}
}
# Set the field centre
$catalog->fieldcentre(%field);
return $catalog;
}
=back
=head2 Translation Methods
The query options stored internally in the object are not necessarily
the form required for a query to a remote server. Methods for converting
from the internal representation to the external query format are
provided in the form of _from_$opt. ie:
($outkey, $outvalue) = $q->_from_ra();
($outkey, $outvalue) = $q->_from_object();
The base class only includes one to one mappings.
=item B<_translate_one_to_one>
( run in 0.787 second using v1.01-cache-2.11-cpan-5a3173703d6 )