Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes

MODISFileData Class Reference

#include <modisfiledata.h>

Inheritance diagram for MODISFileData:
Inheritance graph
[legend]
Collaboration diagram for MODISFileData:
Collaboration graph
[legend]

List of all members.

Public Member Functions

const int get_x_size_10km ()
 accessor to the size of the swath for a 10km resolution
const int get_y_size_10km ()
 accessor to the size of the track for a 10km resolution
const int get_x_size_5km ()
 accessor to the size of the swath for a 5km resolution
const int get_y_size_5km ()
 accessor to the size of the track for a 5km resolution
const int get_x_size_1km ()
 accessor to the size of the swath for a 1km resolution
const int get_y_size_1km ()
 accessor to the size of the track for a 1km resolution
const int get_x_size_250m ()
 accessor to the size of the cross-track dimension of the 250m resolution grid
const int get_y_size_250m ()
 accessor to the size of the along-track dimension of the 250m resolution grid
 MODISFileData (const string &_name, const string &mode="r")
 Constructor.
 ~MODISFileData ()
 Destructor :
void print_gring () const
 prints out the gring values
const string get_radix ()
 access to the radix of the MODIS file. $ What is called the radix is the filename ( without path ) with product and date informations only (and without dot also) Ex : "MYD021KM.A2003281.1340.004.2004158015852.hdf" as a radix of "MYD021KM.A2003281"
const bool get_5_to_1km_index (const float &lat, const float &lon, int *one_km_indexes, const int *five_km_indexes=NULL)
 convert indexes at 5km to ones at 1km. Uses a linear interpolation between the data values read at 5km, and the real desired lat, lon.
const bool get_1km_to_250m_pixel (const float32 lat, const float32 lon, const int i_pix_1km[2], int i_pix_250m[2])
 get 250m indexes of nearest point when geolocation data are given at 1km.
const bool get_5km_to_1km_pixel (const float32 lat, const float32 lon, const int i_pix_5km[2], int i_pix_1km[2])
 get 1km indexes of nearest point when geolocation data are given at 5km.
void get_5_to_1km_area (const int *five_km_idx, int *one_km_min_idx, int *one_km_max_idx)
 get the top-left and bottom-right corner of a 5km cell using 1km indexes. The indexes start from 0. The resulting 1km indexes are included in the 5km area. Precondition : the allocations MUST be already done
const int convert_5_to_1km_index (const int &five_km_index, const bool is_x_axis=false) const
 convert an index at 1km to the one representing the same point at 5km.
void convert_1km_to_250m_index (const int i_pix_1km[2], float i_pix_250m[2]) const
 convert the indexes of a point in the 250m grid to the corresponding indexes in the 1km grid.
const bool contain_data (const float &lat, const float &lon, const double &time, const double &tolerance=0.1)
const bool contain_location (const float &lat, const float &lon, const double &tolerance=0.1)
 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.
const vector< int > get_lat_lon_index_max_5km () const
 access to the higher usable indexes of the "Latitude" and "Longitude" sds. In other words, it returns the size of those sds arrays, diminuted of 1. Ex : if the sds "Latitude" has a size of (287,3), it will return [286,2]
const vector< int > get_lat_lon_index_max_1km () const
 access to the higher usable indexes of the "Latitude" and "Longitude" sds. In other words, it returns the size of those sds arrays, diminuted of 1. Ex : if the sds "Latitude" has a size of (287,3), it will return [286,2]
string get_product () const
 accessor to the product name (MYD06_L2,...)
float get_resolution () const
 accessor to the resolution of th product (in Km)
void load_geolocation_data ()
 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.
void free_geolocation_data ()
 free eventually loaded geolocation data
virtual void close_data_file ()
 closes the file.
virtual void open_data_file ()
 opens the file.
const bool is_geolocation_data_loaded () const
 Tell if the geolocation data have been already loaded.
void get_sds_calibration (const string &sds_name, double &scale, double &offset, const string &scale_name="scale_factor", const string &offset_name="add_offset", const int channel_nb=-1)
 read the calibration coefficients of the sds given in parametre In most cases, you
template<class Value_T , class Count_T >
Value_T * read_calibrated_data (Value_T *data, const char *sds_name="Height", int start[]=NULL, int stride[]=NULL, int edges[]=NULL, int rank=-1, Value_T fill_value=Value_T(0), const string &scale_name="scale_factor", const string &offset_name="add_offset", const int channel_nb=-1)
 read the data of a MODIS file sds, and apply the calibration to it The applied calibration uses the formula : scale*(x-add_offset) The method manages the allocation of the data' array if data is NULL. Here is assumed that once the calibration is applied, the float type fits the data. Perhaps, it will be nexessary to review it The template arguments are :

  • Value_T : the type of the calibrated values
  • Count_T : the type of the count (ie uncalibrated) data

const bool get_index (const float &lat, const float &lon, const double time, int *near_point_idx, float coloc_tolerance=-1.)
 search the index of the nearest point in the data to (lat , lon ) If coloc_tolerance is given, it will compute only the distance of the points that have a distance to ( lat, lon ) inferior to coloc_tolerance
