Scripts: square.py

File square.py, 471 bytes (added by goddard, 16 years ago)
Line 
1# Make a new map by squaring the values of the currently active map.
2
3# Get the currently active volume
4from VolumeViewer import active_volume
5v = active_volume()
6
7# Square the density values.
8import numpy
9m = v.full_matrix().astype(numpy.float32)
10m[:] = m*m
11
12# Make a new map.
13from VolumeData import Array_Grid_Data
14from VolumeViewer.volume import volume_from_grid_data
15g = Array_Grid_Data(m, v.data.origin, v.data.step, v.data.cell_angles)
16c = volume_from_grid_data(g)