UFO
ObsSeaIceFraction.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2017-2018 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 <ostream>
11 #include <string>
12 #include <vector>
13 
14 #include "ioda/ObsVector.h"
15 
16 #include "oops/base/Variables.h"
17 
18 #include "ufo/GeoVaLs.h"
19 #include "ufo/ObsDiagnostics.h"
20 
21 namespace ufo {
22 
23 // -----------------------------------------------------------------------------
25 // -----------------------------------------------------------------------------
26 
27 ObsSeaIceFraction::ObsSeaIceFraction(const ioda::ObsSpace & odb,
28  const eckit::Configuration & config)
29  : ObsOperatorBase(odb, config), varin_()
30 {
31  const std::vector<std::string> vvin{"sea_ice_category_area_fraction"};
32  varin_.reset(new oops::Variables(vvin));
33  oops::Log::trace() << "ObsSeaIceFraction created." << std::endl;
34 }
35 
36 // -----------------------------------------------------------------------------
37 
39  oops::Log::trace() << "ObsSeaIceFraction destructed" << std::endl;
40 }
41 
42 // -----------------------------------------------------------------------------
43 
44 void ObsSeaIceFraction::simulateObs(const GeoVaLs & gv, ioda::ObsVector & ovec,
45  ObsDiagnostics &) const {
46  int nlocs = ovec.size();
47  int nlevs = gv.nlevs("sea_ice_category_area_fraction");
48 
49  std::vector<double> aicen(nlocs);
50  for ( std::size_t k = 0; k < nlevs; ++k ) {
51  gv.getAtLevel(aicen, "sea_ice_category_area_fraction", k);
52  for ( std::size_t i = 0; i < nlocs; ++i ) {
53  ovec[i] += aicen[i];
54  }
55  }
56  oops::Log::trace() << "ObsSeaIceFraction: observation operator run" << std::endl;
57 }
58 
59 // -----------------------------------------------------------------------------
60 
61 void ObsSeaIceFraction::print(std::ostream & os) const {
62  os << "ObsSeaIceFraction::print not implemented";
63 }
64 
65 // -----------------------------------------------------------------------------
66 
67 } // namespace ufo
GeoVaLs: geophysical values at locations.
size_t nlevs(const std::string &var) const
Return number of levels for a specified variable.
Definition: GeoVaLs.cc:310
void getAtLevel(std::vector< double > &, const std::string &, const int) const
Get GeoVaLs at a specified level.
Definition: GeoVaLs.cc:330
void print(std::ostream &) const override
void simulateObs(const GeoVaLs &, ioda::ObsVector &, ObsDiagnostics &) const override
Obs Operator.
std::unique_ptr< const oops::Variables > varin_
ObsSeaIceFraction(const ioda::ObsSpace &, const eckit::Configuration &)
integer function nlocs(this)
Return the number of observational locations in this Locations object.
Definition: RunCRTM.h:27
static ObsOperatorMaker< ObsSeaIceFraction > makerSeaIceFraction_("SeaIceFraction")