const bool get_index (const float &lat, const float &lon, int &nearest_pix_idx, float coloc_tolerance=-1.)
 search the index of the nearest point in the data to (lat , lon ) If coloc_tolerance is given, it will compute only the distance of the points that have a distance to ( lat, lon ) inferior to coloc_tolerance
virtual void get_vindex (vector< vector< int > > &v_index, const float &lat, const float &lon, const float colocation_tolerance)
 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
const float get_nearest_point_distance (const float &lat, const float &lon, float coloc_tolerance=-1.)
 compute the distance to (lat,lon) of the nearest point in the data If coloc_tolerance is given, it will compute only the distance of the points that have a distance to ( lat, lon ) inferior to coloc_tolerance
virtual void get_pixel_coord (const vector< int > &ipix, float &lat, float &lon, double &time)
 retrieve the coordinates of a pixel using its index
vector< float32 > get_lat_gran_corner () const
 accessor to the latitudes of the granule corners
vector< float32 > get_lon_gran_corner () const
 accessor to the longitudes of the granule corners
vector< int > get_geolocation_dim () const
 return the dimensions of the geolocation dataset, in [ npix_track, npix_scan ] order
void get_250m_pix_pos (const int itk_250m, const int isc_250m, float32 &lat, float32 &lon)
 compute the (lat,lon) of a 250m pixel specified with its indexes, when the geolocation datasets are given at 1km resolution
void get_1km_pix_pos (const int itk_1km, const int isc_1km, float &lat, float &lon)
 compute the (lat,lon) of a 1km pixel specified with its indexes, when the geolocation datasets are given at 1km resolution
void get_bounds_1km_to_250m (const int itk_1km, const int isc_1km, int &itk_250m_min, int &itk_250m_max, int &isc_250m_min, int &isc_250m_max)
 return the bound indexes, in the 250m grid, of all the 250m pixels that are included in a 1km pixel The 250m pixels that are situed at the border of a 1km pixel are also returned. The last 250m pixel in the cross-track direction is also considered as included in the last 1km cross-track pixel
void get_bounds_5km_to_1km (const int itk_5km, const int isc_5km, int &itk_1km_min, int &itk_1km_max, int &isc_1km_min, int &isc_1km_max)
 return the bound indexes, in the 1km grid, of all the 1km pixels that are included in a 5km pixel The 1km pixels that are situed at the border of a 5km pixel are also returned. The last 1km pixel in the cross-track direction is also considered as included in the last 5km cross-track pixel

Static Public Attributes

static const int NB_MAX_X_10KM = 135
static const int NB_MAX_Y_10KM = 204
static const int NB_MAX_X_5KM = 271
static const int NB_MAX_Y_5KM = 410
static const int NB_MAX_X_1KM = 1354
static const int NB_MAX_Y_1KM = 2054
static const int NB_MAX_X_250M = 5416
static const int NB_MAX_Y_250M = 8216

Protected Types

enum  PlatformType { UNDEFINED_PLATFORM_TYPE = 0, TERRA, AQUA }
enum  Product_ID {
  UNDEFINED_PRODUCT_ID = 0, MYD02QKM, MYD02HKM, MYD021KM,
  MYD03, MYD02SSH, MYD04_L2, MYD05_L2,
  MYD06_L2, MOD06_L2
}
typedef vector< double > GRingPoint
typedef vector< GRingPoint > GRingPolygon
typedef vector< GRingPolygon > GRing

Protected Member Functions

void init ()
 Initialize some basic attributes.
void set_time_coverage ()
 sets the time coverage of the product
void parse_filename (const string &file_basename)
 initializes some characteristics based on the product name
bool check_filename (const string &file_basename) const
 check if the product name matches the official naming convention
void set_lat_lon_index_max ()
 sets the size of the geolocation dataset
void set_gring ()
 set the GRing coordinates Read in the coremetadata
const bool is_inside_gring (const float &lat, const float &lon) const
 test if the given point is inside the GRing The grings which are crossing the change date longitude are treated
virtual string get_gring_latitude_name (const string &product="")
 access to the name of the field that contains the latitude gring
virtual string get_gring_longitude_name (const string &product="")
 access to the name of the field that contains the longitude gring
virtual void load_v_pixel ()
 load the list data pixels
void init_colocation_tolerance ()
 defines the colocatiuon tolerance, depending of the product type, because the geolocation datasets are not always given at the same resolution
void set_lat_lon_min_max ()
 sets the granule bounding coordinates Minimal and maximal latitudes and longitudes are read in the coremetadata
void get_y_pos_1km_to_250m (const int isc_1km, const int itk_p1_1km, const int itk_p2_1km, const int itk_250m, double &lat, double &lon)
 return the position of 250m pixel defined by its along-track index between 2 successive 1km pixels on a same cross-track line
void get_x_pos_1km_to_250m (const double lat_left_250m, const double lon_left_250m, const int isc_left_1km, const double lat_right_250m, const double lon_right_250m, const int isc_right_1km, const int isc_250m, double &lat, double &lon)
 retrieve the position of a 250m pixel set by its cross-track index and the position of 2 along-track lines set by 2 sucessive 1km pixels
void get_y_pos_5km_to_1km (const int isc_5km, const int itk_p1_5km, const int itk_p2_5km, const int itk_1km, double &lat, double &lon)
 return the position of 1km pixel defined by its along-track index between 2 successive 5km pixels on a same cross-track line
