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

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

#include <SpectralIndex.h>

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

Public Member Functions

 SpectralIndex ()
 The default SpectralIndex has a reference frequency of 1 GHz in the LSR frame and a spectral index of zero. More...
 
 SpectralIndex (const casacore::MFrequency &refFreq, casacore::Double exponent=0.0)
 Construct a SpectralIndex with specified reference frequency and exponent. More...
 
 SpectralIndex (const SpectralIndex &other)
 The copy constructor uses copy semantics. More...
 
virtual ~SpectralIndex ()
 The destructor does nothing special. More...
 
SpectralIndexoperator= (const SpectralIndex &other)
 The assignment operator uses copy semantics. More...
 
virtual
ComponentType::SpectralShape 
type () const
 return the actual spectral type ie., ComponentType::SPECTRAL_INDEX More...
 
const casacore::Doubleindex () const
 set/get the spectral index. More...
 
void setIndex (const casacore::Double &newIndex)
 
const casacore::Vector
< casacore::Double > & 
stokesIndex () const
 
void setStokesIndex (const casacore::Vector< casacore::Double > &newIndex)
 
virtual casacore::Double sample (const casacore::MFrequency &centerFrequency) const
 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 > &iquv) const
 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
 Same as the previous function except that many frequencies can be sampled at once. More...
 
virtual void sampleStokes (casacore::Vector< casacore::Vector< casacore::Double > > &scale, const casacore::Vector< casacore::MFrequency::MVType > &frequencies, const casacore::MFrequency::Ref &refFrame) const
 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
 Return a pointer to a copy of this object upcast to a SpectralModel object. More...
 
virtual casacore::uInt nParameters () const
 return the number of parameters. More...
 
virtual void setParameters (const casacore::Vector< casacore::Double > &newSpectralParms)
 
virtual casacore::Vector
< casacore::Double
parameters () const
 
virtual void setErrors (const casacore::Vector< casacore::Double > &newSpectralErrs)
 
virtual casacore::Vector
< casacore::Double
errors () const
 
virtual casacore::Bool fromRecord (casacore::String &errorMessage, const casacore::RecordInterface &record)
 These functions convert between a casacore::Record and a SpectralIndex. More...
 
virtual casacore::Bool toRecord (casacore::String &errorMessage, casacore::RecordInterface &record) const
 Convert the class to an Record representation. More...
 
virtual casacore::Bool convertUnit (casacore::String &errorMessage, const casacore::RecordInterface &record)
 Convert the parameters of the spectral index object to the specified units. More...
 
virtual casacore::Bool ok () const
 casacore::Function which checks the internal data of this class for consistant values. More...
 
- Public Member Functions inherited from casa::SpectralModel
virtual ~SpectralModel ()
 a virtual destructor is needed so that the actual destructor in the derived class will be used. 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
 
- 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...
 

Private Attributes

casacore::Double itsIndex
 
casacore::Vector
< casacore::Double
itsStokesIndex
 
casacore::Double itsError
 

Additional Inherited Members

- Static Public Member Functions inherited from casa::SpectralModel
static ComponentType::SpectralShape getType (casacore::String &errorMessage, const casacore::RecordInterface &record)
 Return the spectral shape that the supplied record represents. More...
 
- Protected Member Functions inherited from casa::SpectralModel
 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 inherited from casa::SpectralModel
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...
 

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 a spectral index.

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

A spectral index is the exponent in a power law model for the variation flux with frequency. It is mathematically is defined as:

(nu / nu_0)^alpha

Where:

nu_0
is the reference frequency
alpha
is the spectral index
nu
is the user specified frequency

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.

<Dec-2013> Have added a full stokes spectral variation... This is done via setting setStokesIndex. If setIndex is used then only the first element of 4 parameters is set The 4 elements are 0) alpha for stokes I..such that 1) alpha for linear pol fraction i.e make sure that Q and U is such that sqrt(Q_0^2+U_0^2)/I_0 * (nu/nu_0)^alpha(1)) is obeyed. 2) Rot measure (RM=alpha(2)) value to rotate linear pol by angle RM*(lambda^2- lambda_0^2) 3) alpha for circular pol fraction i.e to make V such that V/I=V_0/I_0 *(nu/nu_0)^alpha(3) </Dec-2013> 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 = 'spectral index',
frequency = [type = 'frequency',
refer = 'lsr',
m0 = [value = 1, unit = 'GHz']
],
index = 0.7
]

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

