casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Attributes | List of all members
casa::SpectralModel Class Referenceabstract

Base class for spectral models. More...

#include <SpectralModel.h>

Inheritance diagram for casa::SpectralModel:
casacore::RecordTransformable casa::ConstantSpectrum casa::SpectralIndex casa::TabularSpectrum

Public Member Functions

virtual ~SpectralModel ()
 a virtual destructor is needed so that the actual destructor in the derived class will be used. More...
 
virtual
ComponentType::SpectralShape 
type () const =0
 return the actual spectral type. More...
 
virtual const casacore::Stringident () const
 Specify the identification of the record (e.g. More...
 
virtual void setRefFrequency (const casacore::MFrequency &newRefFreq)
 set/get the reference frequency More...
 
const casacore::MFrequencyrefFrequency () const
 
const casacore::UnitfrequencyUnit () const
 get the frequency unit, and change the default frequency unit to the specified one. More...
 
void convertFrequencyUnit (const casacore::Unit &freqUnit)
 
void setRefFrequencyError (const casacore::Quantum< casacore::Double > &newRefFreqErr)
 set/get the error in the reference frequency. More...
 
const casacore::Quantum
< casacore::Double > & 
refFrequencyError () const
 
virtual casacore::Double sample (const casacore::MFrequency &centerFrequency) const =0
 Return the scaling factor that indicates what proportion of the flux is at the specified frequency. More...
 
virtual void sampleStokes (const casacore::MFrequency &centerFrequency, casacore::Vector< casacore::Double > &stokesval) const =0
 return full casacore::Stokes version especially for models which have different frequency dependence for the casacore::Stokes param (1 or 4 elements) So as allow for fractional pol change and angle change of linear pol w.r.t frequency A a four casacore::Vector of original IQUV should be passed in and it will hold the return values More...
 
virtual void sample (casacore::Vector< casacore::Double > &scale, const casacore::Vector< casacore::MFrequency::MVType > &frequencies, const casacore::MFrequency::Ref &refFrame) const =0
 Same as the previous function except that many frequencies can be sampled at once. More...
 
virtual void sampleStokes (casacore::Vector< casacore::Vector< casacore::Double > > &stokesval, const casacore::Vector< casacore::MFrequency::MVType > &frequencies, const casacore::MFrequency::Ref &refFrame) const =0
 So as allow for fractional pol change and angle change of linear pol w.r.t frequency casacore::Vector of four Vectors of original IQUV should be passed in and it will hold the return values Uitimately this math should really go in Flux and FluxRep to where a rotation of linear pol is allowed. More...
 
virtual SpectralModelclone () const =0
 Return a pointer to a copy of the derived object upcast to a SpectralModel object. More...
 
virtual casacore::uInt nParameters () const =0
 return the number of parameters in this spectral shape and set/get them. More...
 
virtual void setParameters (const casacore::Vector< casacore::Double > &newParms)=0
 
virtual casacore::Vector
< casacore::Double
parameters () const =0
 
virtual void setErrors (const casacore::Vector< casacore::Double > &newErrors)=0
 
virtual casacore::Vector
< casacore::Double
errors () const =0
 
virtual casacore::Bool fromRecord (casacore::String &errorMessage, const casacore::RecordInterface &record)=0
 These functions convert between a record and a SpectralModel. More...
 
virtual casacore::Bool toRecord (casacore::String &errorMessage, casacore::RecordInterface &record) const =0
 Convert the class to an Record representation. More...
 
virtual casacore::Bool convertUnit (casacore::String &errorMessage, const casacore::RecordInterface &record)=0
 Convert the parameters of the spectral model to the specified units. More...
 
virtual casacore::Bool ok () const
 casacore::Function which checks the internal data of this class for correct dimensionality and consistant values. More...
 
- Public Member Functions inherited from casacore::RecordTransformable
virtual ~RecordTransformable ()
 The destructor must be virtual so that the destructor of derived classes is actually used. More...
 
virtual Bool fromString (String &error, const String &inString)
 Initialise the class from a String representation. More...
 

Static Public Member Functions

static ComponentType::SpectralShape getType (casacore::String &errorMessage, const casacore::RecordInterface &record)
 Return the spectral shape that the supplied record represents. More...
 

Protected Member Functions

 SpectralModel ()
 The constructors and assignment operator are protected as only derived classes should use them. More...
 
 SpectralModel (const casacore::MFrequency &refFreq, const casacore::Unit &=casacore::Unit("GHz"))
 
 SpectralModel (const SpectralModel &other)
 
SpectralModeloperator= (const SpectralModel &other)
 
casacore::Double refFreqInFrame (const casacore::MFrequency::Ref &frame) const
 Return the value refFrequency in the requested frame... More...
 

Static Protected Member Functions

static casacore::Bool badError (const casacore::Quantum< casacore::Double > &quantum)
 returns true if the quantum is not a non-negative quantity with units dimensionally identical to the Hz More...
 

Private Attributes

casacore::MFrequency itsRefFreq
 
casacore::Unit itsFreqUnit
 
casacore::Quantity itsFreqErr
 

Detailed Description

Base class for spectral models.

Intended use:

Public interface

Review Status

Date Reviewed:
yyyy/mm/dd
Test programs:
tConstantSpectrum
Demo programs:
dSpectralModel

Prerequisite

Synopsis

This abstract base class defines the interface for different classes which model the spectrum of a component. The most fundamental derived class is the ConstantSpectrum class but the SpectralIndex class is also available. These classes model the spectrum of emission from the sky.

Classes derived from the ComponentShape class are used to model the shape and the Flux class is used to model the flux. The SkyComponent class incorporates these three characteristics (flux, shape & spectrum) and the ComponentList class handles groups of SkyComponent objects.

This class parameterises spectral models with two quantities.

A reference frequency.
This is specified using an MFrequency object and defines a frequency where the model is interesting. See the description of derived classes for the specific interpretation of the reference frequency.
A casacore::Vector of parameters.
This contains other parameters that the are defined differently for different spectral models. The length of the vector may vary for different spectral models.

The basic operation of classes using this interface is to model the flux as a function of frequency. Classes derived from this one do not know what the flux is at the reference frequency. Instead the sample functions return factors that are used to scale the flux and calculate the amount of flux at a specified frequency.

Any allowed frequency reference frame can be used. However the reference frame must be adequately specified in order to allow conversions to other reference frames. For example if the reference frame code for the frequency is casacore::MFrequency::TOPO then the reference frame must also contain the time, position on the earth, and direction of the observation that corresponds to the specified frequency. This way the sample functions can convert the frequency to a value in the LSR reference frame (if you specify the sample frequency in the LSR frame).

Example

Because this is an abstract base class, an actual instance of this class cannot be constructed. However the interface it defines can be used inside a function. This is always recommended as it allows functions which have SpectralModels as arguments to work for any derived class.

In this example the plotSpectrum function prints out the type of spectral model it is working with and the reference frequency of that model. It then uses the model to calculate the proportion of the flux at other frequencies. This example is coded in the dSpectralModel.cc file.

void plotSpectrum(const SpectralModel& modelSpectrum) {
cout << "This is a "
<< ComponentType::name(modelSpectrum.type())
<< " spectrum with a reference frequency of: "
<< setprecision(4) << modelSpectrum.refFrequency().get("GHz") << " ("
<< modelSpectrum.refFrequency().getRefString() << ")"
<< endl;
const casacore::MVFrequency step(casacore::Quantity(100.0, "MHz"));
{
casacore::Quantity obsDec; casacore::MVAngle::read(obsDec, "-63.43.");
casacore::Quantity obsDay; casacore::MVTime::read(obsDay, "1996/11/20/5:20");
}
cout << "Frequency\t scale\n";
for (casacore::uInt i = 0; i < 11; i++) {
cout << setprecision(7) << sampleFreq.get("GHz")
<< "\t\t " << modelSpectrum.sample(casacore::MFrequency(sampleFreq, obsRef))
<< endl;
sampleFreq += step;
}
}

Motivation

The SpectralModel base class was seperated from the ComponentShape base class so that mixing components with different spatial and spectral shapes did not result in a combinatorial explosion in the number of classes required.

To Do

Definition at line 159 of file SpectralModel.h.

Constructor & Destructor Documentation

virtual casa::SpectralModel::~SpectralModel ( )
virtual

a virtual destructor is needed so that the actual destructor in the derived class will be used.

casa::SpectralModel::SpectralModel ( )
protected

The constructors and assignment operator are protected as only derived classes should use them.

casa::SpectralModel::SpectralModel ( const casacore::MFrequency refFreq,
const casacore::Unit = casacore::Unit("GHz") 
)
protected
casa::SpectralModel::SpectralModel ( const SpectralModel other)
protected

Member Function Documentation

static casacore::Bool casa::SpectralModel::badError ( const casacore::Quantum< casacore::Double > &  quantum)
staticprotected

returns true if the quantum is not a non-negative quantity with units dimensionally identical to the Hz

virtual SpectralModel* casa::SpectralModel::clone ( ) const
pure virtual

Return a pointer to a copy of the derived 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.

Implemented in casa::SpectralIndex, casa::TabularSpectrum, and casa::ConstantSpectrum.

void casa::SpectralModel::convertFrequencyUnit ( const casacore::Unit freqUnit)
virtual casacore::Bool casa::SpectralModel::convertUnit ( casacore::String errorMessage,
const casacore::RecordInterface record 
)
pure virtual

Convert the parameters of the spectral model to the specified units.

The casacore::Record must contain the same fields that the to/from casacore::Record functions have (with the exception of the frequency & type fields). These fields will contain strings (and not Quantums) that specify the new units for these parameters. The new units must have the same dimensions as the existing ones. If there is any problem parsing the record then an error message is appended to the supplied string and the function returns false.

Implemented in casa::SpectralIndex, casa::TabularSpectrum, and casa::ConstantSpectrum.

virtual casacore::Vector<casacore::Double> casa::SpectralModel::errors ( ) const
pure virtual
const casacore::Unit& casa::SpectralModel::frequencyUnit ( ) const

get the frequency unit, and change the default frequency unit to the specified one.

This will only affect the units used in the casacore::Record returned by the toRecord function.

virtual casacore::Bool casa::SpectralModel::fromRecord ( casacore::String errorMessage,
const casacore::RecordInterface record 
)
pure virtual

These functions convert between a record and a SpectralModel.

This way derived classes can interpret fields in the record in a class specific way. They return false if the record is malformed and append an error message to the supplied string giving the reason. These functions define how a spectral model is represented in glish. All records should have 'type' & 'frequency' fields which contain respectively; a string indicating which spectral model is actually used, and a record representation of a frequency measure. The interpretation of all other fields depends on the specific spectral model used.

Implements casacore::RecordTransformable.

Implemented in casa::SpectralIndex, casa::TabularSpectrum, and casa::ConstantSpectrum.

static ComponentType::SpectralShape casa::SpectralModel::getType ( casacore::String errorMessage,
const casacore::RecordInterface record 
)
static

Return the spectral shape that the supplied record represents.

The spectral shape is determined by parsing a 'type' field in the supplied record. Returns ComponentType::UNKNOWN_SPECTRAL_SHAPE if the type field (which contains a string) could not be translated into a known spectral shape. It then appends an appropriate error message to the errorMessage String.

virtual const casacore::String& casa::SpectralModel::ident ( ) const
virtual

Specify the identification of the record (e.g.

'meas', 'quant'). The default implementation returns a empty string.

Reimplemented from casacore::RecordTransformable.

virtual casacore::uInt casa::SpectralModel::nParameters ( ) const
pure virtual

return the number of parameters in this spectral shape and set/get them.

Implemented in casa::SpectralIndex, casa::TabularSpectrum, and casa::ConstantSpectrum.

virtual casacore::Bool casa::SpectralModel::ok ( ) const
virtual

casacore::Function which checks the internal data of this class for correct dimensionality and consistant values.

Returns true if everything is fine otherwise returns false.

Reimplemented in casa::SpectralIndex, casa::TabularSpectrum, and casa::ConstantSpectrum.

SpectralModel& casa::SpectralModel::operator= ( const SpectralModel other)
protected
virtual casacore::Vector<casacore::Double> casa::SpectralModel::parameters ( ) const
pure virtual
casacore::Double casa::SpectralModel::refFreqInFrame ( const casacore::MFrequency::Ref frame) const
protected

Return the value refFrequency in the requested frame...

exception is thrown if convert does not work. No direction or epoch is available..so better ask for a frame that works or better convert to the frame of the refFrequency.

const casacore::MFrequency& casa::SpectralModel::refFrequency ( ) const
const casacore::Quantum<casacore::Double>& casa::SpectralModel::refFrequencyError ( ) const
virtual casacore::Double casa::SpectralModel::sample ( const casacore::MFrequency centerFrequency) const
pure virtual

Return the scaling factor that indicates what proportion of the flux is at the specified frequency.

ie. if the centreFrequency argument is the reference frequency then this function will always return one. At other frequencies it will return a non-negative number.

Implemented in casa::SpectralIndex, casa::TabularSpectrum, and casa::ConstantSpectrum.

virtual void casa::SpectralModel::sample ( casacore::Vector< casacore::Double > &  scale,
const casacore::Vector< casacore::MFrequency::MVType > &  frequencies,
const casacore::MFrequency::Ref refFrame 
) const
pure 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. A default implementation of this function is available that uses the sample function described above. However customised versions of this function will be more efficient as intermediate values only need to be computed once.

Implemented in casa::SpectralIndex, casa::TabularSpectrum, and casa::ConstantSpectrum.

virtual void casa::SpectralModel::sampleStokes ( const casacore::MFrequency centerFrequency,
casacore::Vector< casacore::Double > &  stokesval 
) const
pure virtual

return full casacore::Stokes version especially for models which have different frequency dependence for the casacore::Stokes param (1 or 4 elements) So as allow for fractional pol change and angle change of linear pol w.r.t frequency A a four casacore::Vector of original IQUV should be passed in and it will hold the return values

Implemented in casa::SpectralIndex, casa::TabularSpectrum, and casa::ConstantSpectrum.

virtual void casa::SpectralModel::sampleStokes ( casacore::Vector< casacore::Vector< casacore::Double > > &  stokesval,
const casacore::Vector< casacore::MFrequency::MVType > &  frequencies,
const casacore::MFrequency::Ref refFrame 
) const
pure virtual

So as allow for fractional pol change and angle change of linear pol w.r.t frequency casacore::Vector of four Vectors of original IQUV should be passed in and it will hold the return values Uitimately this math should really go in Flux and FluxRep to where a rotation of linear pol is allowed.

Implemented in casa::SpectralIndex, casa::TabularSpectrum, and casa::ConstantSpectrum.

virtual void casa::SpectralModel::setErrors ( const casacore::Vector< casacore::Double > &  newErrors)
pure virtual
virtual void casa::SpectralModel::setParameters ( const casacore::Vector< casacore::Double > &  newParms)
pure virtual
virtual void casa::SpectralModel::setRefFrequency ( const casacore::MFrequency newRefFreq)
virtual

set/get the reference frequency

Reimplemented in casa::TabularSpectrum.

void casa::SpectralModel::setRefFrequencyError ( const casacore::Quantum< casacore::Double > &  newRefFreqErr)

set/get the error in the reference frequency.

Values must be positive angular quantities otherwise an casacore::AipsError exception is thrown. The errors are usually interpreted as the 1-sigma bounds in latitude/longitude and implicitly assume a Gaussian distribution. They must have units with the same dimensions as the Hz.

virtual casacore::Bool casa::SpectralModel::toRecord ( casacore::String error,
casacore::RecordInterface outRecord 
) const
pure 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 casacore::RecordTransformable.

Implemented in casa::SpectralIndex, casa::TabularSpectrum, and casa::ConstantSpectrum.

virtual ComponentType::SpectralShape casa::SpectralModel::type ( ) const
pure virtual

return the actual spectral type.

The ident function returns it as a String.

Implemented in casa::SpectralIndex, casa::TabularSpectrum, and casa::ConstantSpectrum.

Member Data Documentation

casacore::Quantity casa::SpectralModel::itsFreqErr
private

Definition at line 312 of file SpectralModel.h.

casacore::Unit casa::SpectralModel::itsFreqUnit
private

Definition at line 311 of file SpectralModel.h.

casacore::MFrequency casa::SpectralModel::itsRefFreq
private

Definition at line 308 of file SpectralModel.h.


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