Dimensions can be defined in Output using the defdim()
function.
defdim("cnt",10);
This dimension can then be subsequently referred to in method arguments and a left hand cast by prefixing it with a dollar e.g
new_var[$cnt]=time; temperature[$time,$lat,$lon]=35.5; temp_avg=temperature.avg($time);
To refer to the dimension size in an expression use the size
method.
time_avg=time.total() / $time.size;
Increase size of new var by one and set new member to zero;
defdim("cnt_grw", $cnt.size+1); new_var_grw[$cnt_grw]=0.0; new_var_grw( 0:($cnt_grw.size-2))=new_var;
Dimension Abbreviations
Its possible to use dimension abbreviations as method arguments.
$0
is the first dimension of the variable
$1
is the second dimension of the variable
$n
is the n+1 dimension of the variable
consider the variables:
float four_dmn_rec_var(time,lat,lev,lon); double three_dmn_var_dbl(time,lat,lon); four_nw=four_dmn_rev_var.reverse($time,$lon) four_nw=four_dmn_rec_var.reverse($0,$3); four_avg=four_dmn_rec_var.avg($lat,$lev); four_avg=four_dmn_rec_var.avg($1,$2); three_mw=three_dmn_var_dbl.permute($time,$lon,$lat); three_mw=three_dmn_var_dbl.permute($0,$2,$1);
ID Quoting
If the dim name contains non-regular characters use ID quoting. See see ID Quoting
defdim("a--list.A",10); A1['$a--list.A']=30.0;
GOTCHA
It is not possible to manually define in Output any dimensions that exist in Input. When a variable from Input appears in an expression or statement its dimensions in Input are automagically copied to Output (if they are not already present)