NAME

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

SYNOPSIS

use Astro::WaveBand;

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

$w = new Astro::WaveBand( 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");

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.

METHODS

Constructor

new

Create a new instance of an Astro::WaveBand object.

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

Allowed keys for constructor are one of:

Filter     - filter name
Wavelength - wavelength in microns
Frequency  - frequency in Hertz
Wavenumber - wavenumber in cm^-1

plus optionally:

Instrument - name of associated instrument

In the future there may be a Units key to allow the units to be supplied in alternative forms.

If a mandatory key is missing or there is more than one mandatory key the constructor will fail and return undef. Additionally a warning (of class Astro::WaveBand) will be issued.

Accessor methods

All the accessor methods associated with conversions will automatically convert to the correct format on demand and will cache it for later. If a new value is provided all caches will be cleared.

All input values are converted to microns internally (since a single base unit should be chosen to simplify internal conversions).

wavelength

Wavelength in microns.

$wav =  $w->wavelength;
$w->wavelength(450.0);
frequency

Frequency in Hertz.

$frequency = $w->frequency;
$w->frequency(345E9);
wavenumber

Wavenumber (reciprocal of wavelength) in inverse centimetres.

$value = $w->wavenumber;
$w->wavenumber(1500);
filter

Set or retrieve filter name.

Returns undef if the filter can not be determined. If the filter name can not be translated to a wavelength it will not be possible to do any conversions to other forms.

instrument

Name of associated instrument.

$inst = $w->instrument;
$w->instrument( 'SCUBA' );

Used to aid in the choice of natural unit.

natural_unit

Override the natural unit to be used for stringification. If this value is not set the class will determine the unit of choice by looking at the instrument name and then by taking an informed guess.

$w->natural_unit('filter');

General Methods

waveband

Return the name of the waveband associated with the object.

Returns undef if none can be determined.

$band = $w->waveband;
natural

Return the contents of the object in its most natural form. For example, with UFTI the filter name will be returned whereas with ACSIS the frequency will be returned. The choice of unit is chosen using the supplied default unit (see natural_unit) or the instrument name. If none of these is specified filter will be used and if no match is present wavelength in microns.

$value = $w->natural;

Returns undef if the value can not be determined.

This method is called automatically when the object is stringified. Note that you will not know the unit that was chosen....

BUGS

Does not automatically convert metres to microns and GHz to Hz etc.

AUTHORS

Tim Jenness <t.jenness@jach.hawaii.edu>

COPYRIGHT

Copyright (C) 2001 Particle Physics and Astronomy Research Council. All Rights Reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.