src/felt_reader/Felt_File.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_FILE_H_
00025 #define FELT_FILE_H_
00026 
00027 #include <ctime>
00028 #include <map>
00029 #include <vector>
00030 #include <string>
00031 #include <boost/shared_ptr.hpp>
00032 #include <boost/shared_array.hpp>
00033 #include "Data.h"
00034 #include "felt_reader/Felt_Array.h"
00035 #include "felt_reader/Felt_File_Error.h"
00036 #include "felt_reader/FeltParameters.h"
00037 
00038 namespace MetNoFelt {
00039 
00041 
00046 class Felt_File
00047 {
00048         std::string filename;
00049         boost::shared_ptr<int> fdPtr; // file descriptor
00050         std::map<std::string, Felt_Array> feltArrayMap;
00051         FeltParameters feltParameters;
00052         
00053 private:
00054         Felt_Array& findOrCreateFeltArray(const boost::array<short, 16>& idx);
00055         std::vector<short> getDataSlice(Felt_Array& fa, boost::array<short, 16>& idx, int fieldSize) throw(Felt_File_Error);
00056         boost::shared_array<short> getHeaderData(Felt_Array& fa, boost::array<short, 16>& idx, int fieldSize)  throw(Felt_File_Error);
00058         void init() throw(Felt_File_Error);
00059         
00060 public:
00062 
00065         Felt_File() {}
00070         explicit Felt_File(const std::string& filename) throw(Felt_File_Error);
00077         explicit Felt_File(const std::string& filename, const std::vector<std::string>& dianaParamList) throw(Felt_File_Error);
00078         virtual ~Felt_File();
00079         //float* getData(const string& compName);
00080         
00082 
00085         Felt_Array& getFeltArray(const std::string& compName) throw(Felt_File_Error);
00087 
00092         std::vector<short> getDataSlice(const std::string& compName, const std::time_t time, const short level) throw(Felt_File_Error);
00100         boost::shared_ptr<MetNoFimex::Data> getScaledDataSlice(const std::string& compName, const std::time_t time, const short level, double fillValue) throw(Felt_File_Error);
00101 
00105         std::vector<Felt_Array> listFeltArrays();
00106 
00111         std::map<short, std::vector<short> > getFeltLevels() const;
00116         std::map<short, std::vector<pair<short,short> > > getFeltLevelPairs() const;
00118         std::vector<time_t> getFeltTimes() const;
00120         int getNX() const;
00122         int getNY() const;
00124         boost::shared_ptr<MetNoFimex::Data> getXData() const throw(Felt_File_Error);
00126         boost::shared_ptr<MetNoFimex::Data> getYData() const throw(Felt_File_Error);
00127         
00129         short getGridType() const throw(Felt_File_Error);
00130         
00132         const boost::array<float, 6>& getGridParameters() const throw(Felt_File_Error);
00133         
00134 };
00135 
00136 
00137 } // end namespace MetNoFelt
00138 #endif /*FELT_FILE_H_*/

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