Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

grid.h File Reference

#include <ctime>
#include "Hdf.hpp"
#include "common.h"
#include "VFiles.h"

Classes

struct  grid_type_

Typedefs

typedef grid_type_ grid_type

Functions

void create_grid (grid_type *grid, int nrows=0, int ncols=0, float64 slope=1., float64 offset=0., data_type data_fill_value=DEFAULT_DATA_FILL_VALUE, coord_type coord_fill_value=DEFAULT_COORD_FILL_VALUE, distance_type distance_fill_value=DEFAULT_DISTANCE_FILL_VALUE, time_type time_fill_value=DEFAULT_TIME_FILL_VALUE)
void reset_grid (grid_type *grid, data_type data_fill_value, coord_type coord_fill_value, distance_type distance_fill_value, time_type time_fill_value)
void reset_grid (grid_type *grid, data_type data_fill_value, distance_type distance_fill_value, time_type time_fill_value)
void destroy_grid (grid_type *grid)
int load_grid (grid_type *grid, data_type data_fill_value=DEFAULT_DATA_FILL_VALUE, coord_type coord_fill_value=DEFAULT_COORD_FILL_VALUE, distance_type distance_fill_value=DEFAULT_DISTANCE_FILL_VALUE, time_type time_fill_value=DEFAULT_TIME_FILL_VALUE)
int save_grid (grid_type *grid, bool record_delta, bool record_latlontime)
void copy_grid (grid_type *target_grid, grid_type *src_grid)
void copy_grid_footprint (grid_type *target_grid, grid_type *src_grid)
bool have_same_grid_footprint (grid_type *grid1, grid_type *grid2)

Typedef Documentation

typedef struct grid_type_ grid_type
 

Grids are the main data structures handled by the software. They should have been designed as a class instead of a simple struct with functions to handle it, but by lack of time the software had to be delivered as is. A rewritten code with a grid class instead of a struct should be much clearer and easier to maintain, but will need a substantial amount of time to reimplement (and of course redocument !), that is not available today.

