VAPOR3 3.9.4
DCBOV.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4#include <algorithm>
5#include <map>
6#include <iostream>
7#include <vapor/MyBase.h>
9#include <vapor/Proj4API.h>
10#include <vapor/UDUnitsClass.h>
11#include <vapor/utils.h>
12#include <vapor/DC.h>
13#include <vapor/BOVCollection.h>
14
15namespace VAPoR {
16
17class BOVCollection;
18
19// Example BOV header file, bovA1.bov
20//
21// # TIME is a floating point value specifying the timestep being read in DATA_FILE
22// TIME: 1.1
23//
24// # DATA_FILE points to a binary data file. It can be a full file path, or a path relative to the BOV header.
25// DATA_FILE: bovA1.bin
26//
27// # The data size corresponds to NX,NY,NZ in the above example code. It must contain three values
28// DATA_SIZE: 10 10 10
29//
30// # Allowable values for DATA_FORMAT are: INT,FLOAT,DOUBLE
31// DATA_FORMAT: FLOAT
32//
33// # VARIABLE is a string that specifies the variable being read in DATA_FILE. Must be alphanumeric (abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-)
34// VARIABLE: myVariable
35//
36// # 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.
37// BRICK_ORIGIN: 0. 0. 0.
38//
39// # BRICK_SIZE lets you specify the size of the brick on X, Y, and Z. It must contain three values.
40// BRICK_SIZE: 10. 20. 5.
41//
42// # BYTE_OFFSET is optional and lets you specify some number of
43// # 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
44// BYTE_OFFSET. BYTE_OFFSET: 4
45
85class VDF_API DCBOV : public VAPoR::DC {
86public:
91 virtual ~DCBOV();
92
93protected:
110 //
111 virtual int initialize(const vector<string> &paths, const std::vector<string> &options);
112
115 virtual bool getDimension(string dimname, DC::Dimension &dimension) const;
116
119 virtual std::vector<string> getDimensionNames() const;
120
123 std::vector<string> getMeshNames() const;
124
127 virtual bool getMesh(string mesh_name, DC::Mesh &mesh) const;
128
131 virtual bool getCoordVarInfo(string varname, DC::CoordVar &cvar) const;
132
135 virtual bool getDataVarInfo(string varname, DC::DataVar &datavar) const;
136
139 virtual bool getAuxVarInfo(string varname, DC::AuxVar &var) const { return (false); }
140
142 //
143 virtual bool getBaseVarInfo(string varname, DC::BaseVar &var) const;
144
147 virtual std::vector<string> getDataVarNames() const;
148
149 virtual std::vector<string> getAuxVarNames() const { return (vector<string>()); }
150
153 virtual std::vector<string> getCoordVarNames() const;
154
157 virtual size_t getNumRefLevels(string varname) const { return (1); }
158
161 virtual string getMapProjection() const { return (""); }
162
165 virtual bool getAtt(string varname, string attname, vector<double> &values) const;
166 virtual bool getAtt(string varname, string attname, vector<long> &values) const;
167 virtual bool getAtt(string varname, string attname, string &values) const;
168
171 virtual std::vector<string> getAttNames(string varname) const;
172
175 virtual XType getAttType(string varname, string attname) const;
176
179 virtual int getDimLensAtLevel(string varname, int level, std::vector<size_t> &dims_at_level, std::vector<size_t> &bs_at_level) const;
180
183 virtual int openVariableRead(size_t ts, string varname, int, int) { return (DCBOV::openVariableRead(ts, varname)); }
184
185 virtual int openVariableRead(size_t ts, string varname);
186
189 virtual int closeVariable(int fd);
190
192 //
193 virtual int readRegion(int fd, const vector<size_t> &min, const vector<size_t> &max, float *region) { return (_readRegionTemplate(fd, min, max, region)); }
194 virtual int readRegion(int fd, const vector<size_t> &min, const vector<size_t> &max, double *region) { return (_readRegionTemplate(fd, min, max, region)); }
195 virtual int readRegion(int fd, const vector<size_t> &min, const vector<size_t> &max, int *region) { return (_readRegionTemplate(fd, min, max, region)); }
196
199 virtual bool variableExists(size_t ts, string varname, int reflevel = 0, int lod = 0) const;
200
201private:
202 VAPoR::UDUnits _udunits;
203
204 BOVCollection *_bovCollection;
205
206 string _varname;
207 std::map<string, DC::Dimension> _dimsMap;
208 std::map<string, DC::CoordVar> _coordVarsMap;
209 std::map<string, DC::Mesh> _meshMap;
210 std::map<string, DC::DataVar> _dataVarsMap;
211 std::map<string, string> _coordVarKeys;
212
213 void _InitCoordinates();
214
215 void _InitDimensions();
216
217 void _InitVars();
218
219 int _isCoordinateVariable(std::string variable) const;
220
221 template<class T> void _generateCoordinates(int dim, const vector<size_t> &min, const vector<size_t> &max, T *region) const;
222
223 template<class T> int _readRegionTemplate(int fd, const vector<size_t> &min, const vector<size_t> &max, T *region);
224};
225} // namespace VAPoR
Class for reading a "Brick of Values", explained in section 3.1 (page 11) in the following VisIt docu...
Definition: DCBOV.h:85
virtual ~DCBOV()
virtual bool getCoordVarInfo(string varname, DC::CoordVar &cvar) const
virtual XType getAttType(string varname, string attname) const
virtual int initialize(const vector< string > &paths, const std::vector< string > &options)
virtual std::vector< string > getDataVarNames() const
virtual size_t getNumRefLevels(string varname) const
Definition: DCBOV.h:157
virtual int closeVariable(int fd)
virtual std::vector< string > getAttNames(string varname) const
virtual bool getMesh(string mesh_name, DC::Mesh &mesh) const
virtual std::vector< string > getAuxVarNames() const
Definition: DCBOV.h:149
std::vector< string > getMeshNames() const
virtual bool getDataVarInfo(string varname, DC::DataVar &datavar) const
virtual int readRegion(int fd, const vector< size_t > &min, const vector< size_t > &max, int *region)
Definition: DCBOV.h:195
virtual bool getDimension(string dimname, DC::Dimension &dimension) const
virtual int getDimLensAtLevel(string varname, int level, std::vector< size_t > &dims_at_level, std::vector< size_t > &bs_at_level) const
virtual bool variableExists(size_t ts, string varname, int reflevel=0, int lod=0) const
virtual std::vector< string > getDimensionNames() const
virtual string getMapProjection() const
Definition: DCBOV.h:161
virtual int openVariableRead(size_t ts, string varname)
virtual std::vector< string > getCoordVarNames() const
virtual bool getAuxVarInfo(string varname, DC::AuxVar &var) const
Definition: DCBOV.h:139
virtual int openVariableRead(size_t ts, string varname, int, int)
Definition: DCBOV.h:183
virtual bool getAtt(string varname, string attname, vector< double > &values) const
virtual bool getAtt(string varname, string attname, string &values) const
virtual bool getAtt(string varname, string attname, vector< long > &values) const
virtual int readRegion(int fd, const vector< size_t > &min, const vector< size_t > &max, float *region)
Definition: DCBOV.h:193
virtual bool getBaseVarInfo(string varname, DC::BaseVar &var) const
virtual int readRegion(int fd, const vector< size_t > &min, const vector< size_t > &max, double *region)
Definition: DCBOV.h:194
Auxiliary variable metadata.
Definition: DC.h:1230
Base class for storing variable metadata.
Definition: DC.h:754
Coordinate variable metadata.
Definition: DC.h:881
Data variable metadata.
Definition: DC.h:987
Metadata describing a named dimension length.
Definition: DC.h:163
Metadata describing a computational mesh.
Definition: DC.h:310
A Template Method design pattern for reading a collection of data.
Definition: DC.h:150
XType
External storage types for primitive data.
Definition: DC.h:154
#define VDF_API
Definition: common.h:73