UFO
ChannelUseflagCheckRad.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2019 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 <cmath>
11 
12 #include <algorithm>
13 #include <iomanip>
14 #include <iostream>
15 #include <set>
16 #include <string>
17 #include <vector>
18 
19 #include "ioda/ObsDataVector.h"
20 #include "oops/util/IntSetParser.h"
21 #include "ufo/filters/Variable.h"
22 #include "ufo/utils/Constants.h"
23 
24 namespace ufo {
25 
26 static ObsFunctionMaker<ChannelUseflagCheckRad>
27  makerChannelUseflagCheckRad_("ChannelUseflagCheckRad");
28 
29 // -----------------------------------------------------------------------------
30 
31 ChannelUseflagCheckRad::ChannelUseflagCheckRad(const eckit::LocalConfiguration & conf)
32  : invars_() {
33  // Check options
34  options_.deserialize(conf);
35 
36  // Get channels from options
37  std::set<int> channelset = oops::parseIntSet(options_.channelList);
38  std::copy(channelset.begin(), channelset.end(), std::back_inserter(channels_));
39  ASSERT(channels_.size() > 0);
40 
41  // Get channel use flags from options
42  std::vector<int> useflag = options_.useflagChannel.value();
43  ASSERT(useflag.size() == channels_.size());
44 
45  // TODO(EL) the following two lines will be removed when the revised filter behavior is in place
46  // Include required variables from ObsDiag (note: included here to trigger posterFilter)
47  invars_ += Variable("brightness_temperature_jacobian_surface_temperature@ObsDiag", channels_);
48 }
49 
50 // -----------------------------------------------------------------------------
51 
53 
54 // -----------------------------------------------------------------------------
55 
57  ioda::ObsDataVector<float> & out) const {
58  // Get dimension
59  const size_t nlocs = in.nlocs();
60  const size_t nchans = channels_.size();
61 
62  // Get channel use flags from options
63  std::vector<int> useflag = options_.useflagChannel.value();
64 
65  // Output
66  for (size_t ichan = 0; ichan < nchans; ++ichan) {
67  for (size_t iloc = 0; iloc < nlocs; ++iloc) {
68  out[ichan][iloc] = useflag[ichan];
69  }
70  }
71 }
72 
73 // -----------------------------------------------------------------------------
74 
76  return invars_;
77 }
78 
79 // -----------------------------------------------------------------------------
80 
81 } // namespace ufo
const ufo::Variables & requiredVariables() const
geovals required to compute the function
ChannelUseflagCheckRadParameters options_
void compute(const ObsFilterData &, ioda::ObsDataVector< float > &) const
compute the result of the function
ChannelUseflagCheckRad(const eckit::LocalConfiguration &)
oops::RequiredParameter< std::vector< int > > useflagChannel
Useflag (-1: not used; 0: monitoring; 1: used) for each channel in channelList.
oops::RequiredParameter< std::string > channelList
List of channels available for assimilation.
ObsFilterData provides access to all data related to an ObsFilter.
size_t nlocs() const
Returns the number of locations in the associated ObsSpace.
integer function nlocs(this)
Return the number of observational locations in this Locations object.
Definition: RunCRTM.h:27
static ObsFunctionMaker< ChannelUseflagCheckRad > makerChannelUseflagCheckRad_("ChannelUseflagCheckRad")