Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue2798 - BOV Reader #2809

Merged
merged 30 commits into from
Jul 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fd3482f
pop spaces at end of line
sgpearse Jul 13, 2021
3a53e0d
some bugs fixed
sgpearse Jul 13, 2021
eb6d032
add relative file path search
sgpearse Jul 13, 2021
38f17f9
incremental time fix
sgpearse Jul 14, 2021
05ab55c
inc
sgpearse Jul 14, 2021
e29fbd7
limits test
sgpearse Jul 14, 2021
6ccdc21
close if guard
sgpearse Jul 14, 2021
c58ee0a
clang format
sgpearse Jul 14, 2021
a4f4924
clang format
sgpearse Jul 14, 2021
9058cf2
Merge branch 'main' into issue2798
sgpearse Jul 15, 2021
2bba7e4
updated error handling in BOV reader
sgpearse Jul 20, 2021
8725d20
clang format
sgpearse Jul 20, 2021
cdbe3fc
remove unnecessary error check
sgpearse Jul 20, 2021
1b5027d
remove stat.h for windows, and remove directory checker
sgpearse Jul 20, 2021
5c50ff6
fix typo
sgpearse Jul 20, 2021
94d1a52
clang-format
sgpearse Jul 20, 2021
ff4cc09
merge main
sgpearse Jul 20, 2021
7735fac
merge with windows fix
sgpearse Jul 20, 2021
de19617
remove fileTooBig error
sgpearse Jul 20, 2021
2dede48
switch to climits
sgpearse Jul 20, 2021
527fa55
update DCBOV.h documentation
sgpearse Jul 20, 2021
8dd8e2a
remove windows funk
sgpearse Jul 21, 2021
eed8cea
use more FileUtils
sgpearse Jul 21, 2021
f70d912
Fix review requests
sgpearse Jul 21, 2021
e599b72
Add more comments
sgpearse Jul 21, 2021
22f8615
add more documentation, add varname validator
sgpearse Jul 21, 2021
48241d0
Address sam's comments
sgpearse Jul 21, 2021
ea9376e
fix variable name and delete pointer
sgpearse Jul 22, 2021
aec3ade
remove duplicate zeros from variable scrubber
sgpearse Jul 22, 2021
4108550
new return code for fread
sgpearse Jul 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 29 additions & 22 deletions include/vapor/BOVCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ class BOVCollection : public Wasp::MyBase {
DC::XType GetDataFormat() const;
std::array<double, 3> GetBrickOrigin() const;
std::array<double, 3> GetBrickSize() const;
std::string GetDataEndian() const;

template<class T> int ReadRegion(std::string varname, size_t ts, const std::vector<size_t> &min, const std::vector<size_t> &max, T region);

private:
std::string _currentFilePath;

float _time;
std::vector<float> _times;
std::string _dataFile;
Expand All @@ -37,21 +38,22 @@ class BOVCollection : public Wasp::MyBase {
DC::XType _dataFormat;
std::string _variable;
std::vector<std::string> _variables;
std::string _dataEndian;
std::string _centering;
std::array<double, 3> _brickOrigin;
std::array<double, 3> _brickSize;
size_t _byteOffset;
bool _divideBrick;
std::array<size_t, 3> _dataBricklets;
int _dataComponents;

// These values are currently parsed and assigned, but are unimplemented (not used)
bool _divideBrick;
std::string _dataEndian;
std::string _centering;
int _dataComponents;
std::array<size_t, 3> _dataBricklets;

// Placeholder variables to store values read from BOV descriptor files.
// These values must be consistent among BOV files, and are validated before
// assigning to "actual" values such as _gridSize, declaired above.
std::array<size_t, 3> _tmpGridSize;
DC::XType _tmpDataFormat;
std::string _tmpDataEndian;
std::array<double, 3> _tmpBrickOrigin;
std::array<double, 3> _tmpBrickSize;
size_t _tmpByteOffset;
Expand All @@ -60,7 +62,6 @@ class BOVCollection : public Wasp::MyBase {
bool _formatAssigned;
bool _brickOriginAssigned;
bool _brickSizeAssigned;
bool _dataEndianAssigned;
bool _byteOffsetAssigned;

// _dataFileMap allows us to access binary data files with a
Expand All @@ -79,26 +80,30 @@ class BOVCollection : public Wasp::MyBase {

void _findTokenValue(std::string &line) const;

int _sizeOfFormat(DC::XType) const;
void _swapBytes(void *vptr, size_t size, size_t n) const;
int _sizeOfFormat(DC::XType) const;

int _invalidDimensionError(std::string token) const;
int _invalidFormatError(std::string token) const;
int _failureToReadError(std::string token) const;
int _inconsistentValueError(std::string token) const;
int _invalidValueError(std::string token) const;
int _missingValueError(std::string token) const;
int _invalidVarNameError() const;
int _invalidFileSizeError(size_t numElements) const;
int _invalidFileError() const;
int _invalidDimensionError(const std::string &token) const;
int _invalidFormatError(const std::string &token) const;
int _failureToReadError(const std::string &token) const;
int _inconsistentValueError(const std::string &token) const;
int _invalidValueError(const std::string &token) const;
int _missingValueError(const std::string &token) const;

static const std::string TIME_TOKEN;
static const std::string DATA_FILE_TOKEN;
static const std::string GRID_SIZE_TOKEN;
static const std::string FORMAT_TOKEN;
static const std::string VARIABLE_TOKEN;
static const std::string ENDIAN_TOKEN;
static const std::string CENTERING_TOKEN;
static const std::string ORIGIN_TOKEN;
static const std::string BRICK_SIZE_TOKEN;
static const std::string OFFSET_TOKEN;

// These tokens are currently parsed but are not used
static const std::string ENDIAN_TOKEN;
static const std::string CENTERING_TOKEN;
static const std::string DIVIDE_BRICK_TOKEN;
static const std::string DATA_BRICKLETS_TOKEN;
static const std::string DATA_COMPONENTS_TOKEN;
Expand All @@ -107,15 +112,17 @@ class BOVCollection : public Wasp::MyBase {
static const std::string _defaultFile;
static const DC::XType _defaultFormat;
static const std::string _defaultVar;
static const std::string _defaultEndian;
static const std::string _defaultCentering;
static const size_t _defaultByteOffset;
static const size_t _defaultComponents;
static const bool _defaultDivBrick;
static const std::array<double, 3> _defaultOrigin;
static const std::array<double, 3> _defaultBrickSize;
static const std::array<size_t, 3> _defaultGridSize;

// These defaults are currently unimplemented in the BOV reader logic
static const std::string _defaultEndian;
static const std::string _defaultCentering;
static const bool _defaultDivBrick;
static const std::array<size_t, 3> _defaultBricklets;
static const size_t _defaultComponents;

static const std::string _xDim;
static const std::string _yDim;
Expand Down
45 changes: 38 additions & 7 deletions include/vapor/DCBOV.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,33 @@ namespace VAPoR {

class BOVCollection;

// Example BOV header file, bovA1.bov
//
// # TIME is a floating point value specifying the timestep being read in DATA_FILE
// TIME: 1.1
//
// # DATA_FILE points to a binary data file. It can be a full file path, or a path relative to the BOV header.
// DATA_FILE: bovA1.bin
//
// # The data size corresponds to NX,NY,NZ in the above example code. It must contain three values
// DATA_SIZE: 10 10 10
//
// # Allowable values for DATA_FORMAT are: INT,FLOAT,DOUBLE
// DATA_FORMAT: FLOAT
//
// # VARIABLE is a string that specifies the variable being read in DATA_FILE. Must be alphanumeric (abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-)
// VARIABLE: myVariable
//
// # BRICK_ORIGIN lets you specify a new coordinate system origin for # the mesh that will be created to suit your data. It must contain three values.
// BRICK_ORIGIN: 0. 0. 0.
//
// # BRICK_SIZE lets you specify the size of the brick on X, Y, and Z. It must contain three values.
// BRICK_SIZE: 10. 20. 5.
//
// # BYTE_OFFSET is optional and lets you specify some number of
// # bytes to skip at the front of the file. This can be useful for # skipping the 4-byte header that Fortran tends to write to files. # If your file does not have a header then DO NOT USE
// BYTE_OFFSET. BYTE_OFFSET: 4

//!
//! \class DCBOV
//! \ingroup Public_VDCBOV
Expand All @@ -29,23 +56,27 @@ class BOVCollection;
//! - DATA_FORMAT
//!
//! The following BOV tags are optional:
//! - BRICK_ORIGIN
//! - BRICK_SIZE
//! - DATA_ENDIAN
//! - TIME
//! - VARIABLE
//! - BRICK_ORIGIN (default: 0., 0., 0.)
//! - BRICK_SIZE (default: 1., 1., 1.)
//! - TIME (default: 0.)
//! - VARIABLE (default: "brickVar")
//! - BYTE_OFFSET (default: 0)
//!
//! The following BOV tags are currently unsupported:
//! The following BOV tags are currently unsupported. They can be included in a BOV header,
//! but they will be unused.
//! - DATA_ENDIAN
//! - CENTERING
//! - BYTE_OFFSET
//! - DIVIDE_BRICK
//! - DATA_BRICKLETS
//! - DATA_COMPONENTS
//!
//! If duplicate key/value pairs exist in a BOV header, the value closest to the bottom of the file will be used.
//! If duplicate values exist for whatever reason, all entries must be valid (except for DATA_FILE, which gets validated after parsing)
//! Scientific notation is supported for floating point values like BRICK_ORIGIN and BRICK_SIZE.
//! Scientific notation is not supported for integer values like DATA_SIZE.
//! Wild card characters are not currently supported in the DATA_FILE token.
//! Each .bov file can only refer to a single data file.
//! VARIABLE must be alphanumeric (abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-)
//!
//! \author Scott Pearse
//! \date May, 2021
Expand Down
Loading