An important feature of this object is specifying selection criterion for extracting data from the netCDF file. The message is "selection=(var_name, dim_id,start,end, dim_id,start,end, ...)" where var_name is the name of a netCDF variable. If var_name is a n-dimensional variable, any portion of its data can be extracted using combinations of the selection indices dim_id,start,end. Dim_id refers to the dimension id (1,2,...,n), start refers to the starting value for this dimension, and end refers to the ending value for this dimension. Selection indices need not be specified for each dimension: if not specified for some dim_id the indices start and end are set to (1,1). By specifying multiple sets of selection indices it is possible to extract any hyperslab of data from any netCDF variable.
NOTE: See netCDF manual for more information. The selection indices (dim_id, start, end) are mapped into the "start" and "count" variable described for the ncvarget() netCDF function call. Unlike the netCDF C language bindings, however, the indices in LYMB are 1 offset (not zero!!!).
ANOTHER NOTE: Use the methods "variable=" and "dimension_names?" to get a list of dimensions for each variable. (The method "variable_names?" can be used to determine the names of the variables in the netCDF file.) The dim_id of a variable is simply its position in the list returned by "dimension_names?". To get the size of the dimension use the method "dimension_sizes?" or the combination of methods "dimension_name=" and "dimension_size?" for a particualr dimension.
Returns FPTR on argument stack.
selection= (var_name, dim_id,start,end, dim_id,start,end, ...) Set the selection list for extracting hyperslab.
selection? return the value of the current selection list.
create_data_out! Creates an output data set if one doesn't already exist.
free! Free internal memory and return to superclass to free object.
/* * Scripts tests the cdf_extract_data objects */ /* * For scalar extract portion of y-components of velocity data * (second time step) */ scalar new: no_pts = 10; /* set size of data to extract */
cdf_extract_scalar new: scalar_reader filename=`test.cdf' selection=(velocity, 1,2,2, 2,1,no_pts, 3,2,2) ;
/* * Extract third time step of velocity data */ cdf_extract_vector new: vector_reader filename=`test.cdf' vx_selection=(velocity, 1,3,3, 2,1,no_pts, 3,1,1) vy_selection=(velocity, 1,3,3, 2,1,no_pts, 3,2,2) vz_selection=(velocity, 1,3,3, 2,1,no_pts, 3,3,3) ;
/* * Extract first time step of pressure for x-axis; second time step * of velocity z-component for y-axis; points (i.e., * test_grid) y coordinates for z-axis */ cdf_extract_unstructured_points new: geom_reader filename=`test.cdf' x_selection=(pressure, 1,1,1, 2,1,no_pts, 3,1,1) /* default 3,1,1 */
y_selection=(velocity, 1,2,2, 2,1,no_pts, 3,3,3) z_selection=(test_grid, 1,1,no_pts, 2,2,2) ;
merge_data_sets new: merge data_in= (geom_reader, scalar_reader, vector_reader) output! ;