FV3 Bundle
src/lorenz95/ObsBiasCorrection.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 <iostream>
14 #include <string>
15 
16 #include "eckit/config/Configuration.h"
17 #include "lorenz95/ObsBias.h"
19 #include "oops/util/Logger.h"
20 
21 // -----------------------------------------------------------------------------
22 namespace lorenz95 {
23 // -----------------------------------------------------------------------------
24 ObsBiasCorrection::ObsBiasCorrection(const eckit::Configuration & conf)
25  : bias_(0.0), active_(false)
26 {
27  active_ = conf.has("standard_deviation");
28  if (active_) {oops::Log::trace() << "ObsBiasCorrection::ObsBiasCorrection created." << std::endl;}
29 }
30 // -----------------------------------------------------------------------------
32  const bool copy)
33  : bias_(0.0), active_(other.active_)
34 {
35  if (active_ && copy) bias_ = other.bias_;
36 }
37 // -----------------------------------------------------------------------------
39  const eckit::Configuration &)
40  : bias_(0.0), active_(other.active_)
41 {
42  if (active_) bias_ = other.bias_;
43 }
44 // -----------------------------------------------------------------------------
45 void ObsBiasCorrection::diff(const ObsBias & b1, const ObsBias & b2) {
46  if (active_) bias_ = b1.value() - b2.value();
47 }
48 // -----------------------------------------------------------------------------
50  bias_ = 0.0;
51 }
52 // -----------------------------------------------------------------------------
54  if (active_) {
55  bias_ = rhs.bias_;
56  } else {
57  bias_ = 0.0;
58  }
59  return *this;
60 }
61 // -----------------------------------------------------------------------------
63  if (active_) bias_ += rhs.bias_;
64  return *this;
65 }
66 // -----------------------------------------------------------------------------
68  if (active_) bias_ -= rhs.bias_;
69  return *this;
70 }
71 // -----------------------------------------------------------------------------
73  if (active_) bias_ *= fact;
74  return *this;
75 }
76 // -----------------------------------------------------------------------------
77 void ObsBiasCorrection::axpy(const double fact, const ObsBiasCorrection & rhs) {
78  if (active_) bias_ += fact * rhs.bias_;
79 }
80 // -----------------------------------------------------------------------------
82  double zz = 0.0;
83  if (active_) zz = bias_ * rhs.bias_;
84  return zz;
85 }
86 // -----------------------------------------------------------------------------
87 void ObsBiasCorrection::print(std::ostream & os) const {
88  if (active_) {os << std::endl << "ObsBiasCorrection = " << bias_;}
89 }
90 // -----------------------------------------------------------------------------
91 } // namespace lorenz95
Class to handle observation bias parameters.
real, parameter b1
subroutine, public copy(self, rhs)
Definition: conf.py:1
double dot_product_with(const ObsBiasCorrection &) const
integer(long), parameter false
ObsBiasCorrection()
Constructor, destructor.
ObsBiasCorrection & operator-=(const ObsBiasCorrection &)
The namespace for the L95 model.
ObsBiasCorrection & operator=(const ObsBiasCorrection &)
void axpy(const double, const ObsBiasCorrection &)
void diff(const ObsBias &, const ObsBias &)
Linear algebra operators.
ObsBiasCorrection & operator*=(const double)
ObsBiasCorrection & operator+=(const ObsBiasCorrection &)
real, parameter b2