• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

/home/pascal/depot/filedata/src/caliopfiledata.h

00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Nicolas PASCAL                                  *
00003  *   nicolas.pascal@icare.univ-lille1.fr                                   *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 /**************************************************************************
00022 *  History :                                                             *
00023 *  1/08/05 : start                                                        *
00024 **************************************************************************/
00025 
00026 #ifndef CALIOPFILEDATA_H
00027 #define CALIOPFILEDATA_H
00028 
00029 #include "hdffiledata.h"
00030 // #include "tools.h"
00031 #include "file_tools.h"
00032 #include <iterator>
00033 #include <algorithm>
00034 #include "satellitefiledata.h"
00035 
00039 struct FeatureClassFlag{
00040         unsigned int type : 3;
00041         unsigned int typeQA : 2;
00042         unsigned int phase : 2;
00043         unsigned int phaseQA : 2;
00044         unsigned int subtype : 3;
00045         unsigned int subtypeQA : 1;
00046         unsigned int horizontal_avg_detection : 3;
00047     };
00048 
00057 class CALIOPFileData : public SatelliteFileData, public HDFFileData {
00058 public:
00060     static const int nb_cloud_layer=10;
00062     static const int nb_lidar_surface_elevation=8;
00064     static const int nb_aerosol_layer=8;
00066     static const int nb_vbins=583;
00068     static const int nb_vfm_bins=5515;
00070     static const int nb_vfm_samples_per_profile=545;
00071 
00073     static const int nb_meteo_level=33;
00075     static const int nb_05kmcpro_bins=345;
00076 
00078     static const float32 meteo_level_altitude[];
00080     static const float32 cal_lid_l2_vfm_altitude[];
00082     static const float32 cal_lid_l2_vfm_altitude_ud[];
00083 
00085     static const float32 cal_lid_l2_05kmCPro_altitude[];
00086 
00087     static const float colocation_tolerance;
00088 
00092     enum ProductType{
00093             CAL_LID_UNDEFINED,
00094             CAL_LID_L1,
00095             CAL_LID_L2_333mCLay,
00096             CAL_LID_L2_01kmCLay,
00097             CAL_LID_L2_05kmCLay,
00098             CAL_LID_L2_05kmALay,
00099             CAL_LID_L2_40kmAPro,
00100             CAL_LID_L2_05kmCPro,
00101             CAL_LID_L2_VFM
00102     };
00103 
00111     static inline bool is_same_orbit(const CALIOPFileData* fd1, const CALIOPFileData* fd2) {
00112       string fd1_timestamp=(fd1->get_name()).substr((fd1->get_name()).size()-25,21);
00113       string fd2_timestamp=(fd2->get_name()).substr((fd2->get_name()).size()-25,21);
00114       return fd1_timestamp==fd2_timestamp;
00115     }
00120 //     virtual void load_viewing_directions ();
00124     virtual bool is_viewing_directions_data_loaded();
00128     virtual void load_viewing_directions_data ();
00132     virtual void free_viewing_directions_data ();
00138     virtual void get_viewing_directions (const vector <int> & ipix, vector <Observation> & v_obs);
00139 private:
00143     int level;
00147     ProductType product_type;
00151     float resolution;
00155     bool day_mode;
00159     int nb_layer;
00160 
00162     string product;
00163 
00164     int lat_lon_index_max[2];
00165 
00166     float lat_min,lat_max,lon_min,lon_max;
00167 
00169     float64 * v_pos_data;
00171     float32 * v_alt_data;
00172 
00173     // some constant specific to CALIOP
00174     string latitude_sds_name;
00175     string longitude_sds_name;
00176     string time_sds_name;
00177 
00178     void init();
00179 
00180 public:
00181 
00187     CALIOPFileData(const string &_name = string(""), const string & mode = string("r"));
00191     ~CALIOPFileData();
00196     const int get_level() const {
00197         return level;
00198     };
00199     void set_lat_lon_index_max();
00205     const int * get_lat_lon_index_max() const {
00206         return lat_lon_index_max;
00207     }
00212     const bool is_day() const;
00217     const int get_nb_geo_points() const ;
00222     int get_nb_layer() const {
00223       return nb_layer;
00224     };
00230     template <class T>
00231     static const T get_calipso_fill_value(const string &typecode);
00232 
00242     const bool get_index(const float &lat, const float& lon, int &nearest_pix_idx, const float colocation_tolerance=CALIOPFileData::colocation_tolerance);
00243 
00252      virtual void get_vindex(vector < vector < int > > &v_index, const float &lat, const float& lon,
00253                                                     const float colocation_tolerance = CALIOPFileData::colocation_tolerance ) ;
00254 
00263     const float get_nearest_point_distance(const float &lat,const float &lon,const float coloc_tolerance=CALIOPFileData::colocation_tolerance);
00272     const bool contain_location(const float &lat,const float &lon, const double &tolerance=CALIOPFileData::colocation_tolerance);
00283     const bool contain_data(const float &lat, const float &lon, const double &time, const double &colocation_tolerance=CALIOPFileData::colocation_tolerance) ;
00288     void load_geolocation_data();
00292     void free_geolocation_data();
00296     const bool is_geolocation_data_loaded() const;
00300 //     virtual void load_lines_of_sight ();
00304 //     virtual void free_lines_of_sight ();
00308     virtual void load_v_pixel() ;
00312     virtual void close_data_file() {
00313         free_hdf_file();
00314     };
00318     virtual void open_data_file() {
00319         load_hdf_file();
00320     };
00328     virtual void get_pixel_coord ( const vector < int > & ipix, float &lat, float &lon, double &time ) {
00329         if (!is_geolocation_data_loaded())
00330             load_geolocation_data();
00331         lat  = lat_data  [ ipix[0] ];
00332         lon  = lon_data  [ ipix[0] ];
00333         time = time_data [ ipix[0] ];
00334     };
00335 
00340     const float get_resolution() const {
00341         return resolution;
00342     }
00343     virtual string get_product(){
00344         return product;
00345     };
00346 
00351     static const float32* get_cal_lid_l2_vfm_altitude() {
00352         return cal_lid_l2_vfm_altitude;
00353     }
00354 
00359     static const float32* get_cal_lid_l2_05kmcpro_altitude() {
00360         return cal_lid_l2_05kmCPro_altitude;
00361     }
00362 
00363 private:
00369     void check_filename( const string& short_filename ) const;
00374     void parse_filename( const string& short_filename );
00379     void set_time_coverage();
00380 protected:
00384     void set_lat_lon_min_max();
00385 };
00386 template <class T>
00387 const T CALIOPFileData::get_calipso_fill_value(const string &typecode) {
00388     if (typecode=="float64" || typecode=="double" ||
00389         typecode=="float32" || typecode=="float" ||
00390         typecode=="int32"   || typecode=="long" ||
00391         typecode=="int16"   || typecode=="short"
00392         )
00393         return static_cast<T>(-9999);
00394     else if (typecode=="int8"
00395             )
00396         return static_cast<T>(-99);
00397     else {
00398         cerr<<"In "<<__FILE__<<" at "<<__LINE__<<" : case of typecode "<<typecode<<" not treated yet"<<endl;
00399         exit(0);
00400     }
00401 }
00402 
00403 #endif

Generated on Thu Feb 14 2013 17:59:03 for filedata.kdevelop by  doxygen 1.7.1