UFO
locations_f.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 
8 #include "ufo/locations_f.h"
9 
10 #include <algorithm>
11 #include <vector>
12 
13 #include "eckit/exception/Exceptions.h"
14 
15 namespace ufo {
16 
17 // -----------------------------------------------------------------------------
18 std::size_t locations_get_nlocs_f(const Locations & locs) {
19  return locs.size();
20 }
21 // -----------------------------------------------------------------------------
22 void locations_get_lons_f(const Locations & locs,
23  const std::size_t & nlocs, double * lons) {
24  ASSERT(nlocs == locs.size());
25  const std::vector<float> & data = locs.lons();
26  std::copy(data.begin(), data.end(), lons);
27 }
28 // -----------------------------------------------------------------------------
29 void locations_get_lats_f(const Locations & locs,
30  const std::size_t & nlocs, double * lats) {
31  ASSERT(nlocs == locs.size());
32  const std::vector<float> & data = locs.lats();
33  std::copy(data.begin(), data.end(), lats);
34 }
35 // -----------------------------------------------------------------------------
37  const util::DateTime & t1, const util::DateTime & t2,
38  const std::size_t & nlocs, bool * mask) {
39  ASSERT(nlocs == locs.size());
40  std::vector<bool> data = locs.isInTimeWindow(t1, t2);
41  std::copy(data.begin(), data.end(), mask);
42 }
43 // -----------------------------------------------------------------------------
44 } // namespace ufo
Locations class to handle simple lat-lon-time locations.
size_t size() const
size of locations
Definition: Locations.cc:96
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
const std::vector< float > & lons() const
accessor to observation longitudes (on current MPI task)
const std::vector< float > & lats() const
accessor to observation latitudes (on current MPI task)
integer function nlocs(this)
Return the number of observational locations in this Locations object.
Definition: RunCRTM.h:27
void locations_get_lats_f(const Locations &locs, const std::size_t &nlocs, double *lats)
Definition: locations_f.cc:29
void locations_get_timemask_f(const Locations &locs, const util::DateTime &t1, const util::DateTime &t2, const std::size_t &nlocs, bool *mask)
Definition: locations_f.cc:36
void locations_get_lons_f(const Locations &locs, const std::size_t &nlocs, double *lons)
Definition: locations_f.cc:22
std::size_t locations_get_nlocs_f(const Locations &locs)
Definition: locations_f.cc:18