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 incorperates 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)^alphaWhere:
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 = '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.
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; }
Construct a SpectralIndex with specified reference frequency and exponent.
The copy constructor uses copy semantics
The destructor does nothing special.
The assignment operator uses copy semantics.
return the actual spectral type ie., ComponentType::SPECTRAL_INDEX
set/get the spectral index.
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.
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.
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.
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.
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.
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.
Function which checks the internal data of this class for consistant values. Returns True if everything is fine otherwise returns False.