void get_x_pos_5km_to_1km (const double lat_left_1km, const double lon_left_1km, const int isc_left_5km, const double lat_right_1km, const double lon_right_1km, const int isc_right_5km, const int isc_1km, double &lat, double &lon)
 retrieve the position of a 1km pixel set by its cross-track index and the position of 2 along-track lines set by 2 sucessive 5km pixels

Protected Attributes

float colocation_tolerance
PlatformType platform
Product_ID product_id
string product
float resolution
float lat_min
float lat_max
float lon_min
float lon_max
vector< int > lat_lon_index_max
GRing gring
vector< PixelType > v_pixel
vector< float32 > lat_gran_corner
vector< float32 > lon_gran_corner

Static Protected Attributes

static const string latitude_sds_name = "Latitude"
static const string longitude_sds_name = "Longitude"
static const int fast_srch_frame_x
static const int fast_srch_frame_y

Detailed Description

Class managing the opening, reading, and accessing to the data of a MODIS File. MODIS products managed : MYD06_L2 ; MYD021KM ;

Author:
Nicolas PASCAL

Member Enumeration Documentation

enum MODISFileData::PlatformType [protected]

defines the possible types of MODIS platform

enum MODISFileData::Product_ID [protected]

defines an ID for the different supported MODIS product


Constructor & Destructor Documentation

MODISFileData::MODISFileData ( const string &  _name,
const string &  mode = "r" 
)

Constructor.

Parameters:
_name the name (path+filename) of the file to be opened
mode the opening mode. LIMITATION : only "r" mode treated at this time

References init().


Member Function Documentation

bool MODISFileData::check_filename ( const string &  file_basename  )  const [protected]

check if the product name matches the official naming convention

Parameters:
file_basename the basename of the product file
Returns:
true if the file name matches the convention

Referenced by parse_filename().

const bool MODISFileData::contain_data ( const float &  lat,
const float &  lon,
const double &  time,
const double &  tolerance = 0.1 
) [virtual]

check if this file has data coincident with (lat,lon,time)

Parameters:
lat the latitude of the event
lon the longitude of the event
time the time of the event. If -1., time test will be ignored
Returns:

Reimplemented from FileData.

References contain_location(), and FileData::contain_time().

const bool MODISFileData::contain_location ( const float &  lat,
const float &  lon,
const double &  tolerance = 0.1 
) [virtual]

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.

Parameters:
lat the latitude of the event
lon the longitude of the event
tolerance acceptable bias between the nearest point in the data and the given (lat,lon) point
Returns:
true if a point in the data has been found in the colocation frame

Reimplemented from FileData.

References get_index().

Referenced by contain_data().

void MODISFileData::convert_1km_to_250m_index ( const int  i_pix_1km[2],
float  i_pix_250m[2] 
) const

convert the indexes of a point in the 250m grid to the corresponding indexes in the 1km grid.

Parameters:
i_pix_1km the (track, swath) indexes at 1km resolution
i_pix_250m the (track, swath) indexes at 250m resolution. In float type because of non integer offset between the 2 grids along track
const int MODISFileData::convert_5_to_1km_index ( const int &  five_km_index,
const bool  is_x_axis = false 
) const

convert an index at 1km to the one representing the same point at 5km.

Parameters:
five_km_index the index at 5 km resolution
is_x_axis wether the axis we search the index is the x or the y one
Returns:
the index of the same point at at 1 km resolution

References lat_lon_index_max.

Referenced by get_lat_lon_index_max_1km().

void MODISFileData::get_1km_pix_pos ( const int  itk_1km,
const int  isc_1km,
float &  lat,
float &  lon 
) [inline]

compute the (lat,lon) of a 1km pixel specified with its indexes, when the geolocation datasets are given at 1km resolution

Warning:
at this time, this method is only supported for MYD06, MOD06, MYD05 products
Parameters:
itk_1km [IN] grid index of the 1km pixel along-track
isc_1km [IN] grid index of the 1km pixel cross-track
lat [OUT] the latitude of the 1km pixel center at [ itk_1km, isc_1km ]
lon [OUT] the longitude of the 1km pixel center at [ itk_1km, isc_1km ]

References get_x_pos_5km_to_1km(), get_x_size_1km(), get_x_size_5km(), get_y_pos_5km_to_1km(), get_y_size_1km(), product, and product_id.

const bool MODISFileData::get_1km_to_250m_pixel ( const float32  lat,
const float32  lon,
const int  i_pix_1km[2],
int  i_pix_250m[2] 
)

get 250m indexes of nearest point when geolocation data are given at 1km.

Warning:
this method is supposed to be used only with MYD02QKM products Uses a bilinear interpolation between the geolocation data at 1km, and the real desired lat, lon to obtain the 250m indexes
Parameters:
lat [IN] the latitude of the point to search
lon [IN] the longitude of the point to search
i_pix_1km [IN] the indexes at 1km resolution (input)
i_pix_250m [OUT] the indexes at 250m resolution
void MODISFileData::get_250m_pix_pos ( const int  itk_250m,
const int  isc_250m,
float32 &  lat,
float32 &  lon 
) [inline]

