UFO
Cal_RemapScanPosition.cc
Go to the documentation of this file.
1 /*
2  * (C) Crown copyright 2021, Met Office
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 namespace ufo {
11 
12 /************************************************************************************/
13 // Cal_RemapScanPosition
14 /************************************************************************************/
15 
16 static TransformMaker<Cal_RemapScanPosition>
17  makerCal_RemapScanPosition_("RemapScanPosition");
18 
20  const VariableTransformsParameters &options,
21  const ObsFilterData &data,
22  const std::shared_ptr<ioda::ObsDataVector<int>> &flags)
23  : TransformBase(options, data, flags) {}
24 
25 /************************************************************************************/
26 
27 void Cal_RemapScanPosition::runTransform(const std::vector<bool> &apply) {
28  oops::Log::trace() << " --> Renumber satellite scan position"
29  << std::endl;
30  oops::Log::trace() << " --> method: " << method() << std::endl;
31  oops::Log::trace() << " --> obsName: " << obsName() << std::endl;
32 
33  const size_t nlocs = obsdb_.nlocs();
34 
35  std::vector<int> original_scan_position;
36  getObservation("MetaData", "scan_position", original_scan_position, true);
37 
38  std::vector<int> remapped_scan_position(nlocs);
39  remapped_scan_position.assign(nlocs, missingValueInt);
40 
41  // Loop over all obs
42  for (size_t jobs = 0; jobs < nlocs; ++jobs) {
43  // if the data have been excluded by the where statement
44  if (!apply[jobs]) continue;
45 
46  // Calculate wind vector
47  if (original_scan_position[jobs] != missingValueInt) {
48  remapped_scan_position[jobs] = formulas::RenumberScanPosition(original_scan_position[jobs]);
49  }
50  }
51  // Overwrite variable at existing locations
52  obsdb_.put_db("MetaData", "scan_position", remapped_scan_position);
53 }
54 } // namespace ufo
55 
void runTransform(const std::vector< bool > &apply) override
Run variable conversion.
Cal_RemapScanPosition(const VariableTransformsParameters &options, const ObsFilterData &data, const std::shared_ptr< ioda::ObsDataVector< int >> &flags)
ObsFilterData provides access to all data related to an ObsFilter.
Base class for variable conversion.
Definition: TransformBase.h:53
std::string obsName() const
subclasses to access the observation name
formulas::MethodFormulation method() const
subclasses to access Method and formualtion used for the calculation
const int missingValueInt
Missing value (int)
ioda::ObsSpace & obsdb_
Observation space.
void getObservation(const std::string &originalTag, const std::string &varName, std::vector< T > &obsVector, bool require=false) const
templated function for float, int data types
Definition: TransformBase.h:94
Options controlling the operation of the variablestansform filter.
int RenumberScanPosition(int scanpos)
Get renumbered scan position 1,2,3,...
Definition: Formulas.cc:372
integer function nlocs(this)
Return the number of observational locations in this Locations object.
Definition: RunCRTM.h:27
static TransformMaker< Cal_RemapScanPosition > makerCal_RemapScanPosition_("RemapScanPosition")