MI - Fimex
GribCDMReader.h
Go to the documentation of this file.
1 /*
2  * Fimex, GribCDMReader.h
3  *
4  * (C) Copyright 2009, met.no
5  *
6  * Project Info: https://wiki.met.no/fimex/start
7  *
8  * This library is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 2.1 of the License, or
11  * (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16  * License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21  * USA.
22  *
23  * Created on: Sep 9, 2009
24  * Author: Heiko Klein
25  */
26 
27 #ifndef GRIBCDMREADER_H_
28 #define GRIBCDMREADER_H_
29 
30 #ifndef MIFI_IO_READER_SUPPRESS_DEPRECATED
31 #warning \
32  This header-file is deprecated and \
33  may be removed without further notice at a future date. Please use a \
34  non-deprecated interface with equivalent functionality instead, i.e. \
35  instead of \
36  *CDMReader(file,config) \
37  use \
38  CDMFileReaderFactory::create(MIFI_FILETYPE_*,file,config)
39 #endif
40 
41 #include <vector>
42 #include <boost/shared_ptr.hpp>
43 #include "fimex/GribFileIndex.h"
44 #include "fimex/CDMReader.h"
46 #include "fimex/XMLInput.h"
47 #include "fimex/XMLDoc.h"
48 
49 namespace MetNoFimex
50 {
51 
52 // forward decl.
53 class CDM;
54 class CDMDimension;
55 struct GribCDMReaderImpl;
56 
58 {
59 public:
62  virtual ~GribCDMReader();
63  virtual DataPtr getDataSlice(const std::string& varName, size_t unLimDimPos);
64  virtual DataPtr getDataSlice(const std::string& varName, const SliceBuilder& sb);
70  static boost::shared_ptr<XMLDoc> initXMLConfig(const XMLInput& configXML);
75  static std::string getConfigEarthFigure(boost::shared_ptr<XMLDoc> doc);
80  static std::string getConfigExtraKeys(boost::shared_ptr<XMLDoc> doc);
81 
82 
83 
84 private:
85  // pimpl
86  boost::shared_ptr<GribCDMReaderImpl> p_;
87 
91  void initXMLNodeIdx();
92 
99  void initXMLAndMembers(const XMLInput& configXML, const std::vector<std::pair<std::string, std::string> >& members);
105  void initPostIndices();
106 
110  void initSelectParameters(const std::string& select);
115  xmlNodePtr findVariableXMLNode(const GribFileMessage& msg) const;
116  std::string getVariableName(const GribFileMessage& gfm) const;
122  boost::posix_time::ptime getVariableValidTime(const GribFileMessage& gfm) const;
123 
124  size_t getVariableMaxEnsembles(std::string varName) const;
125 
126  void initAddTimeDimension();
127  void initAddGlobalAttributes();
128  void initCreateGFIBoxes();
129  void initLevels();
130 
132 // void initLevels(long edition, const std::map<long, std::set<long> >& levelsOfType, std::map<std::string, CDMDimension>& levelDimsOfType);
133 // std::map<std::string, CDMDimension> initAddLevelDimensions();
134  void initAddEnsembles();
135  void initAddProjection();
136  void initAddVariables();
137 
138  // read levels (pv) from a variable
139  std::vector<double> readVarPv_(std::string exampleVar, bool asimofHeader=false);
140  std::vector<double> readValuesFromXPath_(xmlNodePtr node, DataPtr levelData, std::string exampleVar, std::string extension);
141  void initSpecialLevels_(xmlNodePtr node, const std::string& extension, const std::string& levelType, std::size_t levelPos, const std::vector<std::string>& levelShape, DataPtr& levelData);
142 };
143 
144 }
145 
146 #endif /* GRIBCDMREADER_H_ */
basic_string< char > string
boost::shared_ptr< Data > DataPtr
Definition: DataDecl.h:39
Definition: SliceBuilder.h:46
Definition: GribCDMReader.h:57
xmlNode * xmlNodePtr
Definition: XMLDoc.h:39
Definition: C_CDMReader.h:35
Basic interface for CDM reading and manipulation classes.
Definition: CDMReader.h:53
static boost::shared_ptr< XMLDoc > initXMLConfig(const XMLInput &configXML)
Definition: GribFileIndex.h:46
static std::string getConfigEarthFigure(boost::shared_ptr< XMLDoc > doc)
GribCDMReader(const std::vector< std::string > &fileNames, const XMLInput &configXML, const std::vector< std::pair< std::string, std::string > > &members=std::vector< std::pair< std::string, std::string > >())
static std::string getConfigExtraKeys(boost::shared_ptr< XMLDoc > doc)
Definition: XMLInput.h:49
virtual DataPtr getDataSlice(const std::string &varName, size_t unLimDimPos)
data-reading function to be called from the CDMWriter