Public Member Functions | Protected Member Functions | Protected Attributes

PolderParasolFileData Class Reference

#include <polderparasolfiledata.h>

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

List of all members.

Public Member Functions

 PolderParasolFileData (const string &name=string(""), const string &mode=string("r"))
virtual void * read_data (void *data, const char *sds_name, int *start=NULL, int *stride=NULL, int *edges=NULL, int rank=-1)
 read the data and apply a scaling to them. This method implements the interface of filedata If the read data is a physical value, it will return it as double. If the variable is a bitfield, it will return it as count (unscaled). You can used unsigned char to decode it.
virtual vector< int > get_dataset_dimension (const string &sds_name)
 return the given dataset size along each axis
void get_dataset_fill_value (const string &sds_name, void *fill_value)
 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
int get_n_dataset ()
string get_dataset_name (int i)
int get_dataset_data_type (string sds_name)
string get_values_attr_dataset (string sds_name, string attr_name)
bool has_attr_dataset (string sds_name, string attr_name)
void close_data_file ()
 closes the file
void open_data_file ()
 open the file
void get_fillValue (const string &sds_name, void *fillValue)

Protected Member Functions

void getLatLon (short line, short column, float32 *lat, float32 *lon)
void getLatLon1 (short line, short column, float32 *lat, float32 *lon)
short NINT (float32 x)
void free_read_write_allocations (const bool *are_limits_initialized, int *start, int *stride, int *edges)
const bool check_read_write_limits (const char *sds_name, int *start, int *stride, int *edges, const int rank)
void init_read_write_null_input_param (const char *sds_name, int *&start, int *&stride, int *&edges, int &rank, bool *initialized_values)
float32 * read_data_latlon (float32 *data, const char *sds_name, int *start, int *stride, int *edges, int rank)
template<class T >
T * read_data_T (T *data, const char *sds_name, int *start, int *stride, int *edges, int rank, int type)
int get_dataset_idtype (string name)
template<class T >
void getFillValues (T &fillvalue)
virtual void get_scaling (const string &sds_name, float64 &scale, float64 &offset)
virtual vector< int > get_dataset_full_dimension (const string &sds_name)

Protected Attributes

short colmin
short linemin
short colmax
short linemax
string cursds
int fileid
string filename
string * var_list
 list of all variables of the product
int nb_var_list
 number of variables of the product
int size
int maxLine
int maxColumn

Detailed Description

Author:
James MANLEY

Member Function Documentation

vector< int > PolderParasolFileData::get_dataset_dimension ( const string &  sds_name  )  [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 from FileData.

void PolderParasolFileData::get_dataset_fill_value ( const string &  ds_name,
void *  fillvalue 
) [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 from FileData.

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

read the data and apply a scaling to them. This method implements the interface of filedata If the read data is a physical value, it will return it as double. If the variable is a bitfield, it will return it as count (unscaled). You can used unsigned char to decode it.

Warning:
at this time, stride parameter is ignored. The returned buffer is a 1D linearized array, even if the read data have 2D. To know the real dimensions, you can use the "get_data_dimension" method that will return a vector containing the real dimension of the data, and access to one value can be done as y_index*X_DIM+x_index.
Let's see a little example : reading the sequence number of a L1_B file, and print them out
 // Initialize the PARASOL file instance
 PARASOLFileData pfd(filename);
 string param="seq_nb";
 cout<<"---------- Extract Parameter "<<param<<" ----------"<<endl;
 // read the dimensions of the variable data : for this parametre, has 2 ones [nb_data_record],NB_PARASOL_DIRECTIONS]
 vector<int> dimensions=pfd.get_data_dimension(param);
 int nb_data_record=dimensions[0];
 int nb_viewing_directions=dimensions[1];
 cout<<"Dimensions : ["<<dimensions[0]<<","<<dimensions[1]<<"]"<<endl;
 cout<<"---------------------------------------------------"<<endl;
 // read the data
 signed short* data=NULL; // Set the data buffer to NULL to delegate its allocation to the read_data method
 data=static_cast<signed short*>(pfd.read_data(data,param.c_str()));
 // print out the values
 if (data!=NULL) {
     if (show_val_display) {
         for (int j = 0 ; j<nb_data_record;++j) {
             cout<<"Record #"<<j<<endl;
             for (int i = 0 ; i<nb_viewing_directions;++i) {
                 cout<<"\t"<<data[j*nb_viewing_directions+i];
             }
             cout<<endl;
         }
     }
 }
 // free the buffer once used
 delete[] data;
 data=NULL;

Another example : reading the dqx of the first viewing direction of a L1_B file, and print them out

 // Initialize the PARASOL file instance
 PARASOLFileData pfd(filename);
 string param="dqx";
 cout<<"---------- Extract Parameter "<<param<<" ----------"<<endl;
 // read the dimensions of the variable data : for this parametre, has 2 ones [nb_data_record],NB_PARASOL_DIRECTIONS]
 vector<int> dimensions=pfd.get_data_dimension(param);
 int nb_data_record=dimensions[0];
 int nb_viewing_directions=dimensions[1];
 cout<<"Dimensions : ["<<dimensions[0]<<","<<dimensions[1]<<"]"<<endl;
 cout<<"---------------------------------------------------"<<endl;
 // read the data -> set the range of the data to read
 int start[]={0,4}; // means : start to read the data from the first record (0), and from the 5th viewing direction (4)
 int edges[]={-1,1}; // means : read all the records (-1 is a kind of metaselector), and read only one viewing direction value (1)
 signed short* data=NULL; // Set the data buffer to NULL to delegate its allocation to the read_data method
 data=static_cast<signed short*>(pfd.read_data(data,param.c_str()));
 // print out the values
 if (data!=NULL) {
     if (show_val_display) {
         cout<<"Record\tbits"<<endl;
         for (int i = 0 ; i<nb_data_record];++i)
                 cout<<i<<"\t"<<MyTools::to_bit(&ushort_count_data[i],2)<<endl;
     }
 }
 // free the buffer once used
 delete[] data;
 data=NULL;
Parameters:
data a buffer that will contain the data.
var_name the variable name
start the start indexes of the data to read. Indexes of -1 are considered as metacharacters and will be replaced by 0. Actually, if you read a directionnal parametre, start is [start_record_index, start_direction]
stride step between 2 read values (ignored at this time : 1 used by default)0.
edges the number of data to read along each direction. Indexes of -1 are considered as metacharacters and will be replaced by the maximum number of values. Actually, if you read a directionnal parametre, edges is [nb_record_to_read, nb_direction_to_read]
rank the size of the start and edges arrays : 1 for undirectionnal parametres, and 2 for directionnal ones. This parametre is not mandatory : if not specified, the method computes it.
Returns:
the pointer to the data buffer
the pointer to data

Reimplemented from PARASOLFileData.


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