Gyoto
Public Member Functions | Public Attributes | Static Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
Gyoto::Spectrometer::Uniform Class Reference

Uniformly spaced spectrometers. More...

#include <GyotoUniformSpectrometer.h>

Inheritance diagram for Gyoto::Spectrometer::Uniform:
Gyoto::Spectrometer::Generic Gyoto::SmartPointee Gyoto::Hook::Teller

Public Member Functions

 Uniform ()
 Default constructor.
 
 Uniform (size_t nsamples, double band_min, double band_max, kind_t kind)
 Constructor setting everything.
 
 Uniform (const Uniform &)
 Copy constructor.
 
Genericclone () const
 Cloner.
 
virtual ~Uniform ()
 Destructor.
 
void kind (kind_t)
 Set Generic::kind_. More...
 
void kind (std::string name)
 Set Generic::kind_ from a std::string. More...
 
void nSamples (size_t n)
 Set Generic::nsamples_.
 
void setBand (double nu[2])
 Set Uniform::band_. More...
 
void setBand (double nu[2], std::string unit, std::string kind="")
 Set the spectral band boundaries in specified unit. More...
 
double const * getBand () const
 Get Uniform::band_.
 
void fillElement (FactoryMessenger *fmp) const
 Write out parameters to XML entities. More...
 
virtual void setParameters (FactoryMessenger *fmp)
 Main loop in the (templated) subcontractor. More...
 
virtual int setParameter (std::string name, std::string content, std::string unit)
 Set parameter by name. More...
 
virtual kind_t kind () const
 Get kind_. More...
 
virtual size_t nSamples () const
 Get Generic::nsamples_.
 
virtual size_t getNBoundaries () const
 Get Generic::nboundaries_.
 
virtual double const * getMidpoints () const
 Get Generic::midpoints_.
 
virtual void getMidpoints (double data[], std::string unit)
 Copy Generic::midpoints_, converting to unit. More...
 
virtual void getChannelBoundaries (double data[], std::string unit)
 Copy Generic::boundaries_, converting to unit. More...
 
virtual double const * getChannelBoundaries () const
 Get Generic::boundaries_.
 
virtual size_t const * getChannelIndices () const
 Get Generic::chanind_.
 
virtual double const * getWidths () const
 Get Generic::widths_.
 
virtual void getWidths (double data[], std::string unit)
 Copy Generic::widths_, converting to unit. More...
 
virtual void setParameters (Gyoto::FactoryMessenger *fmp)
 Main loop in Subcontractor_t function. More...
 
virtual void hook (Listener *listener)
 Start listening. More...
 
virtual void unhook (Listener *listener)
 Stop listening. More...
 

Public Attributes

size_t nsamples_
 Number of spectral elements.
 
size_t nboundaries_
 Size of the boundaries_ array.
 
double * boundaries_
 Frequency (in Hz) at the boundaries of the spectral channels. More...
 
size_tchanind_
 Indices in boundaries_. More...
 
double * midpoints_
 Effective frequency (in Hz) of each spectral channel. More...
 
double * widths_
 Width of each channel. More...
 

Static Public Attributes

static kind_t const WaveKind
 "wave" More...
 
static kind_t const WaveLogKind
 "wavelog" More...
 
static kind_t const FreqKind
 "freq" More...
 
static kind_t const FreqLogKind
 "freqlog" More...
 

Protected Types

typedef Gyoto::SmartPointer
< Gyoto::SmartPointee
Subcontractor_t (Gyoto::FactoryMessenger *)
 A subcontractor builds an object upon order from the Factory. More...
 

Protected Member Functions

void reset_ ()
 Computes boundaries_, midpoints_ and widths_.
 
void incRefCount ()
 Increment the reference counter. Warning: Don't mess with the counter.
 
int decRefCount ()
 Decrement the reference counter and return current value. Warning: Don't mess with the counter.
 
int getRefCount ()
 Get the current number of references.
 
virtual void tellListeners ()
 Call tell() on each hooked Listener. More...
 

Protected Attributes

double band_ [2]
 boundaries of the spectro. More...
 
kind_t kind_
 Spectrometer kind name. More...
 

Friends

class Gyoto::SmartPointer< Gyoto::Spectrometer::Uniform >
 

Detailed Description

Uniformly spaced spectrometers.

Spectral channels are contiguous and uniformly spaced in either wavelength, frequency or log10 of either. Gyoto::Spectrometer::Uniform is registered four times in the factory: as kind="wave", "wavelog", "freq" and "freqlog". Example XML entity:

<Spectrometer kind="wave" unit="µm" nsamples=10>
2.0 2.4
</Spectrometer>

