コード例 #1
0
	def __init__(self, data_file, sigma = 0, period=prob_spline.period(),sample=0,combine_index=[],remove_index=[],seed=None):
		if seed is not None:
			numpy.random.seed(seed)
			
		self.data_file = data_file

		msg = 'datafile must be a string'
		assert isinstance(data_file, str), msg
		
		msg = 'combine_index and remove_index cannot both be non-empty'
		if combine_index!=[] and remove_index!=[]:
			assert False, msg

		self.remove_index=remove_index
		self.combine_index=combine_index
		self.read_data()


		self.X=prob_spline.time_transform(self.time)

		assert (sigma >= 0), 'sigma must be nonnegative.'

		if sample == 1:
			self.generate_samples()
			self.splines = self.get_vector_spline(self.X,self.samples,sigma,period)
		else:
			self.splines = self.get_vector_spline(self.X,self.Y,sigma,period)
コード例 #2
0
 def __init__(self,
              bc_splines,
              bm_splines,
              mos_curve,
              tstart,
              tend,
              beta_1=1,
              find_beta=0,
              eps=.001,
              counter=0):
     self.tstart = tstart
     self.tend = tend
     self.time_trans = 365. / prob_spline.period()
     self.eps = eps  # The rate at which birds entering the population enter already infected with EEE
     if find_beta == 1:
         val = scipy.optimize.minimize(self.findbeta,
                                       beta_1,
                                       args=(bm_splines, bc_splines,
                                             mos_curve),
                                       method='COBYLA',
                                       options={"disp": False})
         self.beta_1 = val.x
         print(counter)
     else:
         self.beta_1 = beta_1
     self.bc_splines = bc_splines
     self.bm_splines = bm_splines
     self.mos_curve = mos_curve
     self.Y = self.run_ode(self.beta_1, bm_splines, bc_splines, mos_curve)
コード例 #3
0
	def __init__(self, data_file, sigma = 0, period=prob_spline.period(), sample = 0):

		msg = 'datafile must be a string'
		assert isinstance(data_file, str), msg
		
		assert (sigma >= 0), 'sigma must be nonnegative.'


		self.data_file = data_file

		self.read_data()
		self.X=prob_spline.time_transform(self.time)
		self.sigma = sigma
		self.period = period

		
		self.read_data()



		if sample==1:
			self.generate_samples()
			self.constant = self.get_host_splines(self.samples)
		else:
			self.constant = self.get_host_splines(self.Y)
コード例 #4
0
ファイル: mos_spline.py プロジェクト: mullert613/Thesis
	def __init__(self, data_file,sigma = 0, period=prob_spline.period(), sample = 0):

		msg = 'datafile must be a string'
		assert isinstance(data_file, str), msg
		assert (sigma >= 0), 'sigma must be nonnegative.'
		assert (n_samples >= 0), 'number of samples must be nonnegative.'
		assert isinstance(n_samples,int), 'number of samples must be an integer'
		
		self.data_file = data_file

		self.read_data()

		self.X=prob_spline.time_transform(self.time)

		if sample==1:
			self.generate_samples()
			self.splines = self.get_host_splines(self.X,self.samples,sigma,period)
		else:
			self.splines = self.get_host_splines(self.X,self.Y,sigma,period)
コード例 #5
0
ファイル: mos_sine.py プロジェクト: mullert613/Thesis
    def __init__(self,
                 data_file,
                 MosClass,
                 sigma=0,
                 period=prob_spline.period(),
                 n_samples=0):

        msg = 'datafile must be a string'
        assert isinstance(data_file, str), msg

        self.data_file = data_file

        self.read_data()
        self.X = prob_spline.time_transform(self.time)

        assert (sigma >= 0), 'sigma must be nonnegative.'

        self.splines = prob_spline.MosClass(data_file, sigma)
        self.splines = self.get_host_splines(self.X, self.Y, sigma, period)
