casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions
casa::ConstantSpectrum Class Reference

Model the spectral variation with a constant. More...

#include <ConstantSpectrum.h>

Inheritance diagram for casa::ConstantSpectrum:
casa::SpectralModel casa::RecordTransformable

List of all members.

Public Member Functions

 ConstantSpectrum ()
 The default constructor is the only one you really need as this class has no parameters!
 ConstantSpectrum (const ConstantSpectrum &other)
 The copy constructor uses copy semantics.
virtual ~ConstantSpectrum ()
 The destructor does nothing.
ConstantSpectrumoperator= (const ConstantSpectrum &other)
 The assignment operator uses copy semantics.
virtual
ComponentType::SpectralShape 
type () const
 return the actual spectral type.
virtual Double sample (const MFrequency &centerFrequency) const
 Return the scaling factor that indicates the flux is at the specified frequency assuming the flux at the reference frequency is one.
virtual void sample (Vector< Double > &scale, const Vector< MFrequency::MVType > &frequencies, const MFrequency::Ref &refFrame) const
 Same as the previous function except that many frequencies can be sampled at once.
virtual SpectralModelclone () const
 Return a pointer to a copy of this object upcast to a SpectralModel object.
virtual uInt nParameters () const
 return the number of parameters.
virtual void setParameters (const Vector< Double > &newSpectralParms)
virtual Vector< Doubleparameters () const
virtual void setErrors (const Vector< Double > &newSpectralErrs)
virtual Vector< Doubleerrors () const
virtual Bool fromRecord (String &errorMessage, const RecordInterface &record)
 These functions convert between a Record and a ConstantSpectrum.
virtual Bool toRecord (String &errorMessage, RecordInterface &record) const
 Convert the class to an Record representation.
virtual Bool convertUnit (String &errorMessage, const RecordInterface &record)
 Convert the parameters of the spectrum to the specified units.
virtual Bool ok () const
 Function which checks the internal data of this class for consistant values.

Detailed Description

Model the spectral variation with a constant.

Intended use:

Public interface

 <h3>Review Status</h3><dl><dt>Date Reviewed:<dd>yyyy/mm/dd<dt>Test programs:<dd>tConstantSpectrum<dt>Demo programs:<dd>dConstantSpectrum</dl> 

Prerequisite

Synopsis

This class models the spectral variation of a component as constant, ie. unchanging with frequency. It is the simplest possible model for spectral variation.

This class like the other spectral models becomes more useful when used through the SkyComponent class, which incorperates the flux and spatial variation of the emission, or through the ComponentList class, which handles groups of SkyComponent objects.

Because the flux is constant with frequency the concept of a reference frequency is meaningless with this class. But it can still be accessed using the refFrequency and setRefFrequency. However changing its value will not affect the behaviour of this class.

This class does not have any parameters and the nParameters function will return zero. It is an error that will generate an exception (in Debug mode) to call the setParameters and parameters functions with anything other than a zero length vector.

The sample functions always return 1.0.

This class also contains functions (toRecord & fromRecord) which perform the conversion between Records and ConstantSpectrum objects. These functions define how a ConstantSpectrum object is represented in glish. The format of the record that is generated and accepted by these functions is:

    c := [type = 'constant',
          frequency = [type = 'frequency',
                       refer = 'lsr',
                       m0 = [value = 1, unit = 'GHz']
                      ]
         ]

The frequency field contains a record representation of a frequency measure and its format is defined in the Measures module. Its refer field defines the reference frame for the direction and the m0 field defines the value of the reference frequency. The parsing of the type field is case insensitive.

Example

Its hard to think of a good example for this class as it is basically does nothing! In this example the spectral variation of a component is set to to a constant value.

    SkyComponent myComp(...);
    ..\.
    if (myComp.spectrum().type() != ComponentType::CONSTANT_SPECTRUM) {
      myComp.spectrum() = ConstantSpectrum();
    }

Motivation

A ConstantSpectrum class is needed for users who are not interested in modelling any spectral variation in their components.

To Do

Definition at line 124 of file ConstantSpectrum.h.


Constructor & Destructor Documentation

The default constructor is the only one you really need as this class has no parameters!

The copy constructor uses copy semantics.

The destructor does nothing.


Member Function Documentation

virtual SpectralModel* casa::ConstantSpectrum::clone ( ) const [virtual]

Return a pointer to a copy of this object upcast to a SpectralModel object.

The class that uses this function is responsible for deleting the pointer. This is used to implement a virtual copy constructor.

Implements casa::SpectralModel.

virtual Bool casa::ConstantSpectrum::convertUnit ( String errorMessage,
const RecordInterface record 
) [virtual]

Convert the parameters of the spectrum to the specified units.

As a constant spectrum has no parameters this function does nothing and always returns True.

Implements casa::SpectralModel.

virtual Vector<Double> casa::ConstantSpectrum::errors ( ) const [virtual]

Implements casa::SpectralModel.

virtual Bool casa::ConstantSpectrum::fromRecord ( String errorMessage,
const RecordInterface record 
) [virtual]

These functions convert between a Record and a ConstantSpectrum.

These functions define how a ConstantSpectrum object is represented in glish and this is detailed in the synopsis above. These functions return False if the record is malformed and append an error message to the supplied string giving the reason.

Implements casa::SpectralModel.

virtual uInt casa::ConstantSpectrum::nParameters ( ) const [virtual]

return the number of parameters.

There are no parameters for this spectral model. So calling setParameters or parameters with anything other than a zero length Vector will throw an exception (when compiled in debug mode).

Implements casa::SpectralModel.

virtual Bool casa::ConstantSpectrum::ok ( ) const [virtual]

Function which checks the internal data of this class for consistant values.

Returns True if everything is fine otherwise returns False.

Reimplemented from casa::SpectralModel.

ConstantSpectrum& casa::ConstantSpectrum::operator= ( const ConstantSpectrum other)

The assignment operator uses copy semantics.

virtual Vector<Double> casa::ConstantSpectrum::parameters ( ) const [virtual]

Implements casa::SpectralModel.

virtual Double casa::ConstantSpectrum::sample ( const MFrequency centerFrequency) const [virtual]

Return the scaling factor that indicates the flux is at the specified frequency assuming the flux at the reference frequency is one.

This function always returns one, as the spectrum is constant.

Implements casa::SpectralModel.

virtual void casa::ConstantSpectrum::sample ( Vector< Double > &  scale,
const Vector< MFrequency::MVType > &  frequencies,
const MFrequency::Ref refFrame 
) const [virtual]

Same as the previous function except that many frequencies can be sampled at once.

The reference frame must be the same for all the specified frequencies. Uses a customised implementation.

Implements casa::SpectralModel.

virtual void casa::ConstantSpectrum::setErrors ( const Vector< Double > &  newSpectralErrs) [virtual]

Implements casa::SpectralModel.

virtual void casa::ConstantSpectrum::setParameters ( const Vector< Double > &  newSpectralParms) [virtual]

Implements casa::SpectralModel.

virtual Bool casa::ConstantSpectrum::toRecord ( String error,
RecordInterface outRecord 
) const [virtual]

Convert the class to an Record representation.

The input record may already contain fields and these fields may be silently overridden. New fields may be added to the input Record. If the transformation succeeds then the error String is unchanged and the function returns True. Otherwise the function returns False and appends an error message to the supplied String giving the reason why the conversion failed.

Implements casa::SpectralModel.

return the actual spectral type.

This function always returns ComponentType::CONSTANT_SPECTRUM

Implements casa::SpectralModel.


The documentation for this class was generated from the following file: