OOPS
GetValuesL95.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2019-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 <fstream>
11 #include <string>
12 
13 #include "eckit/exception/Exceptions.h"
14 
15 #include "oops/util/Logger.h"
16 
17 #include "lorenz95/GomL95.h"
18 #include "lorenz95/LocsL95.h"
19 #include "lorenz95/Resolution.h"
20 #include "lorenz95/StateL95.h"
21 
22 namespace lorenz95 {
23 
24 // -----------------------------------------------------------------------------
26  const LocsL95 & locs)
27  : resolidx_(locs.size()), times_(locs.times())
28 {
29  // find indices of gridpoints nearest to all observations (resolidx_)
30  const int npoints = resol.npoints();
31  const double dres = static_cast<double>(npoints);
32  for (size_t jobs = 0; jobs < locs.size(); ++jobs) {
33  int ii = round(locs[jobs] * dres);
34  ASSERT(ii >= 0 && ii <= npoints);
35  if (ii == npoints) ii = 0;
36  resolidx_[jobs] = ii;
37  }
38 }
39 // -----------------------------------------------------------------------------
40 void GetValuesL95::fillGeoVaLs(const StateL95 & state, const util::DateTime & t1,
41  const util::DateTime & t2, GomL95 & vals) const {
42  const FieldL95 & field = state.getField();
43  for (unsigned int jobs = 0; jobs < times_.size(); ++jobs) {
44  // only fill in geovals for (t1, t2) timeslot
45  if (times_[jobs] > t1 && times_[jobs] <= t2) {
46  vals[jobs] = field[resolidx_[jobs]];
47  }
48  }
49 }
50 // -----------------------------------------------------------------------------
51 void GetValuesL95::print(std::ostream & os) const {
52  os << " GetValues for L95" << std::endl;
53 }
54 // -----------------------------------------------------------------------------
55 
56 
57 } // namespace lorenz95
lorenz95::GetValuesL95::resolidx_
std::vector< int > resolidx_
Definition: GetValuesL95.h:42
lorenz95::Resolution
Handles resolution.
Definition: Resolution.h:42
lorenz95::StateL95
L95 model state.
Definition: StateL95.h:53
GetValuesL95.h
lorenz95::GetValuesL95::print
void print(std::ostream &) const
Definition: GetValuesL95.cc:51
lorenz95::LocsL95
LocsL95 class to handle locations for L95 model.
Definition: LocsL95.h:32
lorenz95::LocsL95::size
size_t size() const
Definition: LocsL95.h:40
lorenz95::StateL95::getField
const FieldL95 & getField() const
Definition: StateL95.h:69
lorenz95::Resolution::npoints
int npoints() const
Definition: Resolution.h:50
lorenz95::GomL95
GomL95 class to handle locations for L95 model.
Definition: GomL95.h:33
StateL95.h
lorenz95::GetValuesL95::GetValuesL95
GetValuesL95(const Resolution &, const LocsL95 &locs)
computes indices resolidx_ of nearest gridpoints for all locations locs
Definition: GetValuesL95.cc:25
LocsL95.h
lorenz95::GetValuesL95::times_
std::vector< util::DateTime > times_
Definition: GetValuesL95.h:43
GomL95.h
lorenz95::FieldL95
Class to represent fields for the L95 model.
Definition: FieldL95.h:34
lorenz95
The namespace for the L95 model.
Definition: l95/src/lorenz95/AnalyticInit.cc:17
Resolution.h
lorenz95::GetValuesL95::fillGeoVaLs
void fillGeoVaLs(const StateL95 &state, const util::DateTime &t1, const util::DateTime &t2, GomL95 &geovals) const
fills in geovals for all observations in the timeframe (t1, t2], geovals are equal to the value of st...
Definition: GetValuesL95.cc:40