# MI - Fimex: include/fimex/Felt_File.h Source File

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Examples

# include/fimex/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 <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; // file descriptor
    00051         std::map<std::string, Felt_Array> feltArrayMap;
    00052         FeltParameters feltParameters;
    00053         ShortPairMap hybridLevels; // only set for files with idx[10] = 11
    00054         std::vector<double> gridParameterDelta; // allowed deviation between two grids
    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         //float* getData(const string& compName);
    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 } // end namespace MetNoFelt
    00145 #endif /*FELT_FILE_H_*/