compute the (lat,lon) of a 250m pixel specified with its indexes, when the geolocation datasets are given at 1km resolution

Warning:
at this time, this method is only supported for MYD02QKM products
Parameters:
itk_250m [IN] grid index of the 250m pixel along-track
isc_250m [IN] grid index of the 250m pixel cross-track
lat [OUT] the latitude of the 250m pixel center at [ itk_250m, isc_250m ]
lon [OUT] the longitude of the 250m pixel center at [ itk_250m, isc_250m ]

References get_x_pos_1km_to_250m(), get_x_size_250m(), get_y_pos_1km_to_250m(), get_y_size_250m(), and product_id.

void MODISFileData::get_5_to_1km_area ( const int *  five_km_idx,
int *  one_km_min_idx,
int *  one_km_max_idx 
)

get the top-left and bottom-right corner of a 5km cell using 1km indexes. The indexes start from 0. The resulting 1km indexes are included in the 5km area. Precondition : the allocations MUST be already done

Parameters:
five_km_idx the indexes of a cell of 5km side, using 5km indexes
one_km_min_idx the top-left corner indexes (1km)
one_km_max_idx the bottom-right corner indexes (1km)

References lat_lon_index_max.

const bool MODISFileData::get_5_to_1km_index ( const float &  lat,
const float &  lon,
int *  one_km_indexes,
const int *  five_km_indexes = NULL 
)

convert indexes at 5km to ones at 1km. Uses a linear interpolation between the data values read at 5km, and the real desired lat, lon.

Parameters:
lat the latitude
lon the longitude
one_km_indexes the indexes at 1 km resolution (output)
five_km_indexes the indexes at 5 km resolution (input). Not necessary, but if not precised, the search of those indexes is proceed, and it takes time.

References is_geolocation_data_loaded(), SatelliteFileData::lat_data, lat_lon_index_max, linear_interpolation(), and SatelliteFileData::lon_data.

const bool MODISFileData::get_5km_to_1km_pixel ( const float32  lat,
const float32  lon,
const int  i_pix_5km[2],
int  i_pix_1km[2] 
)

get 1km indexes of nearest point when geolocation data are given at 5km.

Warning:
this method is tested only with MYD06 and MYD05 products Uses a bilinear interpolation between the geolocation data at 5km, and the real desired lat, lon to obtain the 1km indexes
Parameters:
lat [IN] the latitude of the point to search
lon [IN] the longitude of the point to search
i_pix_1km [IN] the indexes at 5km resolution
i_pix_250m [OUT] the indexes at 1km resolution
void MODISFileData::get_bounds_1km_to_250m ( const int  itk_1km,
const int  isc_1km,
int &  itk_250m_min,
int &  itk_250m_max,
int &  isc_250m_min,
int &  isc_250m_max 
) [inline]

return the bound indexes, in the 250m grid, of all the 250m pixels that are included in a 1km pixel The 250m pixels that are situed at the border of a 1km pixel are also returned. The last 250m pixel in the cross-track direction is also considered as included in the last 1km cross-track pixel

Warning:
at this time, this method is only supported for MYD02QKM products
Parameters:
itk_1km [IN] 1km grid index of the 1km pixel along-track
isc_1km [IN] 1km grid index of the 1km pixel cross-track
itk_250m_min [OUT] min 250m grid index along-track of the 250m pixels included in the footprint of the requested 1km pixel
itk_250m_max [OUT] max 250m grid index along-track of the 250m pixels included in the footprint of the requested 1km pixel
isc_250m_min [OUT] min 250m grid index cross-track of the 250m pixels included in the footprint of the requested 1km pixel
isc_250m_max [OUT] max 250m grid index cross-track of the 250m pixels included in the footprint of the requested 1km pixel

References get_x_size_1km().

void MODISFileData::get_bounds_5km_to_1km ( const int  itk_5km,
const int  isc_5km,
int &  itk_1km_min,
int &  itk_1km_max,
int &  isc_1km_min,
int &  isc_1km_max 
) [inline]

return the bound indexes, in the 1km grid, of all the 1km pixels that are included in a 5km pixel The 1km pixels that are situed at the border of a 5km pixel are also returned. The last 1km pixel in the cross-track direction is also considered as included in the last 5km cross-track pixel

Warning:
at this time, this method is only supported for MYD02QKM products
Parameters:
itk_5km [IN] 5km grid index of the 5km pixel along-track
isc_5km [IN] 5km grid index of the 5km pixel cross-track
itk_1km_min [OUT] min 1km grid index along-track of the 1km pixels included in the footprint of the requested 5km pixel
itk_1km_max [OUT] max 1km grid index along-track of the 1km pixels included in the footprint of the requested 5km pixel
isc_1km_min [OUT] min 1km grid index cross-track of the 1km pixels included in the footprint of the requested 5km pixel
isc_1km_max [OUT] max 1km grid index cross-track of the 1km pixels included in the footprint of the requested 5km pixel

References get_x_size_5km(), and product_id.

vector< int > MODISFileData::get_geolocation_dim (  )  const [inline]

return the dimensions of the geolocation dataset, in [ npix_track, npix_scan ] order

Returns:
the dimensions of the geolocation dataset

References lat_lon_index_max.

