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.
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 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).
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 MVFrequency step(Quantity(100.0, "MHz")); MVFrequency sampleFreq(Quantity(1, "GHz")); MeasFrame obsFrame; { Quantity obsRa; MVAngle::read(obsRa, "19:39:"); Quantity obsDec; MVAngle::read(obsDec, "-63.43."); Quantity obsDay; MVTime::read(obsDay, "1996/11/20/5:20"); obsFrame.set(MEpoch(obsDay, MEpoch::UTC), MDirection(obsRa, obsDec, MDirection::J2000)); } MFrequency::Ref obsRef(MFrequency::GEO, obsFrame); cout << "Frequency\t scale\n"; for (uInt i = 0; i < 11; i++) { cout << setprecision(7) << sampleFreq.get("GHz") << "\t\t " << modelSpectrum.sample(MFrequency(sampleFreq, obsRef)) << endl; sampleFreq += step; } }
return the actual spectral type. The ident function returns it as a String.
set/get the reference frequency
get the frequency unit, and change the default frequency unit to the specified one. This will only affect the units used in the Record returned by the toRecord function.
set/get the error in the reference frequency. Values must be positive angular quantities otherwise an 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.
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. 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.
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.
return the number of parameters in this spectral shape and set/get them.
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.
Convert the parameters of the spectral model to the specified units. The Record must contain the same fields that the to/from 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.
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.
Function which checks the internal data of this class for correct dimensionality and consistant values. Returns True if everything is fine otherwise returns False.
returns True if the quantum is not a non-negative quantity with units dimensionally identical to the Hz