MI - Fimex
FeltField.h
Go to the documentation of this file.
1 /*
2  wdb
3 
4  Copyright (C) 2007 met.no
5 
6  Contact information:
7  Norwegian Meteorological Institute
8  Box 43 Blindern
9  0313 OSLO
10  NORWAY
11  E-mail: wdb@met.no
12 
13  This program is free software; you can redistribute it and/or modify
14  it under the terms of the GNU General Public License as published by
15  the Free Software Foundation; either version 2 of the License, or
16  (at your option) any later version.
17 
18  This program is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  GNU General Public License for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with this program; if not, write to the Free Software
25  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
26  MA 02110-1301, USA
27 */
28 #ifndef FELTFIELD_H_
29 #define FELTFIELD_H_
30 
31 #include "FeltConstants.h"
32 #include "FeltGridDefinition.h"
33 #include <boost/shared_array.hpp>
34 #include <boost/array.hpp>
35 #include <boost/date_time/posix_time/posix_time_types.hpp>
36 #include <boost/noncopyable.hpp>
37 #include <string>
38 #include <vector>
39 
40 namespace felt
41 {
42 
43 typedef boost::shared_ptr<FeltGridDefinition> FeltGridDefinitionPtr;
44 
45 class FeltFile;
46 
47 class FeltField : boost::noncopyable
48 {
49 public:
50  typedef boost::array<word, 16> Header;
51 
52  FeltField(const FeltFile & ff, size_t index);
53 
54  ~FeltField();
55 
56  bool valid() const { return gridSize() != 0; }
57 
58  int producer() const { return header_[0]; }
59  int gridArea() const { return header_[1]; }
60 
61  boost::posix_time::ptime referenceTime() const;
62  boost::posix_time::ptime validTime() const;
63 
69  int parameter() const;
70 
74  int dataType() const { return header_[8]; }
75 
76  int verticalCoordinate() const { return header_[10]; }
77 
81  int level1() const;
82 
88  int level2() const;
89 
90  int gridType() const { return header_[14]; }
91 
95  void grid(std::vector<word> & out) const;
96  size_t gridSize() const;
97  int scaleFactor() const;
98  int xNum() const;
99  int yNum() const;
101  int miscField() const;
102 
103  bool isEpsRunParameter() const
104  {
105  int param = parameterUnmodified_();
106  return 2000 <= param and param < 6000;
107  }
108 
112  int dataVersion() const;
113 
115  FeltGridDefinitionPtr projectionInformation() const;
116 
117  std::string information() const;
119 
121  const Header& getHeader() const {return header_;}
122 
123 private:
124 
125  int timeParameter() const { return header_[9]; }
126 
127  int parameterUnmodified_() const { return header_[11]; }
128 
132  bool isSane() const;
133 
134 private:
135  size_t startingGridBlock() const;
136 
137  const std::vector<word> & getGridHeader_() const;
138  const std::vector<word> & getExtraGeometrySpecification_() const;
139 
140  mutable std::vector<word> gridHeader_;
141  mutable std::vector<word> extraGridSpec_;
142  Header header_;
143  const FeltFile & feltFile_;
144  size_t index_;
145 };
146 
147 }
148 
149 #endif /*FELTFIELD_H_*/
int scaleFactor() const
Definition: FeltConstants.h:35
basic_string< char > string
boost::shared_ptr< FeltGridDefinition > FeltGridDefinitionPtr
Definition: FeltField.h:43
int yNum() const
boost::posix_time::ptime validTime() const
const Header & getHeader() const
access felt index header
Definition: FeltField.h:121
Definition: FeltField.h:47
void grid(std::vector< word > &out) const
std::string information() const
int xNum() const
boost::array< word, 16 > Header
Definition: FeltField.h:50
int parameter() const
bool valid() const
Definition: FeltField.h:56
int level2() const
Definition: FeltFile.h:49
int producer() const
Definition: FeltField.h:58
size_t gridSize() const
int level1() const
std::string gridInformation() const
FeltGridDefinitionPtr projectionInformation() const
throws
int miscField() const
this field is described in the felt documentation as "word 19 in data part"
int verticalCoordinate() const
Definition: FeltField.h:76
FeltField(const FeltFile &ff, size_t index)
int gridType() const
Definition: FeltField.h:90
int gridArea() const
Definition: FeltField.h:59
int dataType() const
Definition: FeltField.h:74
bool isEpsRunParameter() const
Definition: FeltField.h:103
int dataVersion() const
boost::posix_time::ptime referenceTime() const