virtual string MODISFileData::get_gring_latitude_name ( const string &  product = ""  )  [inline, protected, virtual]

access to the name of the field that contains the latitude gring

Parameters:
product the file product
Returns:
the gring latitude name. Default : "GRINGPOINTLATITUDE"

Referenced by set_gring().

virtual string MODISFileData::get_gring_longitude_name ( const string &  product = ""  )  [inline, protected, virtual]

access to the name of the field that contains the longitude gring

Parameters:
product the file product
Returns:
the gring longitude name. Default : "GRINGPOINTLONGITUDE"

Referenced by set_gring().

const bool MODISFileData::get_index ( const float &  lat,
const float &  lon,
const double  time,
int *  near_point_idx,
float  coloc_tolerance = -1. 
)

search the index of the nearest point in the data to (lat , lon ) If coloc_tolerance is given, it will compute only the distance of the points that have a distance to ( lat, lon ) inferior to coloc_tolerance

Parameters:
near_point_idx the indexes of the nearest point found (or {-1,-1} if not found)
lat the latitude
lon the longitude
time the time of the observation. If -1., skipped
coloc_tolerance the -/+ maximal tolerance for 2 points considered as colocated
Returns:
true if found

References colocation_tolerance, free_geolocation_data(), Geocentric::get_haversine_dist(), is_geolocation_data_loaded(), lat_max, lat_min, load_geolocation_data(), lon_max, lon_min, and v_pixel.

Referenced by contain_location(), get_index(), and get_nearest_point_distance().

const bool MODISFileData::get_index ( const float &  lat,
const float &  lon,
int &  nearest_pix_idx,
float  coloc_tolerance = -1. 
)

search the index of the nearest point in the data to (lat , lon ) If coloc_tolerance is given, it will compute only the distance of the points that have a distance to ( lat, lon ) inferior to coloc_tolerance

Parameters:
near_point_idx the indexes of the nearest point found (or {-1,-1} if not found)
lat the latitude
lon the longitude
time the time of the observation. If -1., skipped
coloc_tolerance the -/+ maximal tolerance for 2 points considered as colocated
Returns:
true if found

References get_index(), and lat_lon_index_max.

vector< float32 > MODISFileData::get_lat_gran_corner (  )  const [inline]

accessor to the latitudes of the granule corners

Returns:
the latitudes of the granule corners

References lat_gran_corner.

const vector<int> MODISFileData::get_lat_lon_index_max_1km (  )  const [inline]

access to the higher usable indexes of the "Latitude" and "Longitude" sds. In other words, it returns the size of those sds arrays, diminuted of 1. Ex : if the sds "Latitude" has a size of (287,3), it will return [286,2]

Returns:
an array containing the maximal usable indexes for the geolocation sds

References convert_5_to_1km_index(), and lat_lon_index_max.

const vector<int> MODISFileData::get_lat_lon_index_max_5km (  )  const [inline]

access to the higher usable indexes of the "Latitude" and "Longitude" sds. In other words, it returns the size of those sds arrays, diminuted of 1. Ex : if the sds "Latitude" has a size of (287,3), it will return [286,2]

Returns:
an array containing the maximal usable indexes for the geolocation sds

References lat_lon_index_max.

vector< float32 > MODISFileData::get_lon_gran_corner (  )  const [inline]

accessor to the longitudes of the granule corners

Returns:
the longitudes of the granule corners

References lon_gran_corner.

const float MODISFileData::get_nearest_point_distance ( const float &  lat,
const float &  lon,
float  coloc_tolerance = -1. 
)

compute the distance to (lat,lon) of the nearest point in the data If coloc_tolerance is given, it will compute only the distance of the points that have a distance to ( lat, lon ) inferior to coloc_tolerance

Parameters:
lat the latitude
lon the longitude
coloc_tolerance the -/+ maximal tolerance for 2 points considered as colocated
Returns:
the distance to the nearest point, or -1 if no point in the colocalisation frame has been found.

References free_geolocation_data(), Geocentric::get_haversine_dist(), get_index(), is_geolocation_data_loaded(), SatelliteFileData::lat_data, load_geolocation_data(), and SatelliteFileData::lon_data.

virtual void MODISFileData::get_pixel_coord ( const vector< int > &  ipix,
float &  lat,
float &  lon,
double &  time 
) [inline, virtual]

retrieve the coordinates of a pixel using its index

Parameters:
ipix [IN] index of the pixel
lat [OUT] latitude of the pixel
lon [OUT] longitude of the pixel
time [OUT] timestamp of the pixel
string MODISFileData::get_product (  )  const [inline]

accessor to the product name (MYD06_L2,...)

Returns:
the product name

References product.

const string MODISFileData::get_radix (  ) 

access to the radix of the MODIS file. $ What is called the radix is the filename ( without path ) with product and date informations only (and without dot also) Ex : "MYD021KM.A2003281.1340.004.2004158015852.hdf" as a radix of "MYD021KM.A2003281"

Returns:
the radix

References FileData::date, Date::get_day(), Date::get_month(), Date::get_month_string(), Date::get_year(), and product.

float MODISFileData::get_resolution (  )  const [inline]

accessor to the resolution of th product (in Km)

Returns:
the product's resolution (Km)

References resolution.

