IODA Bundle
ArrayDataObject.cpp
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2020 NOAA/NWS/NCEP/EMC
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  */
7 
8 #include <iostream>
9 
10 #include "ArrayDataObject.h"
11 
12 namespace Ingester
13 {
15  eigArray_(eigArray)
16  {
17  }
18 
20  const std::string& name,
21  const std::vector<ioda::Variable>& dimensions,
22  const std::vector<ioda::Dimensions_t>& chunks,
23  int compressionLevel)
24  {
25  auto params = makeCreationParams(chunks, compressionLevel);
26  auto var = obsGroup.vars.createWithScales<FloatType>(name, dimensions, params);
28  return var;
29  }
30 
32  {
33  std::cout << eigArray_ << std::endl;
34  }
35 
36  size_t ArrayDataObject::nrows() const
37  {
38  return eigArray_.rows();
39  }
40 
41  size_t ArrayDataObject::ncols() const
42  {
43  return eigArray_.cols();
44  }
45 
47  const std::vector<ioda::Dimensions_t>& chunks,
48  int compressionLevel)
49  {
51  params.chunk = true;
52  params.chunks = chunks;
53  params.compressWithGZIP(compressionLevel);
54  params.setFillValue<FloatType>(-999);
55 
56  return params;
57  }
58 
59 } // namespace Ingester
static ioda::VariableCreationParameters makeCreationParams(const std::vector< ioda::Dimensions_t > &chunks, int compressionLevel)
Create an ioda::VariableCreationParameters for the data.
ArrayDataObject(const IngesterArray &eigArray)
size_t nrows() const final
Get number of rows represented in the data.
ioda::Variable createVariable(ioda::ObsGroup &obsGroup, const std::string &name, const std::vector< ioda::Variable > &dimensions, const std::vector< ioda::Dimensions_t > &chunks, int compressionLevel) final
Makes an ioda::Variable and ads it to the given ioda::ObsGroup.
void print() const final
Print data to stdout for debug purposes.
size_t ncols() const final
Get number of columns represented in the data.
const IngesterArray eigArray_
Eigen Array that holds the data.
An ObsGroup is a specialization of a ioda::Group. It provides convenience functions and guarantees th...
Definition: ObsGroup.h:32
Has_Variables vars
Use this to access variables.
Definition: Group.h:123
Variable createWithScales(const std::string &name, const std::vector< Variable > &dimension_scales, const VariableCreationParameters &params=VariableCreationParameters::defaulted< DataType >())
Convenience function to create a Variable from certain dimension scales.
Variable_Implementation writeWithEigenRegular(const EigenClass &d, const Selection &mem_selection=Selection::all, const Selection &file_selection=Selection::all)
Write an Eigen object (a Matrix, an Array, a Block, a Map).
Eigen::Array< FloatType, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > IngesterArray
Definition: IngesterTypes.h:19
float FloatType
Definition: IngesterTypes.h:18
Used to specify Variable creation-time properties.
Definition: Has_Variables.h:57