Gyoto::Spectrometer::Uniform Class Reference

Uniformly spaced spectrometers. More...

#include <GyotoUniformSpectrometer.h>

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

List of all members.

Public Types

typedef Gyoto::SmartPointer
< Gyoto::SmartPointee
Subcontractor_t (Gyoto::FactoryMessenger *, std::vector< std::string > const &)
 A subcontractor builds an object upon order from the Factory.

Public Member Functions

virtual Property const * getProperties () const
 Get list of properties.
 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 kindid (kind_t)
 Set Generic::kindid_.
void kind (std::string const &name)
 Set Generic::kind_ from a std::string.
std::string kind () const
void nSamples (size_t n)
 Set Generic::nsamples_.
void band (std::vector< double > const &nu)
void band (std::vector< double > const &nu, std::string const &unit)
std::vector< double > band () const
std::vector< double > band (std::string const &unit) const
void band (double nu[2])
 Set Uniform::band_.
void band (double nu[2], std::string const &unit, std::string const &kind)
 Set the spectral band boundaries in specified unit.
void band (double nu[], std::string const &unit)
double const * getBand () const
 Get Uniform::band_.
void fillProperty (Gyoto::FactoryMessenger *fmp, Property const &p) const
 Output a single Property to XML.
virtual void setParameters (FactoryMessenger *fmp)
 Main loop for parsing Properties from XML description.
virtual kind_t kindid () const
 Get kindid_.
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.
virtual void getChannelBoundaries (double data[], std::string unit)
 Copy Generic::boundaries_, converting to unit.
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.
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 bool isThreadSafe () const
 Whether this class is thread-safe.
void set (Property const &p, Value val)
 Set Value of a Property.
void set (Property const &p, Value val, std::string const &unit)
 Set Value (expressed in unit) of a Property.
void set (std::string const &pname, Value val)
 Set Value of a Property.
void set (std::string const &pname, Value val, std::string const &unit)
 Set Value (expressed in unit) of a Property.
Value get (Property const &p) const
 Get Value of a Property.
Value get (std::string const &pname) const
 Get Value of a Property.
Value get (Property const &p, std::string const &unit) const
 Get Value of a Property, converted to unit.
Value get (std::string const &pname, std::string const &unit) const
 Get Value of a Property, converted to unit.
Property const * property (std::string const pname) const
 Find property by name.
virtual void fillElement (Gyoto::FactoryMessenger *fmp) const
 Fill the XML element for this Object.
virtual int setParameter (std::string name, std::string content, std::string unit)
 Set parameter by name.
virtual void setParameter (Gyoto::Property const &p, std::string const &name, std::string const &content, std::string const &unit)
 Set parameter by Property (and name).
std::string describeProperty (Gyoto::Property const &p) const
 Format desrciption for a property.
void help () const
 Print (to stdout) some help on this class.
virtual void hook (Listener *listener)
 Start listening.
virtual void unhook (Listener *listener)
 Stop listening.

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.
size_t * chanind_
 Indices in boundaries_.
double * midpoints_
 Effective frequency (in Hz) of each spectral channel.
double * widths_
 Width of each channel.

Static Public Attributes

static GYOTO_OBJECT Property const properties []
 Property list.
static kind_t const WaveKind
 "wave"
static kind_t const WaveLogKind
 "wavelog"
static kind_t const FreqKind
 "freq"
static kind_t const FreqLogKind
 "freqlog"

Protected Member Functions

void reset_ ()
 Computes boundaries_, midpoints_ and widths_.
virtual void tellListeners ()
 Call tell() on each hooked Listener.

Protected Attributes

double band_ [2]
 boundaries of the spectro.
kind_t kindid_
 Spectrometer kind ID.
std::string kind_
 The "kind" that is output in the XML entity.
std::vector< std::string > plugins_
 The plug-ins that needs to be loaded to access this instance's class.

Friends

class Gyoto::SmartPointer< Gyoto::Spectrometer::Uniform >
class Gyoto::SmartPointer< Gyoto::Spectrometer::Generic >
class Gyoto::Hook::Listener

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 *, std::vector< std::string > const &) [inherited]

A subcontractor builds an object upon order from the Factory.

