IODA
ObsLocGC99.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2020 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 
8 #include "ioda/core/ObsLocGC99.h"
9 
10 #include "eckit/config/Configuration.h"
11 #include "eckit/exception/Exceptions.h"
12 
13 #include "ioda/ObsSpace.h"
14 #include "ioda/ObsVector.h"
15 
16 #include "oops/generic/gc99.h"
17 #include "oops/interface/ObsLocalization.h"
18 
19 // -----------------------------------------------------------------------------
20 namespace ioda {
21 
22 // -----------------------------------------------------------------------------
23 
24 ObsLocGC99::ObsLocGC99(const eckit::Configuration & config, const ObsSpace & obsdb)
25  : obsdb_(obsdb),
26  rscale_(config.getDouble("lengthscale"))
27 {
28 }
29 
30 // -----------------------------------------------------------------------------
31 
33 
34 // -----------------------------------------------------------------------------
35 
36 void ObsLocGC99::multiply(ObsVector & dy) const {
37  const std::vector<double> & obsdist = obsdb_.obsdist();
38  const size_t nlocs = dy.nlocs();
39  const size_t nvars = dy.nvars();
40 
41  // create a temporary vector with localization values
42  // (by putting in an ObsVector, multiplication respects the missing values)
43  ObsVector gcVec(dy);
44  gcVec.zero();
45  for (size_t jloc = 0; jloc < nlocs; ++jloc) {
46  double gc = oops::gc99(obsdist[jloc] / rscale_);
47  // obsdist is calculated at each location; need to update R for each variable
48  for (size_t jvar = 0; jvar < nvars; ++jvar) {
49  gcVec[jvar + jloc * nvars] = gc;
50  }
51  }
52 
53  dy *= gcVec;
54 }
55 
56 // -----------------------------------------------------------------------------
57 
58 void ObsLocGC99::print(std::ostream & os) const {
59  os << "Gaspari-Cohn localization with " << rscale_ << " lengthscale" << std::endl;
60 }
61 
62 // -----------------------------------------------------------------------------
63 
64 } // namespace ioda
ioda::ObsLocGC99::rscale_
const double rscale_
Definition: ObsLocGC99.h:40
ioda::ObsLocGC99::print
void print(std::ostream &) const
Definition: ObsLocGC99.cc:58
ioda::ObsVector::nvars
std::size_t nvars() const
Definition: src/ObsVector.h:69
ObsSpace.h
ioda::ObsLocGC99::multiply
void multiply(ObsVector &) const
Definition: ObsLocGC99.cc:36
ioda
Definition: IodaUtils.cc:13
ioda::ObsVector
ObsVector class to handle vectors in observation space for IODA.
Definition: src/ObsVector.h:34
ioda::ObsLocGC99::~ObsLocGC99
~ObsLocGC99()
Definition: ObsLocGC99.cc:32
ObsVector.h
ioda::ObsLocGC99::obsdb_
const ObsSpace & obsdb_
Definition: ObsLocGC99.h:39
ioda::ObsLocGC99::ObsLocGC99
ObsLocGC99(const eckit::Configuration &, const ObsSpace &)
Definition: ObsLocGC99.cc:24
ioda::ObsSpace
Observation Space View.
Definition: src/ObsSpace.h:35
ioda::ObsVector::zero
void zero()
Definition: ObsVector.cc:121
ioda::ObsVector::nlocs
std::size_t nlocs() const
Definition: src/ObsVector.h:70
ioda::ObsSpace::obsdist
const std::vector< double > & obsdist() const
Definition: src/ObsSpace.h:108