18 #include "atlas/array.h"
19 #include "atlas/field.h"
20 #include "eckit/config/Configuration.h"
21 #include "eckit/exception/Exceptions.h"
22 #include "eckit/geometry/Sphere.h"
24 #include "oops/util/abor1_cpp.h"
25 #include "oops/util/DateTime.h"
26 #include "oops/util/Duration.h"
27 #include "oops/util/Logger.h"
29 using atlas::array::make_view;
40 const util::DateTime & bgn,
const util::DateTime & end,
41 const eckit::mpi::Comm & timeComm)
42 :
oops::ObsSpaceBase(params, comm, bgn, end), obsname_(params.obsType),
43 winbgn_(bgn), winend_(end), obsvars_()
45 typedef std::map< std::string, F90odb >::iterator otiter;
47 eckit::LocalConfiguration fileconf = params.toConfiguration();
48 std::string ofin(
"-");
49 if (params.
obsdatain.value() != boost::none) {
52 std::string ofout(
"-");
53 if (params.
obsdataout.value() != boost::none) {
55 if (timeComm.size() > 1) {
56 std::ostringstream ss;
57 ss <<
"_" << timeComm.rank();
58 std::size_t found = ofout.find_last_of(
".");
59 if (found == std::string::npos) found = ofout.length();
60 std::string fileout = ofout.insert(found, ss.str());
61 fileconf.set(
"obsdataout.obsfile", fileout);
64 oops::Log::trace() <<
"ObsSpaceQG: Obs files are: " << ofin <<
" and " << ofout << std::endl;
65 std::string ref = ofin + ofout;
67 ABORT(
"Underspecified observation files.");
70 ref = ref + bgn.toString() +
end.toString();
74 oops::Log::trace() <<
"ObsSpaceQG::getHelper: " <<
"Opening " << ref << std::endl;
79 oops::Log::trace() <<
"ObsSpaceQG::getHelper: " << ref <<
" already opened." << std::endl;
93 if (params.
generate.value() != boost::none) {
95 const util::Duration first(gParams.
begin);
96 const util::DateTime start(
winbgn_ + first);
97 const util::Duration freq(gParams.
obsPeriod);
99 util::DateTime now(start);
106 start, freq, nobstimes, iobs);
140 atlas::FieldSet fields;
141 std::vector<util::DateTime> times;
143 return std::unique_ptr<LocationsQG>(
new LocationsQG(fields, std::move(times)));
166 os <<
"ObsSpace for " <<
obsname_ <<
", " << this->
nobs() <<
" obs";
void push_back(const std::string &)
LocationsQG class to handle locations for QG model.
Options controlling generation of artificial observations.
oops::RequiredParameter< util::Duration > obsPeriod
oops::RequiredParameter< util::Duration > begin
Iterator over all observations.
void print(std::ostream &) const
const std::string obsname_
const util::DateTime winend_
const util::DateTime winbgn_
void getdb(const std::string &, int &) const
read data or metadata
static int theObsFileCount_
std::unique_ptr< LocationsQG > locations() const
create locations for the whole time window
ObsIteratorQG end() const
iterator to the observation past-the-last
void putdb(const std::string &, const int &) const
save data or metadata
void save() const
save and close file
ObsIteratorQG begin() const
iterator to the first observation
ObsSpaceQG(const Parameters_ &, const eckit::mpi::Comm &, const util::DateTime &, const util::DateTime &, const eckit::mpi::Comm &)
create full ObsSpace (read or generate data)
static std::map< std::string, F90odb > theObsFileRegister_
int nobs() const
return number of observations (unique locations)
Configuration parameters for the QG model's ObsSpace.
oops::OptionalParameter< ObsDataParameters > obsdataout
File to which to save observations and analysis.
oops::OptionalParameter< ObsDataParameters > obsdatain
File from which to load observations.
oops::OptionalParameter< ObsGenerateParameters > generate
Options controlling generation of artificial observations.
The namespace for the main oops code.
The namespace for the qg model.
void qg_obsdb_put_f90(const F90odb &, const int &, const char *, const int &, const char *, const F90ovec &)
void qg_obsdb_get_f90(const F90odb &, const int &, const char *, const int &, const char *, const F90ovec &)
void qg_obsdb_delete_f90(F90odb &)
void qg_obsdb_setup_f90(F90odb &, const eckit::Configuration &, const util::DateTime &, const util::DateTime &)
void qg_obsdb_generate_f90(const F90odb &, const int &, const char *, const eckit::Configuration &, const util::DateTime &, const util::Duration &, const int &, int &)
void qg_obsdb_nobs_f90(const F90odb &, const int &, const char *, int &)
void qg_obsdb_locations_f90(const F90odb &, const int &, const char *, atlas::field::FieldSetImpl *, std::vector< util::DateTime > &)