20 #include "eckit/config/LocalConfiguration.h"
21 #include "eckit/config/YAMLConfiguration.h"
22 #include "eckit/filesystem/PathName.h"
27 #include "ioda/config.h"
30 #include "odc/api/odc.h"
41 "The ODB / ODC engine is disabled. odc was "
42 "not found at compile time."};
45 void initODC() {
static bool inited =
false;
69 eckit::YAMLConfiguration conf(eckit::PathName(odcparams.
queryFile));
71 queryParameters.validateAndDeserialize(conf);
73 vector<std::string> columns = {
"lat",
"lon",
"date",
"time",
"seqno",
"varno",
"ops_obsgroup",
"vertco_type",
"initial_obsvalue"};
75 columns.push_back(varParameters.name);
77 std::sort(columns.begin(), columns.end());
78 auto last = std::unique(columns.begin(), columns.end());
79 columns.erase(last, columns.end());
82 const vector<int> &varnos = queryParameters.
where.value().varno.value().as<std::vector<int>>();
87 const int num_rows = sql_data.numberOfMetadataRows();
88 if (num_rows <= 0)
return storageGroup;
92 std::vector<std::string> ignores;
93 ignores.push_back(
"nlocs");
94 ignores.push_back(
"MetaData/datetime");
95 ignores.push_back(
"MetaData/receiptdatetime");
96 ignores.push_back(
"nchans");
110 v =
og.vars.createWithScales<std::string>(
111 "MetaData/datetime", {
og.vars[
"nlocs"]},
params);
112 v.
write(sql_data.getDates(
"date",
"time"));
113 v =
og.vars.createWithScales<std::string>(
114 "MetaData/receiptdatetime", {
og.vars[
"nlocs"]},
params);
115 v.
write(sql_data.getDates(
"receipt_date",
"receipt_time"));
117 auto groups =
og.listObjects();
119 auto sqlColumns = sql_data.getColumns();
120 for (
int i = 0; i < sqlColumns.size(); i++) {
121 const set<string> ignoredNames{
"initial_obsvalue",
122 "initial_vertco_reference",
133 if (ignoredNames.count(sqlColumns.at(i)))
continue;
134 sql_data.getIodaVariable(sqlColumns.at(i),
og,
params);
137 groups =
og.listObjects();
138 for (
int i = 0; i < varnos.size(); i++) {
141 sql_data.getIodaObsvalue(varnos.at(i),
og,
params);
145 sql_data.getIodaObsvalue(varnos.at(i),
og,
params);
148 sql_data.getIodaObsvalue(varnos.at(i),
og,
params);
Interfaces for ioda::Group and related classes.
void select(const std::vector< std::string > &columns, const std::string &filename, const std::vector< int > &varnos, const std::string &query)
Populate structure with data from specified columns, file and varnos.
oops::Parameter< std::vector< OdbVariableParameters > > variables
Variables to select.
oops::RequiredParameter< OdbWhereParameters > where
Selection criteria.
The ioda exception class.
Groups are a new implementation of ObsSpaces.
An ObsGroup is a specialization of a ioda::Group. It provides convenience functions and guarantees th...
static ObsGroup generate(Group &emptyGroup, const NewDimensionScales_t &fundamentalDims, std::shared_ptr< const detail::DataLayoutPolicy > layout=nullptr)
Create an empty ObsGroup and populate it with the fundamental dimensions.
static std::shared_ptr< const DataLayoutPolicy > generate(const std::string &polid="")
Factory generator.
virtual Variable write(gsl::span< char > data, const Type &in_memory_dataType, const Selection &mem_selection=Selection::all, const Selection &file_selection=Selection::all)
The fundamental write function. Backends overload this function to implement all write operations.
IODA_DL ObsGroup openFile(const ODC_Parameters ¶ms, Group emptyStorageGroup=ioda::Engines::ObsStore::createRootGroup())
Import an ODB file.
const char odcMissingMessage[]
Standard message when the ODC API is unavailable.
void initODC()
Function initializes the ODC API, just once.
static constexpr int varno_rawbt_mwts
static constexpr int obsgroup_mwsfy3
static constexpr int obsgroup_amsr
static constexpr int varno_rawbt
std::vector< std::shared_ptr< NewDimensionScale_Base > > NewDimensionScales_t
Encapsulate the parameters to make calling simpler.
std::string filename
The name of the database "file" to open.
Used to specify Variable creation-time properties.