12#ifndef __Pulsar_BackendEstimate_H
13#define __Pulsar_BackendEstimate_H
15#include "MEAL/Complex2.h"
28 setMJD () { set =
false; }
30 operator const MJD& ()
const {
return mjd; }
32 const setMJD& operator = (
const MJD& _mjd)
33 { mjd = _mjd; set =
true;
return *
this; }
35 friend bool operator < (
const setMJD& setmjd,
const MJD& mjd)
36 {
return !setmjd.set || setmjd.mjd < mjd; }
38 friend bool operator > (
const setMJD& setmjd,
const MJD& mjd)
39 {
return !setmjd.set || setmjd.mjd > mjd; }
41 friend bool operator < (
const MJD& mjd,
const setMJD& setmjd)
42 {
return !setmjd.set || mjd < setmjd.mjd; }
44 friend bool operator > (
const MJD& mjd,
const setMJD& setmjd)
45 {
return !setmjd.set || mjd > setmjd.mjd; }
47 friend ostream& operator << (ostream& os,
const setMJD& setmjd)
48 {
if (!setmjd.set) os <<
"unset";
else os << setmjd.mjd;
return os; }
81 BackendEstimate () { weight = 0.0; }
98 void set_start_time (
const MJD& epoch) { start_time = epoch; }
99 const MJD& get_start_time ()
const {
return start_time; }
101 void set_end_time (
const MJD& epoch) {
end_time = epoch; }
102 const MJD& get_end_time ()
const {
return end_time; }
105 bool spans (
const MJD& epoch);
110 void add_weight (
float amount) { weight += amount; }
111 float get_weight ()
const {
return weight; }
116#include "MEAL/ChainRule.h"
117#include "MEAL/ProductRule.h"
121 template<
class Type,
class Base>
122 Type* extract (Base* base)
124 Type*
type =
dynamic_cast<Type*
>( base );
128 MEAL::ChainRule<Base>* chain;
129 chain =
dynamic_cast<MEAL::ChainRule<Base>*
>( base );
131 return extract<Type> ( chain->get_model() );
133 MEAL::ProductRule<Base>* product;
134 product =
dynamic_cast<MEAL::ProductRule<Base>*
>( base );
137 for (
unsigned imodel=0; imodel<product->get_nmodel(); imodel++)
139 Type*
type = extract<Type> ( product->get_model(imodel) );
149 void print (std::ostream& os, Base* base,
const std::string& indent =
"")
151 os << indent << (
void*) base <<
" " << base->get_name() << endl;
153 MEAL::ChainRule<Base>* chain;
154 chain =
dynamic_cast<MEAL::ChainRule<Base>*
>( base );
157 Base* model = chain->get_model();
158 print (os, model, indent +
" model ");
160 for (
unsigned i=0; i < model->get_nparam(); i++)
161 if (chain->has_constraint (i))
162 print (os, chain->get_constraint(i),
163 indent +
" by[" + tostring(i) +
"] ");
168 MEAL::ProductRule<Base>* product;
169 product =
dynamic_cast<MEAL::ProductRule<Base>*
>( base );
172 for (
unsigned imodel=0; imodel<product->get_nmodel(); imodel++)
173 print (os, product->get_model(imodel), indent +
" ");
178 for (
unsigned i=0; i<base->get_nparam(); i++)
179 os << indent <<
" " << i <<
" " << base->
get_param (i)
180 <<
" " << base->get_infit(i) << endl;
setMJD start_time
The start of the period spanned by this backend solution.
Definition BackendEstimate.h:66
MJD min_time
The mimimum observation time.
Definition BackendEstimate.h:72
void integrate(const MEAL::Complex2 *xform)
Integrate a calibrator solution.
Definition BackendEstimate.C:72
unsigned path_index
The index of the SignalPath in which this backend is a component.
Definition BackendEstimate.h:84
setMJD end_time
The end of the period spanned by this solution.
Definition BackendEstimate.h:69
Reference::To< MEAL::Mean< MEAL::Complex2 > > mean
The mean of the backend component.
Definition BackendEstimate.h:63
Reference::To< MEAL::Complex2 > backend
The backend component.
Definition BackendEstimate.h:60
virtual void set_response(MEAL::Complex2 *xform)
Set the response that contains the backend.
Definition BackendEstimate.C:20
virtual void update()
Update the transformation with the current estimate, if possible.
Definition BackendEstimate.C:127
unsigned get_path_index() const
Return the path index.
Definition BackendEstimate.h:96
void add_observation_epoch(const MJD &epoch)
update min_time and max_time
Definition BackendEstimate.C:154
MJD max_time
The maximum observation time.
Definition BackendEstimate.h:75
bool spans(const MJD &epoch)
Return true if this estimate spans the epoch.
Definition BackendEstimate.C:143
double get_param(unsigned index) const