-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.py
More file actions
32 lines (25 loc) · 1.17 KB
/
example.py
File metadata and controls
32 lines (25 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Simple Example
from __future__ import print_function
import numpy as np
import cubeshow as cs
from matplotlib import cm
import matplotlib.pyplot as plt
reload(cs)
Ncube = 10 # Number of voxels along each axis
Lcube = 100 # Length of cube in meters
voxsize = Lcube / Ncube # size of one voxel in meters
cgen = (np.linspace(1,Ncube,Ncube) - 0.5) * voxsize
# coordinate array for geophysical properties
x3, y3, z3 = np.meshgrid(cgen, cgen, cgen)
r = np.sqrt((x3-Lcube/2)**2 + (y3-Lcube/2)**2 + (z3-Lcube/2)**2)
zshift = Lcube/3. * 1. / (1 + np.exp(0.2*(-y3 + Lcube/2)))
density = 1. + Lcube/10. * (1./(1+np.exp(-5*(z3 - Lcube * 4/10. + zshift) )) - 1./(1+np.exp(-5*(z3 - Lcube * 6/10. + zshift))))
magnetic = 10. * np.exp(-0.05*r)
mask = np.zeros_like(magnetic)
mask[density < 3] = 1
# plot voxel model with mask
ic = cs.imcube()
ic.cubeshow(density, data_color=magnetic, mask = mask, colorscheme = cm.jet, voxelsize = (voxsize,voxsize,voxsize), offset = (0,0,-100), show = True, savefig = False)
# plot voxel model without mask and only one datacube
print(" ")
ic.cubeshow(density, colorscheme = cm.jet, voxelsize = (voxsize,voxsize,voxsize), offset = (0,0,-100), show = True, savefig = False)