コード例 #6
0
    def rhs(self, Y, t, bc_splines, bm_splines, mos_curve):
        # Consider adding epsilon term , for proportion infected entering population eps = .001
        p = self.p
        eps = self.eps
        s = Y[0:p]
        i = Y[p:2 * p]
        r = Y[2 * p:3 * p]
        sv = Y[3 * p]
        iv = Y[3 * p + 1]
        c = Y[3 * p + 1:4 * p + 1]  #cumulative infections
        e = Y[4 * p + 1:5 * p + 1]  #exposure

        transform_constant = 365. / prob_spline.period()

        alpha_val = self.alpha_calc(bm_splines(t), bc_splines(t))
        N = bc_splines(t)
        N_v = mos_curve(t)
        denom = numpy.dot(N, alpha_val)
        lambdab = self.beta1 * self.v * iv * numpy.array(
            alpha_val) * N_v / denom
        lambdav = self.v * (numpy.dot(self.beta2 * i * N, alpha_val)) / denom
        '''
		Note that bc_splines.pos_der returns the normalized dervivative of the spline, that is
		the derivative of the spline at the given time, divided by the value of the spline at
		that given time.
		'''

        ds = bc_splines.pos_der(t) * (1 - eps - s) - lambdab * s
        di = bc_splines.pos_der(t) * (eps - i) + lambdab * s - self.gammab * i
        dr = self.gammab * i - r * bc_splines.pos_der(t)
        dsv = mos_curve.pos_der(t) * iv - lambdav * sv + self.dv * iv
        div = lambdav * sv - mos_curve.pos_der(t) * iv - self.dv * iv

        dc = lambdab * s * N  #cumulative infections eq
        #de = numpy.sum(s*N)        			#exposure eq
        de = bc_splines.pos_der(t) * N  # proposed change

        dY = numpy.hstack(
            (ds, di, dr, dsv, div, dc,
             de))  # the 365/2 is the rate of change of the time transform
        return dY
コード例 #7
0
ファイル: host_spline.py プロジェクト: mullert613/Thesis
	def __init__(self, data_file, sigma = 0, period=prob_spline.period(), sample = 0, combine_index=[], remove_index=[],
		seed=None):
		if seed is not None:
			numpy.random.seed(seed)


		msg = 'datafile must be a string'
		assert isinstance(data_file, str), msg
		
		msg = 'combine_index and remove_index cannot both be non-empty'
		if combine_index!=[] and remove_index!=[]:
			assert False, msg

		self.remove_index=remove_index
		self.data_file = data_file
		self.combine_index=combine_index

		self.read_data()
		self.X=prob_spline.time_transform(self.time)
		
		'''
		Index here is a list of values correlating to which bird species you want combined
		An empty list indicates each line in the datafile will be examined independently
		A list with specified indices will combine those species, and return a matrix with
		only the non-specified indices, and a final index of the combined species.
		'''

		

		if hasattr(sigma,"__len__"):
			for j in sigma:
				assert (j >=0 ), 'sigma must be nonnegative'
		else:
			assert (sigma >= 0), 'sigma must be nonnegative.'
			sigma = sigma*numpy.ones(len(self.Y))

		if sample==1:
			self.generate_samples()
			self.splines = self.get_host_splines(self.X,self.samples,sigma,period)
		else:
			self.splines = self.get_host_splines(self.X,self.Y,sigma,period)
コード例 #8
0
ファイル: mos_curve.py プロジェクト: timbmuller/EEE-SIR-Model
    def __init__(self,
                 data_file,
                 MosClass,
                 sigma=0,
                 period=prob_spline.period(),
                 sample=0):

        msg = 'datafile must be a string'
        assert isinstance(data_file, str), msg

        self.data_file = data_file

        self.read_data()
        self.X = prob_spline.time_transform(self.time)

        assert (sigma >= 0), 'sigma must be nonnegative.'

        self.curves = MosClass(data_file,
                               sigma=sigma,
                               period=period,
                               sample=sample)