Grids are abstracts for reprojection. Their main purpose is to handle 2-dimensional buffers of geolocated data (measures along with their latitudes, longitudes and times of acquisition). The reprojection algorithm remaps a grid of data (from one instrument product) into another one. For convenience, origin and target of the data (files and datasets) are also maintained in the structure (although this is not a very clever design, I have to confess, I hope I'll have a chance to change this if more time is given to this project)


Function Documentation

void copy_grid grid_type target_grid,
grid_type src_grid
 

intended to copy src_grid into target_grid (does correct allocation and copies) this function is not used in the current implementation

void copy_grid_footprint grid_type target_grid,
grid_type src_grid
 

intended to copy the footprint of a grid (the footprint includes lightweight data, namely scalar fields, but not buffers) this function is not used in the current implementation

void create_grid grid_type grid,
int  nrows = 0,
int  ncols = 0,
float64  slope = 1.,
float64  offset = 0.,
data_type  data_fill_value = DEFAULT_DATA_FILL_VALUE,
coord_type  coord_fill_value = DEFAULT_COORD_FILL_VALUE,
distance_type  distance_fill_value = DEFAULT_DISTANCE_FILL_VALUE,
time_type  time_fill_value = DEFAULT_TIME_FILL_VALUE
 

the grid constructor

Parameters:
grid the address of a grid structure to initialize. All fields will be allocated (for field pointers) and initialized with the values of the subsequent parameters.
nrows the number of rows of the grid (common number of rows of all the buffers in the grid)
ncols the number of columns of the grid (common number of columns of all the buffers in the grid)
slope the initialization value for the slope field of the grid
offset the initialization value for the offset field of the grid
data_fill_value the initialization value for the grid_type::data buffer of the grid (after allocation of nrows*ncols elements)
coord_fill_value the initialization value the grid_type::lat and grid_type::lon buffers of the grid (after allocation of nrows*ncols elements)
distance_fill_value the initialization value for the grid_type::distance_from_ref buffer of the grid (after allocation of nrows*ncols elements)
time_fill_value the initialization value for the grid_type::tim and grid_type::time_from_ref buffers of the grid (after allocation of nrows*ncols elements)
See also:
reset_grid(grid_type *, data_type, coord_type, distance_type, time_type)
cautious: create_grid currently does not initialize the grid_type::is_target field (this one had to be added to meet some user's new requirements, only after the interface of create_grid was designed. So for the time being, the grid_type::is_target field must be set directly before create_grid is called, in order to allow create_grid to allocate and initialize correctly the grid_type::src_irows and grid_type::src_icols fields. This should be fixed in a future release (this will imply to break the interface of create_grid, in order to pass the initialization value of grid_type::is_target as an argument).

void destroy_grid grid_type grid  ) 
 

the destructor of a grid

it resets all the scalars fields and deallocates (and nullifies) all the pointer fields of a grid structure

Parameters:
grid a pointer to the grid to destroy
See also:
create_grid

load_grid

bool have_same_grid_footprint grid_type grid1,
grid_type grid2
 

intended to compare two grids footprints (the footprint includes lightweight data, namely scalar fields, but not buffers) this function is not used in the current implementation

int load_grid grid_type grid,
data_type  data_fill_value = DEFAULT_DATA_FILL_VALUE,
coord_type  coord_fill_value = DEFAULT_COORD_FILL_VALUE,
distance_type  distance_fill_value = DEFAULT_DISTANCE_FILL_VALUE,
time_type  time_fill_value = DEFAULT_TIME_FILL_VALUE
 

loads data from the dataset grid_type::input_dataset of the file grid_type::file into a grid. The function calls create_grid, so don't do it yourself. Grids allocated and filled by load_grid must be destroyed by the caller with destroy_grid

Parameters:
grid a pointer to the grid_type structure to allocate and fill with the file data
data_fill_value the new initialization value of the grid_type::data buffer elements
coord_fill_value the new initialization value of the grid_type::lat, grid_type::lon buffer elements
distance_fill_value the new initialization value of the grid_type::distance_from_ref buffer elements
time_fill_value the new initialization value of the grid_type::tim and grid_type::time_from_ref buffer_elements
See also:
create_grid (called by this one)

destroy_grid (to call when the grid is not used anymore)

void reset_grid grid_type grid,
data_type  data_fill_value,
distance_type  distance_fill_value,
time_type  time_fill_value
 

resets all the fields of a grid, except grid_type::lat, grid_type::lon, grid_type::tim

It is used for the target grid whose geolocation fields never change. On the other hand, grid_type::data (measures), grid_type::distance_from_ref and grid_type::time_from_ref buffers must be reset with each new source grid (as source will be remapped into target). This function is essentially called from the main loop in the ::main function.

Parameters:
grid the pointer to the grid to reset
data_fill_value the new initialization value of the grid_type::data buffer elements
distance_fill_value the new initialization value of the grid_type::distance_from_ref buffer elements
time_fill_value the new initialization value of the grid_type::time_from_ref buffer_elements

void reset_grid grid_type grid,
data_type  data_fill_value,
coord_type  coord_fill_value,
distance_type  distance_fill_value,
time_type  time_fill_value
 

resets all the fields of a grid. It is essentially called by create_grid after allocations of pointers have been done.

Parameters:
grid the pointer to the grid to reset
data_fill_value the new initialization value of the grid_type::data buffer elements
coord_fill_value the new initialization value of the grid_type::lat, grid_type::lon buffer elements
distance_fill_value the new initialization value of the grid_type::distance_from_ref buffer elements
time_fill_value the new initialization value of the grid_type::tim and grid_type::time_from_ref buffer_elements
See also:
create_grid

int save_grid grid_type grid,
bool  record_delta,
bool  record_latlontime
 

saves grid_type::data buffer (with its slope and offset) into the grid_type::output_dataset of the file grid_type::file recorded in the grid structure.

Parameters:
grid a pointer to the grid to save into a file
record_delta if true, saves grid_type::distance_from_ref and grid_type::time_from_ref (namely 'delta' buffers) along with the grid_type::data buffer (this parameter may be controled by a user option, see ::main)
record_latlontime if true, saves grid_type::lat, grid_type::lon and grid_type::tim buffers along with the grid_type::data buffer (this is currently only used to save latitudes, longitudes and times of acquisition of the reference grid, see ::main)


Generated on Wed Apr 19 17:05:06 2006 for Remap by  doxygen 1.3.9.1