The content of the entity yields the band pass expressed in "unit" or in log10(unit).

Member Typedef Documentation

typedef Gyoto::SmartPointer<Gyoto::SmartPointee> Gyoto::SmartPointee::Subcontractor_t(Gyoto::FactoryMessenger *)
inherited

A subcontractor builds an object upon order from the Factory.

Various classes need to provide a subcontractor to be able to instanciate themselves upon order from the Factory. A subcontractor is a function (often a static member function) which accepts a pointer to a FactoryMessenger as unique parameter, communicates with the Factory using this messenger to read an XML description of the object to build, and returns this objet. SmartPointee::Subcontractor_t* is just generic enough a typedef to cast to and from other subcontractor types: Astrobj::Subcontractor_t, Metric::Subcontractor_t, Spectrum::Subcontractor_t. A subcontractor needs to be registered using the relevant Register() function: Astrobj::Register(), Metric::Register(), Spectrum::Register().

Member Function Documentation

void Gyoto::Spectrometer::Uniform::fillElement ( FactoryMessenger *  fmp) const
virtual

Write out parameters to XML entities.

Spectrometers implementations should impement fillElement to save their parameters to XML and call the Spectrometer::fillElement(fmp) for the shared properties.

This is mainly used by the Yorick plug-in to print out any sort of GYOTO objects and to save them to XML files.

Reimplemented from Gyoto::Spectrometer::Generic.

virtual void Gyoto::Spectrometer::Generic::getChannelBoundaries ( double  data[],
std::string  unit 
)
virtualinherited

Copy Generic::boundaries_, converting to unit.

Parameters
dataan array of Generic::nboundaries_ doubles to fill with result
unita string
virtual void Gyoto::Spectrometer::Generic::getMidpoints ( double  data[],
std::string  unit 
)
virtualinherited

Copy Generic::midpoints_, converting to unit.

Parameters
dataan array of Generic::nsamples_ doubles to fill with result
unita string
virtual void Gyoto::Spectrometer::Generic::getWidths ( double  data[],
std::string  unit 
)
virtualinherited

Copy Generic::widths_, converting to unit.

Think carefully before using: widths are often used to convert spectral flux density to flux. If flux density is per Herz, you don't need to convert widths.

Parameters
dataan array of Generic::nboundaries_ doubles to fill with result
unita string
virtual void Gyoto::Hook::Teller::hook ( Listener listener)
virtualinherited

Start listening.

Use from a Hook::Listener object method:

teller->hook(this)

where "this" is a Listener and "teller" is a Teller.

Use unhook() later to stop listening to a given Teller.

Parameters
listenerpointer to the new listener
void Gyoto::Spectrometer::Uniform::kind ( kind_t  )
virtual

Set Generic::kind_.

This should rarely be used as the Generic::kind_ attribute usually is set in the constructor and doesn't change after that.

Always set to the adress of a static variable, not to a temporary. Usually your class should have a static member for that purpose:

class MyKind : public Spectrometer::Generic
{
static kind_t Kind;
};
kind_t MyKind::Kind = "MyKind";
...
SmartPointer<MyKind> sp();
sp->kind(MyKind::Kind)

Reimplemented from Gyoto::Spectrometer::Generic.

void Gyoto::Spectrometer::Uniform::kind ( std::string  name)

Set Generic::kind_ from a std::string.

Generic::kind_ will actually be set to one of Uniform::WaveKind, Uniform::WaveLogKind, Uniform::FreqKind or Uniform::FreqLogKind.

Parameters
namestd::string, one of "wave", "wavelog", "freq" or "freqlog"
virtual kind_t Gyoto::Spectrometer::Generic::kind ( ) const
virtualinherited

Get kind_.

You can check whether the Spectrometer sp is of a given kind MyKind with something like:

if (sp->kind()) == MyKind::Kind;

See Uniform::WaveKind, Uniform::WaveLogKind, Uniform::FreqKind, Uniform::FreqLogKind and Complex::Kind.

void Gyoto::Spectrometer::Uniform::setBand ( double  nu[2])

Set Uniform::band_.

Parameters
nu2-element vector, in Hz, m, log10(Hz) or log10(m) depending on Generic::kind_
void Gyoto::Spectrometer::Uniform::setBand ( double  nu[2],
std::string  unit,
std::string  kind = "" 
)

Set the spectral band boundaries in specified unit.

If kind is not specified, member kind_ is used. Else kind_ is updated.

unit is actually the unit for 10^nu for freqlog and wavelog. Defaults:

  • kind==freq: nu in Hz
  • kind==freqlog: 10^nu in Hz
  • kind==wave: nu in meters
  • kind==wavelog: 10^nu in meters
