|
Astro::WaveBand - Transparently work in waveband, wavelength or filter |
Astro::WaveBand - Transparently work in waveband, wavelength or filter
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");
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.
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.
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).
$wav = $w->wavelength; $w->wavelength(450.0);
$frequency = $w->frequency; $w->frequency(345E9);
$value = $w->wavenumber; $w->wavenumber(1500);
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.
$inst = $w->instrument; $w->instrument( 'SCUBA' );
Used to aid in the choice of natural unit.
$w->natural_unit('filter');
Returns undef if none can be determined.
$band = $w->waveband;
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....
Does not automatically convert metres to microns and GHz to Hz etc.
Tim Jenness <t.jenness@jach.hawaii.edu>
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.
|
Astro::WaveBand - Transparently work in waveband, wavelength or filter |