| Astro-Flux documentation | Contained in the Astro-Flux distribution. |
Astro::FluxColor - Class for handling astronomical color quantities.
use Astro::FluxColor;
$color = new Astro::FluxColor( lower => $lower_waveband,
upper => $upper_waveband,
quantity => $quantity,
datetime => new DateTime );
$quantity = $color->quantity;
Class for handling astronomical color quantities.
Create a new instance of an Astro::FluxColor object.
$color = new Astro::FluxColor( lower => $lower_waveband, upper => $upper_waveband, quantity => $quantity, datetime => new DateTime );
The three named parameters are mandatory. lower and upper
denote the lower and upper wavebands for the colour, and
must be Astro::WaveBand objects. quantity is a numerical
value in magnitudes.
Returns the actual color value.
my $value = $color->quantity;
There are no parameters.
Returns the actual uncertainty in the cerror.
my $e = $color->error;
There are no parameters.
Returns the lower waveband.
my $lower = $color->lower;
There are no parameters. An Astro::WaveBand object is returned.
Returns the upper waveband.
my $upper = $color->upper;
There are no parameters. An Astro::WaveBand object is returned.
Returns the datetime stamp for the given flux object.
my $datetime = $flux->datetime;
Returns an Date::datetime object if defined. If not, returns undef.
$Id: FluxColor.pm,v 1.6 2005/06/15 01:14:01 allan Exp $
Brad Cavanagh <b.cavanagh@jach.hawaii.edu>, Alasdair Allan <aa@astro.ex.ac.uk>
Copyright (C) 2004 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-Flux documentation | Contained in the Astro-Flux distribution. |
package Astro::FluxColor;
use 5.006; use strict; use warnings; use warnings::register; use Carp; use Astro::WaveBand; use Number::Uncertainty; our $VERSION = '0.01';
sub new { my $proto = shift; my $class = ref( $proto ) || $proto; my %args = @_; if( ! defined( $args{'lower'} ) ) { croak "Lower waveband must be defined"; } elsif( ! UNIVERSAL::isa( $args{'lower'}, "Astro::WaveBand" ) ) { $args{'lower'} = new Astro::WaveBand( Filter => $args{'lower'} ); } if( ! defined( $args{'upper'} ) ) { croak "Upper waveband must be defined"; } elsif( ! UNIVERSAL::isa( $args{'upper'}, "Astro::WaveBand" ) ) { $args{'upper'} = new Astro::WaveBand( Filter => $args{'upper'} ); } my $quantity; if( ! defined( $args{'quantity'} ) ) { croak "Color quantity must be defined"; } elsif ( ! UNIVERSAL::isa($args{'quantity'}, "Number::Uncertainty" ) ) { $quantity = new Number::Uncertainty( Value => $args{'quantity'} ); } else { $quantity = $args{'quantity'}; } my $color = {}; $color->{LOWER} = $args{'lower'}; $color->{UPPER} = $args{'upper'}; $color->{QUANTITY} = $quantity; if( defined( $args{'datetime'} ) ) { unless ( UNIVERSAL::isa( $args{'datetime'}, "DateTime" ) ) { croak "Time stamp must be a DateTime object\n"; } else { $color->{TIME} = $args{'datetime'}; } } bless( $color, $class ); return $color; }
sub quantity { my $self = shift; my $number = $self->{QUANTITY}; my $value = $number->value(); return $value; }
sub error { my $self = shift; my $number = $self->{QUANTITY}; my $error = $number->error(); return $error; }
sub lower { my $self = shift; return $self->{LOWER}; }
sub upper { my $self = shift; return $self->{UPPER}; }
sub datetime { my $self = shift; return $self->{TIME}; }
1;