src/felt_reader/Felt_Array.h

Go to the documentation of this file.
00001 /*
00002  * Fimex
00003  * 
00004  * (C) Copyright 2008, met.no
00005  *
00006  * Project Info:  https://wiki.met.no/fimex/start
00007  *
00008  * This library is free software; you can redistribute it and/or modify it
00009  * under the terms of the GNU Lesser General Public License as published by
00010  * the Free Software Foundation; either version 2.1 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00015  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00016  * License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
00021  * USA.
00022  */
00023 
00024 #ifndef FELT_ARRAY_H_
00025 #define FELT_ARRAY_H_
00026 #include <string>
00027 #include <set>
00028 #include <vector>
00029 #include <map>
00030 #include <ctime>
00031 #include <boost/array.hpp>
00032 #include "Felt_File_Error.h"
00033 
00034 namespace MetNoFelt {
00035 using namespace std;
00036 
00041 struct ShortPairLess : public binary_function<const pair<short, short>, const pair<short, short>, bool> 
00042 {
00043         bool operator()(const pair<short, short>& p1, const pair<short, short>& p2) {
00044                 if (p1.first == p2.first) return p1.second < p2.second;
00045                 return p1.first < p2.first;
00046         }
00047 };
00049 typedef set<pair<short,short>, ShortPairLess > ShortPairSet;
00050 
00051 
00053 
00057 class Felt_Array
00058 {
00059 private:
00060         typedef map<time_t, boost::array<short, 4> > TIME_MAP;
00061         string feltArrayName;
00062         ShortPairSet levelPairs;
00063         // the time-array[0,1,2,3] correspond to index-array[2,3,4,9]
00064         TIME_MAP times;
00065         map<time_t, map<short, int> > fieldSizeMap;
00066         int nx;
00067         int ny;
00068         long scaling_factor;
00069         int gridType;
00070         boost::array<short, 16> idx;
00071         boost::array<short, 20> header;
00072         boost::array<float, 6> gridParameters;
00073         string dataType;
00074         double fillValue;
00075         
00076 public:
00078         Felt_Array();
00085         explicit Felt_Array(const string name, const boost::array<short, 16> idx, const string& dataType = "short");
00086         virtual ~Felt_Array();
00091         void addInformationByIndex(const boost::array<short, 16>& idx, int fieldSize) throw(Felt_File_Error);
00093         const boost::array<short, 16>& getIndexHeader() const {return idx;}
00094         
00100         void setDataHeader(boost::array<short, 20> header) throw(Felt_File_Error);
00102         const boost::array<short, 20>& getDataHeader() const {return header;} 
00103         
00105         short getLevelType() const {return idx[10];}
00107         void setGridType(int gridType) {this->gridType = gridType;}
00109         int getGridType() const {return gridType;}
00113         void setGridParameters(boost::array<float, 6> gridParameters) {this->gridParameters = gridParameters;}
00115         const boost::array<float, 6>& getGridParameters() const {return gridParameters;}
00116 
00118         const string& getName() const;
00120         const string& getDatatype() const {return dataType;}
00122         double getFillValue() const { return fillValue;}
00124         void setFillValue(double fillValue) {this->fillValue = fillValue;}
00126         vector<time_t> getTimes() const;
00128         vector<short> getLevels() const;
00132         vector<pair<short, short> > getLevelPairs() const;
00134         int getX() const {return header[9];}
00136         int getY() const {return header[10];}
00138         short getVerticalFeltType() const {return idx[10];}
00140         double getScalingFactor() const;
00141         
00143         boost::array<short, 16> const getIndex(time_t time, short level) throw(Felt_File_Error);
00144         int getFieldSize(time_t time, short level) const throw (Felt_File_Error);
00145         
00146 private:
00147         void testHeaderElement(short oldVal, short newVal, const std::string& msg) const throw(Felt_File_Error);
00148 };
00149 
00150 } // end namespace MetNoFelt
00151 #endif /*FELT_ARRAY_H_*/

Generated on Thu Jun 5 14:58:22 2008 for MI - Fimex by  doxygen 1.4.6