Skip to content

Commit

Permalink
Merge branch 'release-0.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
twsearle committed Oct 14, 2021
2 parents 1a99b95 + a78b11c commit a81fd17
Show file tree
Hide file tree
Showing 53 changed files with 2,457 additions and 9,773 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ set( CMAKE_DIRECTORY_LABELS "orca-jedi" )
################################################################################
# Required packages

ecbuild_find_package( NAME eckit VERSION 1.16 REQUIRED )
ecbuild_find_package( NAME eckit VERSION 1.16 COMPONENTS LZ4 REQUIRED )
ecbuild_debug( " eckit_FEATURES : [${eckit_FEATURES}]" )

#ecbuild_find_package( NAME atlas VERSION 0.25 REQUIRED )
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.0
0.2.0
5 changes: 5 additions & 0 deletions src/mains/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ ecbuild_add_executable( TARGET orcamodel_hofx.x
SOURCES orcamodelHofX.cc
LIBS orcamodel
)

ecbuild_add_executable( TARGET orcamodel_hofx3D.x
SOURCES orcamodelHofX3D.cc
LIBS orcamodel
)
6 changes: 3 additions & 3 deletions src/mains/orcamodelHofX.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
#include "oops/generic/instantiateModelFactory.h"

#include "oops/runs/HofX4D.h"
#include "oops/runs/Run.h"

#include "ufo/ObsTraits.h"
#include "ufo/instantiateObsFilterFactory.h"

#include "orca-jedi/run/Run.h"
#include "orca-jedi/utilities/OrcaModelTraits.h"

int main(int argc, char ** argv) {
orcamodel::Run run(argc, argv);
oops::Run run(argc, argv);
oops::instantiateModelFactory<orcamodel::OrcaModelTraits>();
atlas::Library::instance().initialise();
ufo::instantiateObsFilterFactory<ufo::ObsTraits>();
ufo::instantiateObsFilterFactory();
oops::HofX4D<orcamodel::OrcaModelTraits , ufo::ObsTraits> hofx;
int i = run.execute(hofx);
atlas::Library::instance().finalise();
Expand Down
28 changes: 28 additions & 0 deletions src/mains/orcamodelHofX3D.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* (C) British Crown Copyright 2020 MetOffice
*
* 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 "atlas/library/Library.h"
#include "oops/generic/instantiateModelFactory.h"

#include "oops/runs/HofX3D.h"
#include "oops/runs/Run.h"

#include "ufo/ObsTraits.h"
#include "ufo/instantiateObsFilterFactory.h"

#include "orca-jedi/utilities/OrcaModelTraits.h"

int main(int argc, char ** argv) {
oops::Run run(argc, argv);
oops::instantiateModelFactory<orcamodel::OrcaModelTraits>();
atlas::Library::instance().initialise();
ufo::instantiateObsFilterFactory();
oops::HofX3D<orcamodel::OrcaModelTraits , ufo::ObsTraits> hofx;
int i = run.execute(hofx);
atlas::Library::instance().finalise();
return i;
}
6 changes: 4 additions & 2 deletions src/orca-jedi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )
list( APPEND oops_orcamodel_src_files
errorcovariance/ErrorCovariance.cc
errorcovariance/ErrorCovariance.h
geometry/GeometryParameters.h
geometry/Geometry.h
geometry/Geometry.cc
getvalues/GetValuesParameters.h
getvalues/GetValues.h
getvalues/GetValues.cc
getvalues/LinearGetValues.h
Expand All @@ -21,15 +23,15 @@ model/ModelBiasCovariance.h
model/ModelBias.h
model/ModelBiasIncrement.h
model/Model.h
run/Run.cc
run/Run.h
state/State.h
state/State.cc
state/StateReadUtils.h
state/StateReadUtils.cc
nemo_io/NemoFieldReader.h
nemo_io/NemoFieldReader.cc
utilities/OrcaModelTraits.h
variablechanges/model2geovals/VarChaModel2GeoVaLs.h
variablechanges/model2geovals/VarChaModel2GeoVaLs.cc
)


Expand Down
22 changes: 8 additions & 14 deletions src/orca-jedi/errorcovariance/ErrorCovariance.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* (C) British Crown Copyright 2020 Met Office
*
*
* 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.
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
*/

