casa::TabularSpectrum Class Reference

Models the spectral variation with a spectral index. More...

#include <TabularSpectrum.h>

Inheritance diagram for casa::TabularSpectrum:
casa::SpectralModel

List of all members.

Public Member Functions

 TabularSpectrum ()
 The default SpectralIndex has a reference frequency of 1 GHz in the LSR frame and a spectral index of zero.
 TabularSpectrum (const MFrequency &refFreq, const Vector< MFrequency::MVType > &freq, const Vector< Flux< Double > > &flux, const MFrequency::Ref &refFrame)
 Construct a Tabular values with I and f specified exponent.
 TabularSpectrum (const TabularSpectrum &other)
 The copy constructor uses copy semantics.
virtual ~TabularSpectrum ()
 The destructor does nothing special.
TabularSpectrumoperator= (const TabularSpectrum &other)
 The assignment operator uses copy semantics.
virtual
ComponentType::SpectralShape 
type () const
 return the actual spectral type ie., ComponentType::TABULAR_SPECTRUM
virtual void setRefFrequency (const MFrequency &newRefFreq)
 set/get the reference frequency
void values (Vector< MFrequency::MVType > &freq, Vector< Flux< Double > > &flux) const
 set/get the Tabular values
void setValues (const Vector< MFrequency::MVType > &frequencies, const Vector< Flux< Double > > &flux, const MFrequency::Ref &refFrame)
virtual Double sample (const MFrequency &centerFrequency) const
 Return the scaling factor that indicates what proportion of the flux is at the specified frequency.
virtual void sampleStokes (const MFrequency &centerFrequency, Vector< Double > &iquv) const
 return full Stokes version especially for models which have different frequency dependence for the 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 Vector of original IQUV should be passed in and it will hold the return values
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 void sampleStokes (Vector< Vector< Double > > &iquv, const Vector< MFrequency::MVType > &frequencies, const MFrequency::Ref &refFrame) const
 So as allow for fractional pol change and angle change of linear pol w.r.t frequency 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.
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< Double > parameters () const
virtual void setErrors (const Vector< Double > &newSpectralErrs)
virtual Vector< Double > errors () const
virtual Bool fromRecord (String &errorMessage, const RecordInterface &record)
 These functions convert between a Record and a SpectralIndex.
virtual Bool toRecord (String &errorMessage, RecordInterface &record) const
virtual Bool convertUnit (String &errorMessage, const RecordInterface &record)
 Convert the parameters of the spectral index object to the specified units.
virtual Bool ok () const
 Function which checks the internal data of this class for consistant values.

Private Attributes

MFrequency::Ref freqRef_p
Vector< Double > tabFreqVal_p
Vector< Flux< Double > > flux_p
Vector< Double > ival_p
Vector< Double > qval_p
Vector< Double > uval_p
Vector< Double > vval_p
Vector< Double > refVal_p
Double referenceFreq_p
Double maxFreq_p
Double minFreq_p

Detailed Description

Models the spectral variation with a spectral index.

Intended use:

Public interface

Review Status

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

Prerequisite

Synopsis

This class models the spectral variation of a component with measured values at given frequencies. The values are interpolated in betweenm

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.

As with all classes derived from SpectralModel the basic operation of this class is to model the flux as a function of frequency. This class does 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.

Besides the reference frequency this class has one parameter; the spectral index. This parameter can be set & queried using the general purpose parameters functions or the class specific index functions.

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

 c = {'type' : 'tabular',
 'frequency' : {'type' : 'frequency',
 refer : 'lsr',
 m0 :{'value' : [1,1.1, 1.2, 1.3, 1.4], 'unit' : 'GHz'}
 },

 'flux' : {'value' : [1.0,1.1, 1.2, 1.3, 1.4], 'unit' : 'Jy'}
 }

The frequency field contains a record representation of a vector 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. The index field contains the spectral index.

Example

These examples are coded in the tSpectralModel.h file.

Example 1:

In this example a SpectralIndex object is created and used to calculate the flux at a number of frequencies.

 SpectralIndex siModel;
 siModel.setRefFrequency(MFrequency(Quantity(1.0, "GHz")));
 siModel.setIndex(1.0, Stokes::I);  
 siModel.setIndex(0.5, Stokes::Q);  
 siModel.setIndex(0.5, Stokes::U);  
 siModel.setIndex(-1.0, Stokes::V);
 const Flux<Double> LBandFlux(1.0, 1.0, 1.0, 1.0);
 const MVFrequency step(Quantity(100.0, "MHz"));
 MVFrequency sampleFreq = siModel.refFrequency().getValue();
 Flux<Double> sampleFlux;
 cout << "Frequency\t I-Flux\t Q-Flux\t U-Flux\t V-Flux\n";
 for (uInt i = 0; i < 11; i++) {
 sampleFlux = LBandFlux.copy();
 sampleFlux.convertPol(ComponentType::LINEAR);
 sampleFlux.convertUnit(Unit("WU"));
 siModel.sample(sampleFlux,
 MFrequency(sampleFreq, siModel.refFrequency().getRef()));
 cout << setprecision(3) << sampleFreq.get("GHz")
 << "\t\t " << sampleFlux.value(0u).re
 << "\t " << sampleFlux.value(1u).re
 << "\t " << sampleFlux.value(2u).re
 << "\t " << sampleFlux.value(3u).re
 << " " << sampleFlux.unit().getName() << endl;
 sampleFreq += step;
 }

