Canoe
Comprehensive Atmosphere N' Ocean Engine
profile_inversion_prior.cpp
Go to the documentation of this file.
1 // C/C++
2 #include <iostream>
3 
4 // canoe
5 #include <configure.hpp>
6 
7 // athena
8 #include <athena/coordinates/coordinates.hpp>
9 #include <athena/hydro/hydro.hpp>
10 #include <athena/mesh/mesh.hpp>
11 
12 // application
13 #include <application/application.hpp>
14 
15 // inversion
16 #include "gaussian_process.hpp"
17 #include "profile_inversion.hpp"
18 
19 Real ProfileInversion::LogPriorProbability(Real **XpSample) const {
20  Application::Logger app("inversion");
21 
22  int nsample = plevel_.size();
23  std::vector<Real> zlev(nsample);
24  std::vector<Real> zstd(nsample);
25 
26  Real P0 = pmy_block_->pcoord->GetReferencePressure();
27  Real H0 = pmy_block_->pcoord->GetPressureScaleHeight();
28 
29  for (int i = 0; i < nsample; ++i) zlev[i] = -H0 * log(plevel_[i] / P0);
30 
31  Real lnprior = 0.;
32  for (auto m : idx_) {
33  for (int i = 0; i < nsample; ++i)
34  zstd[i] = Xstd_[m] * pow(exp(zlev[i] / H0), chi_);
35  lnprior += gp_lnprior(SquaredExponential, XpSample[m], zlev.data(),
36  zstd.data(), nsample, Xlen_[m]);
37  }
38 
39  app->Log("Log prior probability = " + std::to_string(lnprior));
40 
41  return lnprior;
42 }
MeshBlock const * pmy_block_
pointer to parent MeshBlock
Definition: inversion.hpp:97
virtual Real LogPriorProbability(Real **XpSample) const
Real Xstd_[1+NVAPOR]
std::vector< int > idx_
Real Xlen_[1+NVAPOR]
std::vector< Real > plevel_
double gp_lnprior(KernelFunction_t kernel, double const *arr1, double const *x1, double const *s1, int n1, double len)
double SquaredExponential(double x1, double x2, double l, double s1s2=1.)