<Dec-2013> The example below was NEVER implemented..\.
Could well have written the following and call it documentation:
Sous un arbre, vos laitues naissent-elles ?
Si vos laitues naissent, vos navets aussi naissent !
Leaving it as is for archeological purposes
</Dec-2013>
SpectralIndex siModel;
siModel.setRefFrequency(casacore::MFrequency(casacore::Quantity(1.0, "GHz")));
siModel.setIndex(1.0, casacore::Stokes::I);
siModel.setIndex(0.5, casacore::Stokes::Q);
siModel.setIndex(0.5, casacore::Stokes::U);
siModel.setIndex(-1.0, casacore::Stokes::V);
const Flux<casacore::Double> LBandFlux(1.0, 1.0, 1.0, 1.0);
const casacore::MVFrequency step(casacore::Quantity(100.0, "MHz"));
casacore::MVFrequency sampleFreq = siModel.refFrequency().getValue();
Flux<casacore::Double> sampleFlux;
cout << "Frequency\t I-Flux\t Q-Flux\t U-Flux\t V-Flux\n";
for (casacore::uInt i = 0; i < 11; i++) {
sampleFlux = LBandFlux.copy();
sampleFlux.convertPol(ComponentType::LINEAR);
sampleFlux.convertUnit(casacore::Unit("WU"));
siModel.sample(sampleFlux,
casacore::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;
}
<Dec-2013>
Now for an example
SpectralIndex siModel;
siModel.setIndex(1.0);
cout << "scale value at 1 GHz for setIndex 1.0 " << siModel.sample(f1) << endl;
indices(0)=1.0; indices(1)=0.2; indices(2)=0.0005; indices(3)=0.1;
siModel.setStokesIndex(indices);
iquv(0)=10.0; iquv(1)=0.2; iquv(2)=0.4; iquv(3)=0.1;
cerr << "iquv in " << iquv << " indices " << indices << endl;
siModel.sampleStokes(f1, iquv);
cerr << "scale value of I at 1.0 GHz " << siModel.sample(f1) << " iquv out " << iquv << endl;
siModel.sampleStokes(f2, iquv);
cerr << "scale value of I at 2.0 GHz " << siModel.sample(f2) << " iquv out " << iquv << endl;
</Dec-2013>

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 194 of file SpectralIndex.h.

Constructor & Destructor Documentation

casa::SpectralIndex::SpectralIndex ( )

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::SpectralIndex::SpectralIndex ( const casacore::MFrequency refFreq,
casacore::Double  exponent = 0.0 
)

Construct a SpectralIndex with specified reference frequency and exponent.

casa::SpectralIndex::SpectralIndex ( const SpectralIndex other)

The copy constructor uses copy semantics.

virtual casa::SpectralIndex::~SpectralIndex ( )
virtual

The destructor does nothing special.

Member Function Documentation

virtual SpectralModel* casa::SpectralIndex::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 casacore::Bool casa::SpectralIndex::convertUnit ( casacore::String errorMessage,
const casacore::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 casacore::Vector<casacore::Double> casa::SpectralIndex::errors ( ) const
virtual

Implements casa::SpectralModel.

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

These functions convert between a casacore::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.

const casacore::Double& casa::SpectralIndex::index ( ) const

set/get the spectral index.

virtual casacore::uInt casa::SpectralIndex::nParameters ( ) const
virtual

return the number of parameters.

There is one parameter or 4 for this spectral model, namely the spectral index for I or I,Q,U,V. So you supply a unit length vector or one 4 element long when using these functions. Otherwise an exception (casacore::AipsError) may be thrown.

Implements casa::SpectralModel.

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

casacore::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.

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

The assignment operator uses copy semantics.

virtual casacore::Vector<casacore::Double> casa::SpectralIndex::parameters ( ) const
virtual

Implements casa::SpectralModel.

virtual casacore::Double casa::SpectralIndex::sample ( const casacore::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::SpectralIndex::sample ( casacore::Vector< casacore::Double > &  scale,
const casacore::Vector< casacore::MFrequency::MVType > &  frequencies,
const casacore::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 void casa::SpectralIndex::sampleStokes ( const casacore::MFrequency centerFrequency,
casacore::Vector< casacore::Double > &  stokesval 
) const
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

Implements casa::SpectralModel.

virtual void casa::SpectralIndex::sampleStokes ( casacore::Vector< casacore::Vector< casacore::Double > > &  stokesval,
const casacore::Vector< casacore::MFrequency::MVType > &  frequencies,
const casacore::MFrequency::Ref refFrame 
) const
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.

Implements casa::SpectralModel.

virtual void casa::SpectralIndex::setErrors ( const casacore::Vector< casacore::Double > &  newSpectralErrs)
virtual

Implements casa::SpectralModel.

void casa::SpectralIndex::setIndex ( const casacore::Double newIndex)
virtual void casa::SpectralIndex::setParameters ( const casacore::Vector< casacore::Double > &  newSpectralParms)
virtual

Implements casa::SpectralModel.

void casa::SpectralIndex::setStokesIndex ( const casacore::Vector< casacore::Double > &  newIndex)
const casacore::Vector<casacore::Double>& casa::SpectralIndex::stokesIndex ( ) const
virtual casacore::Bool casa::SpectralIndex::toRecord ( casacore::String error,
casacore::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.

virtual ComponentType::SpectralShape casa::SpectralIndex::type ( ) const
virtual

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

Implements casa::SpectralModel.

Member Data Documentation

casacore::Double casa::SpectralIndex::itsError
private

Definition at line 287 of file SpectralIndex.h.

casacore::Double casa::SpectralIndex::itsIndex
private

Definition at line 285 of file SpectralIndex.h.

casacore::Vector<casacore::Double> casa::SpectralIndex::itsStokesIndex
private

Definition at line 286 of file SpectralIndex.h.


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