Manipulating a cube using script commands
Introduction
A cube is an organized way of holding data in x, y and z direction. The dimension of the cube is the number_of_elements_in_a_row x number_of_elements_in_a_column x number_of_layers. The first two parts is the definition of a grid. Thus a cube is consisting of a certain set of grids stacked upon each other to form the layers in the cube.
The text deals with a simple form of cube manipulation that is valuable in a certain context. Although there are many menus attached to cube generation and the cube, there is also a need for creating and manipulating the cube through commands that are scripted. Below are some basic script commands used for cube manipulation.
Velocity cube displayed in two ways in a viewport presentation
Â
Â
On this page:
Basic script commands for manipulating a cube
The commands are taken from the shell command reference.
gen 'number_in_rows' 'number_in_colums' 'number_of_layers' ;# generate a dummy cube within the grid window set nrow [gvar nrow] ;# Tcl syntax to assign the numbers in a row into a variable. set ncol [gvar ncol] ;# Tcl syntax to assign the numbers in a column into a variable. set nlay [gvar nlay] ;# Tcl syntax to assign the numbers of layers into a variable. ima sla 'layer_number' ;# select grid layer 'layer_number' from cube in active workspace. ima ins 'layer_number' 'cube_in_workspace' ;# insert a grid into 'cube_in_workspace' at layer 'layer_number'. pro 'cube_in_workspace' ;# probe (sample) values from the cube into the scalar part of a polydata.
The cube commands make it possible to change and update the interior of a cube.
The interior of a velocity cube displayed by the cube manipulator
Converting a time velocity cube into a time depth cube
A time velocity cube is a cube where the cube dimensions are in time values while the cube nodes are in velocity. The script below will transform such a cube into a time depth cube, i.e. a cube that has dimensions in time while the node values are in depth.
The cube is supposed to be in active. This is achieved when the script is placed in the main part of a command object and the CO is executed on the cube.
mhi cubegrid ;# the cube is saved in workspace cubegrid set nlay [gvar nlay] ;# get number of layers in the cube for {set i 0} {$i < $nlay} {incr i} { mlo cubegrid ;# move low the cubegrid to active ima sla $i ;# getting layer i from the cubegrid set time [gvar zval] ;# the time value is taken form the zval variable mul $time ;# velocity values are multiplied with time values getting depth values div 2000 ;# divide by 2000 if the time is in two_way_travel_time ima ins $i cubegrid ;# the grid is inserted back into the cubegrid }
After running the script loop the updated cube is in workspace cubegrid according to the script. Assign the cube back into the project from cubegrid.
One idea with a cube format is that it is a convenient way to probe values (or sample values) directly to some dataset that has the form x y time scalar. The time in this context is placed in the z values.
For a time velocity cube the input to probing has to be: x y time scalar. After probing the result is x y time velocity.
For a time depth cube the input to probing has to be: x y time scalar. After probing the result is x y time depth.
Geocap will generate the scalars if they are not present in the input dataset. A convenient way to generate scalars manually is to use the command mak sca.
Generating a cube by single grids
A technique for cube generation is to generate all the individual grids in the cube layers one by one, then insert them into the cube. In this way the user has completely control if there is a need for working out grids in this style. Below is a sketch of the procedure.
Assume there is a folder with 82 files of that represents values laying above each other. Then generate a command object for gridding all the data into individual grids and place it into a cube. The command object shall be executed on the folder containing all the datasets.
# Place this part in prestep # Do Scale window to data in folder first to get the grid window gen 100 100 82 ;# generate a cube of dimension 100 * 100 * 82 inside the grid window. mhi cubegrid ;# save the cube into workspace cubegrid # Place this part in main for {set i 0} {$i < 82} {incr i} { grp mav 100 100 ;# grid the points using moving average interpolator ima ins $i cubegrid ;# insert layer grid into layer i in the cube } # Place this part in poststep mlo cubegrid ;# move to active from cubegrid in workspace dis ;# display the cube in default mode. # The cube can now be added back into an appropriate folder in the project.
Smoothing a cube by smoothing each layer
The menu for smoothing a cube is found under cube_data->Smoothing cube. The menu has option for smoothing the cube in all xyz direction (Gaussian 3D) or lateral smoothing where each planes is smoothed individually.
The script below tells how to perform the individual cube layer smoothing thus enabling the user to take full control of any 2D smooth technique and optionally vary the smoothing for z plane location.
The cube is supposed to be in active. This is achieved when the script is placed in the main part of a command object and the CO is executed on the cube.
# To smooth a cube by smoothing each layer mhi cubeorg ;# the original cube is saved in workspace cubeorg mak csd ;# csd: copy same data, makes a new copy of the cube mhi cubesmooth ;# the new cube is saved in workspace cubesmooth set nlay [gvar nlay] ;# get number of layers in the cube ssc ;# scale cube to grid window for {set i 0} {$i < $nlay} {incr i} { mlo cubesmooth ;# move low the cube to active ima sla $i ;# getting layer i from the cube grp exc exrad 8 nod 16 ;# regrid and exclude 8 nodes and use 16 nodes ima ins $i cubesmooth ;# the grid is inserted back into cubesmooth } # To generate the difference between the original cube and the smoothed cube mlo cubeorg ;# move low the original cube sub lo cubesmooth ;# subtract the smoothed cube mhi cubediff ;# save the difference cube as cubediff # The new cubes: cubesmooth and cubediff can be added to the project
The scripts above shows how easy it is to manipulate a cube by individual cube layer control. The option of saving the original cube and generating a difference cube can be dropped if of no interest or if the cube is so large that memory space requires a minimum of cubes involved.