#include <cmath>
Expand Down Expand Up @@ -42,41 +42,37 @@ ErrorCovariance::ErrorCovariance(const Geometry & resol,


ErrorCovariance::~ErrorCovariance() {

oops::Log::trace() << "ErrorCovariance(UM) destructed" << std::endl;
}


void ErrorCovariance::linearize(const State &,
const Geometry & resol) {

geom_.reset(new Geometry(resol));
oops::Log::trace() << "ErrorCovariance(UM) linearize" << std::endl;
}


void ErrorCovariance::multiply(const Increment & dxin,
Increment & dxout) const {

oops::Log::trace() << "ErrorCovariance(UM) multiply start dxin" << dxin << std::endl;
oops::Log::trace() << "ErrorCovariance(UM) multiply start dxin"
<< dxin << std::endl;

if (covarianceType_ == "identity") {
dxout = dxin;
} else {

std::string err_message =
"umjedi::ErrorCovariance::multiply option " + covarianceType_ + " not implemented";
std::string err_message = "umjedi::ErrorCovariance::multiply option "
+ covarianceType_ + " not implemented";
throw eckit::NotImplemented(err_message, Here());

}

oops::Log::trace() << "ErrorCovariance(UM) multiply end dxout" << dxout << std::endl;
oops::Log::trace() << "ErrorCovariance(UM) multiply end dxout"
<< dxout << std::endl;
}


void ErrorCovariance::inverseMultiply(const Increment & dxin,
Increment & dxout) const {

if (covarianceType_ == "identity") {
dxout = dxin;
} else {
Expand All @@ -89,7 +85,6 @@ void ErrorCovariance::inverseMultiply(const Increment & dxin,


void ErrorCovariance::randomize(Increment & dx) const {

oops::Log::trace() << "ErrorCovariance(UM) randomize" << std::endl;
std::string err_message =
"umjedi::ErrorCovariance::randomise not implemented ";
Expand All @@ -98,7 +93,6 @@ void ErrorCovariance::randomize(Increment & dx) const {


void ErrorCovariance::print(std::ostream & os) const {

os << "ErrorCovariance::print not implemented";
}

Expand Down
40 changes: 15 additions & 25 deletions src/orca-jedi/errorcovariance/ErrorCovariance.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
// Forward declarations
namespace atlas {
class FieldSet;
//class Redistribution;
}

namespace oops {
Expand All @@ -37,37 +36,28 @@ namespace orcamodel {
class Increment;
class State;

// -----------------------------------------------------------------------------
/// Background error covariance matrix for UNIFIEDmodel

/// Background error covariance matrix
class ErrorCovariance : public util::Printable,
private eckit::NonCopyable,
private util::ObjectCounter<ErrorCovariance> {
public:
static const std::string classname() {return "orcamodel::ErrorCovariance";}

ErrorCovariance(const Geometry &, const oops::Variables &,
const eckit::Configuration &, const State &,
const State &);
~ErrorCovariance();
public:
static const std::string classname() {return "orcamodel::ErrorCovariance";}

void linearize(const State &, const Geometry &);
void multiply(const Increment &, Increment &) const;
void inverseMultiply(const Increment &, Increment &) const;
void randomize(Increment &) const;
ErrorCovariance(const Geometry &, const oops::Variables &,
const eckit::Configuration &, const State &, const State &);
~ErrorCovariance();

private:
void print(std::ostream &) const;
std::string covarianceType_; // can be "identity" or "spectral"
std::size_t gaussHaloSize_; // might need to be changed for
// the gauss PE to cover the region
// associated with the regular grid.
std::shared_ptr<const Geometry> geom_;
void linearize(const State &, const Geometry &);
void multiply(const Increment &, Increment &) const;
void inverseMultiply(const Increment &, Increment &) const;
void randomize(Increment &) const;

util::DateTime time_;
//std::unique_ptr<const CovarianceStatistics> cs_;
private:
void print(std::ostream &) const;
std::string covarianceType_; // can be "identity" or "spectral"
std::shared_ptr<const Geometry> geom_;

util::DateTime time_;
};
// -----------------------------------------------------------------------------

} // namespace orcamodel
89 changes: 62 additions & 27 deletions src/orca-jedi/geometry/Geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,42 +20,42 @@

#include "oops/base/Variables.h"
#include "oops/util/DateTime.h"
#include "oops/util/Logger.h"


namespace orcamodel {

const std::vector<std::string> Geometry::surface_names({"iiceconc", "sst"});
const std::vector<std::string> Geometry::depth_names({"votemper"});

oops::Variables orcaVariableFactory(const eckit::Configuration & config) {
eckit::LocalConfiguration nemo_var_mapping;
config.get("nemo names", nemo_var_mapping);
Geometry::Parameters__ params;
params.validateAndDeserialize(config);

std::vector<int> channels{};
std::vector<std::string> names{};
for (std::string std_name : nemo_var_mapping.keys()) {
if (std::find(names.begin(), names.end(), std_name) == names.end()) {
names.push_back(nemo_var_mapping.getString(std_name));
for (const NemoFieldParameters& nemoVariable :
params.nemoFields.value()) {
std::string name = nemoVariable.name.value();
if (std::find(names.begin(), names.end(), name) == names.end()) {
names.push_back(name);
}
}
//return oops::Variables(config, "varnames");

return oops::Variables(names, channels);
}

// -----------------------------------------------------------------------------
Geometry::Geometry(const eckit::Configuration & config,
const eckit::mpi::Comm & comm) :
comm_(comm), vars_(orcaVariableFactory(config)),
grid_(config.getString("grid name")),
const eckit::mpi::Comm & comm) :
comm_(comm), vars_(orcaVariableFactory(config)),
variance_vars_(config, "variance names"),
grid_(config.getString("grid name")),
n_levels_(config.getInt("number levels"))
{

config.get("nemo names", nemo_var_config);
params_.validateAndDeserialize(config);
auto meshgen_config = grid_.meshgenerator();
atlas::MeshGenerator meshgen( meshgen_config );
atlas::MeshGenerator meshgen(meshgen_config);
auto partitioner_config = grid_.partitioner();
partitioner_ = atlas::grid::Partitioner( partitioner_config );
mesh_ = meshgen.generate( grid_, partitioner_.partition( grid_ ) );
partitioner_ = atlas::grid::Partitioner(partitioner_config);
mesh_ = meshgen.generate(grid_, partitioner_.partition(grid_));

funcSpace_ = atlas::functionspace::NodeColumns(
mesh_, atlas::option::halo(0));
Expand All @@ -65,29 +65,49 @@ Geometry::Geometry(const eckit::Configuration & config,
// -----------------------------------------------------------------------------
Geometry::~Geometry() {}

const std::string Geometry::nemo_var_name(const std::string std_name) const {
for (const auto & nemoField : params_.nemoFields.value()) {
if (std_name == nemoField.name.value()) return nemoField.nemoName.value();
}
std::stringstream err_stream;
err_stream << "orcamodel::Geometry::nemo_var_name variable name \" ";
err_stream << "\" " << std_name << " not recognised. " << std::endl;
throw eckit::BadValue(err_stream.str(), Here());
}

// -----------------------------------------------------------------------------
/// \brief Give the number of levels for each provided level - surface variables
/// have 1 level, volumetric variables have "number levels" levels.
/// \param[in] vars variables to check.
/// \return vector of number of levels in each variable.
std::vector<size_t> Geometry::variableSizes(const oops::Variables & vars) const
{
// Number of geoval levels in vars
std::vector<size_t> varSizes(vars.size());
std::fill(varSizes.begin(), varSizes.end(), 0);

for (size_t i=0; i<vars.size(); ++i) {
if (std::find(surface_names.begin(), surface_names.end(), nemo_var_name(vars[i])) != surface_names.end()) {
varSizes[i] = 1;
} else if (std::find(depth_names.begin(), depth_names.end(), nemo_var_name(vars[i])) != depth_names.end()) {
varSizes[i] = n_levels_;
} else {
auto nemoFields = params_.nemoFields.value();

for (size_t i=0; i < vars.size(); ++i) {
for (const auto & nemoField : nemoFields) {
if (nemoField.name.value() == vars[i]) {
if (nemoField.type.value() == "surface") {
varSizes[i] = 1;
} else {
varSizes[i] = n_levels_;
}
}
}
if (varSizes[i] == 0) {
std::stringstream err_stream;
err_stream << "orcamodel::Geometry::variableSizes variable name \" ";
err_stream << "\" " << vars[i] << " not recognised. " << std::endl;
throw eckit::NotImplemented(err_stream.str(), Here());
throw eckit::BadValue(err_stream.str(), Here());
}
}
return varSizes;
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
atlas::FunctionSpace * Geometry::atlasFunctionSpace() const {
std::string err_message =
"orcamodel::Geometry::atlasFunctionSpace Not implemented ";
Expand All @@ -108,9 +128,24 @@ const oops::Variables & Geometry::variables() const {
return vars_;
}

/// \brief Check if a variable's data is a member of a type (e.g if it can be
/// sourced from the background file, variance file, or MDT file).
/// \param[in] variable_name Name of variable.
/// \param[in] variable_type Type of variable.
/// \return Boolean for membership.
const bool Geometry::variable_in_variable_type(std::string variable_name,
std::string variable_type) const {
bool is_bkg_var = variance_vars_.has(variable_name);
if (variable_type == "background variance") {
return is_bkg_var;
} else {
return !is_bkg_var;
}
}

void Geometry::print(std::ostream & os) const {
os << "Not Implemented";
}


}
} // namespace orcamodel
Loading

0 comments on commit a81fd17

Please sign in to comment.