21 #ifndef DCREADERGRIB_H
22 #define DCREADERGRIB_H
24 #include <vapor/DCReader.h>
30 #include <vapor/UDUnitsClass.h>
32 #include "vapor/udunits2.h"
48 void _generateWeightTable();
49 string GetGridType()
const;
51 return(_vertCoordinates);};
54 virtual int OpenVariableRead(
size_t timestep,
string varname,
55 int reflevel=0,
int lod=0);
57 fclose(_inFile);
return 0;}
58 virtual int Read(
float *values);
59 virtual int ReadSlice(
float *slice);
60 virtual bool VariableExists(
size_t ts,
string varname,
61 int reflevel=0,
int lod=0)
const;
62 virtual void GetLatLonExtents(
size_t ts,
double lon_exts[2],
63 double lat_exts[2])
const;
64 virtual std::vector<std::string> GetVariables2DExcluded()
const;
65 virtual std::vector<std::string> GetVariables3DExcluded()
const;
67 virtual long GetNumTimeSteps()
const;
68 virtual void GetGridDim(
size_t dim[3])
const;
69 virtual std::vector<string> GetVariables3D()
const;
70 virtual std::vector<string> GetVariables2DXY()
const;
73 std::vector<string> empty;
return(empty);};
75 std::vector<string> empty;
return(empty);};
82 virtual void GetBlockSize(
size_t bs[3],
int reflevel)
const { GetGridDim(bs); }
83 virtual std::vector<double>
GetExtents(
size_t ts = 0)
const {
return _cartographicExtents;}
84 virtual std::vector<long> GetPeriodicBoundary()
const;
85 virtual std::vector<long> GetGridPermutation()
const;
86 virtual void GetTSUserTimeStamp(
size_t ts, std::string &s)
const;
87 virtual std::string GetMapProjection()
const;
92 void _LinearInterpolation(
float* values);
98 int _Initialize(vector<string> files);
100 int PrintVar(
string var);
101 float GetLevel(
int index)
const {
return _pressureLevels[index];}
105 double BarometricFormula(
const double pressure)
const;
106 int _InitCartographicExtents(
string mapProj);
109 struct MessageLocation {
119 void _AddTime(
double t) {_unitTimes.push_back(t);}
120 void _AddMessage(
int msg) {_messages.push_back(msg);}
121 void _AddLevel(
float lvl) {_pressureLevels.push_back(lvl);}
122 void _AddIndex(
double time,
float level,
string file,
int offset);
124 int GetOffset(
double time,
float level)
const;
125 string GetFileName(
double time,
float level)
const;
126 std::vector<int> GetMessages()
const {
return _messages;}
127 std::vector<double> GetTimes()
const {
return _unitTimes;}
128 std::vector<float> GetLevels()
const {
return _pressureLevels;}
129 float GetLevel(
int index)
const {
return _pressureLevels[index];}
131 void PrintMessages();
132 void PrintIndex(
double time,
float level);
133 void _SortLevels() {sort(_pressureLevels.begin(), _pressureLevels.end());}
134 void _SortTimes() {sort(_unitTimes.begin(), _unitTimes.end());}
135 bool _Exists(
double time)
const;
136 void setScanDirection(
bool i,
bool j) {iScan = i; jScan = j;}
137 void setOperatingCenter(
string oc) {_operatingCenter = oc;}
138 void setParamId(
int id) {_paramId = id;}
139 string getOperatingCenter() {
return _operatingCenter;}
140 int getParamId() {
return _paramId;}
141 bool getiScan()
const {
return iScan;}
142 bool getjScan()
const {
return jScan;}
146 std::map<double, std::map<float, MessageLocation> > _indices;
147 std::vector<int> _messages;
148 std::vector<float> _pressureLevels;
151 std::vector<size_t> _varTimes;
153 std::vector<double> _unitTimes;
154 string _operatingCenter;
161 bool _ignoreForecastData;
162 static int _sliceNum;
167 double _LaDInDegrees;
168 double _LoVInDegrees;
177 string _Latin1InDegrees;
178 string _Latin2InDegrees;
179 string _orientationOfTheGridInDegrees;
184 std::vector<double> _pressureLevels;
185 std::vector<double> _vertCoordinates;
186 std::vector<double> _cartesianExtents;
187 std::vector<double> _cartographicExtents;
188 std::vector<double> _gribTimes;
189 std::map<std::string, Variable*> _vars1d;
190 std::map<std::string, Variable*> _vars2d;
191 std::map<std::string, Variable*> _vars3d;
192 double* _gaussianLats;
193 std::vector<double> _weights;
194 std::vector<int> _latIndices;
196 double* _regularLats;
204 int _LoadRecord(
string file,
size_t offset);
205 int _LoadRecordKeys(
const string file);
207 std::vector<std::map<std::string, std::string> > GetRecords()
const {
return _recordKeys;}
208 int doWeIgnoreForecastTimes() {
return _ignoreForecastTimes;}
212 std::vector<std::map<std::string, std::string> > _recordKeys;
213 std::vector<std::string> _consistentKeys;
214 std::vector<std::string> _varyingKeys;
215 bool _recordKeysVerified;
216 int _ignoreForecastTimes;
217 DCReaderGRIB *_metadata;
220 unsigned long _key_iterator_filter_flags;
227 double _min,_max,_average;
237 Record(
string file,
int recordNum);
239 void setTime(
string input) {time = input;}
240 void setUnits(
string input) {units = input;}
241 void setNi(
string input) {Ni = input;}
242 void setNj(
string input) {Nj = input;}
243 void setGridType(
string input) {gridType = input;}
244 void setVarName(
string input) {varName = input;}
245 string getTime() {
return time;}
246 string getUnits() {
return units;}
247 string getNi() {
return Ni;}
248 string getNj() {
return Nj;}
249 string getGridType() {
return gridType;}
250 string getVarName() {
return varName;}
262 #endif // GRIBPARSER_H
virtual double GetTSUserTime(size_t ts) const
virtual int CloseVariable()
virtual std::vector< double > GetExtents(size_t ts=0) const
virtual void GetBlockSize(size_t bs[3], int reflevel) const
vector< double > GetZCoordsInMeters() const
virtual std::vector< string > GetVariables2DYZ() const
virtual std::vector< double > GetTSZCoords(size_t) const
virtual std::vector< string > GetVariables2DXZ() const