Astro::FluxColor - Class for handling astronomical color quantities.


Astro-Flux documentation Contained in the Astro-Flux distribution.

Index


Code Index:

NAME

Top

Astro::FluxColor - Class for handling astronomical color quantities.

SYNOPSIS

Top

use Astro::FluxColor;

  $color = new Astro::FluxColor( lower => $lower_waveband,
                                 upper => $upper_waveband,
                                 quantity => $quantity,
				 datetime => new DateTime );

  $quantity = $color->quantity;

DESCRIPTION

Top

Class for handling astronomical color quantities.

METHODS

Top

Constructor

new

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.

Accessor Methods

quantity

Returns the actual color value.

  my $value = $color->quantity;

There are no parameters.

error

Returns the actual uncertainty in the cerror.

  my $e = $color->error;

There are no parameters.

lower

Returns the lower waveband.

  my $lower = $color->lower;

There are no parameters. An Astro::WaveBand object is returned.

upper

Returns the upper waveband.

  my $upper = $color->upper;

There are no parameters. An Astro::WaveBand object is returned.

datetime

Returns the datetime stamp for the given flux object.

  my $datetime = $flux->datetime;

Returns an Date::datetime object if defined. If not, returns undef.

REVISION

Top

  $Id: FluxColor.pm,v 1.6 2005/06/15 01:14:01 allan Exp $

AUTHORS

Top

Brad Cavanagh <b.cavanagh@jach.hawaii.edu>, Alasdair Allan <aa@astro.ex.ac.uk>

COPYRIGHT

Top


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;