void MODISFileData::get_sds_calibration ( const string &  sds_name,
double &  scale,
double &  offset,
const string &  scale_name = "scale_factor",
const string &  offset_name = "add_offset",
const int  channel_nb = -1 
)

read the calibration coefficients of the sds given in parametre In most cases, you

Parameters:
sds_name the name of the sds where to read the calibration coefficients
scale the output scale
offset the output offset
scale_name the name of the scale attribute as given in the sds
offset_name the name of the offset attribute as given in the sds
channel_nb the channel number. Useful only for multiple scaling values in one sds

References HDFFileData::hdf_file, HDFFileData::is_hdf_file_loaded(), and product.

Referenced by read_calibrated_data().

virtual void MODISFileData::get_vindex ( vector< vector< int > > &  v_index,
const float &  lat,
const float &  lon,
const float  colocation_tolerance 
) [inline, virtual]

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

Parameters:
lat the latitude
lon the longitude
colocation_tolerance the acceptable bias (in km or degrees. Supposed to be in, a plane approximation) between [lat,lon] and the nearest data point.
Returns:
the list of indices of pixels
void MODISFileData::get_x_pos_1km_to_250m ( const double  lat_left_250m,
const double  lon_left_250m,
const int  isc_left_1km,
const double  lat_right_250m,
const double  lon_right_250m,
const int  isc_right_1km,
const int  isc_250m,
double &  lat,
double &  lon 
) [inline, protected]

retrieve the position of a 250m pixel set by its cross-track index and the position of 2 along-track lines set by 2 sucessive 1km pixels

Parameters:
lat_left_250m [IN] latitude of the 250m along track pixel that is the intersection between cross-track line at index isc_250m and the along-track line that joins the 2 sucessive bounding 1km pixels on the left of the point to interpolate
lon_left_250m [IN] longitude of the 250m along track pixel that is the intersection between cross-track line at index isc_250m and the along-track line that joins the 2 sucessive bounding 1km pixels on the left of the point to interpolate
isc_left_1km [IN] cross-track index at 1km of the left border
lat_right_250m [IN] latitude of the 250m along track pixel that is the intersection between cross-track line at index isc_250m and the along-track line that joins the 2 sucessive bounding 1km pixels on the right of the point to interpolate
lon_right_250m [IN] longitude of the 250m along track pixel that is the intersection between cross-track line at index isc_250m and the along-track line that joins the 2 sucessive bounding 1km pixels on the right of the point to interpolate
isc_right_1km [IN] cross-track index at 1km of the right border
lat [OUT] latitude of the pixel at [itk_250m, isc_1km], interpolated between the 2 successive 1km pixels p1 and p2
lon [OUT] longitude of the pixel at [itk_250m, isc_1km], interpolated between the 2 successive 1km pixels p1 and p2

Referenced by get_250m_pix_pos().

void MODISFileData::get_x_pos_5km_to_1km ( const double  lat_left_1km,
const double  lon_left_1km,
const int  isc_left_5km,
const double  lat_right_1km,
const double  lon_right_1km,
const int  isc_right_5km,
const int  isc_1km,
double &  lat,
double &  lon 
) [inline, protected]

retrieve the position of a 1km pixel set by its cross-track index and the position of 2 along-track lines set by 2 sucessive 5km pixels

Parameters:
lat_left_1km [IN] latitude of the 1km along track pixel that is the intersection between cross-track line at index isc_1km and the along-track line that joins the 2 sucessive bounding 5km pixels on the left of the point to interpolate
lon_left_1km [IN] longitude of the 1km along track pixel that is the intersection between cross-track line at index isc_1km and the along-track line that joins the 2 sucessive bounding 5km pixels on the left of the point to interpolate
isc_left_5km [IN] cross-track index at 5km of the left border
lat_right_1km [IN] latitude of the 1km along track pixel that is the intersection between cross-track line at index isc_1km and the along-track line that joins the 2 sucessive bounding 5km pixels on the right of the point to interpolate
lon_right_1km [IN] longitude of the 1km along track pixel that is the intersection between cross-track line at index isc_1km and the along-track line that joins the 2 sucessive bounding 5km pixels on the right of the point to interpolate
isc_right_5km [IN] cross-track index at 5km of the right border
lat [OUT] latitude of the pixel at [itk_1km, isc_5km], interpolated between the 2 successive 5km pixels p1 and p2
lon [OUT] longitude of the pixel at [itk_1km, isc_5km], interpolated between the 2 successive 5km pixels p1 and p2

Referenced by get_1km_pix_pos().

const int MODISFileData::get_x_size_10km (  )  [inline]

accessor to the size of the swath for a 10km resolution

Returns:
the size of the swath at 10km

References lat_lon_index_max, product, and product_id.

const int MODISFileData::get_x_size_1km (  )  [inline]

accessor to the size of the swath for a 1km resolution

Returns:
the size of the swath at 1km

References get_x_size_5km(), lat_lon_index_max, product, and product_id.

Referenced by get_1km_pix_pos(), get_bounds_1km_to_250m(), get_x_size_250m(), and get_y_pos_1km_to_250m().

const int MODISFileData::get_x_size_250m (  )  [inline]

accessor to the size of the cross-track dimension of the 250m resolution grid

