FV3 Bundle
l95/src/lorenz95/ObsBiasCovariance.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2009-2016 ECMWF.
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  * In applying this licence, ECMWF does not waive the privileges and immunities
7  * granted to it by virtue of its status as an intergovernmental organisation nor
8  * does it submit to any jurisdiction.
9  */
10 
12 
13 #include <cmath>
14 #include <iostream>
15 #include <random>
16 #include <string>
17 
18 #include "eckit/config/Configuration.h"
20 #include "oops/util/Logger.h"
21 
22 // -----------------------------------------------------------------------------
23 namespace lorenz95 {
24 // -----------------------------------------------------------------------------
25 ObsBiasCovariance::ObsBiasCovariance(const eckit::Configuration & conf)
26  : conf_(conf), variance_(0.0), active_(false)
27 {
28  if (conf_.has("standard_deviation")) {
29  active_ = true;
30  const double zz = conf_.getDouble("standard_deviation");
31  variance_ = zz * zz;
32  ASSERT(variance_ > 0.0);
33  oops::Log::info() << "ObsBiasCovariance variance = " << variance_ << std::endl;
34  }
35 }
36 // -----------------------------------------------------------------------------
38  ObsBiasCorrection & dxout) const {
39  if (active_) {
40  dxout = dxin;
41  dxout *= variance_;
42  } else {
43  dxout.zero();
44  }
45 }
46 // -----------------------------------------------------------------------------
48  ObsBiasCorrection & dxout) const {
49  if (active_) {
50  dxout = dxin;
51  dxout *= 1.0 / variance_;
52  } else {
53  dxout.zero();
54  }
55 }
56 // -----------------------------------------------------------------------------
58  if (active_) {
59  static std::mt19937 generator(4);
60  static std::normal_distribution<double> distribution(0.0, 1.0);
61  double zz = distribution(generator);
62  dx.value() = zz * std::sqrt(variance_);
63  } else {
64  dx.zero();
65  }
66 }
67 // -----------------------------------------------------------------------------
68 void ObsBiasCovariance::print(std::ostream & os) const {
69  if (active_) {
70  os << "ObsBiasCovariance: variance = " << variance_;
71  } else {
72  os << "ObsBiasCovariance not active";
73  }
74 }
75 // -----------------------------------------------------------------------------
76 } // namespace lorenz95
void inverseMultiply(const ObsBiasCorrection &, ObsBiasCorrection &) const
ObsBiasCovariance(const eckit::Configuration &)
Constructor, destructor.
Definition: conf.py:1
integer(long), parameter false
subroutine, public info(self)
The namespace for the L95 model.
void multiply(const ObsBiasCorrection &, ObsBiasCorrection &) const
void randomize(ObsBiasCorrection &) const