#include <TimeGrid.hpp>

Classes | |
| class | Bin |
Public Member Functions | |
| int | binForDistance (double distance) const |
| int | binForTime (double time) const |
| double | left (int k) const |
| int | numBins () const |
| Range | range () const |
| double | right (int k) const |
| double | time (int k) const |
| double | width (int k) const |
| Public Member Functions inherited from SimulationItem | |
| template<class T> | |
| T * | find (bool setup=true) const |
| template<class T> | |
| T * | interface (int levels=-999999, bool setup=true) const |
| virtual string | itemName () const |
| void | setup () |
| string | typeAndName () const |
| Public Member Functions inherited from Item | |
| Item (const Item &)=delete | |
| virtual | ~Item () |
| void | addChild (Item *child) |
| const vector< Item * > & | children () const |
| virtual void | clearItemListProperty (const PropertyDef *property) |
| void | destroyChild (Item *child) |
| virtual bool | getBoolProperty (const PropertyDef *property) const |
| virtual vector< double > | getDoubleListProperty (const PropertyDef *property) const |
| virtual double | getDoubleProperty (const PropertyDef *property) const |
| virtual string | getEnumProperty (const PropertyDef *property) const |
| virtual int | getIntProperty (const PropertyDef *property) const |
| virtual vector< Item * > | getItemListProperty (const PropertyDef *property) const |
| virtual Item * | getItemProperty (const PropertyDef *property) const |
| virtual string | getStringProperty (const PropertyDef *property) const |
| int | getUtilityProperty (string name) const |
| virtual void | insertIntoItemListProperty (const PropertyDef *property, int index, Item *item) |
| Item & | operator= (const Item &)=delete |
| Item * | parent () const |
| virtual void | removeFromItemListProperty (const PropertyDef *property, int index) |
| virtual void | setBoolProperty (const PropertyDef *property, bool value) |
| virtual void | setDoubleListProperty (const PropertyDef *property, vector< double > value) |
| virtual void | setDoubleProperty (const PropertyDef *property, double value) |
| virtual void | setEnumProperty (const PropertyDef *property, string value) |
| virtual void | setIntProperty (const PropertyDef *property, int value) |
| virtual void | setItemProperty (const PropertyDef *property, Item *item) |
| virtual void | setStringProperty (const PropertyDef *property, string value) |
| void | setUtilityProperty (string name, int value) |
| virtual string | type () const |
Protected Member Functions | |
| TimeGrid () | |
| virtual void | getTimeBins (vector< Bin > &bins) const =0 |
| void | setupSelfBefore () override |
| Protected Member Functions inherited from SimulationItem | |
| SimulationItem () | |
| virtual bool | offersInterface (const std::type_info &interfaceTypeInfo) const |
| virtual void | setupSelfAfter () |
| Protected Member Functions inherited from Item | |
| Item () | |
Private Types | |
| using | BaseType |
| using | ItemType |
Private Attributes | |
| vector< Bin > | _bins |
| vector< double > | _borders |
| vector< int > | _indices |
Friends | |
| class | ItemRegistry |
TimeGrid is an abstract class that defines the interface for time grids that can be used, for example, to specify the time bins in a light curve instrument.
A time grid consists of one or more non-overlapping, nonempty time bins in increasing time order. Each bin is defined by its left and right borders and has a characteristic time that falls inside the bin. The left border is considered to be inside the bin; the right border is considered to be outside of the bin. Neighboring bins may have a common border but can also be disconnected. Note that time values can be negative.
Formally, assuming \(N>0\) bins with zero-based indices, we have
\[ t^\mathrm{left}_k \le t^\mathrm{c}_k < t^\mathrm{right}_k, \quad k=0\dots N-1 \]
and if \(N>1\), we additionally have
\[ t^\mathrm{right}_k \le t^\mathrm{left}_{k+1}, \quad k=0\dots N-2. \]
Finally, each bin of course has an associated bin width,
\[t^\mathrm{right}_k - t^\mathrm{left}_k > 0, \quad k=0\dots N-1.\]
The public interface offers functions to obtain the properties of each bin, and to determine the (index of the) bin that contains a given time point.
A TimeGrid subclass is expected to implement the getTimeBins() function, which is invoked by this base class during setup to initialize the time grid.
|
inlineprotected |
| int TimeGrid::binForDistance | ( | double | distance | ) | const |
This function returns the index \(k\) of the time bin that contains the time corresponding to the specified distance \(d\) at the speed of light, i.e. the bin for which \(t^\mathrm{left}_k \le d/c < t^\mathrm{right}_k\). If no times bins match this condition, the function returns -1.
| int TimeGrid::binForTime | ( | double | time | ) | const |
This function returns the index \(k\) of the time bin that contains the specified time \(t\), i.e. for which \(t^\mathrm{left}_k \le t < t^\mathrm{right}_k\). If no times bins match this condition, the function returns -1.
This function must be implemented in a subclass; it is invoked by this base class during setup. The function must place the time bins for this grid in the specified vector, which is guaranteed to be empty upon invocation. The bins must be sorted in increasing order and must otherwise conform to the restrictions listed in the class header.
Implemented in FileTimeGrid, LinTimeGrid, and LogTimeGrid.
| double TimeGrid::left | ( | int | k | ) | const |
This function returns the left border \(t^\mathrm{left}_k\) of the bin corresponding to the index \(k\).
| int TimeGrid::numBins | ( | ) | const |
This function returns the number of bins \(N\) in the grid.
| Range TimeGrid::range | ( | ) | const |
This function returns the range covered by the time grid, running from the left border of the leftmost bin to the right border of the rightmost bin.
| double TimeGrid::right | ( | int | k | ) | const |
This function returns the right border \(t^\mathrm{right}_k\) of the bin corresponding to the index \(k\).
|
overrideprotectedvirtual |
This function invokes the getTimeBins() function, implemented in each subclass, to obtain a list of time bins. After verifying that the bins are properly formed and sorted, the function builds a data structure that allows the bin() function, implemented here, to efficiently locate the bin containing a given time point.
Reimplemented from SimulationItem.
| double TimeGrid::time | ( | int | k | ) | const |
This function returns the characteristic time \(t^\mathrm{c}_k\) for the bin corresponding to the index \(k\).
| double TimeGrid::width | ( | int | k | ) | const |
This function returns width \(t^\mathrm{right}_k - t^\mathrm{left}_k\) of the bin corresponding to the index \(k\).