Warning:
only supported for MYD02QKM products at this time
Returns:
the size of the cross-track dimension at 250m

References get_x_size_1km(), product, and product_id.

Referenced by get_250m_pix_pos().

const int MODISFileData::get_x_size_5km (  )  [inline]

accessor to the size of the swath for a 5km resolution

Returns:
the size of the swath at 5km

References lat_lon_index_max, product, and product_id.

Referenced by get_1km_pix_pos(), get_bounds_5km_to_1km(), get_x_size_1km(), and get_y_pos_5km_to_1km().

void MODISFileData::get_y_pos_1km_to_250m ( const int  isc_1km,
const int  itk_p1_1km,
const int  itk_p2_1km,
const int  itk_250m,
double &  lat,
double &  lon 
) [inline, protected]

return the position of 250m pixel defined by its along-track index between 2 successive 1km pixels on a same cross-track line

Warning:
If the 2 pixels are crossing the changing date meridian, the negative longitude will be returned with an increment of 360 to manage correctly the interpolation
Parameters:
isc_1km [IN] index of the cross-track line in the 1km grid
itk_p1_1km [IN] index of the first along-track pixel in the 1km grid
itk_p2_1km [IN] index of the second along-track pixel in the 1km grid
itk_250m [IN] index of the along-track 250m along-track pixel to interpolate
lat [OUT] latitude of the pixel at [itk_250m, isc_1km], interpolated between the 2 successive 1km pixels p1 and p2
lon [OUT] longitude of the pixel at [itk_250m, isc_1km], interpolated between the 2 successive 1km pixels p1 and p2

References get_x_size_1km(), SatelliteFileData::lat_data, and SatelliteFileData::lon_data.

Referenced by get_250m_pix_pos().

void MODISFileData::get_y_pos_5km_to_1km ( const int  isc_5km,
const int  itk_p1_5km,
const int  itk_p2_5km,
const int  itk_1km,
double &  lat,
double &  lon 
) [inline, protected]

return the position of 1km pixel defined by its along-track index between 2 successive 5km pixels on a same cross-track line

Warning:
If the 2 pixels are crossing the changing date meridian, the negative longitude will be returned with an increment of 360 to manage correctly the interpolation
Parameters:
isc_5km [IN] index of the cross-track line in the 5km grid
itk_p1_5km [IN] index of the first along-track pixel in the 5km grid
itk_p2_5km [IN] index of the second along-track pixel in the 5km grid
itk_1km [IN] index of the along-track 1km along-track pixel to interpolate
lat [OUT] latitude of the pixel at [itk_1km, isc_5km], interpolated between the 2 successive 5km pixels p1 and p2
lon [OUT] longitude of the pixel at [itk_1km, isc_5km], interpolated between the 2 successive 5km pixels p1 and p2

References get_x_size_5km(), SatelliteFileData::lat_data, and SatelliteFileData::lon_data.

Referenced by get_1km_pix_pos().

const int MODISFileData::get_y_size_10km (  )  [inline]

accessor to the size of the track for a 10km resolution

Returns:
the size of the track at 10km

References lat_lon_index_max, product, and product_id.

const int MODISFileData::get_y_size_1km (  )  [inline]

accessor to the size of the track for a 1km resolution

Returns:
the size of the track at 1km

References get_y_size_5km(), lat_lon_index_max, product, and product_id.

Referenced by get_1km_pix_pos(), and get_y_size_250m().

const int MODISFileData::get_y_size_250m (  )  [inline]

accessor to the size of the along-track dimension of the 250m resolution grid

Warning:
only supported for MYD02QKM products at this time
Returns:
the size of the along-track dimension at 250m

References get_y_size_1km(), and product_id.

Referenced by get_250m_pix_pos().

const int MODISFileData::get_y_size_5km (  )  [inline]

accessor to the size of the track for a 5km resolution

Returns:
the size of the track at 5km

References lat_lon_index_max, product, and product_id.

Referenced by get_y_size_1km().

const bool MODISFileData::is_inside_gring ( const float &  lat,
const float &  lon 
) const [protected]

test if the given point is inside the GRing The grings which are crossing the change date longitude are treated

Parameters:
lat the latitude of the point
lon the longitude of the point
Returns:
true if the point is inside the gring

References gring.

void MODISFileData::parse_filename ( const string &  file_basename  )  [protected]

initializes some characteristics based on the product name

Parameters:
file_basename the basename of the product file

References check_filename(), FileData::date, platform, product, product_id, resolution, and Date::set_date_str().

Referenced by init().

template<class Value_T , class Count_T >
Value_T * MODISFileData::read_calibrated_data ( Value_T *  data,
const char *  sds_name = "Height",
int  start[] = NULL,
int  stride[] = NULL,
int  edges[] = NULL,
int  rank = -1,
Value_T  fill_value = Value_T(0),
const string &  scale_name = "scale_factor",
const string &  offset_name = "add_offset",
const int  channel_nb = -1 
)

read the data of a MODIS file sds, and apply the calibration to it The applied calibration uses the formula : scale*(x-add_offset) The method manages the allocation of the data' array if data is NULL. Here is assumed that once the calibration is applied, the float type fits the data. Perhaps, it will be nexessary to review it The template arguments are :

  • Value_T : the type of the calibrated values
  • Count_T : the type of the count (ie uncalibrated) data

