UFO
ObsChlEuzIntegr.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2020-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 
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 #include "ufo/utils/Constants.h"
21 
22 namespace ufo {
23 
24 // -----------------------------------------------------------------------------
25 static ObsOperatorMaker<ObsChlEuzIntegr> makerChlEuzIntegr_("Chlorophyll Ocean Color");
26 // -----------------------------------------------------------------------------
27 
28 ObsChlEuzIntegr::ObsChlEuzIntegr(const ioda::ObsSpace & odb,
29  const eckit::Configuration & config)
30  : ObsOperatorBase(odb, config), varin_()
31 {
32  const std::vector<std::string> vvin{"mass_concentration_of_chlorophyll_in_sea_water",
33  "sea_water_cell_thickness"};
34  varin_.reset(new oops::Variables(vvin));
35  oops::Log::trace() << "ObsChlEuzIntegr created." << std::endl;
36 }
37 
38 // -----------------------------------------------------------------------------
39 
41  oops::Log::trace() << "ObsChlEuzIntegr destructed" << std::endl;
42 }
43 
44 // -----------------------------------------------------------------------------
45 void ObsChlEuzIntegr::simulateObs(const GeoVaLs & gv, ioda::ObsVector & ovec,
46  ObsDiagnostics &) const {
47  int nlocs = ovec.size();
48  int nlevs = gv.nlevs("mass_concentration_of_chlorophyll_in_sea_water");
49 
50  // common vectors storage
51  std::vector <double> tmp(nlocs, 0.0);
52 
53  // Retrieve the chlorophyll and cell thickness
54  std::vector<std::vector<double>> chl;
55  std::vector<std::vector<double>> h;
56  for ( std::size_t k = 0; k < nlevs; ++k ) {
57  gv.get(tmp, "sea_water_cell_thickness", k+1);
58  h.push_back(tmp);
59  gv.get(tmp, "mass_concentration_of_chlorophyll_in_sea_water", k+1);
60  chl.push_back(tmp);
61  }
62 
63  // Calculate mean chlorophyll averaged over euphotic layer (euz_mod)
64  for ( std::size_t i = 0; i < nlocs; ++i ) {
65  double euz = Constants::euzc_0 * pow(chl[0][i], Constants::euzc_1);
66  double euz_mod = 0.0;
67  int elev = 0;
68  for ( std::size_t k = 0; k < nlevs; ++k ) {
69  if (euz_mod < euz) {
70  euz_mod += h[k][i];
71  elev++;
72  }
73  }
74  ovec[i] = 0.0;
75  for ( std::size_t k = 0; k < elev; ++k ) {
76  ovec[i] += chl[k][i] * h[k][i] / euz_mod;
77  }
78  }
79  oops::Log::trace() << "ObsChlEuzIntegr: observation operator run" << std::endl;
80 }
81 
82 // -----------------------------------------------------------------------------
83 
84 void ObsChlEuzIntegr::print(std::ostream & os) const {
85  os << "Chlorophyll Ocean Color obs operator";
86 }
87 
88 // -----------------------------------------------------------------------------
89 
90 } // namespace ufo
ufo::makerChlEuzIntegr_
static ObsOperatorMaker< ObsChlEuzIntegr > makerChlEuzIntegr_("Chlorophyll Ocean Color")
ufo::ObsChlEuzIntegr::simulateObs
void simulateObs(const GeoVaLs &, ioda::ObsVector &, ObsDiagnostics &) const override
Obs Operator.
Definition: ObsChlEuzIntegr.cc:45
ObsChlEuzIntegr.h
ufo::ObsChlEuzIntegr::print
void print(std::ostream &) const override
Definition: ObsChlEuzIntegr.cc:84
ufo::ObsChlEuzIntegr::varin_
std::unique_ptr< const oops::Variables > varin_
Definition: ObsChlEuzIntegr.h:56
ufo
Definition: RunCRTM.h:27
ufo::GeoVaLs::get
void get(std::vector< float > &, const std::string &) const
Return all values for a specific 2D variable.
Definition: GeoVaLs.cc:268
ufo::ObsChlEuzIntegr::ObsChlEuzIntegr
ObsChlEuzIntegr(const ioda::ObsSpace &, const eckit::Configuration &)
Definition: ObsChlEuzIntegr.cc:28
ufo::ObsOperatorBase
Base class for observation operators.
Definition: ObsOperatorBase.h:37
ufo::ObsDiagnostics
Definition: src/ufo/ObsDiagnostics.h:35
ufo::ObsOperatorMaker
Definition: ObsOperatorBase.h:78
ufo::GeoVaLs
GeoVaLs: geophysical values at locations.
Definition: src/ufo/GeoVaLs.h:39
ufo::ObsChlEuzIntegr::~ObsChlEuzIntegr
virtual ~ObsChlEuzIntegr()
Definition: ObsChlEuzIntegr.cc:40
ufo::Constants::euzc_1
static constexpr double euzc_1
Definition: Constants.h:65
ufo::Constants::euzc_0
static constexpr double euzc_0
Definition: Constants.h:64
Constants.h
ufo::GeoVaLs::nlevs
size_t nlevs(const std::string &var) const
Return number of levels for a specified variable.
Definition: GeoVaLs.cc:259