IODA
|
File access class for IODA. More...
#include <IodaIO.h>
Classes | |
struct | DimInfoRec |
struct | FrameInfoRec |
struct | VarInfoRec |
Public Types | |
typedef GroupVarInfoMap::const_iterator | GroupIter |
group-variable map, group iterator More... | |
typedef VarInfoMap::const_iterator | VarIter |
group-variable map, variable iterator More... | |
typedef DimInfoMap::const_iterator | DimIter |
typedef FrameInfo::const_iterator | FrameIter |
typedef FrameDataMap< int >::FrameStoreIter | FrameIntIter |
typedef FrameDataMap< float >::FrameStoreIter | FrameFloatIter |
typedef FrameDataMap< std::string >::FrameStoreIter | FrameStringIter |
Public Member Functions | |
IodaIO (const std::string &FileName, const std::string &FileMode, const std::size_t MaxFrameSize) | |
virtual | ~IodaIO ()=0 |
std::string | fname () const |
std::string | fmode () const |
std::size_t | nlocs () const |
std::size_t | nvars () const |
bool | unexpected_data_types () const |
bool | excess_dims () const |
GroupIter | group_begin () |
GroupIter | group_end () |
std::string | group_name (GroupIter) |
VarIter | var_begin (GroupIter) |
VarIter | var_end (GroupIter) |
std::string | var_name (VarIter) |
bool | grp_var_exists (const std::string &, const std::string &) |
std::string | var_dtype (VarIter) |
std::string | var_dtype (const std::string &, const std::string &) |
std::vector< std::size_t > | var_shape (VarIter) |
std::vector< std::size_t > | var_shape (const std::string &, const std::string &) |
std::vector< std::size_t > | file_shape (VarIter) |
std::vector< std::size_t > | file_shape (const std::string &, const std::string &) |
std::string | file_name (VarIter) |
std::string | file_name (const std::string &, const std::string &) |
std::string | file_type (VarIter) |
std::string | file_type (const std::string &, const std::string &) |
std::size_t | var_id (VarIter) |
std::size_t | var_id (const std::string &, const std::string &) |
void | grp_var_insert (const std::string &GroupName, const std::string &VarName, const std::string &VarType, const std::vector< std::size_t > &VarShape, const std::string &FileVarName, const std::string &FileType, const std::size_t MaxStringSize=0) |
DimIter | dim_begin () |
DimIter | dim_end () |
bool | dim_exists (const std::string &) |
std::string | dim_name (DimIter) |
int | dim_id (DimIter) |
std::size_t | dim_size (DimIter) |
std::size_t | dim_id_size (const int &) |
std::string | dim_id_name (const int &) |
std::size_t | dim_name_size (const std::string &) |
int | dim_name_id (const std::string &) |
void | dim_insert (const std::string &, const std::size_t) |
FrameIter | frame_begin () |
beginning frame iterator More... | |
FrameIter | frame_end () |
ending frame iterator More... | |
void | frame_initialize () |
initialize frame access More... | |
void | frame_finalize () |
finalize frame access More... | |
std::size_t | frame_start (FrameIter &) |
start value of current frame More... | |
std::size_t | frame_size (FrameIter &) |
size value of current frame More... | |
void | frame_info_init (std::size_t MaxVarSize) |
initialize the frame info container More... | |
void | frame_info_insert (std::size_t Start, std::size_t Size) |
insert item into the frame info container More... | |
void | frame_data_init () |
initialize the frame data container More... | |
void | frame_read (FrameIter &) |
read from the file into the frame containers More... | |
void | frame_write (FrameIter &) |
write from the frame containers into the file More... | |
FrameIntIter | frame_int_begin () |
FrameIntIter | frame_int_end () |
bool | frame_int_has (std::string &GroupName, std::string &VarName) |
std::vector< int > | frame_int_get_data (FrameIntIter &iframe) |
std::string | frame_int_get_gname (FrameIntIter &iframe) |
std::string | frame_int_get_vname (FrameIntIter &iframe) |
void | frame_int_get_data (std::string &GroupName, std::string &VarName, std::vector< int > &VarData) |
void | frame_int_put_data (std::string &GroupName, std::string &VarName, std::vector< int > &VarData) |
FrameFloatIter | frame_float_begin () |
FrameFloatIter | frame_float_end () |
bool | frame_float_has (std::string &GroupName, std::string &VarName) |
std::vector< float > | frame_float_get_data (FrameFloatIter &iframe) |
std::string | frame_float_get_gname (FrameFloatIter &iframe) |
std::string | frame_float_get_vname (FrameFloatIter &iframe) |
void | frame_float_get_data (std::string &GroupName, std::string &VarName, std::vector< float > &VarData) |
void | frame_float_put_data (std::string &GroupName, std::string &VarName, std::vector< float > &VarData) |
FrameStringIter | frame_string_begin () |
FrameStringIter | frame_string_end () |
bool | frame_string_has (std::string &GroupName, std::string &VarName) |
std::vector< std::string > | frame_string_get_data (FrameStringIter &iframe) |
std::string | frame_string_get_gname (FrameStringIter &iframe) |
std::string | frame_string_get_vname (FrameStringIter &iframe) |
void | frame_string_get_data (std::string &GroupName, std::string &VarName, std::vector< std::string > &VarData) |
void | frame_string_put_data (std::string &GroupName, std::string &VarName, std::vector< std::string > &VarData) |
Static Public Member Functions | |
static void | ExtractGrpVarName (const std::string &Name, std::string &GroupName, std::string &VarName) |
Protected Types | |
typedef std::map< std::string, VarInfoRec > | VarInfoMap |
variable information map More... | |
typedef std::map< std::string, VarInfoMap > | GroupVarInfoMap |
group-variable information map More... | |
typedef std::map< std::string, DimInfoRec > | DimInfoMap |
dimension information map More... | |
typedef std::vector< FrameInfoRec > | FrameInfo |
frame information map More... | |
Protected Member Functions | |
virtual void | DimInsert (const std::string &Name, const std::size_t Size)=0 |
virtual void | InitializeFrame ()=0 |
virtual void | FinalizeFrame ()=0 |
virtual void | ReadFrame (IodaIO::FrameIter &iframe)=0 |
virtual void | WriteFrame (IodaIO::FrameIter &iframe)=0 |
virtual void | GrpVarInsert (const std::string &GroupName, const std::string &VarName, const std::string &VarType, const std::vector< std::size_t > &VarShape, const std::string &FileVarName, const std::string &FileType, const std::size_t MaxStringSize)=0 |
Protected Attributes | |
std::string | fname_ |
file name More... | |
std::string | fmode_ |
file mode More... | |
std::size_t | nlocs_ |
number of unique locations More... | |
std::size_t | nvars_ |
number of unique variables More... | |
std::size_t | num_unexpect_dtypes_ |
count of unexpected data types More... | |
std::size_t | num_excess_dims_ |
count of too many dimensions More... | |
GroupVarInfoMap | grp_var_info_ |
group-variable information map More... | |
DimInfoMap | dim_info_ |
dimension information map More... | |
FrameInfo | frame_info_ |
frame information vector More... | |
std::size_t | max_frame_size_ |
maximum frame size More... | |
std::unique_ptr< FrameDataMap< int > > | int_frame_data_ |
Containers for file frame. More... | |
std::unique_ptr< FrameDataMap< float > > | float_frame_data_ |
std::unique_ptr< FrameDataMap< std::string > > | string_frame_data_ |
File access class for IODA.
The IodaIO class provides the interface for file access. Note that IodaIO is an abstract base class.
There are two dimensions defined in the file:
nlocs: number of locations nvars: number of variables
Files are logically organized as a 2D array (table) where the rows are locations (nlocs) and the columns are variables (nvars). To avoid reading in the entire file into a table, and then selecting observations, the selection process is done on the fly. The table in the file is partitioned into "frames" where a frame is cut along a row. For example, the first frame consists of the first n rows; the second frame, the next n rows; etc.
The frame idea is taken from ODB file organization. It is possible to treat a netcdf file as consisting of frames using the netcdf hyperslab access scheme. Treating both ODB and netcdf files as sets of frames allows IodaIO to remain file agnostic, making it easier to handle both ODB and netcdf files.
Missing values are allowed for variable data. The native scheme for each file type is recognized and when reading/writing file data, the missing values are converted to the JEDI in-memory missing values. This again aids in keeping IodaIO file agnostic.
IodaIO provides access to files via a frame object. The idea, when reading, is to iterate over frames where the first action of each iteration is to read the frame from the file (frame_read method) then walk through the frame to read the individual variable data values (for that frame). Similarly, when writing, the first action is to fill in a frame object with the individual variable values (for that frame) and then write that frame to the file (frame_write method). For details see the code examples in the test_ioda_io test and the ObsData class methods InitFromFile and SaveToFile.
Definition at line 116 of file src/io/IodaIO.h.
|
protected |
dimension information map
This typedef is dimension information map which containes information about the dimensions of the variables.
Definition at line 171 of file src/io/IodaIO.h.
typedef DimInfoMap::const_iterator ioda::IodaIO::DimIter |
Definition at line 256 of file src/io/IodaIO.h.
typedef FrameDataMap<float>::FrameStoreIter ioda::IodaIO::FrameFloatIter |
Definition at line 316 of file src/io/IodaIO.h.
|
protected |
frame information map
This typedef contains information about the frames in the file
Definition at line 188 of file src/io/IodaIO.h.
typedef FrameDataMap<int>::FrameStoreIter ioda::IodaIO::FrameIntIter |
Definition at line 291 of file src/io/IodaIO.h.
typedef FrameInfo::const_iterator ioda::IodaIO::FrameIter |
Definition at line 275 of file src/io/IodaIO.h.
typedef FrameDataMap<std::string>::FrameStoreIter ioda::IodaIO::FrameStringIter |
Definition at line 341 of file src/io/IodaIO.h.
typedef GroupVarInfoMap::const_iterator ioda::IodaIO::GroupIter |
group-variable map, group iterator
This typedef is defining the iterator for the group key in the group-variable map. See the GrpVarInfoMap typedef for details.
Definition at line 218 of file src/io/IodaIO.h.
|
protected |
group-variable information map
This typedef is defining the group-variable map which is a nested map containing information about the variables in the input file. This map is keyed first by group name, then by variable name and is used to pass information to the caller so that the caller can iterate through the contents of the input file.
Definition at line 157 of file src/io/IodaIO.h.
|
protected |
variable information map
This typedef is part of the group-variable map which is a nested map containing information about the variables in the input file (see GroupVarInfoMap typedef for details).
Definition at line 146 of file src/io/IodaIO.h.
typedef VarInfoMap::const_iterator ioda::IodaIO::VarIter |
group-variable map, variable iterator
This typedef is defining the iterator for the variable key in the group-variable map. See the GrpVarInfoMap typedef for details.
Definition at line 230 of file src/io/IodaIO.h.
ioda::IodaIO::IodaIO | ( | const std::string & | FileName, |
const std::string & | FileMode, | ||
const std::size_t | MaxFrameSize | ||
) |
IodaIO::DimIter ioda::IodaIO::dim_begin | ( | ) |
IodaIO::DimIter ioda::IodaIO::dim_end | ( | ) |
bool ioda::IodaIO::dim_exists | ( | const std::string & | name | ) |
int ioda::IodaIO::dim_id | ( | IodaIO::DimIter | idim | ) |
std::string ioda::IodaIO::dim_id_name | ( | const int & | id | ) |
std::size_t ioda::IodaIO::dim_id_size | ( | const int & | id | ) |
void ioda::IodaIO::dim_insert | ( | const std::string & | Name, |
const std::size_t | Size | ||
) |
std::string ioda::IodaIO::dim_name | ( | IodaIO::DimIter | idim | ) |
int ioda::IodaIO::dim_name_id | ( | const std::string & | name | ) |
std::size_t ioda::IodaIO::dim_name_size | ( | const std::string & | name | ) |
std::size_t ioda::IodaIO::dim_size | ( | IodaIO::DimIter | idim | ) |
|
protectedpure virtual |
bool ioda::IodaIO::excess_dims | ( | ) | const |
|
static |
This method extracts the group and variable names from the given compound name.
[in] | Name | Compound name (eg, Temperature@ObsValue) |
[out] | GroupName | Group name (eg, ObsValue) |
[out] | VarName | Variable name (eg, Temperature) |
Definition at line 678 of file IodaIO.cc.
std::string ioda::IodaIO::file_name | ( | const std::string & | GroupName, |
const std::string & | VarName | ||
) |
This method returns the variable name in the file for the group name, variable name combination in the group, variable information map.
[in] | GroupName | Group key for GrpVarInfoMap |
[in] | VarName | Variable key for GrpVarInfoMap |
Definition at line 307 of file IodaIO.cc.
std::string ioda::IodaIO::file_name | ( | IodaIO::VarIter | ivar | ) |
std::vector< std::size_t > ioda::IodaIO::file_shape | ( | const std::string & | GroupName, |
const std::string & | VarName | ||
) |
This method returns the variable shape in the file for the group name, variable name combination in the group, variable information map.
[in] | GroupName | Group key for GrpVarInfoMap |
[in] | VarName | Variable key for GrpVarInfoMap |
Definition at line 273 of file IodaIO.cc.
std::vector< std::size_t > ioda::IodaIO::file_shape | ( | IodaIO::VarIter | ivar | ) |
std::string ioda::IodaIO::file_type | ( | const std::string & | GroupName, |
const std::string & | VarName | ||
) |
This method returns the variable type in the file for the group name, variable name combination in the group, variable information map.
[in] | GroupName | Group key for GrpVarInfoMap |
[in] | VarName | Variable key for GrpVarInfoMap |
Definition at line 340 of file IodaIO.cc.
std::string ioda::IodaIO::file_type | ( | IodaIO::VarIter | ivar | ) |
|
protectedpure virtual |
std::string ioda::IodaIO::fmode | ( | ) | const |
std::string ioda::IodaIO::fname | ( | ) | const |
IodaIO::FrameIter ioda::IodaIO::frame_begin | ( | ) |
void ioda::IodaIO::frame_data_init | ( | ) |
IodaIO::FrameIter ioda::IodaIO::frame_end | ( | ) |
void ioda::IodaIO::frame_finalize | ( | ) |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 331 of file src/io/IodaIO.h.
|
inline |
|
inline |
|
inline |
Definition at line 319 of file src/io/IodaIO.h.
|
inline |
Definition at line 335 of file src/io/IodaIO.h.
void ioda::IodaIO::frame_info_init | ( | std::size_t | MaxVarSize | ) |
void ioda::IodaIO::frame_info_insert | ( | std::size_t | Start, |
std::size_t | Size | ||
) |
void ioda::IodaIO::frame_initialize | ( | ) |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 306 of file src/io/IodaIO.h.
|
inline |
|
inline |
|
inline |
Definition at line 294 of file src/io/IodaIO.h.
|
inline |
Definition at line 310 of file src/io/IodaIO.h.
void ioda::IodaIO::frame_read | ( | IodaIO::FrameIter & | iframe | ) |
std::size_t ioda::IodaIO::frame_size | ( | IodaIO::FrameIter & | iframe | ) |
std::size_t ioda::IodaIO::frame_start | ( | IodaIO::FrameIter & | iframe | ) |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 356 of file src/io/IodaIO.h.
|
inline |
|
inline |
|
inline |
Definition at line 344 of file src/io/IodaIO.h.
|
inline |
Definition at line 360 of file src/io/IodaIO.h.
void ioda::IodaIO::frame_write | ( | IodaIO::FrameIter & | iframe | ) |
IodaIO::GroupIter ioda::IodaIO::group_begin | ( | ) |
IodaIO::GroupIter ioda::IodaIO::group_end | ( | ) |
std::string ioda::IodaIO::group_name | ( | IodaIO::GroupIter | igrp | ) |
bool ioda::IodaIO::grp_var_exists | ( | const std::string & | GroupName, |
const std::string & | VarName | ||
) |
void ioda::IodaIO::grp_var_insert | ( | const std::string & | GroupName, |
const std::string & | VarName, | ||
const std::string & | VarType, | ||
const std::vector< std::size_t > & | VarShape, | ||
const std::string & | FileVarName, | ||
const std::string & | FileType, | ||
const std::size_t | MaxStringSize = 0 |
||
) |
|
protectedpure virtual |
|
protectedpure virtual |
std::size_t ioda::IodaIO::nlocs | ( | ) | const |
std::size_t ioda::IodaIO::nvars | ( | ) | const |
|
protectedpure virtual |
bool ioda::IodaIO::unexpected_data_types | ( | ) | const |
IodaIO::VarIter ioda::IodaIO::var_begin | ( | GroupIter | igrp | ) |
std::string ioda::IodaIO::var_dtype | ( | const std::string & | GroupName, |
const std::string & | VarName | ||
) |
This method returns the variable data type for the group name, variable name combination in the group, variable information map.
[in] | GroupName | Group key for GrpVarInfoMap |
[in] | VarName | Variable key for GrpVarInfoMap |
Definition at line 206 of file IodaIO.cc.
std::string ioda::IodaIO::var_dtype | ( | IodaIO::VarIter | ivar | ) |
IodaIO::VarIter ioda::IodaIO::var_end | ( | GroupIter | igrp | ) |
std::size_t ioda::IodaIO::var_id | ( | const std::string & | GroupName, |
const std::string & | VarName | ||
) |
std::size_t ioda::IodaIO::var_id | ( | IodaIO::VarIter | ivar | ) |
std::string ioda::IodaIO::var_name | ( | IodaIO::VarIter | ivar | ) |
std::vector< std::size_t > ioda::IodaIO::var_shape | ( | const std::string & | GroupName, |
const std::string & | VarName | ||
) |
This method returns the variable shape for the group name, variable name combination in the group, variable information map.
[in] | GroupName | Group key for GrpVarInfoMap |
[in] | VarName | Variable key for GrpVarInfoMap |
Definition at line 239 of file IodaIO.cc.
std::vector< std::size_t > ioda::IodaIO::var_shape | ( | IodaIO::VarIter | ivar | ) |
|
protectedpure virtual |
|
protected |
dimension information map
Definition at line 409 of file src/io/IodaIO.h.
|
protected |
Definition at line 419 of file src/io/IodaIO.h.
|
protected |
file mode
File modes that are accepted are: "r" -> read, "w" -> overwrite, and "W" -> create and write.
Definition at line 391 of file src/io/IodaIO.h.
|
protected |
file name
Definition at line 383 of file src/io/IodaIO.h.
|
protected |
frame information vector
Definition at line 412 of file src/io/IodaIO.h.
|
protected |
group-variable information map
Definition at line 406 of file src/io/IodaIO.h.
|
protected |
Containers for file frame.
Definition at line 418 of file src/io/IodaIO.h.
|
protected |
maximum frame size
Definition at line 415 of file src/io/IodaIO.h.
|
protected |
number of unique locations
Definition at line 394 of file src/io/IodaIO.h.
|
protected |
count of too many dimensions
Definition at line 403 of file src/io/IodaIO.h.
|
protected |
count of unexpected data types
Definition at line 400 of file src/io/IodaIO.h.
|
protected |
number of unique variables
Definition at line 397 of file src/io/IodaIO.h.
|
protected |
Definition at line 420 of file src/io/IodaIO.h.