8 #include "oops/util/abor1_cpp.h" 
   10 #include "ioda/core/IodaUtils.h" 
   12 #include "ioda/io/ObsFrame.h" 
   21       params_(
params), gnlocs_(0), gnlocs_outside_timewindow_(0) {
 
   22     oops::Log::trace() << 
"Constructing ObsFrame" << std::endl;
 
   27                                            const Dimensions_t frameCount) {
 
   33     std::vector<Dimensions_t> memShape = varShape;
 
   38     Dimensions_t numElements = std::accumulate(
 
   39         memShape.begin(), memShape.end(), 1, std::multiplies<Dimensions_t>());
 
   41     std::vector<Dimensions_t> memStarts(1, 0);
 
   42     std::vector<Dimensions_t> memCounts(1, numElements);
 
   50                                                    const Dimensions_t frameCount) {
 
   53     std::vector<Dimensions_t> entireFrameCounts = varShape;
 
   59     std::vector<Dimensions_t> frameVarShape = varShape;
 
   64     std::vector<Dimensions_t> entireFrameStarts(entireFrameCounts.size(), 0);
 
   66     entireFrameSelect.
extent(frameVarShape)
 
   68     return entireFrameSelect;
 
   73                                        const Dimensions_t frameStart,
 
   74                                        const Dimensions_t frameCount) {
 
   77     std::vector<Dimensions_t> varCounts = varShape;
 
   82     std::vector<Dimensions_t> varStarts(varCounts.size(), 0);
 
   92                                              const Dimensions_t frameStart,
 
   93                                              const Dimensions_t frameCount) {
 
   96     std::vector<Dimensions_t> obsIoCounts = varShape;
 
  101     std::vector<Dimensions_t> obsIoStarts(obsIoCounts.size(), 0);
 
  119     backendParams.
flush = 
false;
 
  126     for (
auto & dimNameObject : dimVarList) {
 
  127         std::string dimName = dimNameObject.first;
 
  128         Variable srcDimVar = dimNameObject.second;
 
  133         if (dimName != 
"nchans") {
 
  138         Dimensions_t maxDimSize = dimSize;
 
  139         Dimensions_t chunkSize = dimSize;
 
  141         if (srcDimVar.
isA<
int>()) {
 
  143                 ioda::NewDimensionScale<int>(
 
  144                     dimName, dimSize, maxDimSize, chunkSize));
 
  145         } 
else if (srcDimVar.
isA<
float>()) {
 
  147                 ioda::NewDimensionScale<float>(
 
  148                     dimName, dimSize, maxDimSize, chunkSize));
 
  154     for (
auto & dimVarNameObject : dimVarList) {
 
  155         std::string dimVarName = dimVarNameObject.first;
 
  156         Variable srcDimVar = dimVarNameObject.second;
 
  171             if (srcDimVar.
isA<
int>()) {
 
  172                 std::vector<int> dimCoords;
 
  173                 srcDimVar.
read<
int>(dimCoords, memSelect, srcSelect);
 
  174                 destDimVar.
write<
int>(dimCoords, memSelect, destSelect);
 
  175             } 
else if (srcDimVar.
isA<
float>()) {
 
  176                 std::vector<float> dimCoords;
 
  177                 srcDimVar.
read<
float>(dimCoords, memSelect, srcSelect);
 
  178                 destDimVar.
write<
float>(dimCoords, memSelect, destSelect);
 
  184     for (
auto & varNameObject : varList) {
 
  185         std::string varName = varNameObject.first;
 
  188         std::vector<std::string> dimVarNames = varDimMap.at(varName);
 
  189         std::vector<Variable> dimVars;
 
  190         for (
auto & dimVarName : dimVarNames) {
 
  194         Variable sourceVar = varNameObject.second;
 
  195         if (sourceVar.
isA<
int>()) {
 
  199                 params.setFillValue<
int>(ioda::detail::getFillValue<int>(varFillValue));
 
  202         } 
else if (sourceVar.
isA<
float>()) {
 
  206                 params.setFillValue<
float>(ioda::detail::getFillValue<float>(varFillValue));
 
  209         } 
else if (sourceVar.
isA<std::string>()) {
 
  213                 params.setFillValue<std::string>(
 
  214                     ioda::detail::getFillValue<std::string>(varFillValue));
 
Contains definitions for how data are arranged in ioda internally.
 
Interfaces  for ioda::Variable and related classes.
 
Groups are a new implementation of ObsSpaces.
 
Selection createMemSelection(const std::vector< Dimensions_t > &varShape, const Dimensions_t frameCount)
create selection object for accessing a memory buffer
 
void createFrameFromObsGroup(const VarNameObjectList &varList, const VarNameObjectList &dimVarList, const VarDimMap &varDimMap)
create a frame object based on dimensions and variables from a source ObsGroup
 
Dimensions_t max_frame_size_
maximum frame size
 
virtual Dimensions_t frameCount(const std::string &varName)=0
return current frame count for variable
 
Selection createEntireFrameSelection(const std::vector< Dimensions_t > &varShape, const Dimensions_t frameCount)
create selection object for accessing the entire frame variable
 
Selection createVarSelection(const std::vector< Dimensions_t > &varShape, const Dimensions_t frameStart, const Dimensions_t frameCount)
create selection object for accessing a frame from a whole variable
 
Selection createObsIoSelection(const std::vector< Dimensions_t > &varShape, const Dimensions_t frameStart, const Dimensions_t frameCount)
create selection object for accessing an ObsIo variable
 
ObsFrame(const ObsSpaceParameters ¶ms)
 
virtual Dimensions_t frameStart()=0
return current frame starting index
 
ObsGroup obs_frame_
ObsGroup object (temporary storage for a single frame)
 
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.
 
A Selection represents the bounds of the data, in ioda or in userspace, that you are reading or writi...
 
Has_Variables vars
Use this to access variables.
 
Variable createWithScales(const std::string &name, const std::vector< Variable > &dimension_scales, const VariableCreationParameters ¶ms=VariableCreationParameters::defaulted< DataType >())
Convenience function to create a Variable from certain dimension scales.
 
virtual Variable open(const std::string &name) const
Open a Variable by name.
 
virtual FillValueData_t getFillValue() const
Retrieve the fill value.
 
bool isA() const
Convenience function to check a Variable's storage type.
 
virtual bool hasFillValue() const
Check if a variable has a fill value set.
 
virtual Dimensions getDimensions() const
 
virtual Variable read(gsl::span< char > data, const Type &in_memory_dataType, const Selection &mem_selection=Selection::all, const Selection &file_selection=Selection::all) const
Read the Variable - as char array. Ordering is row-major.
 
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 std::string genUniqueName()
Convenience function to generate a random file name.
 
BackendNames
Backend names.
 
IODA_DL Group constructBackend(BackendNames name, BackendCreationParameters ¶ms)
This is a simple factory style function that will instantiate a different backend based on a given na...
 
@ Create
Create a new file.
 
@ ObsStore
ObsStore in-memory.
 
@ Truncate_If_Exists
If the file already exists, overwrite it.
 
Selection & extent(const VecDimensions_t &sz)
Provide the dimensions of the object that you are selecting from.
 
Selection & select(const SingleSelection &s)
Append a new selection.
 
std::vector< std::pair< std::string, Variable > > VarNameObjectList
typedef for holding list of variable names with associated variable object
 
std::vector< std::shared_ptr< NewDimensionScale_Base > > NewDimensionScales_t
 
std::map< std::string, std::vector< std::string > > VarDimMap
typedef for holding dim names attached to variables
 
std::vector< Dimensions_t > dimsCur
The dimensions of the data.
 
Used to specify backend creation-time properties.
 
BackendFileActions action
 
BackendCreateModes createMode
 
Used to specify Variable creation-time properties.