FV3 Bundle
qg/model/ObsBias.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 
11 #include "model/ObsBias.h"
12 
13 #include <cmath>
14 #include <iostream>
15 #include <sstream>
16 #include <string>
17 
18 #include "eckit/config/Configuration.h"
19 #include "model/ObsBiasIncrement.h"
20 #include "oops/util/Logger.h"
21 
22 // -----------------------------------------------------------------------------
23 namespace qg {
24 // -----------------------------------------------------------------------------
25 ObsBias::ObsBias(const eckit::Configuration & conf) : bias_(ntypes, 0.0), active_(false) {
26  oops::Log::info() << "ObsBias: conf = " << conf << std::endl;
27  active_ = conf.has("stream") || conf.has("uwind") || conf.has("vwind") || conf.has("wspeed");
28  if (active_) {
29  if (conf.has("stream")) bias_[0] = conf.getDouble("stream");
30  if (conf.has("uwind")) bias_[1] = conf.getDouble("uwind");
31  if (conf.has("vwind")) bias_[2] = conf.getDouble("vwind");
32  if (conf.has("wspeed")) bias_[3] = conf.getDouble("wspeed");
33  std::string strn = "";
34  for (unsigned int jj = 0; jj < ObsBias::ntypes; ++jj) {
35  if (jj > 0) strn += ", ";
36  std::ostringstream strs;
37  strs << bias_[jj];
38  strn += strs.str();
39  }
40  oops::Log::info() << "ObsBias::ObsBias created, bias = " << strn << std::endl;
41  }
42 }
43 // -----------------------------------------------------------------------------
44 ObsBias::ObsBias(const ObsBias & other, const bool copy)
45  : bias_(ntypes, 0.0), active_(other.active_)
46 {
47  if (active_ && copy) {
48  for (unsigned int jj = 0; jj < ntypes; ++jj) bias_[jj] = other.bias_[jj];
49  }
50 }
51 // -----------------------------------------------------------------------------
53  if (active_) {
54  for (unsigned int jj = 0; jj < ntypes; ++jj) bias_[jj] += dx[jj];
55  }
56  return *this;
57 }
58 // -----------------------------------------------------------------------------
59 double ObsBias::norm() const {
60  double zz = 0.0;
61  if (active_) {
62  for (unsigned int jj = 0; jj < ntypes; ++jj) zz += bias_[jj]*bias_[jj];
63  zz = std::sqrt(zz/3.0);
64  }
65  return zz;
66 }
67 // -----------------------------------------------------------------------------
68 void ObsBias::print(std::ostream & os) const {
69  if (active_) {
70  std::string strn = "";
71  for (unsigned int jj = 0; jj < ObsBias::ntypes; ++jj) {
72  if (jj > 0) strn += ", ";
73  std::ostringstream strs;
74  strs << bias_[jj];
75  strn += strs.str();
76  }
77  os << std::endl << "ObsBias = " << strn;
78  }
79 }
80 // -----------------------------------------------------------------------------
81 } // namespace qg
82 
std::vector< double > bias_
subroutine, public copy(self, rhs)
Definition: conf.py:1
ObsBias & operator+=(const ObsBiasIncrement &)
double norm() const
integer(long), parameter false
void print(std::ostream &) const
Class to handle observation bias parameters.
subroutine, public info(self)
static const unsigned int ntypes
ObsBias(const eckit::Configuration &)
The namespace for the qg model.