Warning:
this method has been used only with Value_T of float.
Parameters:
data the buffer to fill with the read values
sds_name the name of the sds (Scientific Data Set) we want to access.
start begining of the selection. If NULL, start at (0,0) if rank is 2 ; (0,0,0) if rank is 3...
stride step between 2 interesting values. If NULL, this step is set to 1 in each dimension (ie all values will be read)
edges number of values to be read in each dimension. if NULL, it will be all data along each dimension.
rank the dimension of start, stride and edges
fill_value the fill value to use in the calibrated data
scale_name the name of the scale attribute as define in the sds
offset_name the name of the offset attribute as define in the sds
channel_nb the index of the channel for scaling with multiple values
Returns:
a pointer to the read data array. It is useful when you let this method manage the allocation to update the allocated pointer to the data. If you've done it yourself or you are using a static buffer, it isn't necessary to catch this return pointer

References HDFFileData::free_hdf_file(), HDFFileData::free_read_write_allocations(), HDFFileData::get_dataset_fill_value(), get_sds_calibration(), HDFFileData::hdf_file, HDFFileData::init_read_write_null_input_param(), HDFFileData::is_hdf_file_loaded(), HDFFileData::load_hdf_file(), and HDFFileData::read_data().


Member Data Documentation

default maximal distance for which to pixels are considered as coincident. Depends of the product

Referenced by get_index(), and init_colocation_tolerance().

const int MODISFileData::fast_srch_frame_x [static, protected]

x size to do a fast search when searching for a coincidence and when a previous coincidence in the granule has already been computed. Optimization purpose

const int MODISFileData::fast_srch_frame_y [static, protected]

y size to do a fast search when searching for a coincidence and when a previous coincidence in the granule has already been computed. Optimization purpose

GRing MODISFileData::gring [protected]

list of the polygons that compose the GRing (each polygon is a list of points)

Referenced by init(), is_inside_gring(), print_gring(), and set_gring().

vector< float32 > MODISFileData::lat_gran_corner [protected]

latitudes of the granule corners as read in the geolocation dataset, in the order [0,0], [0,I_SCAN_MAX], [J_TRACK_MAX, 0], [J_TRACK_MAX, I_SCAN_MAX]

Referenced by get_lat_gran_corner(), init(), and load_geolocation_data().

vector<int> MODISFileData::lat_lon_index_max [protected]
float MODISFileData::lat_max [protected]

maximal bounding latitude of the granule

Referenced by get_index(), and set_lat_lon_min_max().

float MODISFileData::lat_min [protected]

minimal bounding latitude of the granule

Referenced by get_index(), and set_lat_lon_min_max().

const string MODISFileData::latitude_sds_name = "Latitude" [static, protected]

name of the geolocation latitudes dataset

Referenced by load_geolocation_data(), and set_lat_lon_index_max().

vector< float32 > MODISFileData::lon_gran_corner [protected]

longitudes of the granule corners as read in the geolocation dataset, in the order [0,0], [0,I_SCAN_MAX], [J_TRACK_MAX, 0], [J_TRACK_MAX, I_SCAN_MAX]

Referenced by get_lon_gran_corner(), init(), and load_geolocation_data().

float MODISFileData::lon_max [protected]

maximal bounding longitude of the granule

Referenced by get_index(), and set_lat_lon_min_max().

float MODISFileData::lon_min [protected]

minimal bounding longitude of the granule

Referenced by get_index(), and set_lat_lon_min_max().

const string MODISFileData::longitude_sds_name = "Longitude" [static, protected]

name of the geolocation longitudes dataset

Referenced by load_geolocation_data().

const int MODISFileData::NB_MAX_X_10KM = 135 [static]

Is the maximum number of pixels the along X at 10Km resolution

const int MODISFileData::NB_MAX_X_1KM = 1354 [static]

Is the maximum number of pixels the along X at 1Km resolution

const int MODISFileData::NB_MAX_X_250M = 5416 [static]

Is the maximum number of pixels the along X at 250m resolution

const int MODISFileData::NB_MAX_X_5KM = 271 [static]

Is the maximum number of pixels the along X at 5Km resolution

const int MODISFileData::NB_MAX_Y_10KM = 204 [static]

Is the maximum number of pixels the along Y at 10Km resolution

const int MODISFileData::NB_MAX_Y_1KM = 2054 [static]

Is the maximum number of pixels the along Y at 1Km resolution

const int MODISFileData::NB_MAX_Y_250M = 8216 [static]

Is the maximum number of pixels the along Y at 250m resolution

const int MODISFileData::NB_MAX_Y_5KM = 410 [static]

Is the maximum number of pixels the along Y at 5Km resolution

Platform for this product

Referenced by parse_filename().

string MODISFileData::product [protected]
float MODISFileData::resolution [protected]

resolution of the geolocation data in km

Referenced by get_resolution(), init_colocation_tolerance(), and parse_filename().

vector<PixelType> MODISFileData::v_pixel [protected]

list of pixels data, sorted by increasing latitude, then increasing longitude

Referenced by free_geolocation_data(), get_index(), and load_v_pixel().


The documentation for this class was generated from the following files: