-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f9e1295
commit dfeb1dc
Showing
11 changed files
with
191 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
umdsst_target_sources( | ||
StdDev.cc | ||
StdDev.h | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* (C) Copyright 2021-2021 UCAR | ||
* | ||
* This software is licensed under the terms of the Apache Licence Version 2.0 | ||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. | ||
*/ | ||
|
||
#include "umdsst/LinearVariableChange/StdDev.h" | ||
#include "umdsst/State/State.h" | ||
#include "umdsst/Geometry/Geometry.h" | ||
#include "umdsst/Traits.h" | ||
#include "umdsst/Increment/Increment.h" | ||
|
||
#include "oops/interface/LinearVariableChange.h" | ||
#include "oops/util/abor1_cpp.h" | ||
|
||
namespace umdsst { | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
StdDev::StdDev(const State &bkg, const State &traj, const Geometry &geom, | ||
const eckit::Configuration &conf) { | ||
stddev_.reset(new Increment(geom, bkg.variables(), bkg.validTime())); | ||
stddev_->ones(); | ||
|
||
if ( conf.has("fixed") ) { | ||
// a single global fixed value | ||
double val; | ||
conf.get("fixed", val); | ||
*stddev_ *= val; | ||
} else { | ||
util::abor1_cpp("StdDev::StdDev() no standard deviation " | ||
"method specified", __FILE__, __LINE__); | ||
} | ||
|
||
// TODO(someone) place the real horizontally varying background error | ||
// standard deviation in stddev_ | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
void StdDev::multiply(const Increment &dxin, Increment &dxout) const { | ||
dxout = dxin; | ||
dxout.schur_product_with(*stddev_); | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
void StdDev::multiplyAD(const Increment &dxin, Increment &dxout) const { | ||
multiply(dxin, dxout); | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
void StdDev::multiplyInverse(const Increment &dxin, Increment &dxout) const { | ||
dxout = dxin; | ||
dxout.schur_product_with_inv(*stddev_); | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
void StdDev::multiplyInverseAD(const Increment &dxin, Increment &dxout) const { | ||
multiplyInverse(dxin, dxout); | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
oops::LinearVariableChangeMaker<Traits, | ||
oops::LinearVariableChange<Traits, StdDev> > | ||
makerLinearVariableChangeStdDev_("umdsstStdDev"); | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
} // namespace umdsst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* (C) Copyright 2021-2021 UCAR | ||
* | ||
* This software is licensed under the terms of the Apache Licence Version 2.0 | ||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. | ||
*/ | ||
|
||
#ifndef UMDSST_LINEARVARIABLECHANGE_STDDEV_H_ | ||
#define UMDSST_LINEARVARIABLECHANGE_STDDEV_H_ | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include "oops/util/Printable.h" | ||
|
||
// Forward Declaration | ||
namespace eckit { | ||
class Configuration; | ||
} | ||
namespace umdsst { | ||
class Geometry; | ||
class Increment; | ||
class State; | ||
} | ||
|
||
namespace umdsst { | ||
|
||
class StdDev: public util::Printable { | ||
public: | ||
static const std::string classname() {return "umdsst:StdDev";} | ||
|
||
explicit StdDev(const State &, const State &, const Geometry &, | ||
const eckit::Configuration &); | ||
|
||
void multiply(const Increment &, Increment &) const; | ||
void multiplyInverse(const Increment &, Increment &) const; | ||
void multiplyAD(const Increment &, Increment &) const; | ||
void multiplyInverseAD(const Increment &, Increment &) const; | ||
|
||
private: | ||
void print(std::ostream &) const override {} | ||
std::unique_ptr<Increment> stddev_; | ||
}; | ||
|
||
} // namespace umdsst | ||
|
||
#endif // UMDSST_LINEARVARIABLECHANGE_STDDEV_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* (C) Copyright 2021-2021 UCAR. | ||
* | ||
* This software is licensed under the terms of the Apache Licence Version 2.0 | ||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. | ||
*/ | ||
|
||
#include "umdsst/Traits.h" | ||
#include "oops/runs/Run.h" | ||
#include "test/interface/LinearVariableChange.h" | ||
|
||
int main(int argc, char ** argv) { | ||
oops::Run run(argc, argv); | ||
test::LinearVariableChange<umdsst::Traits> tests; | ||
return run.execute(tests); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
geometry: | ||
grid: S360x180 | ||
domain: | ||
type: global | ||
west: -180 | ||
landmask: | ||
filename: Data/landmask.nc | ||
|
||
background: | ||
state variables: &vars [sea_surface_temperature] | ||
date: 2018-04-15T00:00:00Z | ||
|
||
linear variable change tests: | ||
- variable change: umdsstStdDev | ||
tolerance inverse: 1e-12 | ||
test inverse: 1 | ||
input variables: *vars | ||
output variables: *vars | ||
fixed: 2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters