Main Page | User's Guide | Namespace List | Class List | File List | Namespace Members | Class Members

Format.hxx

00001 // Copyright (C) 2003-2005 CEREA
00002 //     Author: Vivien Mallet
00003 //
00004 // CEREA (http://www.enpc.fr/cerea) is a joint laboratory of
00005 // ENPC (http://www.enpc.fr) and EDF R&D (http://www.edf.fr).
00006 //
00007 // This file is part of AtmoData library.
00008 // AtmoData library is a tool for data processing in atmospheric
00009 // sciences.
00010 //
00011 // AtmoData is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU General Public License as published by
00013 // the Free Software Foundation; either version 2 of the License, or
00014 // (at your option) any later version.
00015 //
00016 // AtmoData is distributed in the hope that it will be useful,
00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 // GNU General Public License (file "license") for more details.
00020 //
00021 // For more information, please see the AtmoData home page:
00022 //     http://www.enpc.fr/cerea/atmodata/
00023 
00024 
00025 #ifndef ATMODATA_FILE_FORMAT_HXX
00026 
00027 namespace AtmoData
00028 {
00029 
00031   class FormatCSV: public Format
00032   {
00033 
00034   protected:
00035 
00036   public:
00037     FormatCSV()  throw();
00038     ~FormatCSV()  throw();
00039 
00040     // Data.
00041 
00042     template<class TD, int N, class TG,
00043              class TS, class TGS>
00044     void Read(string FileName, Data<TD, N, TG>& D,
00045               Data<TS, 1, TGS>& S) const;
00046     template<class TD, int N, class TG,
00047              class TS, class TGS>
00048     void Read(ifstream& FileStream, Data<TD, N, TG>& D,
00049               Data<TS, 1, TGS>& S) const;
00050 
00051     // Array.
00052 
00053     template<class TA, int N,
00054              class TS, class TGS>
00055     void Read(string FileName, Array<TA, N>& A,
00056               Data<TS, 1, TGS>& S) const;
00057     template<class TA, int N,
00058              class TS, class TGS>
00059     void Read(ifstream& FileStream, Array<TA, N>& A,
00060               Data<TS, 1, TGS>& S) const;
00061 
00062   };
00063 
00065   template<class T>
00066   class FormatECMWF: public Format
00067   {
00068 
00069   protected:
00071     int date_;
00072 
00073   public:
00074     FormatECMWF()  throw();
00075     FormatECMWF(int date)  throw();
00076     ~FormatECMWF()  throw();
00077 
00078     void SetDate(int date);
00079     int GetDate() const;
00080 
00081     // Data.
00082 
00083     template<class TD, int N, class TG>
00084     void Read(string FileName, Data<TD, N, TG>& D) const;
00085     template<class TD, int N, class TG>
00086     void Read(ifstream& FileStream, Data<TD, N, TG>& D) const;
00087 
00088     // Array.
00089 
00090     template<class TA, int N>
00091     void Read(string FileName, Array<TA, N>& A) const;
00092     template<int N>
00093     void Read(ifstream& FileStream, Array<T, N>& A) const;
00094     template<class TA, int N>
00095     void Read(ifstream& FileStream, Array<TA, N>& A) const;
00096 
00097   };
00098 
00099   // For MM5 sub-headers.
00100   class MM5SubHeader;
00101 
00103   class FormatMM5: public Format
00104   {
00105 
00106   protected:
00107 
00108   public:
00109     FormatMM5()  throw();
00110     ~FormatMM5()  throw();
00111 
00112     // Flag.
00113     int ReadFlag(ifstream& FileStream) const;
00114 
00115     // Big header.
00116     void ReadBigHeader(string FileName,
00117                        Array<int, 2>& BHI, Array<float, 2>& BHR,
00118                        Array<string, 2>& BHIC, Array<string, 2>& BHRC) const;
00119     void ReadBigHeader(ifstream& FileStream,
00120                        Array<int, 2>& BHI, Array<float, 2>& BHR,
00121                        Array<string, 2>& BHIC, Array<string, 2>& BHRC) const;
00122     void ReadBigHeader(ifstream& FileStream) const;
00123 
00124     // Sub-header.
00125     void ReadSubHeader(ifstream& FileStream, MM5SubHeader& SH) const;
00126     void ReadSubHeader(ifstream& FileStream) const;
00127 
00128     // Field.
00129     template <int N, class TG>
00130     void ReadWholeField(string FileName, string FieldName,
00131                         Data<float, N, TG>& A) const;
00132     template <int N>
00133     void ReadWholeField(string FileName, string FieldName,
00134                         Array<float, N>& A) const;
00135     template <int N, class TG>
00136     void ReadWholeField(ifstream& FileStream, string FieldName,
00137                         Data<float, N, TG>& A) const;
00138     template <int N>
00139     void ReadWholeField(ifstream& FileStream, string FieldName,
00140                         Array<float, N>& A) const;
00141     template <int N>
00142     void ReadField(ifstream& FileStream, bool cross,
00143                    Array<float, N>& A) const;
00144     template <int N, class TG>
00145     void ReadField(ifstream& FileStream, Data<float, N, TG>& A) const;
00146     template <int N>
00147     void ReadField(ifstream& FileStream, MM5SubHeader& SH,
00148                    Array<float, N>& A) const;
00149     template <int N>
00150     void ReadField(ifstream& FileStream, Array<float, N>& A) const;
00151     void ReadField(ifstream& FileStream) const;
00152 
00153   };
00154 
00156   class MM5SubHeader
00157   {
00158 
00159   public:
00161     int ndim;
00163     Array<int, 1> start_index;
00165     Array<int, 1> end_index;
00167     float xtime;
00169     string staggering;
00171     string ordering;
00173     string current_date;
00175     string name;
00177     string unit;
00179     string description;
00180 
00181   public:
00182     MM5SubHeader()  throw();
00183     MM5SubHeader(const MM5SubHeader&)  throw();
00184     ~MM5SubHeader()  throw();
00185 
00186     void Init();
00187     MM5SubHeader& operator=(MM5SubHeader&);
00188     string GetCurrentDate();
00189 
00190   };
00191 
00192 }  // namespace AtmoData.
00193 
00194 
00195 #define ATMODATA_FILE_FORMAT_HXX
00196 #endif

Generated on Wed Apr 25 11:28:00 2007 for AtmoData by  doxygen 1.4.2