Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends

PARASOLData Class Reference

#include <parasoldata.h>

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

List of all members.

Public Member Functions

 PARASOLData (const string data_filename="")
void print_data_file_descriptor ()
virtual void print_data ()
bool read_data (void *buf, const int &param_index, int *start, int *edges, const int rank)
 read the data in the parasol data file
const PARASOLDataFormatget_data_file_format ()
 access to the data file format for a given product
const int get_nb_data_record () const
 access to the number of data' records contained in the file
const int get_sz_data_record () const
 access to the size of one data record
const int get_data_entry_index (const string &var_name) const
 retrieve the index of a parameter's in the data record If the entry isn't a parameter,throws an bad_parametre Exception
const int get_nb_val (const string &var_name, const int edges=-1, const int dir_idx=-1) const
 retrieve the number of values that will be read for the given variable using the given indexes
const int get_nb_val (const int &var_index, const int edges=-1, const int dir_idx=-1) const
 retrieve the number of values that will be read for the given variable using the given indexes

Public Attributes

DataFileDescriptorRecorddata_file_descriptor

Protected Member Functions

virtual void read_data_file (const string &data_filename)
const bool is_record_loaded (const Record &rec)
 check if a record has been read.
void free_records ()
 Free the objects used to store the values read in the file records.
PARASOLFileRecordinit_record (const Record &rec)
 Initialize a record class.
const int get_record_offset (const Record &rec)
 access to ones record file offset If the record isn't in the data data file, it returns -1
virtual const RecordFormat * get_record_format (const Record &rec)
 access to the RecordFormat object that describes the name, type, offset and length of each record entry
PARASOLFileRecordget_record (const Record &rec)
 access to one record entry
vector< EntryBlockget_entry_block (const Record rec, const int entry_idx) const
 This method implements the interface of PARASOLFileReader, which is an abstraction for describing a group of repeated entries either in a data record or in a leader one. In th particular case of data record (so on, here), nb_val as the particular meaning of "number of viewing directions".
template<class T >
void apply_scaling (double *scaled_data, const T *count_data, const double &slope, const double &offset, const int &nb_val, const T count_fill_value=T(0))
 access to the offset of an entry, relative to the record start

Protected Attributes

string filename
DataRecorddata

Friends

class PARASOLFileData

Detailed Description

Interface for managing the reading of a PARASOL data file.

Warning:
this class is designed to be general and treat all PARASOL data files BUT it only has been fully implemented and tested for -> RB 2 products
Author:
Nicolas PASCAL

Member Function Documentation

template<class T >
void PARASOLData::apply_scaling ( double *  scaled_data,
const T *  count_data,
const double &  slope,
const double &  offset,
const int &  nb_val,
const T  count_fill_value = T(0) 
) [protected]

access to the offset of an entry, relative to the record start

Parameters:
rec the concerned record. Unused here. Set it to DATA
entry_idx index of the entry
record_idx index of the data record to read
direction_index index of the direction (useful only for directionnal parameters)
val_index unused
Returns:
the offset, from the record start apply the scaling to a count data
Parameters:
scaled_data the output scaled data. Must be allocated
count_data the input count data. Musn't be NULL
slope the slope
offset the offset
nb_val the number of values

References PARASOLFileData::get_level().

Referenced by PARASOLFileData::read_scaled_data().

const int PARASOLData::get_data_entry_index ( const string &  var_name  )  const

retrieve the index of a parameter's in the data record If the entry isn't a parameter,throws an bad_parametre Exception

Parameters:
var_name the name of the variable
Returns:
the entry index

References PARASOLDataFormat::get_entry_index().

Referenced by PARASOLFileData::get_data_dimension(), PARASOLFileData::get_scaling(), and PARASOLFileData::read_scaled_data().

const PARASOLDataFormat* PARASOLData::get_data_file_format (  )  [inline]

access to the data file format for a given product

Returns:
the data file format

Referenced by PARASOLFileData::get_entry_format(), get_record_format(), print_data_file_descriptor(), PARASOLFileData::read_count_data(), and read_data().

vector< EntryBlock > PARASOLData::get_entry_block ( const Record  rec,
const int  entry_idx 
) const [protected, virtual]

This method implements the interface of PARASOLFileReader, which is an abstraction for describing a group of repeated entries either in a data record or in a leader one. In th particular case of data record (so on, here), nb_val as the particular meaning of "number of viewing directions".

