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

code/Format.hxx

00001 // Copyright (C) 2003-2004 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://spacetown.free.fr/lib/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: 00070 int date_; 00071 00072 public: 00073 FormatECMWF() throw(); 00074 FormatECMWF(int date) throw(); 00075 ~FormatECMWF() throw(); 00076 00077 void SetDate(int date); 00078 int GetDate() const; 00079 00080 // Data. 00081 00082 template<class TD, int N, class TG> 00083 void Read(string FileName, Data<TD, N, TG>& D) const; 00084 template<class TD, int N, class TG> 00085 void Read(ifstream& FileStream, Data<TD, N, TG>& D) const; 00086 00087 // Array. 00088 00089 template<class TA, int N> 00090 void Read(string FileName, Array<TA, N>& A) const; 00091 template<int N> 00092 void Read(ifstream& FileStream, Array<T, N>& A) const; 00093 template<class TA, int N> 00094 void Read(ifstream& FileStream, Array<TA, N>& A) const; 00095 00096 }; 00097 00098 // For MM5 sub-headers. 00099 class MM5SubHeader; 00100 00102 class FormatMM5: public Format 00103 { 00104 00105 protected: 00106 00107 public: 00108 FormatMM5() throw(); 00109 ~FormatMM5() throw(); 00110 00111 // Flag. 00112 int ReadFlag(ifstream& FileStream) const; 00113 00114 // Big header. 00115 void ReadBigHeader(string FileName, 00116 Array<int, 2>& BHI, Array<float, 2>& BHR, 00117 Array<string, 2>& BHIC, Array<string, 2>& BHRC) const; 00118 void ReadBigHeader(ifstream& FileStream, 00119 Array<int, 2>& BHI, Array<float, 2>& BHR, 00120 Array<string, 2>& BHIC, Array<string, 2>& BHRC) const; 00121 void ReadBigHeader(ifstream& FileStream) const; 00122 00123 // Sub-header. 00124 void ReadSubHeader(ifstream& FileStream, MM5SubHeader& SH) const; 00125 void ReadSubHeader(ifstream& FileStream) const; 00126 00127 // Field. 00128 template <int N, class TG> 00129 void ReadWholeField(string FileName, string FieldName, 00130 Data<float, N, TG>& A) const; 00131 template <int N> 00132 void ReadWholeField(string FileName, string FieldName, 00133 Array<float, N>& A) const; 00134 template <int N, class TG> 00135 void ReadWholeField(ifstream& FileStream, string FieldName, 00136 Data<float, N, TG>& A) const; 00137 template <int N> 00138 void ReadWholeField(ifstream& FileStream, string FieldName, 00139 Array<float, N>& A) const; 00140 template <int N> 00141 void ReadField(ifstream& FileStream, bool cross, 00142 Array<float, N>& A) const; 00143 template <int N, class TG> 00144 void ReadField(ifstream& FileStream, Data<float, N, TG>& A) const; 00145 template <int N> 00146 void ReadField(ifstream& FileStream, MM5SubHeader& SH, 00147 Array<float, N>& A) const; 00148 template <int N> 00149 void ReadField(ifstream& FileStream, Array<float, N>& A) const; 00150 void ReadField(ifstream& FileStream) const; 00151 00152 }; 00153 00155 class MM5SubHeader 00156 { 00157 00158 public: 00159 int ndim; 00160 Array<int, 1> start_index; 00161 Array<int, 1> end_index; 00162 float xtime; 00163 string staggering; 00164 string ordering; 00165 string current_date; 00166 string name; 00167 string unit; 00168 string description; 00169 00170 public: 00171 MM5SubHeader() throw(); 00172 MM5SubHeader(const MM5SubHeader&) throw(); 00173 ~MM5SubHeader() throw(); 00174 00175 void Init(); 00176 MM5SubHeader& operator=(MM5SubHeader&); 00177 00178 }; 00179 00180 } // namespace AtmoData. 00181 00182 00183 #define ATMODATA_FILE_FORMAT_HXX 00184 #endif

Generated on Fri Nov 5 14:42:11 2004 for AtmoData by doxygen 1.3.8