UFO
SunGlintAngle.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2021 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 #include <iostream>
12 #include <string>
13 #include <vector>
14 
15 #include "ioda/ObsDataVector.h"
16 #include "ufo/filters/Variable.h"
17 #include "ufo/utils/Constants.h"
18 
19 namespace ufo {
20 
22 
23 SunGlintAngle::SunGlintAngle(const eckit::LocalConfiguration & conf)
24  : invars_() {
25  // Include list of required data from ObsSpace
26  invars_ += Variable("solar_zenith_angle@MetaData");
27  invars_ += Variable("solar_azimuth_angle@MetaData");
28  invars_ += Variable("sensor_zenith_angle@MetaData");
29  invars_ += Variable("sensor_azimuth_angle@MetaData");
30 }
31 
32 // -----------------------------------------------------------------------------
33 
35 
36 // -----------------------------------------------------------------------------
37 
39  ioda::ObsDataVector<float> & out) const {
40  // Get dimension
41  const size_t nlocs = in.nlocs();
42 
43  // This is taken from AMSR2's Sun_glint_angle calculation in GSI's subroutine "setuprad.f90".
44  std::vector<float> &sun_glint = out[0];
45  std::vector<float> sun_zenith(nlocs), sun_azimuth(nlocs);
46  std::vector<float> sat_zenith(nlocs), sat_azimuth(nlocs);
47 
48  in.get(Variable("solar_zenith_angle@MetaData"), sun_zenith);
49  in.get(Variable("solar_azimuth_angle@MetaData"), sun_azimuth);
50  in.get(Variable("sensor_zenith_angle@MetaData"), sat_zenith);
51  in.get(Variable("sensor_azimuth_angle@MetaData"), sat_azimuth);
52  for (size_t iloc = 0; iloc < nlocs; ++iloc) {
53  sun_zenith[iloc] *= Constants::deg2rad;
54  sun_azimuth[iloc] *= Constants::deg2rad;
55  sat_zenith[iloc] *= Constants::deg2rad;
56  sat_azimuth[iloc] *= Constants::deg2rad;
57  float cosza = cos(sat_zenith[iloc]);
58  float bearaz = sun_azimuth[iloc] - sat_azimuth[iloc] + M_PI;
59  sun_glint[iloc] = acos(cos(sun_zenith[iloc])*cosza + sin(sun_zenith[iloc])
60  *sin(sat_zenith[iloc])*cos(bearaz))*Constants::rad2deg;
61  }
62 }
63 
64 // -----------------------------------------------------------------------------
65 
67  return invars_;
68 }
69 
70 // -----------------------------------------------------------------------------
71 
72 } // namespace ufo
ObsFilterData provides access to all data related to an ObsFilter.
size_t nlocs() const
Returns the number of locations in the associated ObsSpace.
void get(const Variable &varname, std::vector< float > &values) const
Fills a std::vector with values of the specified variable.
SunGlintAngle(const eckit::LocalConfiguration &=eckit::LocalConfiguration())
void compute(const ObsFilterData &, ioda::ObsDataVector< float > &) const
compute the result of the function
ufo::Variables invars_
Definition: SunGlintAngle.h:33
const ufo::Variables & requiredVariables() const
geovals required to compute the function
integer function nlocs(this)
Return the number of observational locations in this Locations object.
Definition: RunCRTM.h:27
static ObsFunctionMaker< SunGlintAngle > makerSunGlintAngle_("SunGlintAngle")
static constexpr double deg2rad
Definition: Constants.h:21
static constexpr double rad2deg
Definition: Constants.h:22