UFO
src/ufo/Locations.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2017-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 #ifndef UFO_LOCATIONS_H_
9 #define UFO_LOCATIONS_H_
10 
11 #include <memory>
12 #include <ostream>
13 #include <string>
14 #include <vector>
15 
16 #include "eckit/mpi/Comm.h"
17 #include "ioda/distribution/Distribution.h"
18 #include "oops/util/DateTime.h"
19 #include "oops/util/ObjectCounter.h"
20 #include "oops/util/Printable.h"
21 
22 namespace eckit {
23  class Configuration;
24 }
25 
26 namespace ufo {
27 
28 /// \brief Locations class to handle simple lat-lon-time locations
29 class Locations : public util::Printable,
30  private util::ObjectCounter<Locations> {
31  public:
32  static const std::string classname() {return "ufo::Locations";}
33 
34  /// \brief constructor from passed \p lons, \p lats, \p times
35  Locations(const std::vector<float> & lons, const std::vector<float> & lats,
36  const std::vector<util::DateTime> & times,
37  std::shared_ptr<const ioda::Distribution>);
38  /// \brief constructor used in oops tests
39  Locations(const eckit::Configuration &, const eckit::mpi::Comm &);
40 
41  /// append locations with more locations
42  Locations & operator+=(const Locations &);
43 
44  /// find which observations are in the (\p t1, \p t2] time window
45  std::vector<bool> isInTimeWindow(const util::DateTime & t1, const util::DateTime & t2) const;
46 
47  /// size of locations
48  size_t size() const;
49 
50  /// accessor to the observations MPI distribution
51  const std::shared_ptr<const ioda::Distribution> & distribution() const {return dist_;}
52  /// accessor to observation longitudes (on current MPI task)
53  const std::vector<float> & lons() const {return lons_;}
54  /// accessor to observation latitudes (on current MPI task)
55  const std::vector<float> & lats() const {return lats_;}
56  /// accessor to DateTimes (on current MPI task)
57  const std::vector<util::DateTime> & times() const {return times_;}
58 
59 
60  private:
61  void print(std::ostream & os) const override;
62 
63  std::shared_ptr<const ioda::Distribution> dist_; /// observations MPI distribution
64  std::vector<float> lons_; /// longitudes on current MPI task
65  std::vector<float> lats_; /// latitudes on current MPI task
66  std::vector<util::DateTime> times_; /// times of observations on current MPI task
67 };
68 
69 } // namespace ufo
70 
71 #endif // UFO_LOCATIONS_H_
Locations class to handle simple lat-lon-time locations.
size_t size() const
size of locations
Definition: Locations.cc:96
static const std::string classname()
std::shared_ptr< const ioda::Distribution > dist_
const std::vector< util::DateTime > & times() const
accessor to DateTimes (on current MPI task)
std::vector< bool > isInTimeWindow(const util::DateTime &t1, const util::DateTime &t2) const
find which observations are in the (t1, t2] time window
Definition: Locations.cc:85
Locations & operator+=(const Locations &)
append locations with more locations
Definition: Locations.cc:77
const std::vector< float > & lons() const
accessor to observation longitudes (on current MPI task)
std::vector< float > lats_
longitudes on current MPI task
std::vector< util::DateTime > times_
latitudes on current MPI task
const std::vector< float > & lats() const
accessor to observation latitudes (on current MPI task)
const std::shared_ptr< const ioda::Distribution > & distribution() const
accessor to the observations MPI distribution
Locations(const std::vector< float > &lons, const std::vector< float > &lats, const std::vector< util::DateTime > &times, std::shared_ptr< const ioda::Distribution >)
constructor from passed lons, lats, times
Definition: Locations.cc:26
void print(std::ostream &os) const override
Definition: Locations.cc:102
std::vector< float > lons_
observations MPI distribution
Forward declarations.
Definition: ObsAodExt.h:21
Definition: RunCRTM.h:27