OpenCPN Partial API docs
Loading...
Searching...
No Matches
grib_reader.h
Go to the documentation of this file.
1/**********************************************************************
2zyGrib: meteorological GRIB file viewer
3Copyright (C) 2008 - Jacques Zaninetti - http://www.zygrib.org
4
5This program is free software: you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation, either version 3 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program. If not, see <http://www.gnu.org/licenses/>.
17***********************************************************************/
18
36#ifndef GRIBREADER_H
37#define GRIBREADER_H
38
39#include <cmath>
40#include <iostream>
41#include <map>
42#include <set>
43#include <vector>
44
45#ifndef WX_PRECOMP
46#include <wx/wx.h>
47#endif
48#include <wx/wxprec.h>
49
50#include "grib_record.h"
51#include "zu_file.h"
52
53//===============================================================
55public:
56 GribReader();
57 GribReader(const wxString fname);
59
60 void OpenFile(const wxString fname);
61 bool IsOk() const { return ok; }
62 long GetFileSize() const { return fileSize; }
63 wxString GetFileName() const { return fileName; }
64
65 int GetNumberOfGribRecords(int dataType, int levelType, int levelValue);
66 int GetTotalNumberOfGribRecords();
67
68 GribRecord *GetGribRecord(int dataType, int levelType, int levelValue,
69 time_t date);
70
71 GribRecord *GetFirstGribRecord();
72 GribRecord *GetFirstGribRecord(int dataType, int levelType, int levelValue);
73
74 std::vector<GribRecord *> *getListOfGribRecords(int dataType, int levelType,
75 int levelValue);
76
77 // double getHoursBeetweenGribRecords() {return
78 // hoursBetweenRecords;}
79 std::set<time_t> GetListDates() { return SetAllDates; }
80 int GetNumberOfDates() { return SetAllDates.size(); }
81 time_t GetRefDate() {
82 return !SetAllDates.empty() > 0 ? *SetAllDates.begin() : 0;
83 }
84
85 // Valeur pour un point et une date quelconques
86 double GetTimeInterpolatedValue(int dataType, int levelType, int levelValue,
87 double px, double py, time_t date);
88
89 // Crée un GribRecord interpolé
90 GribRecord *GetTimeInterpolatedGribRecord(int dataType, int levelType,
91 int levelValue, time_t date);
92
93 double ComputeDewPoint(double lon, double lat, time_t date);
94
95 int GetDewpointDataStatus(int levelType, int levelValue);
96
97 enum GribFileDataStatus { DATA_IN_FILE, NO_DATA_IN_FILE, COMPUTED_DATA };
98
107 // void removeFirstCumulativeRecord ();
117 void CopyFirstCumulativeRecord(int dataType, int levelType, int levelValue);
118 // void removeFirstCumulativeRecord (int data_type,int level_type,int
119 // level_value);
120 void CopyMissingWaveRecords(int dataType, int levelType, int levelValue);
121
122 void ComputeAccumulationRecords(int dataType, int levelType, int levelValue);
123
124 std::map<std::string, std::vector<GribRecord *> *> *GetGribMap() {
125 return &mapGribRecords;
126 } // dsr
127
128private:
129 bool ok;
130 wxString fileName;
131 ZUFILE *file;
132 long fileSize;
133 // double hoursBetweenRecords;
134 int dewpointDataStatus;
135
136 std::map<std::string, std::vector<GribRecord *> *> mapGribRecords;
137
138 void storeRecordInMap(GribRecord *rec);
139
140 void ReadGribFileContent();
141 void ReadAllGribRecords();
142 void CreateListDates();
143 double ComputeHoursBeetweenGribRecords();
144 std::set<time_t> SetAllDates;
145
146 void CleanVector(std::vector<GribRecord *> &ls);
147 void CleanAllVectors();
148 std::vector<GribRecord *> *GetFirstNonEmptyList();
149
150 // Interpolation between 2 GribRecord
151 double Get2GribsInterpolatedValueByDate(double px, double py, time_t date,
152 GribRecord *before,
153 GribRecord *after);
154
155 // Détermine les GribRecord qui encadrent une date
156 void FindGribsAroundDate(int dataType, int levelType, int levelValue,
157 time_t date, GribRecord **before,
158 GribRecord **after);
159};
160
161#endif
void CopyMissingWaveRecords()
Fills gaps in wave-related data fields by propagating known values across missing time periods.
void CopyFirstCumulativeRecord()
Initializes cumulative meteorological parameters by copying their first record values.
A meteorological data grid from a GRIB (Gridded Binary) file.
GRIB Record Base Class Implementation.
Unified Compressed File Access System.