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

FileData Class Reference

#include <filedata.h>

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

List of all members.

Public Member Functions

 FileData (const string &name="", const string &mode="r")
 Build a generic file reader interface.
 FileData (const FileData &fd)
 Copy constructor.
FileDataoperator= (const FileData &fd)
 Affectation operator.
virtual ~FileData ()
 Destructor.
const string get_name () const
 file name accessor
virtual string get_filename ()
 alias to get_name method, dfor data2grid/mapsoperator compatibility
const Date get_date () const
 return the date of data' acquisition start
const bool contain_time (const double time=-1.) const
 test if the file contains data that occur at time If time is -1 (deault), always return true
virtual void * read_data (void *data, const char *sds_name, int *start=NULL, int *stride=NULL, int *edges=NULL, int rank=-1)=0
 Read the selected data in the file.
double get_time_coverage () const
virtual void close_data_file ()
 closes the file
virtual void open_data_file ()
 open the file
virtual const bool contain_location (const float &lat, const float &lon, const double &tolerance)
 check if this file has eventually data coincident with (lat,lon)
virtual const bool contain_data (const float &lat, const float &lon, const double &time, const double &colocation_tolerance)
 check if the file has possible (lat,lon) coincidence
virtual void load_geolocation_data ()
 read the geolocations data and put it in memory
virtual void free_geolocation_data ()
 free eventually loaded geolocation data
virtual const bool is_geolocation_data_loaded () const
 check if the geolocation data have been already loaded
virtual void get_dataset_fill_value (const string &ds_name, void *fillvalue)
 read the given dataset's fill value TODO Same method with many names of this method transfered from filedatareader. Need to be reformatted after functionnal tests with Data2Grid/MapsOperator
virtual vector< int > get_dataset_dimension (const string &sds_name)
 return the given dataset size along each axis
template<class X >
void get_fillValue (const string &ds_name, X &fillValue)
 read the given dataset's fill value
virtual void get_fillValue (const string &ds_name, void *fillValue)
template<class X >
void get_fill_value (const string &ds_name, X &fillValue)
virtual void get_fill_value (const string &ds_name, void *fillValue)
virtual bool is_viewing_directions_data_loaded ()
 test if the data requested for computing the viewing directions has been loaded
virtual void load_viewing_directions_data ()
 load the data requested for computing the viewing directions
virtual void free_viewing_directions_data ()
 free the data requested for computing the viewing directions
virtual void get_viewing_directions (const vector< int > &ipix, vector< Observation > &v_obs)
 constucts the viewing directions observations for the given pixel

Static Public Member Functions

static void check_geolocation (const float lat, const float lon)
 check the validity of the (lat, lon) coordinates. If lat not in [-90, 90] or lon not in [-180, 180], raise an exception

Protected Member Functions

void set_name (const string &name)
void set_date (const Date &d)

Protected Attributes

string name
string mode
Datedate
double time_coverage

Detailed Description

Generic class managing the reading. It describes the data generally

Author:
Nicolas PASCAL

Constructor & Destructor Documentation

FileData::FileData ( const string &  name = "",
const string &  mode = "r" 
)

Build a generic file reader interface.

Exceptions:
bad_file if the name given in parametre doesn't exist or is NULL
bad_file_opening_mode :

  • if the opening mode isn't allowed. At this time, only "r" is allowed.
  • if the user isn't authorized to access to this file.
Parameters:
name the name of the file (path included) we want to parse /
mode the file's opening mode for this file. At this time, only "r" is allowed

References date.

FileData::FileData ( const FileData fd  ) 

Copy constructor.

Parameters:
fd the FileData to copy

References date, mode, and name.


Member Function Documentation

void FileData::check_geolocation ( const float  lat,
const float  lon 
) [static]

check the validity of the (lat, lon) coordinates. If lat not in [-90, 90] or lon not in [-180, 180], raise an exception

Parameters:
lat latitude
lon longitude

Referenced by PARASOLFileData::geolocation_to_grid().

virtual void FileData::close_data_file (  )  [inline, virtual]

closes the file

Warning:
here for interface implementation prupose. All subclasses should implement this method

Reimplemented in CALIOPFileData, CERESFileData, CLOUDSATFileData, DARDARFileData, ECMWFFileData, GribFileData, HDF5FileData, HDFFileData, IIRFileData, MerisFileData, MODISFileData, NETCDFFileData, OMIFileData, PARASOLFileData, PMFileData, PolderParasolFileData, and SatelliteFileData.

virtual const bool FileData::contain_data ( const float &  lat,
const float &  lon,
const double &  time,
const double &  colocation_tolerance 
) [inline, virtual]

check if the file has possible (lat,lon) coincidence

Warning:
it's an EVENTUAL coincidence. That is not a proof !!!
here for interface implementation prupose. All subclasses should implement this method
Parameters:
lat latitude
lon longitude
time time
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:
true if can eventually contain a coincidence with the point.
Warning:
at this time always true. I don't have a good way to do it

Reimplemented in CALIOPFileData, CERESFileData, CLOUDSATFileData, DARDARFileData, IIRFileData, MODISFileData, OMIFileData, PARASOLFileData, PMFileData, and SatelliteFileData.

virtual const bool FileData::contain_location ( const float &  lat,
const float &  lon,
const double &  tolerance 
) [inline, virtual]

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

Warning:
here for interface implementation prupose. All subclasses should implement this method
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 in CALIOPFileData, CERESFileData, CLOUDSATFileData, DARDARFileData, IIRFileData, MODISFileData, OMIFileData, PARASOLFileData, PMFileData, and SatelliteFileData.

const bool FileData::contain_time ( const double  time = -1.  )  const

test if the file contains data that occur at time If time is -1 (deault), always return true

