Astro-WaveBand

 view release on metacpan or  search on metacpan

lib/Astro/WaveBand.pm  view on Meta::CPAN

package Astro::WaveBand;

=head1 NAME

Astro::WaveBand - Transparently work in waveband, wavelength or filter

=head1 SYNOPSIS

    use Astro::WaveBand;

    $w = Astro::WaveBand->new(Filter => $filter);
    $w = Astro::WaveBand->new(Wavelength => $wavelength);

    $w = Astro::WaveBand->new(
        Wavelength => $wavelength,
        Instrument => 'CGS4');

    $filter = $w->filter;
    $wave = $w->wavelength;
    $band = $w->waveband;  # radio, xray, submm
    $freq = $w->frequency;
    $wnum = $w->wavenumber;

    $natural = $w->natural;
    $natural = "$w";

    $w->natural_unit("wavelength");

    if ($w1 > $w2) {...}
    if ($w1 == $w2) {...}

=head1 DESCRIPTION

Class to transparently deal with the conversion between filters,
wavelength, frequency and other methods of specifying a location
in the electro-magentic spectrum.

The class tries to determine the natural form of the numbers such that
a request for a summary of the object when it contains 2.2 microns
would return the filter name but would return the wavelength if it was
not a standard filter. In ambiguous cases an instrument name is
required to decide what to return. In really ambiguous cases the user
can specify the unit in which to display the numbers on
stringification.

Used mainly as a way of storing a single number in a database table
but using logic to determine the number that an observer is most likely
to understand.

Numerical comparison operators can be used to compare two C<Astro::WaveBand>
objects. When checking equality, the "natural" and "instrument" methods are
used, so if two C<Astro::WaveBand> objects return the same value from those
methods, they are considered to be equal. When checking other comparisons
such as greater than, the wavelength is used.

=cut

use 5.006;
use strict;
use warnings;
use Carp;

# Register an Astro::WaveBand warning category
use warnings::register;

# CVS version: $Revision$
our $VERSION = '0.12';

# Overloading
use overload
    '""' => "natural",
    '==' => "equals",
    '!=' => "not_equals",
    '<=>' => "compare",
    'fallback' => 1;

# Constants

# Speed of light in m/s
use constant CLIGHT => 299792458;

# list of instruments specific to a telescope
my %TELESCOPE = (
    UKIRT => [
        qw/CGS4 IRCAM UFTI UIST MICHELLE WFCAM/],
    JCMT => [
        qw/SCUBA SCUBA-2 RXA3 RXA3M RXB3 RXW RXH3
            ACSIS DAS HARP ALAIHI UU AWEOWEO
            KUNTUR/
    ],
);

# Continuum Filters are keyed by instrument
# although if an instrument is not specified the filters



( run in 3.240 seconds using v1.01-cache-2.11-cpan-7fcb06a456a )