Printing a contour plot of tmpprs
::grads::exec d tmpprs;
::grads::exec printim "tmpprs.png";
or a color filles plot instead
::grads::exec set gxout shaded;
::grads::exec d tmpprs;
::grads::exec printim "tmpprs.png";
Transforming variables
set lon -125;
set lat 37;
::grads::transform w2gr $lon $lat gx gy;
puts "$gx $gy";
::grads::transform gr2xy $gx $gy x y;
puts "$x $y";
::grads::transform xy2w $x $y lon lat;
puts "$lon $lat";
Getting the list of variable names
::grads::get_vars vars;
foreach v $vars {
puts $v;
}
Get and output all the levels
::grads::get_levels levels;
foreach l $levels {
puts $l;
}
Only the currently set level
::grads::get_levels levels -r;
foreach l $levels {
puts $l;
}
Set a range and output the levels in that range
::grads::exec set z 1 10;
::grads::get_levels levels -r;
foreach l $levels {
puts $l;
}
This function can set various variables in one call
gradsu::mset x 10 y 10 t "1 3";
Using eval_expr1 returns the list (in t) of values of tmpprs for the above range. The list of values starts with the index 0.
set tmpprs [::grads::eval_expr1 tmpprs t];
foreach t $tmpprs {
puts $t;
}
This function is similar, but the first element of $t is the number of items while the first value of tmpprs starts at the index 1. In addition the result is saved in the last argument, passed by name.
gradsu::getval1 tmpprs t result;
foreach t $result {
puts $t;
}
::grads::init;
::grads::open "yq";;
Set the range in the xy plane
::grads::exec set x 10 14;
::grads::exec set y 11 15;
Evaluate the "tmpprs" variable at each point and print the matrix. The first commented line will store in the matrix the lon/lat coordinates along with the value of the variable at each point. The second commented line will store in the matrix the xy wind components along with the tmpprs at each point.
set m [::grads::eval_expr_xy "tmpprs" -r];
# set m [::grads::eval_expr_xy "lon|lat|tmpprs" -r];
# set m [::grads::eval_expr_xy "tmpprs|ugrdprs|vgrdprs" -r];
$m is now a matrix object that can be manipulated with the functions from the struct::matrix package of the tcllib.
puts [$m columns];
puts [$m rows];
set i 0;
while {$i < [$m rows]} {
set row [$m get row $i];
foreach j $row {
puts -nonewline "$j ";
}
puts "";
incr i;
}