FV3 Bundle
ObsFilters.h
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 
8 #ifndef OOPS_BASE_OBSFILTERS_H_
9 #define OOPS_BASE_OBSFILTERS_H_
10 
11 #include <string>
12 #include <vector>
13 
14 #include <boost/shared_ptr.hpp>
15 
16 #include "eckit/config/LocalConfiguration.h"
17 #include "oops/base/FilterBase.h"
18 #include "oops/base/ObsFilter.h"
19 #include "oops/base/ObsSpaces.h"
20 #include "oops/util/Printable.h"
21 
22 namespace oops {
23 
24 // -----------------------------------------------------------------------------
25 
26 template <typename MODEL>
27 class ObsFilters : public util::Printable {
31 
32  public:
33  ObsFilters(const ObsSpace_ &, const eckit::Configuration &);
34  ~ObsFilters();
35 
36  const ObsFilter_ & operator[](const std::size_t ii) const {return *filters_.at(ii);}
37 
38  private:
39  void print(std::ostream &) const;
40  std::vector<boost::shared_ptr<ObsFilter_> > filters_;
41 };
42 
43 // -----------------------------------------------------------------------------
44 
45 template <typename MODEL>
46 ObsFilters<MODEL>::ObsFilters(const ObsSpace_ & os, const eckit::Configuration & conf)
47  : filters_(os.size())
48 {
49  for (std::size_t jj = 0; jj < os.size(); ++jj) {
50  boost::shared_ptr<ObsFilter_> tmp(new ObsFilter_);
51  filters_[jj] = tmp;
52  }
53 
54  std::vector<eckit::LocalConfiguration> confs;
55  conf.get("ObsFilters", confs);
56 
57  for (std::size_t jj = 0; jj < confs.size(); ++jj) {
58  const std::string type = confs[jj].getString("ObsType");
59  const std::size_t ii = os.itype(type);
60  boost::shared_ptr<FilterBase_> tmp(FilterFactory<MODEL>::create(confs[jj]));
61  filters_[ii]->enrollFilter(tmp);
62  }
63 }
64 
65 // -----------------------------------------------------------------------------
66 
67 template <typename MODEL>
69 
70 // -----------------------------------------------------------------------------
71 
72 template <typename MODEL>
73 void ObsFilters<MODEL>::print(std::ostream & os) const {
74  os << "ObsFilters for " << filters_.size() << " types:" << std::endl;
75  for (std::size_t jj = 0; jj < filters_.size(); ++jj) {
76  os << *filters_[jj] << std::endl;
77  }
78 }
79 
80 // -----------------------------------------------------------------------------
81 
82 } // namespace oops
83 
84 #endif // OOPS_BASE_OBSFILTERS_H_
Base class for QC filters applied to observations.
Definition: FilterBase.h:29
ObsFilters(const ObsSpace_ &, const eckit::Configuration &)
Definition: ObsFilters.h:46
ObsSpaces< MODEL > ObsSpace_
Definition: ObsFilters.h:30
std::vector< boost::shared_ptr< ObsFilter_ > > filters_
Definition: ObsFilters.h:40
Definition: conf.py:1
The namespace for the main oops code.
type
Definition: c2f.py:15
FilterBase< MODEL > FilterBase_
Definition: ObsFilters.h:28
ObsFilter Factory.
Definition: FilterBase.h:50
std::size_t itype(const std::string &type) const
Definition: ObsSpaces.h:53
************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If see< http:! ***********************************************************************subroutine READ_RECORD_CORE_(unit, field, nwords, data, start, axsiz) integer, intent(in) ::unit type(fieldtype), intent(in) ::field integer, intent(in) ::nwords MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in) ::start(:), axsiz(:) integer(SHORT_KIND) ::i2vals(nwords)!rab used in conjunction with transfer intrinsic to determine size of a variable integer(KIND=1) ::one_byte(8) integer ::word_sz!#ifdef __sgi integer(INT_KIND) ::ivals(nwords) real(FLOAT_KIND) ::rvals(nwords)!#else! integer ::ivals(nwords)! real ::rvals(nwords)!#endif real(DOUBLE_KIND) ::r8vals(nwords) pointer(ptr1, i2vals) pointer(ptr2, ivals) pointer(ptr3, rvals) pointer(ptr4, r8vals) if(mpp_io_stack_size< nwords) call mpp_io_set_stack_size(nwords) call mpp_error(FATAL, 'MPP_READ currently requires use_netCDF option') end subroutine READ_RECORD_CORE_ subroutine READ_RECORD_(unit, field, nwords, data, time_level, domain, position, tile_count, start_in, axsiz_in)!routine that is finally called by all mpp_read routines to perform the read!a non-netCDF record contains:! field ID! a set of 4 coordinates(is:ie, js:je) giving the data subdomain! a timelevel and a timestamp(=NULLTIME if field is static)! 3D real data(stored as 1D)!if you are using direct access I/O, the RECL argument to OPEN must be large enough for the above!in a global direct access file, record position on PE is given by %record.!Treatment of timestamp:! We assume that static fields have been passed without a timestamp.! Here that is converted into a timestamp of NULLTIME.! For non-netCDF fields, field is treated no differently, but is written! with a timestamp of NULLTIME. There is no check in the code to prevent! the user from repeatedly writing a static field. integer, intent(in) ::unit, nwords type(fieldtype), intent(in) ::field MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in), optional ::time_level type(domain2D), intent(in), optional ::domain integer, intent(in), optional ::position, tile_count integer, intent(in), optional ::start_in(:), axsiz_in(:) integer, dimension(size(field%axes(:))) ::start, axsiz integer ::tlevel !, subdomain(4) integer ::i, error, is, ie, js, je, isg, ieg, jsg, jeg type(domain2d), pointer ::io_domain=> tlevel if(PRESENT(start_in) .AND. PRESENT(axsiz_in)) then if(size(start(! the data domain and compute domain must refer to the subdomain being passed ! In this ! since that attempts to gather all data on PE size(field%axes(:)) axsiz(i)
void print(std::ostream &) const
Definition: ObsFilters.h:73
Controls application of QC filters to observations.
Definition: ObsFilter.h:28
const ObsFilter_ & operator[](const std::size_t ii) const
Definition: ObsFilters.h:36
ObsFilter< MODEL > ObsFilter_
Definition: ObsFilters.h:29
std::size_t size() const
Access.
Definition: ObsSpaces.h:51