Importing:
import numpy as np
Creating
a = np.array([3.14, 60, 17])
a
m = np.array([1, 2, 3], dtype=int)
type(m)
type(m[0])
z = np.zeros((10, 10))
z
z2 = np.zeros_like(z)
z2
onesy = np.ones(15)
onesy
c = z + z2
c = z * z2
c
a
a[:]
a[1:]
a[:2]
a[1:3]
a[-1]
a
a[-2]
a[-3]
b = np.array([10., 9., 8.])
b
a *b
np.shape(a)
np.size(a)
np.shape(c)
np.size(c)
c.size
b.shape
c.reshape(1,100)
d = np.arange(25)
d
d = np.arange(0, 100, 5)
d
np.amin(d)
np.amax(d)
np.mean(d)
np.sum(d)
a
b
a == b
a > b
np.where(a > 10.)
a
w = np.where(a > 10.0)[0]
w
a[w]
np.where(np.logical_and(a > 3.0, a < 20.0))[0]
dt = 1000.0
run_duration = 2.0e6
num_time_steps = int(run_duration / dt)
C = np.zeros(num_time_steps)
k = np.log(2.0) / 730000.0
P = 20.0
for i in range(1, num_time_steps):
C[i] = C[i-1] + dt * (-k * C[i-1] + P)
import matplotlib.pyplot as plt
%matplotlib inline
t = np.arange(0.0, run_duration / 1000.0, dt / 1000.0)
plt.plot(t, C)
plt.xlabel('Time (ky)')
plt.ylabel('Concentration (atoms/g quartz)')