22 Photometry::Photometry(
Pvl &pvl) {
29 std::string msg =
"A Photometric model must be specified to do any type of photometry";
35 if (pvl.
hasObject(
"NormalizationModel")) {
36 if (p_phtAmodel != NULL) {
46 if(p_phtAmodel != NULL) {
51 if(p_phtPmodel != NULL) {
56 if(p_phtNmodel != NULL) {
78 double dn,
double &albedo,
double &mult,
82 p_phtNmodel->
CalcNrmAlbedo(pha, inc, ema, dn, albedo, mult, base);
93 double deminc,
double demema,
double dn,
94 double &albedo,
double &mult,
double &base) {
97 p_phtNmodel->
CalcNrmAlbedo(pha, inc, ema, deminc, demema, dn, albedo, mult, base);
127 int iter=0, max_iter=100;
128 const gsl_root_fsolver_type *T;
131 T = gsl_root_fsolver_brent;
132 s = gsl_root_fsolver_alloc (T);
133 gsl_root_fsolver_set(s, Func, x_lo, x_hi);
137 status = gsl_root_fsolver_iterate(s);
138 root = gsl_root_fsolver_x_lower(s);
139 x_lo = gsl_root_fsolver_x_lower(s);
140 x_hi = gsl_root_fsolver_x_upper(s);
141 status = gsl_root_test_interval(x_lo, x_hi, 0, tolerance);
143 }
while (status != GSL_SUCCESS && iter < max_iter);
145 gsl_root_fsolver_free(s);
169 double & x_minimum,
double tolerance) {
171 int iter=0, max_iter=100;
173 const gsl_min_fminimizer_type *T;
174 gsl_min_fminimizer *s;
177 T = gsl_min_fminimizer_brent;
178 s = gsl_min_fminimizer_alloc(T);
184 gsl_min_fminimizer_set(s, Func, x_minimum, x_lower, x_upper);
188 status = gsl_min_fminimizer_iterate(s);
189 x_minimum = gsl_min_fminimizer_x_minimum(s);
190 x_lower = gsl_min_fminimizer_x_lower(s);
191 x_upper = gsl_min_fminimizer_x_upper(s);
193 status = gsl_min_test_interval(x_lower, x_upper, tolerance, 0.0);
194 }
while(status == GSL_CONTINUE && iter < max_iter);
197 gsl_min_fminimizer_free(s);
208 double &fc,
double Func(
double par,
void *params),
void *params) {
209 double eps = 1.0e-21;
210 double Gold = 1.618034;
211 double GrowLimit = 110;
214 fa = Func(xa, params);
215 fb = Func(xb, params);
224 xc = xb + Gold * (xb - xa);
225 fc = Func(xc, params);
229 double tmp1 = (xb - xa) * (fb - fc);
230 double tmp2 = (xb - xc) * (fb - fa);
231 double val = tmp2 - tmp1;
233 if (fabs(val) < eps) {
238 double w = xb - ((xb -xc) * tmp2 - (xb - xa) * tmp1) / denom;
239 double wlim = xb + GrowLimit * (xc - xb);
240 if (iter > maxiter) {
241 IString msg =
"Maximum iterations exceeded in minimum bracketing ";
242 msg +=
"algorithm (minbracket) - root cannot be bracketed";
247 if (((w-xc)*(xb-w)) > 0.0) {
248 fw = Func(w, params);
255 }
else if (fw > fb) {
260 w = xc + Gold * (xc - xb);
261 fw = Func(w, params);
262 }
else if (((w-wlim)*(wlim-xc)) >= 0.0) {
264 fw = Func(w, params);
265 }
else if (((w-wlim)*(xc-w)) > 0.0) {
266 fw = Func(w, params);
270 w = xc + Gold * (xc - xb);
273 fw = Func(w, params);
276 w = xc + Gold * (xc - xb);
277 fw = Func(w, params);
virtual ~Photometry()
Destroy Photometry object.
virtual void SetNormWavelength(double wavelength)
Set the wavelength parameter.
static void minbracket(double &xa, double &xb, double &xc, double &fa, double &fb, double &fc, double Func(double par, void *params), void *params)
Double precision version of bracketing algorithm ported from Python. Solution bracketing for 1-D mini...
virtual void SetPhotomWl(double wl)
Set the wavelength.
static AtmosModel * Create(Pvl &pvl, PhotoModel &pmodel)
Create an AtmosModel object using a PVL specification.
bool hasObject(const QString &name) const
Returns a boolean value based on whether the object exists in the current PvlObject or not...
static int brentsolver(double x_lo, double x_hi, gsl_function *Func, double tolerance, double &root)
GSL's the Brent-Dekker method (Brent's method) combines an interpolation strategy with the bisection ...
#define _FILEINFO_
Macro for the filename and line number.
A type of error that could only have occurred due to a mistake on the user's part (e...
static PhotoModel * Create(Pvl &pvl)
Create a PhotoModel object using a PVL specification.
Container for cube-like labels.
void Compute(double pha, double inc, double ema, double dn, double &albedo, double &mult, double &base)
Calculate the surface brightness.
static NormModel * Create(Pvl &pvl, PhotoModel &pmodel)
Create a NormModel object using a PVL specification.
Adds specific functionality to C++ strings.
Namespace for ISIS/Bullet specific routines.
void CalcNrmAlbedo(double pha, double inc, double ema, double dn, double &albedo, double &mult, double &base)
Calculate the albedo normalization.
static int brentminimizer(double x_lower, double x_upper, gsl_function *Func, double &x_minimum, double tolerance)
Brent's method 1-D minimization routine using GSL's r8Brent minimization Algorithm.