Parameters:
record_code the code of the record
entry_group_start the first entry of the group
entry_group_end (output) the last entry of the group. For entries of one value, the next entrie
nb_val (output) the number of viewing directions. For entries of one value, 1 returns the size (in bytes) an a group that contains the given entry. If the entry is not repeated in a record, returns 0
Exceptions:
bad_parametre_idx if the entry idx is invalid for the current product
Parameters:
entry_idx index of the entry (product specific)
Returns:
the size of the container group, in bytes. O if the entry is not in a group returns the size (in bytes) an a group that contains the given entry. If the entry is not repeated in a record, returns 0
Exceptions:
bad_parametre_idx if the entry idx is invalid for the current product
Parameters:
entry_idx index of the entry (product specific)
Returns:
the size of the container group, in bytes. O if the entry is not in a group returns the number of times an entry group is repeated in the data record. If the entry is not repeated in a record, returns 1
Exceptions:
bad_parametre_idx if the entry idx is invalid for the current product
Parameters:
entry_idx index of the entry (product specific)
Returns:
the number of times the group is repeated return the block describing the given entry : the number of times the entry is repeated and the size in bytes of the group
Parameters:
rec current record
entry_idx indice of the entry
Returns:
the block(s) of the entry. If the entry is composed of a unique value, returns an empty vector

Implements PARASOLFileReader.

References get_nb_data_record(), get_sz_data_record(), and g_exception::set().

Referenced by PARASOLFileData::get_data_dimension(), get_nb_val(), and read_data().

const int PARASOLData::get_nb_data_record (  )  const

access to the number of data' records contained in the file

Warning:
it starts at 0 for the 1st pixel data record. So it differs of 2 compared to the record number read in the data file : nb_data_record = record_number_in_file - 2
Returns:
the number of data records

References DataFileDescriptorRecord::nb_data_rec.

Referenced by get_entry_block(), PARASOLFileData::get_nb_data(), PARASOLFileData::idata2igrid(), and PARASOLFileData::load_geolocation_data().

const int PARASOLData::get_nb_val ( const string &  var_name,
const int  edges = -1,
const int  dir_idx = -1 
) const

retrieve the number of values that will be read for the given variable using the given indexes

Parameters:
var_name the name of the variable
edges the number of records to read. -1 = all
dir_idx the index of the direction to read (for directionnal parameters). -1 = all
Returns:
the number of possible values

References PARASOLDataFormat::get_entry_index().

const int PARASOLData::get_nb_val ( const int &  var_index,
const int  edges = -1,
const int  dir_idx = -1 
) const

retrieve the number of values that will be read for the given variable using the given indexes

Parameters:
var_index the index of the variable
edges the number of records to read. -1 = all
dir_idx the index of the direction to read (for directionnal parameters). -1 = all
Returns:
the number of possible values

References get_entry_block(), and DataFileDescriptorRecord::nb_data_rec.

PARASOLFileRecord * PARASOLData::get_record ( const Record &  rec  )  [protected, virtual]

access to one record entry

Parameters:
rec the record code
Returns:
the entry corresponding to record code

Implements PARASOLFileReader.

Referenced by is_record_loaded().

const RecordFormat * PARASOLData::get_record_format ( const Record &  rec  )  [protected, virtual]

access to the RecordFormat object that describes the name, type, offset and length of each record entry

Parameters:
rec the record code
Returns:
the RecordFormat corresponding to record code

Implements PARASOLFileReader.

References get_data_file_format().

const int PARASOLData::get_record_offset ( const Record &  rec  )  [protected, virtual]

access to ones record file offset If the record isn't in the data data file, it returns -1

Parameters:
rec the record code
Returns:
the record's offset in the data file

Implements PARASOLFileReader.

References init_record(), is_record_loaded(), PARASOLFileReader::read_record(), and PARASOLFileRecord::rec_len.

Referenced by read_data().

const int PARASOLData::get_sz_data_record (  )  const

access to the size of one data record

Returns:
the size of one data record in bytes

References DataFileDescriptorRecord::one_data_rec_len.

Referenced by get_entry_block().

PARASOLFileRecord * PARASOLData::init_record ( const Record &  rec  )  [protected, virtual]

Initialize a record class.

Parameters:
rec the record code
Returns:
the initialized object (or NULL in case of problem)

Implements PARASOLFileReader.

Referenced by get_record_offset().

const bool PARASOLData::is_record_loaded ( const Record &  rec  )  [protected, virtual]

check if a record has been read.

Returns:
true if the record has already been read

Implements PARASOLFileReader.

References get_record().

Referenced by get_record_offset().

void PARASOLData::print_data_file_descriptor (  ) 
bool PARASOLData::read_data ( void *  buf,
const int &  param_index,
int *  start,
int *  edges,
const int  rank 
)

read the data in the parasol data file

Warning:
start, edges and rank must be given and valid
Parameters:
buf the buffer to be fill. MUST BE ALLOCATED
param_index the index of the parameter to extract
start the start data record index. DON'T USE IT
edges the number of data records to read. DON'T USE IT
dir_idx the index of the direction for directionnal parameters. DON'T USE IT
Returns:
true if the data have been read without problem

References PARASOLFileReader::fill_buffer_default(), get_data_file_format(), get_entry_block(), PARASOLFileReader::get_entry_offset(), get_record_offset(), PARASOLFileFormat::get_size_of(), PARASOLFileReader::inc_ptr(), PARASOLFileReader::is_file_loaded(), and PARASOLFileReader::swap_endianess().


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