UFO
ROobserrInflation.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 
9 #include <algorithm>
10 #include <set>
11 
12 #include "ioda/ObsDataVector.h"
13 #include "oops/util/IntSetParser.h"
14 #include "oops/util/missingValues.h"
16 #include "ufo/utils/StringUtils.h"
17 
18 namespace ufo {
19 
20 // -----------------------------------------------------------------------------
21 
23 
24 // -----------------------------------------------------------------------------
25 
27  : allvars_() {
28 }
29 // -----------------------------------------------------------------------------
30 
32  const std::vector<std::vector<bool>> & flagged,
33  const ObsFilterData & data,
34  int filterQCflag,
36  ioda::ObsDataVector<float> & obserr) const {
37  const float missing = util::missingValue(missing);
38  oops::Log::debug() << " input obserr: " << obserr << std::endl;
39  size_t nlocs = data.nlocs();
40  ioda::ObsDataVector<int> record(data.obsspace(), "record_number", "MetaData");
41  ioda::ObsDataVector<int> layeridx(data.obsspace(), "bending_angle", "LayerIdx");
42 
43  std::vector<int> rec_idx(nlocs);
44  std::vector<int> layer_idx(nlocs);
45  std::vector<float> factor(nlocs);
46  const int maxlev = 500;
47  std::vector<std::vector<int> > super_obs_inlayer(maxlev, std::vector<int>(nlocs));
48 
49  for (size_t i = 0; i < maxlev; ++i) {
50  for (size_t j = 0; j < nlocs; ++j) {
51  super_obs_inlayer[i][j] = 0;
52  }
53  }
54  int irec = 1;
55  for (size_t jobs = 0; jobs < nlocs; ++jobs) {
56  if (jobs > 0 && record[0][jobs] != record[0][jobs-1]) irec = irec +1;
57  rec_idx[jobs] = irec;
58  layer_idx[jobs] = layeridx[0][jobs];
59  if (flags[0][jobs] == 0) super_obs_inlayer[layer_idx[jobs]][rec_idx[jobs]]++;
60  }
61  for (size_t jobs = 0; jobs < nlocs; ++jobs) {
62  factor[jobs] = 1.0;
63  if (super_obs_inlayer[layer_idx[jobs]][rec_idx[jobs]] > 0) {
64  factor[jobs] = super_obs_inlayer[layer_idx[jobs]][rec_idx[jobs]];
65  factor[jobs] = sqrt(factor[jobs]);
66  }
67  if (obserr[0][jobs] != missing) obserr[0][jobs] *= factor[jobs];
68  }
69 }
70 // -----------------------------------------------------------------------------
71 
72 } // namespace ufo
ObsFilterData provides access to all data related to an ObsFilter.
size_t nlocs() const
Returns the number of locations in the associated ObsSpace.
ioda::ObsSpace & obsspace() const
Returns reference to ObsSpace associated with ObsFilterData.
void apply(const Variables &, const std::vector< std::vector< bool >> &, const ObsFilterData &, int, ioda::ObsDataVector< int > &, ioda::ObsDataVector< float > &) const override
ROobserrInflation(const Parameters_ &)
constexpr int missing
Definition: QCflags.h:20
integer function nlocs(this)
Return the number of observational locations in this Locations object.
Definition: RunCRTM.h:27
static FilterActionMaker< InflateError > makerInflateErr_("inflate error")