00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef PMFILEDATA_H
00021 #define PMFILEDATA_H
00022
00023 #include "hdffiledata.h"
00024 #include "pixel.h"
00025 #include "satellitefiledata.h"
00026
00031 class PMFileData : public SatelliteFileData, public HDFFileData {
00032 static const float colocation_tolerance;
00033
00034
00036 static const string latitude_name;
00038 static const string longitude_name;
00040 static const int16 sz_grid_y;
00042 static const int16 sz_grid_x;
00043
00044
00046 string product;
00048 string version;
00050 int lat_lon_index_max [2];
00052 int orbit_nb;
00054 int16 * irow_shift_data;
00056 float32 node_lon;
00057
00061 void init();
00065 void set_time_coverage();
00070 void parse_filename ( const string & short_filename );
00075 static bool check_filename(const string & short_filename);
00079 void set_lat_lon_index_max();
00080
00081 public:
00087 PMFileData(const string &name, const string &mode="r");
00091 ~PMFileData();
00096 void load_geolocation_data();
00101 void free_geolocation_data();
00102
00111 const bool contain_location(const float &lat,const float &lon, const double &tolerance=0.01);
00122 const bool contain_data(const float &lat, const float &lon, const double &time, const double &colocation_tolerance=0.01) ;
00131 const float get_nearest_point_distance ( const float &lat, const float &lon,
00132 const float coloc_tolerance = PMFileData::colocation_tolerance ) {
00133 UnimplementedMethod e(__FILE__,__LINE__,__PRETTY_FUNCTION__);
00134 throw e;
00135 };
00140 string get_product () const { return product; }
00145 string get_version () const { return version; }
00155 const bool get_index(const float &lat, const float& lon, int igrid [2], const float colocation_tolerance=0.01);
00165 const bool get_index(const float &lat, const float& lon, int &idata, const float colocation_tolerance=0.01);
00174 virtual void get_vindex(vector < vector < int > > &v_index, const float &lat, const float& lon,
00175 const float colocation_tolerance=0.01 ) {
00176 UnimplementedMethod e(__FILE__,__LINE__,__PRETTY_FUNCTION__);
00177 throw e;
00178 };
00179
00184 const int get_nb_geo_points() {
00185 return ( PMFileData::sz_grid_y * PMFileData::sz_grid_x ) ;
00186 }
00191 virtual void load_v_pixel() {;};
00195 virtual void close_data_file() {
00196 free_hdf_file();
00197 };
00201 virtual void open_data_file() {
00202 load_hdf_file();
00203 };
00211 virtual void get_pixel_coord ( const vector < int > & ipix, float &lat, float &lon, double &time ) {
00212 float lat_minmax [2];
00213 float lon_minmax [2];
00214 int igrid [2];
00215 copy ( ipix.begin(), ipix.end(), igrid );
00216 grid_to_geolocation ( igrid, lat_minmax, lon_minmax );
00217 lat = -9999.;
00218 if ( lat_minmax [0] != -9999. && lat_minmax [1] != -9999. )
00219 lat = ( lat_minmax [0] + lat_minmax [1] ) / 2.;
00220 lon = -9999.;
00221 if ( lon_minmax [0] != -9999. && lon_minmax [1] != -9999. )
00222 lon = ( lon_minmax [0] + lon_minmax [1] ) / 2.;
00223 time = -9999.;
00224 };
00229 int get_orbit_nb() const {
00230 return orbit_nb;
00231 }
00232
00238 void geolocation_to_grid ( const float * lat_lon, int * igrid );
00245 inline void geolocation_to_grid ( const float &lat, const float &lon, int * igrid ) {
00246 float lat_lon [] = { lat, lon };
00247 geolocation_to_grid ( lat_lon, igrid );
00248 };
00249
00257 void grid_to_geolocation ( const int* igrid, float* lat_minmax, float* lon_minmax = NULL );
00258
00263 const int16* get_irow_shift_data() const {
00264 return irow_shift_data;
00265 }
00266
00271 float32 get_node_lon() const {
00272 return node_lon;
00273 }
00274
00278 void read_node_lon ();
00282 const bool is_geolocation_data_loaded() const {
00283 return ( lat_data != NULL && lon_data != NULL );
00284 };
00285
00290 static const int16 get_sz_grid_y() {
00291 return sz_grid_y;
00292 }
00293
00298 static const int16 get_sz_grid_x() {
00299 return sz_grid_x;
00300 }
00301
00302 };
00303
00304 #endif