UFO
ObsErrorDiagonal.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2021 UCAR.
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  */
7 
9 
10 #include "eckit/config/Configuration.h"
11 
12 #include "oops/util/Logger.h"
13 
14 
15 namespace ufo {
16 
17 // -----------------------------------------------------------------------------
18 
19 ObsErrorDiagonal::ObsErrorDiagonal(const Parameters_ & options, ioda::ObsSpace & obsgeom,
20  const eckit::mpi::Comm &timeComm)
21  : ObsErrorBase(timeComm),
22  stddev_(obsgeom, "ObsError"), inverseVariance_(obsgeom), options_(options)
23 {
26  inverseVariance_.invert();
27  oops::Log::trace() << "ObsErrorDiagonal:ObsErrorDiagonal constructed nobs = "
28  << stddev_.nobs() << std::endl;
29 }
30 
31 // -----------------------------------------------------------------------------
32 
33 void ObsErrorDiagonal::update(const ioda::ObsVector & obserr) {
34  stddev_ = obserr;
37  inverseVariance_.invert();
38  oops::Log::info() << "ObsErrorDiagonal covariance updated " << stddev_.nobs() << std::endl;
39 }
40 
41 // -----------------------------------------------------------------------------
42 
43 void ObsErrorDiagonal::multiply(ioda::ObsVector & dy) const {
44  dy /= inverseVariance_;
45 }
46 
47 // -----------------------------------------------------------------------------
48 
49 void ObsErrorDiagonal::inverseMultiply(ioda::ObsVector & dy) const {
50  dy *= inverseVariance_;
51 }
52 
53 // -----------------------------------------------------------------------------
54 
55 void ObsErrorDiagonal::randomize(ioda::ObsVector & dy) const {
56  dy.random();
57  dy *= stddev_;
58  dy *= options_.pert;
59 }
60 
61 // -----------------------------------------------------------------------------
62 
63 void ObsErrorDiagonal::save(const std::string & name) const {
64  stddev_.save(name);
65 }
66 
67 // -----------------------------------------------------------------------------
68 
69 std::unique_ptr<ioda::ObsVector> ObsErrorDiagonal::getObsErrors() const {
70  return std::make_unique<ioda::ObsVector>(stddev_);
71 }
72 
73 // -----------------------------------------------------------------------------
74 
75 std::unique_ptr<ioda::ObsVector> ObsErrorDiagonal::getInverseVariance() const {
76  return std::make_unique<ioda::ObsVector>(inverseVariance_);
77 }
78 
79 // -----------------------------------------------------------------------------
80 void ObsErrorDiagonal::print(std::ostream & os) const {
81  os << "UFO Diagonal observation error covariance, inverse variances: "
82  << inverseVariance_ << std::endl;
83 }
84 
85 // -----------------------------------------------------------------------------
86 
87 
88 } // namespace ufo
void randomize(ioda::ObsVector &) const override
Generate random perturbation.
std::unique_ptr< ioda::ObsVector > getInverseVariance() const override
Return inverseVariance.
void inverseMultiply(ioda::ObsVector &) const override
Multiply a Departure by .
void print(std::ostream &) const override
ioda::ObsVector stddev_
ObsErrorDiagonal(const Parameters_ &, ioda::ObsSpace &, const eckit::mpi::Comm &timeComm)
void update(const ioda::ObsVector &) override
Update after obs errors potentially changed.
ioda::ObsVector inverseVariance_
void multiply(ioda::ObsVector &) const override
Multiply a Departure by .
void save(const std::string &) const override
Save obs errors.
std::unique_ptr< ioda::ObsVector > getObsErrors() const override
Get obs errors std deviation.
Parameters for diagonal obs errors.
oops::Parameter< double > pert
perturbation amplitude multiplier
Definition: RunCRTM.h:27