grad [ parameter=value ... ] [ inputfile outputfile ] grad [ parameter=value ... ] [ inputfile ... directory ]
Parameters are: include_vars, deriv_dim, same_grid, approx_edges, use_etx.
grad computes gradients of variables with respect to a specified dimension. Derivatives are computed over one pixel. The discrete form of the derivative depends on the value of same_grid. If same_grid=yes, the derivative dimension, deriv_dim, will be the same length in the output dataset. In this case, the derivatives are approximated at the input grid points. Thus, the gradient of variable V in the x direction at point i is given by:
dV(i)/dx = [V(i+1) - V(i-1)] / [x(i+1) - x(i-1)]
If approx_edges=no, the end points are set to the bad value of the variable. If approx_edges=yes, the the derivatives at points V(0) and V(N) are given by:
dV(0)/dx = [V(1) - V(0)] / [x(1) - x(0)] dV(N)/dx = [V(N) - V(N-1)] / [x(N) - x(N-1)]
If same_grid=no, the derivatives are aproximated at the points in between the grid points of the input variable and the output dimension is reduced by one. In this case the derivatives are given by:
dV(i)/dx = [V(i) - V(i-1)] / [x(i) - x(i-1)]
If a bad value occurs on the right hand side of the formulas above, the result will be output as a bad value. Thus one bad value in the input will produce two bad values in the output (see fixline). If gradients of larger scales are desired, smoothing should be done either before or after (see smear).
Distances are determined in kilometers if the dataset has a map projection (etx, datasets) and use_etx=yes. In this case, output variable units will be equal input variable units divided by "kilometers". If use_etx=no, then the distances are specified by the dimension values with scaling and offset applied, and output variable units will be equal input variable units divided by the name of deriv_dim. However, if the deriv_dim points to a variable which holds the values of the dimension (i.e. dim->var, see datasets), these values will be used for distances, the variable pointed to by the deriv_dim will be copied to the output dataset, and the output variable units will equal the input variable units divided by the units of this variable. In this latter case, if same_grid=yes, the output values of the dim->var are the same as the input values. If same_grid=no, the values are linearly interpolated and a warning is printed to the user that a linear interpolation of the dimension values was applied.
Specifies which variables in the input dataset(s) to compute the gradient for.
The default is all variables in the input dataset(s).
Specifies the dimension in which the derivative is to be taken.
The default is the first dimension defined in the dataset.
Specifies whether derivatives are estimated on the grid of the the input variable or at points in between, see description above. If same_grid=no, the size of the derivative dimension is reduced by one.
Valid responses are [ yes, no ]. The default is yes.
If same_grid=yes, this specifies whether grad is to estimate the gradients at the end points, see description above.
Valid responses are [ yes, no ]. The default is no.
Specifies how the distances are to be calculated. If use_etx=yes then distances are retrieved via the map transform of the dataset and specified in kilometers, otherwise distances are retrieved from the dimension values. See description above.
Valid responses are [ yes, no ]. The default is no.
If a "gradient" of a two dimension field is desired, it is necessary to take the derivative of each dimension separately and then add the result using emath. This would, for example, allow a calculation of the scalar quantity dV/dx + dV/dy. An example of this procedure is given below for channel 1 of an AVHRR (avhrr) image.
% grad in/out files : char(255) ? avhrrimg av1dx include_vars : char(255) ? [] avhrr_ch1 deriv_dim : char( 31) ? [] sample same_grid : char( 3) ? [yes] approx_edges : char( 3) ? [no] use_etx : char( 3) ? [no] y % grad in/out files : char(255) ? avhrrimg av1dy include_vars : char(255) ? [] avhrr_ch1 deriv_dim : char( 31) ? [] line same_grid : char( 3) ? [yes] approx_edges : char( 3) ? [no] use_etx : char( 3) ? [no] y % emath2 in/out files : char(255) ? av1dx av1dy gradav1 file1_vars : char(255) ? [] avhrr_ch1 file2_vars : char(255) ? [] avhrr_ch1 expression : char(255) ? x1 + x2 var_name : char( 31) ? grad_avhrr_ch1 var_units : char( 31) ? [] raw_counts/kilometer var_type : char( 15) ? [float]
The following is an example of taking successive derivatives such as d/dy(dV/dx). In the case below, the final output file has the derivatives estimated in between the grid points of the original file, and both the line and sample dimensions is reduced by one.
% grad in/out files : char(255) ? avhrrimg av1dx include_vars : char(255) ? [] avhrr_ch1 deriv_dim : char( 31) ? [] sample same_grid : char( 3) ? [yes] n approx_edges : char( 3) ? [no] use_etx : char( 3) ? [no] y % grad in/out files : char(255) ? av1dx av1dydx include_vars : char(255) ? [] avhrr_ch1 deriv_dim : char( 31) ? [] line same_grid : char( 3) ? [yes] n approx_edges : char( 3) ? [no] use_etx : char( 3) ? [no] y
datasets, etx, smear, composite, emath, nhood, xvu, sample, fixline.
Last Update: $Date: 1999/05/10 20:14:08 $