10#include "Photometry.h"
11#include "PhotoModelFactory.h"
12#include "PhotoModel.h"
13#include "AtmosModelFactory.h"
14#include "AtmosModel.h"
15#include "NormModelFactory.h"
28 Photometry::Photometry(
Pvl &pvl) {
32 if(pvl.hasObject(
"PhotometricModel")) {
35 std::string msg =
"A Photometric model must be specified to do any type of photometry";
38 if(pvl.hasObject(
"AtmosphericModel")) {
41 if (pvl.hasObject(
"NormalizationModel")) {
42 if (p_phtAmodel != NULL) {
52 if(p_phtAmodel != NULL) {
57 if(p_phtPmodel != NULL) {
62 if(p_phtNmodel != NULL) {
84 double dn,
double &albedo,
double &mult,
88 p_phtNmodel->
CalcNrmAlbedo(pha, inc, ema, dn, albedo, mult, base);
99 double deminc,
double demema,
double dn,
100 double &albedo,
double &mult,
double &base) {
103 p_phtNmodel->
CalcNrmAlbedo(pha, inc, ema, deminc, demema, dn, albedo, mult, base);
133 int iter=0, max_iter=100;
134 const gsl_root_fsolver_type *T;
137 T = gsl_root_fsolver_brent;
138 s = gsl_root_fsolver_alloc (T);
139 gsl_root_fsolver_set(s, Func, x_lo, x_hi);
143 status = gsl_root_fsolver_iterate(s);
144 root = gsl_root_fsolver_x_lower(s);
145 x_lo = gsl_root_fsolver_x_lower(s);
146 x_hi = gsl_root_fsolver_x_upper(s);
147 status = gsl_root_test_interval(x_lo, x_hi, 0, tolerance);
149 }
while (status != GSL_SUCCESS && iter < max_iter);
151 gsl_root_fsolver_free(s);
175 double & x_minimum,
double tolerance) {
177 int iter=0, max_iter=100;
179 const gsl_min_fminimizer_type *T;
180 gsl_min_fminimizer *s;
183 T = gsl_min_fminimizer_brent;
184 s = gsl_min_fminimizer_alloc(T);
190 gsl_min_fminimizer_set(s, Func, x_minimum, x_lower, x_upper);
194 status = gsl_min_fminimizer_iterate(s);
195 x_minimum = gsl_min_fminimizer_x_minimum(s);
196 x_lower = gsl_min_fminimizer_x_lower(s);
197 x_upper = gsl_min_fminimizer_x_upper(s);
199 status = gsl_min_test_interval(x_lower, x_upper, tolerance, 0.0);
200 }
while(status == GSL_CONTINUE && iter < max_iter);
203 gsl_min_fminimizer_free(s);
214 double &fc,
double Func(
double par,
void *params),
void *params) {
215 double eps = 1.0e-21;
216 double Gold = 1.618034;
217 double GrowLimit = 110;
220 fa = Func(xa, params);
221 fb = Func(xb, params);
230 xc = xb + Gold * (xb - xa);
231 fc = Func(xc, params);
235 double tmp1 = (xb - xa) * (fb - fc);
236 double tmp2 = (xb - xc) * (fb - fa);
237 double val = tmp2 - tmp1;
239 if (fabs(val) < eps) {
244 double w = xb - ((xb -xc) * tmp2 - (xb - xa) * tmp1) / denom;
245 double wlim = xb + GrowLimit * (xc - xb);
246 if (iter > maxiter) {
247 IString msg =
"Maximum iterations exceeded in minimum bracketing ";
248 msg +=
"algorithm (minbracket) - root cannot be bracketed";
253 if (((w-xc)*(xb-w)) > 0.0) {
254 fw = Func(w, params);
261 }
else if (fw > fb) {
266 w = xc + Gold * (xc - xb);
267 fw = Func(w, params);
268 }
else if (((w-wlim)*(wlim-xc)) >= 0.0) {
270 fw = Func(w, params);
271 }
else if (((w-wlim)*(xc-w)) > 0.0) {
272 fw = Func(w, params);
276 w = xc + Gold * (xc - xb);
279 fw = Func(w, params);
282 w = xc + Gold * (xc - xb);
283 fw = Func(w, params);
static AtmosModel * Create(Pvl &pvl, PhotoModel &pmodel)
Create an AtmosModel object using a PVL specification.
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Adds specific functionality to C++ strings.
static NormModel * Create(Pvl &pvl, PhotoModel &pmodel)
Create a NormModel object using a PVL specification.
void CalcNrmAlbedo(double pha, double inc, double ema, double dn, double &albedo, double &mult, double &base)
Calculate the albedo normalization.
virtual void SetNormWavelength(double wavelength)
Set the wavelength parameter.
static PhotoModel * Create(Pvl &pvl)
Create a PhotoModel object using a PVL specification.
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 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.
void Compute(double pha, double inc, double ema, double dn, double &albedo, double &mult, double &base)
Calculate the surface brightness.
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 ...
virtual ~Photometry()
Destroy Photometry object.
Container for cube-like labels.
This is free and unencumbered software released into the public domain.