caltrack_reader_common.h File Reference

#include "float.h"
#include "math.h"
#include "c_hdf_reader.h"

Go to the source code of this file.

Defines

#define NB_INPUT_FILE_MAX   20
#define NB_AEROSOL_LAYER_CALIOP   8
#define NB_PARASOL_DIRECTION   16
#define NB_CLOUDSAT_VERTICAL_BINS   125

Functions

double default_scale_function (const double invalue, const double scale_factor, const double scale_offset)
 default scaling function for HDF data : scaled_value = (bin_value - scale_offset) * scale_factor
double parasol_scale_function (const double invalue, const double scale_factor, const double scale_offset)
 scaling function for PARASOL data : scaled_value = bin_value * scale_factor + scale_offset
double * read_custom_scale_sds_data_by_id (const int32 sd_id, const char *sds_name, double *sds_data, int32 *start, int32 *stride, int32 *edges, double(*scale_function)(const double, const double, const double))
 read the data of one dataset and apply the scaling to it
double * custom_scale_data (const void *indata, const int32 indata_size, const int32 indata_typecode, const double scale_factor, const double scale_offset, double(*scale_function)(const double, const double, const double), double *outdata)
 apply a non HDF standard scaling function to an array of calibrated data
int32 get_v_input_files (const char *filename, const char *product, char v_files[][MAX_NC_NAME], int32 *nb_file)
 read the list of input files of a product that have been used to build a caltrack product
int32 get_v_input_files_by_id (const int32 sd_id, const char *product, char v_files[][MAX_NC_NAME], int32 *nb_file)
 read the list of input files of a product that have been used to build a caltrack product
int32 get_input_file_by_id (const int32 sd_id, const char *product, const int32 i_file, char infile[MAX_NC_NAME])
 retrieve an input file name of a given product, using its index
int32 is_fill_value (const void *p_value, const int32 typecode)
 check if the given variable is a Caltrack fill value


Detailed Description

Functions used to read caltrack files common to all products

Function Documentation

double* custom_scale_data ( const void *  indata,
const int32  indata_size,
const int32  indata_typecode,
const double  scale_factor,
const double  scale_offset,
double(*)(const double, const double, const double)  scale_function,
double *  outdata 
)

apply a non HDF standard scaling function to an array of calibrated data

Parameters:
indata [IN] array of calibrated binary data
indata_size [IN] number of elements in indata
indata_typecode [IN] indata HDF typecode
scale_factor [IN] scaling factor
scale_offset [IN] scaling offset
scale_function [IN] pointer to the scaling function
outdata [OUT] output scaled data
Returns:
a pointer to the eventually allocate data buffer if successfull, NULL in case of error

References custom_scale_data(), get_data_type_size(), and is_fill_value().

Referenced by custom_scale_data(), and read_custom_scale_sds_data_by_id().

double default_scale_function ( const double  invalue,
const double  scale_factor,
const double  scale_offset 
)

default scaling function for HDF data : scaled_value = (bin_value - scale_offset) * scale_factor

Parameters:
invalue value to scale
scale_factor slope
scale_offset offset
Returns:
the scaled data value

References default_scale_function().

Referenced by default_scale_function().

int32 get_input_file_by_id ( const int32  sd_id,
const char *  product,
const int32  i_file,
char  infile[MAX_NC_NAME] 
)

retrieve an input file name of a given product, using its index

Parameters:
sd_id [IN] an SD id as returned by the open_hdf_file function
product [IN] name of the product
i_file [IN] index of the file, as set in caltrack's "Input_File_Index" datasets
infile[] [OUT] name of the input file used to produce the caltrack file
Returns:
0 if successfull, -1 in case of error

References get_input_file_by_id(), and get_v_input_files_by_id().

Referenced by get_input_file_by_id().

int32 get_v_input_files ( const char *  filename,
const char *  product,
char  v_files[][MAX_NC_NAME],
int32 *  nb_file 
)

read the list of input files of a product that have been used to build a caltrack product

Parameters:
filename [IN] the full path to the file to read
product [IN] name of the product
v_files[][] array of files names
nb_file number of files of v_files
Returns:
0 if successfull, -1 in case of error

References close_hdf_file(), get_v_input_files(), get_v_input_files_by_id(), and open_hdf_file().

Referenced by get_v_input_files().

int32 get_v_input_files_by_id ( const int32  sd_id,
const char *  product,
char  v_files[][MAX_NC_NAME],
int32 *  nb_file 
)

read the list of input files of a product that have been used to build a caltrack product

Parameters:
sd_id [IN] an SD id as returned by the open_hdf_file function
product [IN] name of the product
v_files[][] array of files names
nb_file number of files of v_files
Returns:
0 if successfull, -1 in case of error

References free_attr(), get_file_attr_by_id(), get_v_input_files_by_id(), and ATTR::value.

Referenced by get_input_file_by_id(), get_v_input_files(), and get_v_input_files_by_id().

int32 is_fill_value ( const void *  p_value,
const int32  typecode 
)

check if the given variable is a Caltrack fill value

Parameters:
p_value [IN] pointer to the value to test
typecode [IN] an HDF typecode
Returns:
1 if data is a fill value, 0 if not, -1 in case of problem

References is_fill_value().

Referenced by custom_scale_data(), and is_fill_value().

double parasol_scale_function ( const double  invalue,
const double  scale_factor,
const double  scale_offset 
)

scaling function for PARASOL data : scaled_value = bin_value * scale_factor + scale_offset

Parameters:
invalue value to scale
scale_factor slope
scale_offset offset
Returns:
the scaled data value

References parasol_scale_function().

Referenced by parasol_scale_function().

double* read_custom_scale_sds_data_by_id ( const int32  sd_id,
const char *  sds_name,
double *  sds_data,
int32 *  start,
int32 *  stride,
int32 *  edges,
double(*)(const double, const double, const double)  scale_function 
)

read the data of one dataset and apply the scaling to it

Warning:
if the caller delegate the allocation of the data buffer (sds_data) to the funtion by setting it to NULL, the data will be accessed lineary. So, if the dataset has 2 dimensions, to access the value at (i,j) you will do sds_data[j*dim_x+i] instead of the usual sds_data[j][i] (with dim_x the size of the x dimension). If you want to use an indexation as [j][i], the caller must manage the allocation
Parameters:
sd_id [IN] an SD id as returned by the open_hdf_file function
sds_name [IN] name of the sds to read
sds_data [OUT] the buffer where is stored the read data. If set to NULL, the method will manage the memory allocation
start [IN] Array specifying the starting location from where data is read. Set it to NULL to read all the dataset
stride [IN] Array specifying the interval between the values that will be read along each dimension. Set it to NULL to read all the contigous data
edges [IN] Array specifying the number of values to be read along each dimension. Set it to NULL to read all the dataset
scale_function [IN] pointer to the scaling function
Returns:
a pointer to the eventually allocate data buffer if successfull, NULL in case of error

References custom_scale_data(), SDS_INFO::data_type, free_sds_info(), free_typed_data(), get_sds_calibration_by_id(), get_sds_info_by_id(), SDS_INFO::rank, read_custom_scale_sds_data_by_id(), read_sds_binary_data_by_id(), set_start_stride_edge(), and SDS_INFO::v_attr.

Referenced by read_custom_scale_sds_data_by_id().


Generated on Wed Sep 2 15:04:31 2009 for caltrack_reader.kdevelop by  doxygen 1.5.8