Canoe
Comprehensive Atmosphere N' Ocean Engine
juno_profile_inversion_target.cpp
Go to the documentation of this file.
1 
9 // C/C++ headers
10 #include <iomanip>
11 #include <iostream>
12 
13 // climath
14 #include <climath/interpolation.h>
15 #include <climath/linalg.h>
16 
17 // athena
18 #include <athena/athena.hpp>
19 #include <athena/mesh/mesh.hpp>
20 
21 // application
22 #include <application/application.hpp>
23 #include <application/exceptions.hpp>
24 
25 // harp
26 #include <harp/radiation.hpp>
27 #include <harp/radiation_band.hpp>
28 
29 // inversion
30 #include "profile_inversion.hpp"
31 
33  int nvalue, int k, int j) const {
34  std::stringstream msg;
35  Application::Logger app("inversioon");
36 
37  app->Log("JunoProfileInversion::CalculateFitTarget");
38  app->Log("model = " + std::to_string(j));
39 
40  if (nvalue != 2 * prad->GetNumBands()) {
41  throw ValueError("CalculateFitTarget", "nvalue", prad->GetNumBands(),
42  nvalue);
43  }
44 
45  // 11. log likelihood
46  std::vector<Real> mus, tbs;
47 
48  for (int b = 0; b < prad->GetNumBands(); ++b) {
49  auto pband = prad->GetBand(b);
50 
51  // emission angles;
52  int ndir = pband->GetNumOutgoingRays();
53  mus.resize(ndir);
54  tbs.resize(ndir);
55 
56  for (int n = 0; n < ndir; ++n) mus[n] = pband->GetCosinePolarAngle(n);
57 
58  // brightness temperatures
59  val[b * 2] = pband->btoa(0, k, j);
60 
61  // limb darkening
62  for (int n = 0; n < ndir; ++n) tbs[n] = pband->btoa(n, k, j);
63 
64  Real tb45 = interp1(cos(45. / 180. * M_PI), tbs.data(), mus.data(), ndir);
65  val[b * 2 + 1] = (tbs[0] - tb45) / tbs[0] * 100.;
66 
67  if (fit_differential_) {
68  // brightness temperatures
69  val[b * 2] -= pband->btoa(0, k, pmy_block_->js - 1);
70 
71  // limb darkening
72  for (int n = 0; n < ndir; ++n)
73  tbs[n] = pband->btoa(n, k, pmy_block_->js - 1);
74 
75  tb45 = interp1(cos(45. / 180. * M_PI), tbs.data(), mus.data(), ndir);
76  val[b * 2 + 1] -= (tbs[0] - tb45) / tbs[0] * 100.;
77  }
78  }
79 
80  // app->Log("foward model results = ", val, nvalue);
81 }
bool fit_differential_
Definition: inversion.hpp:91
MeshBlock const * pmy_block_
pointer to parent MeshBlock
Definition: inversion.hpp:97
void CalculateFitTarget(Radiation const *prad, Real *val, int nvalue, int k, int j) const override
std::shared_ptr< RadiationBand > GetBand(int i) const
Get band by index.
Definition: radiation.hpp:47
size_t GetNumBands() const
Get number of bands.
Definition: radiation.hpp:44
double interp1(double x, double const *data, double const *axis, size_t len)
Definition: interpn.c:61