/*************************************************************************** * Copyright (C) 2005 by Nicolas PASCAL * * nicolas.pascal@icare.univ-lille1.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef SATELLITEFILEDATA_H #define SATELLITEFILEDATA_H #include "filedata.h" #include "pixel.h" #include "geometry.h" #include "viewing_geometry.h" #include "observation.h" #include class SatelliteFileData : virtual public FileData { protected: // define types for coincident pixels search typedef P_Pixel_base > PixelType; typedef vector::iterator I_Pixel; /***** Geolocation buffers *****/ /** The latitude values */ float *lat_data; /** The longitude values */ float *lon_data; /** The time values */ double *time_data; /** a list of pixels data, sorted by increasing latitude, then increasing longitude */ vector< PixelType > v_pixel; /** the lines of sight for all pixels, from satellite position to viewed pixel center. Points are given in Earth Center Rotating carthesian coordinates */ typedef vector PixelIndice; std::map viewing_directions; /** maps a pixel to its indice in the data. Most of time, it will be exactly the same, but for instance, in the PARASOL data, it will maps a gridded pixel to its record number */ typedef vector DataIndice; std::map ipix2idata; public: SatelliteFileData(const string &name, const string &mode/*= "r"*/) : FileData(name,mode) { lat_data = NULL; lon_data = NULL; time_data = NULL; }; /** * @brief Destructor */ virtual ~SatelliteFileData(); /** * check if this file has data coincident with (lat,lon,time) * @param lat the latitude of the event * @param lon the longitude of the event * @param time the time of the event. If -1., time test will be ignored * @return */ virtual const bool contain_data(const float &lat,const float &lon, const double &time, const double &tolerance)=0; /** * @brief check if this file has eventually data coincident with (lat,lon) * Actually, it only tests if (lat,lon) is contained in the data's bounding rectangle. * @param lat the latitude of the event * @param lon the longitude of the event * @param tolerance acceptable bias between the nearest point in the data and the given (lat,lon) point * @return true if a point in the data has been found in the colocation frame */ virtual const bool contain_location(const float &lat,const float &lon, const double &tolerance)=0 ; /** * @brief find the index of the nearest point to (lat,lon) in the data. * If (lat,lon) is not found or out of the colocalisation_frame, returned indexes are [-1,-1] * @param lat the latitude * @param lon the longitude * @param nearest_pix_idx the index of the nearest measure. -1 if no coincidence found. * @param colocation_tolerance the acceptable bias (in km or degrees. Supposed to be in, a plane approximation) between [lat,lon] and the nearest data point. * @return true if the coincidence has been found */ virtual const bool get_index(const float &lat, const float& lon, int &nearest_pix_idx, const float colocation_tolerance)=0; /** * @brief build the list of indices of pixels that are in colocation tolerance, sorted by increasing distance to (lat,lon) * If (lat,lon) is not found or out of the colocalisation_frame, returns an empty vector * @param v_index [OUT] the vector of neighbour pixels indices * @param lat the latitude * @param lon the longitude * @param colocation_tolerance the acceptable bias (in km or degrees. Supposed to be in, a plane approximation) between [lat,lon] and the nearest data point. */ virtual void get_vindex(vector < vector < int > > &v_index, const float &lat, const float& lon, const float colocation_tolerance) = 0; virtual const float get_nearest_point_distance(const float &lat, const float &lon, const float coloc_tolerance)=0; /** * @brief read the geolocation data and put it in memory. * This method is used to make the search of the indexes of a (lat,lon,time) point faster. */ virtual void load_geolocation_data()=0; /** * @brief free eventually loaded geolocation data */ virtual void free_geolocation_data(); /** * @brief Tell if the geolocation data have been already loaded */ virtual const bool is_geolocation_data_loaded() const; /** * @brief closes the file. */ virtual void close_data_file()=0; /** * @brief opens the file. */ virtual void open_data_file()=0; /** * @brief load the list data pixels */ virtual void load_v_pixel() = 0; /** * @brief free the list data pixels */ virtual void free_v_pixel(); /** * @brief accessor to the list of data pixels * @return the list of data pixels */ virtual const vector< PixelType > & get_v_pixel() const { return v_pixel; } /** * @brief retrieve the coordinates of a pixel using its index * @param ipix [IN] index of the pixel * @param lat [OUT] latitude of the pixel * @param lon [OUT] longitude of the pixel * @param time [OUT] timestamp of the pixel */ virtual void get_pixel_coord ( const vector < int > & ipix, float &lat, float &lon, double &time ) = 0; /** * @brief accessor to the latitude data buffer * @return the latitude data buffer */ float* get_lat_data() const { return lat_data; } /** * @brief accessor to the longitude data buffer * @return the longitude data buffer */ float* get_lon_data() const { return lon_data; } /** * @brief accessor to the timestamps data buffer * @return the timestamps data buffer */ double* get_time_data() const { return time_data; } /** * @brief build the pixels viewing directions, as a segement from satellite position to viewed pixel center. All positions are stored in Earth Center Rotating carthesian coordinates */ // virtual void load_viewing_directions () { // UnimplementedMethod e(__FILE__,__LINE__,__PRETTY_FUNCTION__); // throw e; // }; /** * @brief free the pixels viewing directions, if any set */ // virtual void free_viewing_directions (); /** * @brief print all the viewing directions */ // void print_viewing_directions (); /** * @brief build the table that maps the gridded pixels indices to their data representation * Most of time, it will be exactly the same, but for instance, in the PARASOL data, it will maps the gridded pixels indices to their matching record number */ virtual void load_pix2data_map () { UnimplementedMethod e(__FILE__,__LINE__,__PRETTY_FUNCTION__); throw e; }; /** * @brief print the table that maps the gridded pixels indices to their data representation */ void print_pix2data_map (); /** * @brief free the table that maps the gridded pixels indices to their data representation */ void free_pix2data_map (); /** * @brief viewing directions table accessor * @return the viewing directions table */ // const std::map< PixelIndice, Carthesian::Segment3D > & get_viewing_directions() const { // return viewing_directions; // } /** * @brief a unique viewing direction accessor * @param ipix a pixel indice * @return the viewing direction for the given pixel */ // const Carthesian::Segment3D & get_viewing_direction(const PixelIndice & ipix) { // return viewing_directions[ipix]; // } /** * @brief constucts the viewing directions observations for the given grid pixel * @param ipix pixel indices * @param v_obs vector of observation(s). Can contains more than one for directional products */ virtual void get_viewing_directions (const vector & ipix, vector & v_obs){v_obs.clear();}; /** * @brief test if the data requested for computing the viewing directions has been loaded */ virtual bool is_viewing_directions_data_loaded() {return false;}; /** * @brief load the data requested for computing the viewing directions */ virtual void load_viewing_directions_data () {;}; /** * @brief free the data requested for computing the viewing directions */ virtual void free_viewing_directions_data () {;}; }; #endif