ConstantSpectrum.h

Classes

ConstantSpectrum -- Model the spectral variation with a constant (full description)

class ConstantSpectrum: public SpectralModel

Interface

Public Members
ConstantSpectrum()
ConstantSpectrum(const ConstantSpectrum& other)
virtual ~ConstantSpectrum()
ConstantSpectrum& operator=(const ConstantSpectrum& other)
virtual ComponentType::SpectralShape type() const
virtual Double sample(const MFrequency& centerFrequency) const
virtual void sample(Vector<Double>& scale, const Vector<MFrequency::MVType>& frequencies, const MFrequency::Ref& refFrame) const
virtual SpectralModel* clone() const
virtual uInt nParameters() const
virtual void setParameters(const Vector<Double>& newSpectralParms)
virtual Vector<Double> parameters() const
virtual void setErrors(const Vector<Double>& newSpectralErrs)
virtual Vector<Double> errors() const
virtual Bool fromRecord(String& errorMessage, const RecordInterface& record)
virtual Bool toRecord(String& errorMessage, RecordInterface& record) const
virtual Bool convertUnit(String& errorMessage, const RecordInterface& record)
virtual Bool ok() const
See Also
SpectralIndex - Uses a spectral index to model the spectrum

Description

Review Status

Date Reviewed:
yyyy/mm/dd
Programs:
Demos:
Tests:

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

Member Description

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.

ConstantSpectrum& operator=(const ConstantSpectrum& other)

The assignment operator uses copy semantics.

virtual ComponentType::SpectralShape type() const

return the actual spectral type. This function always returns ComponentType::CONSTANT_SPECTRUM

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. This function always returns one, as the spectrum is constant.

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. The reference frame must be the same for all the specified frequencies. Uses a customised implementation.

virtual SpectralModel* clone() const

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.

virtual uInt nParameters() const
virtual void setParameters(const Vector<Double>& newSpectralParms)
virtual Vector<Double> parameters() const
virtual void setErrors(const Vector<Double>& newSpectralErrs)
virtual Vector<Double> errors() const

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).

virtual Bool fromRecord(String& errorMessage, const RecordInterface& record)
virtual Bool toRecord(String& errorMessage, RecordInterface& record) const

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.

virtual Bool convertUnit(String& errorMessage, const RecordInterface& record)

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.

virtual Bool ok() const

Function which checks the internal data of this class for consistant values. Returns True if everything is fine otherwise returns False.