virtual int Gyoto::Spectrometer::Uniform::setParameter ( std::string  name,
std::string  content,
std::string  unit 
)
virtual

Set parameter by name.

Assume MyKind is a subclass of Spectrometer::Generic which has two members (a string StringMember and a double DoubleMember):

int MyKind::setParameter(std::string name, std::string content, std::string unit)
{
if (name=="StringMember") setStringMember(content);
else if (name=="DoubleMember") setDoubleMemeber(atof(content.c_str()), unit);
else return Generic::setParameter(name, content, unit);
return 0;
}

If MyKind is not a direct subclass of Generic, it should call the corresponding setParameter() implementation instead of Generic::setParameter().

Parameters
nameXML name of the parameter
contentstring representation of the value
unitstring representation of the unit
Returns
0 if this parameter is known, 1 if it is not.

Reimplemented from Gyoto::Spectrometer::Generic.

virtual void Gyoto::Spectrometer::Uniform::setParameters ( FactoryMessenger *  fmp)
virtual

Main loop in the (templated) subcontractor.

In the case of Spectrometer::Complex, the setParameter() API is not sufficient: setParameters() needs acces to the FactoryMessenger to instanciate childs for the SubSpectrometers.

virtual void Gyoto::Spectrometer::Generic::setParameters ( Gyoto::FactoryMessenger *  fmp)
virtualinherited

Main loop in Subcontractor_t function.

The Subcontractor_t function for each Spectrometer kind should look somewhat like this (templated as Gyoto::Spectrometer::Subcontractor<MyKind>):

SmartPointer<Spectrometer::Generic>
{
SmartPointer<MyKind> gg = new MyKind();
gg -> setParameters(fmp);
return gg;
}

Each spectrometer kind should implement setParameter(string name, string content, string unit) to interpret the individual XML elements. setParameters() can be overloaded in case the specific Spectrometer class needs low level access to the FactoryMessenger. See Gyoto::Astrobj::UniformSphere::setParameters().

virtual void Gyoto::Hook::Teller::tellListeners ( )
protectedvirtualinherited

Call tell() on each hooked Listener.

Whenever a Teller mutates, it should warn any Listener hooked to it using tellListeners().

virtual void Gyoto::Hook::Teller::unhook ( Listener listener)
virtualinherited

Stop listening.

Use from a Hook::Listener object method:

teller->unhook(this)

where "this" is a Listener, "teller" is a Teller, and "this" has called teller->hook(this) previously.

Parameters
listenerpointer to the listener

Member Data Documentation

double Gyoto::Spectrometer::Uniform::band_[2]
protected

boundaries of the spectro.

Depending on the kind, band_ is stored in Hz, log10(Hz), m or log10(m).

double* Gyoto::Spectrometer::Generic::boundaries_
inherited

Frequency (in Hz) at the boundaries of the spectral channels.

Array of size nboundaries_

Spectral channel i extends from

to

. Channels may or may not be contiguous or ordered.

size_t* Gyoto::Spectrometer::Generic::chanind_
inherited

Indices in boundaries_.

Array of size 2*nsamples_

kind_t const Gyoto::Spectrometer::Uniform::FreqKind
static

"freq"

Use this static member attribute to check whether a Spectrometer object spectro is of this kind:

if (spectro->kind() == Uniform::FreqKind) ... ;
kind_t const Gyoto::Spectrometer::Uniform::FreqLogKind
static

"freqlog"

Use this static member attribute to check whether a Spectrometer object spectro is of this kind:

if (spectro->kind() == Uniform::FreqLogKind) ... ;
kind_t Gyoto::Spectrometer::Generic::kind_
protectedinherited

Spectrometer kind name.

The content is not copied. kind_ should be set (as a parameter to the Generic() constructor or using kind()) to the adress of a static variable holding the name. This allows checking the kind using pointer comparison rather than string comparison.

double* Gyoto::Spectrometer::Generic::midpoints_
inherited

Effective frequency (in Hz) of each spectral channel.

Array of size nsamples_

kind_t const Gyoto::Spectrometer::Uniform::WaveKind
static

"wave"

Use this static member attribute to check whether a Spectrometer object spectro is of this kind:

if (spectro->kind() == Uniform::WaveKind) ... ;

"wave"

kind_t const Gyoto::Spectrometer::Uniform::WaveLogKind
static

"wavelog"

Use this static member attribute to check whether a Spectrometer object spectro is of this kind:

if (spectro->kind() == Uniform::WaveLogKind) ... ;
double* Gyoto::Spectrometer::Generic::widths_
inherited

Width of each channel.

Array of size nsamples_ (in Hz)


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