00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef FELT_FILE_H_
00025 #define FELT_FILE_H_
00026
00027 #include <map>
00028 #include <vector>
00029 #include <string>
00030 #include <boost/shared_ptr.hpp>
00031 #include <boost/shared_array.hpp>
00032 #include "fimex/Data.h"
00033 #include "fimex/Felt_Array.h"
00034 #include "fimex/Felt_File_Error.h"
00035 #include "fimex/FeltParameters.h"
00036 #include "fimex/Logger.h"
00037 #include "fimex/Utils.h"
00038
00039 namespace MetNoFelt {
00040 using MetNoFimex::epoch_seconds;
00042
00047 class Felt_File
00048 {
00049 std::string filename;
00050 boost::shared_ptr<int> fdPtr;
00051 std::map<std::string, Felt_Array> feltArrayMap;
00052 FeltParameters feltParameters;
00053 ShortPairMap hybridLevels;
00054 std::vector<double> gridParameterDelta;
00055 MetNoFimex::LoggerPtr logger;
00056
00057 private:
00058 Felt_Array& findOrCreateFeltArray(const boost::array<short, 16>& idx);
00059 std::vector<short> getDataSlice(Felt_Array& fa, boost::array<short, 16>& idx, int fieldSize) throw(Felt_File_Error);
00060 boost::shared_array<short> getHeaderData(Felt_Array& fa, boost::array<short, 16>& idx, int fieldSize) throw(Felt_File_Error);
00062 void init(const std::map<std::string, std::string>& options) throw(Felt_File_Error);
00064 void setOptions(const std::map<std::string, std::string>& options);
00065
00066 public:
00068
00071 Felt_File() {}
00076 explicit Felt_File(const std::string& filename) throw(Felt_File_Error);
00083 explicit Felt_File(const std::string& filename, const std::vector<std::string>& dianaParamList, const std::map<std::string, std::string>& options) throw(Felt_File_Error);
00084 virtual ~Felt_File();
00085
00086
00088
00091 Felt_Array& getFeltArray(const std::string& compName) throw(Felt_File_Error);
00093
00098 std::vector<short> getDataSlice(const std::string& compName, const epoch_seconds time, const short level) throw(Felt_File_Error);
00106 boost::shared_ptr<MetNoFimex::Data> getScaledDataSlice(const std::string& compName, const epoch_seconds time, const short level, double fillValue) throw(Felt_File_Error);
00107
00111 std::vector<Felt_Array> listFeltArrays();
00112
00117 std::map<short, std::vector<short> > getFeltLevels() const;
00122 std::map<short, std::vector<pair<short,short> > > getFeltLevelPairs() const;
00123 const ShortPairMap& getHybridLevels() const {return hybridLevels;}
00125 std::vector<epoch_seconds> getFeltTimes() const;
00127 int getNX() const;
00129 int getNY() const;
00131 boost::shared_ptr<MetNoFimex::Data> getXData() const throw(Felt_File_Error);
00133 boost::shared_ptr<MetNoFimex::Data> getYData() const throw(Felt_File_Error);
00134
00136 short getGridType() const throw(Felt_File_Error);
00137
00139 const boost::array<float, 6>& getGridParameters() const throw(Felt_File_Error);
00140
00141 };
00142
00143
00144 }
00145 #endif