In [1]:
import math
import numpy as np
%matplotlib inline
import matplotlib
matplotlib.style.use('ggplot')
import matplotlib.pyplot as plt
# Htemp = Temporary habitat
# Dcell = in a grid of diameter Dcell
# Prain = increases with rainfall Prain and
# tautemp = decays with a rate τtemp proportional to the evaporation rate driven by
# Tk = temperature T (K) and
# RH= humidity RH:
# Gas constant in units J K^{-1} mol^{-1}]]]]]]]]]]
# Htemp - Htemp(deltat/tautemp) = Prain * Ktemp * Dcell**2
# Htemp(1- deltat/tautemp) = Prain * Ktemp * Dcell**2
# H_temp = P_rain * K_temp * D_cell**2 / (1- delta_t/tau_temp)
yrindays = range(0,356)
Ktemp = [1.25e+9, 11.25e+9] # 1.25 × 109 for gambiae ss and 11.25 × 109 for arabiensis
ktempdecay = 0.05 # ktempdecay
Tkrange = np.arange(293,313,4)
R = 8.31451
RH = np.arange(0,1.0,0.2)
j = 0
dat = []
for Tk in Tkrange:
tautemp = 1./(5.1e+11 * math.exp(-5628.1/Tk) * ktempdecay * math.sqrt(.018/(2.0*math.pi*R*Tk))*(1-RH))
j +=1
dat.append(tautemp)
deltat = np.arange(0,365,1)
Prainrange = np.random.uniform(0,15,800)
Htemp = []#0 # when there isn't rain
Prain = np.mean(Prainrange)
Dcell = 0.8e-4 #km, 1 km radius
for tautemp in dat:
Htemp.append((Prain * Ktemp[0] * Dcell**2)/(1 - 1/tautemp))
In [45]:
# print Tk
# print RH
# print Htemp
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
i = 0
for row in Htemp:
ax.plot(Tkrange-273.15,row, label= ('humidity %.1g'%RH[i]))
i +=1
ax.set_ylabel("Habitat Decay")
ax.set_xlabel("Temperateure (C)")
plt.legend(loc='upper right', shadow=True, fontsize='x-large')
# print Htemp[0][:]
Out[45]:
In [27]:
import numpy as np
volume = 0.5 # range [0.0, 1.0]
fs = 1000 # sampling rate, Hz, must be integer
duration = 1.0 # in seconds, may be float
f = 440.0 # sine frequency, Hz, may be float
# generate samples, note conversion to float32 array
samples = (np.sin(2*np.pi*np.arange(fs*duration)*f/fs)).astype(np.float32)
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.plot(range(0,len(samples)),samples)
plt.show()
import numpy as np
dt = 1./1000
time = np.arange(0., 6., dt)
frequency = np.sin(2*math.pi*time*1.) # a 1Hz oscillation
waveform = np.sin(2*math.pi*time*1000)
plt.plot(time, waveform)
#Pxx, freqs, bins, im = plt.specgram(waveform, NFFT=4*1024, Fs=44100, noverlap=90, cmap=plt.cm.gist_heat)
plt.show()
In [ ]:
rain