Motivation

A Spectral Index frequency variation is the most widely used model in radio astronomy. In particular the NFRA package 'newstar' uses it extensively.

To Do

Definition at line 147 of file TabularSpectrum.h.


Constructor & Destructor Documentation

casa::TabularSpectrum::TabularSpectrum (  ) 

The default SpectralIndex has a reference frequency of 1 GHz in the LSR frame and a spectral index of zero.

As such it is no different from the ConstantSpectrum class (except slower).

casa::TabularSpectrum::TabularSpectrum ( const MFrequency &  refFreq,
const Vector< MFrequency::MVType > &  freq,
const Vector< Flux< Double > > &  flux,
const MFrequency::Ref &  refFrame 
)

Construct a Tabular values with I and f specified exponent.

casa::TabularSpectrum::TabularSpectrum ( const TabularSpectrum other  ) 

The copy constructor uses copy semantics.

virtual casa::TabularSpectrum::~TabularSpectrum (  )  [virtual]

The destructor does nothing special.


Member Function Documentation

virtual SpectralModel* casa::TabularSpectrum::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::TabularSpectrum::convertUnit ( String &  errorMessage,
const RecordInterface &  record 
) [virtual]

Convert the parameters of the spectral index object to the specified units.

Only one field of the supplied record is used, namely 'index'. This field is optional as the spectral index is a unitless quantity. If the index field is specified it must have the empty string as its value. This function always returns True unless the index field is specified and does not contain an empty string.

Implements casa::SpectralModel.

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

Implements casa::SpectralModel.

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

These functions convert between a Record and a SpectralIndex.

These functions define how a SpectralIndex 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::TabularSpectrum::nParameters (  )  const [virtual]

return the number of parameters.

There is one parameter for this spectral model, namely the spectral index. So you supply a unit length vector when using these functions. Otherwise an exception (AipsError) may be thrown.

Implements casa::SpectralModel.

virtual Bool casa::TabularSpectrum::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.

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

The assignment operator uses copy semantics.

Reimplemented from casa::SpectralModel.

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

Implements casa::SpectralModel.

virtual void casa::TabularSpectrum::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 for improved speed.

Implements casa::SpectralModel.

virtual Double casa::TabularSpectrum::sample ( const MFrequency &  centerFrequency  )  const [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.

Implements casa::SpectralModel.

virtual void casa::TabularSpectrum::sampleStokes ( Vector< Vector< Double > > &  stokesval,
const Vector< MFrequency::MVType > &  frequencies,
const MFrequency::Ref &  refFrame 
) const [virtual]

So as allow for fractional pol change and angle change of linear pol w.r.t frequency 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.

Implements casa::SpectralModel.

virtual void casa::TabularSpectrum::sampleStokes ( const MFrequency &  centerFrequency,
Vector< Double > &  stokesval 
) const [virtual]

return full Stokes version especially for models which have different frequency dependence for the 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 Vector of original IQUV should be passed in and it will hold the return values

Implements casa::SpectralModel.

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

Implements casa::SpectralModel.

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

Implements casa::SpectralModel.

virtual void casa::TabularSpectrum::setRefFrequency ( const MFrequency &  newRefFreq  )  [virtual]

set/get the reference frequency

Reimplemented from casa::SpectralModel.

void casa::TabularSpectrum::setValues ( const Vector< MFrequency::MVType > &  frequencies,
const Vector< Flux< Double > > &  flux,
const MFrequency::Ref &  refFrame 
)
virtual Bool casa::TabularSpectrum::toRecord ( String &  errorMessage,
RecordInterface &  record 
) const [virtual]

Implements casa::SpectralModel.

virtual ComponentType::SpectralShape casa::TabularSpectrum::type (  )  const [virtual]

return the actual spectral type ie., ComponentType::TABULAR_SPECTRUM

Implements casa::SpectralModel.

void casa::TabularSpectrum::values ( Vector< MFrequency::MVType > &  freq,
Vector< Flux< Double > > &  flux 
) const

set/get the Tabular values


Member Data Documentation

Vector<Flux<Double> > casa::TabularSpectrum::flux_p [private]

Definition at line 239 of file TabularSpectrum.h.

MFrequency::Ref casa::TabularSpectrum::freqRef_p [private]

Definition at line 237 of file TabularSpectrum.h.

Vector<Double> casa::TabularSpectrum::ival_p [private]

Definition at line 240 of file TabularSpectrum.h.

Definition at line 243 of file TabularSpectrum.h.

Definition at line 244 of file TabularSpectrum.h.

Vector<Double> casa::TabularSpectrum::qval_p [private]

Definition at line 240 of file TabularSpectrum.h.

Definition at line 242 of file TabularSpectrum.h.

Vector<Double> casa::TabularSpectrum::refVal_p [private]

Definition at line 241 of file TabularSpectrum.h.

Vector<Double> casa::TabularSpectrum::tabFreqVal_p [private]

Definition at line 238 of file TabularSpectrum.h.

Vector<Double> casa::TabularSpectrum::uval_p [private]

Definition at line 240 of file TabularSpectrum.h.

Vector<Double> casa::TabularSpectrum::vval_p [private]

Definition at line 240 of file TabularSpectrum.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1