Various classes need to provide a subcontractor to be able to instantiate 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::band ( double  nu[2],
std::string const &  unit,
std::string const &  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
void Gyoto::Spectrometer::Uniform::band ( double  nu[2]  ) 

Set Uniform::band_.

Parameters:
nu 2-element vector, in Hz, m, log10(Hz) or log10(m) depending on Generic::kind_
std::string Gyoto::Object::describeProperty ( Gyoto::Property const &  p  )  const [inherited]

Format desrciption for a property.

Returns a string containing the name(s) and type of the property, as well as whether it supports unit.

virtual void Gyoto::Object::fillElement ( Gyoto::FactoryMessenger fmp  )  const [virtual, inherited]

Fill the XML element for this Object.

The base implementation simply calls fillProperty() for each Property defined for the Object.

Derived classes should avoid overriding fillElement(). It may make sense occasionally, e.g. to make sure that the metric is output first.

To customize how a given Property is rendered, it is better to override fillProperty().

If this method is overridden, the implementation should in general call fillElement() on the direct base.

Reimplemented in Gyoto::Astrobj::Complex, Gyoto::Spectrometer::Complex, and Gyoto::Scenery.

void Gyoto::Spectrometer::Uniform::fillProperty ( Gyoto::FactoryMessenger fmp,
Property const &  p 
) const [virtual]

Output a single Property to XML.

The base implementation decides what to do based on the p.type. The format matches how setParameters() an setParameter() would interpret the XML descition.

Overriding this method should be avoided, but makes sense in some cases (for instance Screen::fillProperty() selects a different unit for Distance based on its magnitude, so that stellar sizes are expressed in solar radii while smaller sizes can be expressed in meters and larger sizes in parsecs).

Overriding implementation should fall-back on calling the implementation in the direct parent class:

 class A: public Object {};
 class B: public A { 
  using B::setParameter;
  virtual void fillProperty(Gyoto::FactoryMessenger *fmp,
                        Property const &p) const ;
 };
 void B::fillProperty(Gyoto::FactoryMessenger *fmp,
                        Property const &p) const {
   if (name=="Duff") fmp->doSomething();
   else A::fillProperty(fmp, p);
 }

Reimplemented from Gyoto::Object.

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

Copy Generic::boundaries_, converting to unit.

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

Copy Generic::midpoints_, converting to unit.

Parameters:
data an array of Generic::nsamples_ doubles to fill with result
unit a string
virtual Property const* Gyoto::Spectrometer::Uniform::getProperties (  )  const [virtual]

Get list of properties.

This method is declared automatically by the GYOTO_OBJECT macro and defined automatically by the GYOTO_PROPERTY_END macro.

Reimplemented from Gyoto::Spectrometer::Generic.

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

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:
data an array of Generic::nboundaries_ doubles to fill with result
unit a string
void Gyoto::Object::help (  )  const [inherited]

Print (to stdout) some help on this class.

Describe all properties that this instance supports.

virtual void Gyoto::Hook::Teller::hook ( Listener listener  )  [virtual, inherited]

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:
listener pointer to the new listener
virtual bool Gyoto::Object::isThreadSafe (  )  const [virtual, inherited]

Whether this class is thread-safe.

Return True if this object is thread-safe, i.e. if an instance and its clone can be used in parallel threads (in the context of Scenery::raytrace()). Known objects which are not thread-safe include Lorene metrics and everything from the Python plug-in.

The default implementation considers that the class itself is thread safe and recurses into the declared properties to check whether they are safe too. Classes that abide to the Object/Property paradigm and are themselves thread-safe have nothing special to do.

Objects that clone children in their copy constructor that are not declared as properties must take these children into account.

Classes that are never thread-safe must declare it. It acn be easily done using GYOTO_OBJECT_THREAD_SAFETY in the class declaration and GYOTO_PROPERTY_THREAD_UNSAFE in the class definition.

void Gyoto::Spectrometer::Uniform::kind ( std::string const &  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:
name std::string, one of "wave", "wavelog", "freq" or "freqlog"
virtual kind_t Gyoto::Spectrometer::Generic::kindid (  )  const [virtual, inherited]

Get kindid_.

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

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

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

void Gyoto::Spectrometer::Uniform::kindid ( kind_t   )  [virtual]

Set Generic::kindid_.

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

Always set to the address 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 Kindid;
 };
 kind_t MyKind::Kind = "MyKind";
 ...
 SmartPointer<MyKind> sp();
 sp->kindid(MyKind::Kindid)

Reimplemented from Gyoto::Spectrometer::Generic.

Property const* Gyoto::Object::property ( std::string const   pname  )  const [inherited]

Find property by name.

Look into the Property list for a Property whose name (or name_false, for a boolean Property) is pname. Return a const pointer to the first such property found, or NULL if none is found.

virtual void Gyoto::Object::setParameter ( Gyoto::Property const &  p,
std::string const &  name,
std::string const &  content,
std::string const &  unit 
) [virtual, inherited]

Set parameter by Property (and name).

This function is used when parsing an XML description, if Property (p) of this name is found (i.e. either p.name or p.name_false is equal to name). Implementation should fall-back on calling the direct's parent implementation:

 class A: public Object {};
 class B: public A { 
  using B::setParameter;
  virtual void setParameter(Gyoto::Property const &p,
                            std::string name,
                                std::string content,
                                std::string unit);
 };
 void B::setParameter(Gyoto::Property const &p,
                          std::string name,
                          std::string content,
                          std::string unit) {
   if (name=="Duff") doSomething(content, unit);
   else A::setParameter(p, name, content, unit);
 }
Parameters:
p Property that matches name (p.name == name or p.name_false == name)
name XML name of the parameter (XML entity)
content string representation of the value
unit string representation of the unit

Reimplemented in Gyoto::Astrobj::PolishDoughnut.

virtual int Gyoto::Object::setParameter ( std::string  name,
std::string  content,
std::string  unit 
) [virtual, inherited]

Set parameter by name.

This function is used when parsing an XML description, if no Property of this name is found. Overriding implementation should fall-back on calling the direct's parent implementation:

 class A: public Object {};
 class B: public A { 
  using B::setParameter;
  virtual int setParameter(std::string name,
                            std::string content,
                            std::string unit);
 };
 int B::setParameter(std::string name,
                            std::string content,
                            std::string unit) {
   if (name=="Duff") doSomething(content, unit);
   else return A::setParameter(name, content, unit);
   return 0;  // name was known
 }
Parameters:
name XML name of the parameter (XML entity). This may have a path component, e.g. "Astrobj::Radius", in which case a property named "Astrobj" will be sought in the current object, and setParameter will be called recusrively on this Astrobj with Radius as name.
content string representation of the value
unit string representation of the unit
Returns:
0 if this parameter is known, 1 if it is not.

Reimplemented in Gyoto::Astrobj::EquatorialHotSpot, Gyoto::Metric::KerrKS, Gyoto::Metric::RotStar3_1, and Gyoto::Astrobj::Star.

virtual void Gyoto::Spectrometer::Uniform::setParameters ( FactoryMessenger fmp  )  [virtual]

Main loop for parsing Properties from XML description.

This function queries the FactoryMessenger for elements to parse, and tries to matche each element to a Property to set it accordingly.

Any class that tries to be buildable from XML must supply a subcontractor (for base classes such as Metric, Astrobj, Spectrum and Spectrometer, it is done as a template that must be specialized for each class).

This subcontractor typically looks somewhat like this:

SmartPointer<Metric::Generic>
Gyoto::Metric::MyKind::Subcontractor(FactoryMessenger* fmp) {
  SmartPointer<MyKind> gg = new MyKind();
  gg -> setParameters(fmp);
  return gg;
}

Although this is discouraged, it is possible to override the following functions to customize how XML entities are parsed:

  • setParameters() if low-level access to the FactoryMessenger is required;
  • setParameter(std::string name, std::string content, std::string unit) to interpret an entity that does not match a Property (e.g. alternative name);
  • setParameter(Gyoto::Property const &p, std::string const &name, std::string const &content, std::string const &unit) to change how a Property is interpreted.

Reimplemented from Gyoto::Object.

virtual void Gyoto::Hook::Teller::tellListeners (  )  [protected, virtual, inherited]

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  )  [virtual, inherited]

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:
listener pointer 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).

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.