Parameters:
time a measure time using TAI93 convention (number of seconds since 1993/01/01 at 00:00:00)
Returns:
true if the file has data time stamped with time

References date, Date::get_TAI93_time(), and time_coverage.

Referenced by PMFileData::contain_data(), PARASOLFileData::contain_data(), OMIFileData::contain_data(), MODISFileData::contain_data(), IIRFileData::contain_data(), DARDARFileData::contain_data(), CLOUDSATFileData::contain_data(), CERESFileData::contain_data(), CALIOPFileData::contain_data(), and CERESFileData::get_index().

virtual void FileData::free_geolocation_data (  )  [inline, virtual]

free eventually loaded geolocation data

Warning:
here for interface implementation prupose. All subclasses should implement this method

Reimplemented in CALIOPFileData, CERESFileData, CLOUDSATFileData, DARDARFileData, ECMWFFileData, IIRFileData, MODISFileData, PARASOLFileData, PMFileData, and SatelliteFileData.

virtual vector<int> FileData::get_dataset_dimension ( const string &  sds_name  )  [inline, virtual]

return the given dataset size along each axis

Parameters:
ds_name [IN] dataset name
Returns:
the axis dimensions in ordering [..., Z, Y, X]

Reimplemented in GribFileData, HDF5FileData, HDFFileData, MerisFileData, NETCDFFileData, and PolderParasolFileData.

virtual void FileData::get_dataset_fill_value ( const string &  ds_name,
void *  fillvalue 
) [inline, virtual]

read the given dataset's fill value TODO Same method with many names of this method transfered from filedatareader. Need to be reformatted after functionnal tests with Data2Grid/MapsOperator

Parameters:
ds_name [IN] dataset name
fillvalue [OUT] fill value.

Reimplemented in GribFileData, HDF5FileData, HDFFileData, MerisFileData, NETCDFFileData, and PolderParasolFileData.

const Date FileData::get_date (  )  const [inline]

return the date of data' acquisition start

Returns:
the acquisition date

References date.

Referenced by IIRFileData::contains_data_at().

virtual string FileData::get_filename (  )  [inline, virtual]

alias to get_name method, dfor data2grid/mapsoperator compatibility

Returns:

Reimplemented in MerisFileData.

References get_name().

template<class X >
void FileData::get_fillValue ( const string &  ds_name,
X &  fillValue 
) [inline]

read the given dataset's fill value

Parameters:
ds_name [IN] dataset name
fillvalue [OUT] fill value.
const string FileData::get_name (  )  const [inline]

file name accessor

Returns:
the name with its full path

References name.

Referenced by get_filename(), MODISFileData::init(), CERESFileData::init(), CALIOPFileData::is_same_orbit(), and HDFFileData::load_hdf_file().

virtual void FileData::get_viewing_directions ( const vector< int > &  ipix,
vector< Observation > &  v_obs 
) [inline, virtual]

constucts the viewing directions observations for the given pixel

Parameters:
ipix pixel indice(s)
v_obs vector of observation(s) for the given pixel

Reimplemented in CALIOPFileData, PARASOLFileData, and SatelliteFileData.

virtual const bool FileData::is_geolocation_data_loaded (  )  const [inline, virtual]

check if the geolocation data have been already loaded

Warning:
here for interface implementation prupose. All subclasses should implement this method

Reimplemented in CALIOPFileData, CERESFileData, IIRFileData, MODISFileData, PARASOLFileData, PMFileData, and SatelliteFileData.

virtual void FileData::load_geolocation_data (  )  [inline, virtual]

read the geolocations data and put it in memory

Warning:
here for interface implementation prupose. All subclasses should implement this method This method is used to make the search of the indexes of a (lat,lon,time) point faster.

Reimplemented in CALIOPFileData, CERESFileData, CLOUDSATFileData, DARDARFileData, IIRFileData, MODISFileData, OMIFileData, PARASOLFileData, PMFileData, and SatelliteFileData.

virtual void FileData::open_data_file (  )  [inline, virtual]

open the file

Warning:
here for interface implementation prupose. All subclasses should implement this method

Reimplemented in CALIOPFileData, CERESFileData, CLOUDSATFileData, DARDARFileData, ECMWFFileData, GribFileData, HDF5FileData, HDFFileData, IIRFileData, MerisFileData, MODISFileData, NETCDFFileData, OMIFileData, PARASOLFileData, PMFileData, PolderParasolFileData, and SatelliteFileData.

FileData & FileData::operator= ( const FileData fd  ) 

Affectation operator.

Parameters:
fd the FileData to copy
Returns:
this

References date, mode, and name.

virtual void* FileData::read_data ( void *  data,
const char *  sds_name,
int *  start = NULL,
int *  stride = NULL,
int *  edges = NULL,
int  rank = -1 
) [pure virtual]

Read the selected data in the file.

Warning:
If you delegate the allocation of the buffer at this method, you need to call delete[] data yourself.
Parameters:
data the buffer to fill with the read values. Can be NULL. In this case, the allocation is done by the method
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
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

Implemented in ECMWFFileData, GribFileData, HDF5FileData, HDFFileData, MerisFileData, NETCDFFileData, PARASOLFileData, and PolderParasolFileData.

Referenced by GMAOFileData::load_height_level(), and GMAOFileData::load_time_level().

void FileData::set_date ( const Date d  )  [inline, protected]

set the acquisition date

Parameters:
_x the new date

References date.

void FileData::set_name ( const string &  name  )  [inline, protected]

set the name of the file

Parameters:
_name the new name

Member Data Documentation

Date* FileData::date [protected]
string FileData::mode [protected]

the opening mode : only "r" supported at this time

Referenced by FileData(), GribFileData::open_data_file(), and operator=().

string FileData::name [protected]
double FileData::time_coverage [protected]

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