Welcome, guest | Sign In | My Account | Store | Cart

calculate apparent infection rate

Python, 83 lines
 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Created by Donyo Ganchev, Agricultural University, town of Plovdiv, Bulgaria

# donyo@abv.bg

import math

import datetime



choice=None

def air():

      f_y, f_m, f_d=input('Enter first date in format "year, month, day": ')

      s_y, s_m, s_d=input('Enter second date in format "year, month, day": ')

      f_pdi=float(input('Enter pdi observed at first date: '))

      s_pdi=float(input('Enter pdi observed at second date: '))



      f_date=datetime.date(f_y, f_m, f_d)

      s_date=datetime.date(s_y, s_m, s_d)

      sdif=str(s_date-f_date)

      int_dif=int(sdif[0:2])



      r=(1/float(int_dif))*math.log((s_pdi*(1-f_pdi))/(f_pdi*(1-s_pdi)))



      print \

            """

            """

      

      print "%2.10f" %r 

      

              

                        

while choice!="0":

      print \

      """

      Apparent Infection Rate Calculation



      Created by Donyo Ganchev - Agricultural University, Plovdiv, Bulgaria

      

     1 - Begin calculation

     0 - Exit

     """

      choice= raw_input("Choice: ")

      if choice == "0":

                  exit()

      elif choice=="1":

             air()
Created by donyo Ganchev on Tue, 6 Apr 2010 (MIT)
Python recipes (4591)
donyo Ganchev's recipes (11)

Required Modules

Other Information and Tasks