Indices in boundaries_.

Array of size 2*nsamples_

"freq"

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

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

"freqlog"

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

 if (spectro->kind() == Uniform::FreqLogKind) ... ;
std::string Gyoto::Object::kind_ [protected, inherited]

The "kind" that is output in the XML entity.

E.g. for an Astrobj, fillElement() will ensure

   <Astrobj kind="kind_" ...>...</Astrobj>

is written.

Spectrometer kind ID.

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

Effective frequency (in Hz) of each spectral channel.

Array of size nsamples_

std::vector<std::string> Gyoto::Object::plugins_ [protected, inherited]

The plug-ins that needs to be loaded to access this instance's class.

E.g. for an Astrobj, fillElement() will ensure

   <Astrobj ... plugin="plugins_">...</Astrobj>

is written.

GYOTO_OBJECT Property const Gyoto::Spectrometer::Uniform::properties[] [static]

Property list.

This static member is declared automatically by the GYOTO_OBJECT macro and defined automatically by the GYOTO_PROPERTY_START, GYOTO_PROPERTY_END and GYOTO_PROPERTY_* macros.

The list of properties is implemented as a static array of Property instances. The last item in a Property of type Property::empty_t, which evaluates to false, so the list can be considered to be NULL-terminated (it is actually rather false-terminated). This empty_t last item can be a link to another Property list: for instance, the last item in Gyoto::Astrobj::Standard::properties is a link to Gyoto::Astrobj::Generic::properties.

Reimplemented from Gyoto::Spectrometer::Generic.

"wave"

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

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

"wave"

"wavelog"

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

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

Width of each channel.

Array of size nsamples_ (in Hz)


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

Generated on 6 May 2017 for Gyoto by  doxygen 1.6.1