hanpa

mould risk index

Dec 21st, 2017
1,942
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.22 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. #
  3. # Usage:
  4. #
  5. # mindex.py t h
  6. #
  7. #  t = temperature in °C
  8. #  h = relative humidity in %
  9. #
  10. # Returns a mould growth risk index 0-3 based on
  11. # http://www.penthon.com/vanliga-fragor/faq/vad-innebar-mogelindex/
  12. #
  13. #  0 = No risk
  14. #  1 = Mould growth possible after > 8 weeks
  15. #  2 = Mould growth after 4-8 weeks
  16. #  3 = Mould growth after 0-4 weeks
  17. #
  18. #  Hans Palm 2017-12-21
  19.  
  20. import sys
  21. import math
  22. temp = float(sys.argv[1])
  23. hum  = float(sys.argv[2])
  24. mtab = [
  25.      [0,0,0,0],     # 0°
  26.      [0,97,98,100], # 1°
  27.      [0,95,97,100], # 2°
  28.      [0,93,95,100], # 3°
  29.      [0,91,93,98],  # 4°
  30.      [0,88,92,97],  # 5°
  31.      [0,87,91,96],  # 6°  
  32.      [0,86,91,95],  # 7°  
  33.      [0,84,90,95],  # 8°  
  34.      [0,83,89,94],  # 9°  
  35.      [0,82,88,93],  # 10°  
  36.      [0,81,88,93],  # 11°  
  37.      [0,81,88,92],  # 12°  
  38.      [0,80,87,92],  # 13°  
  39.      [0,79,87,92],  # 14°  
  40.      [0,79,87,91],  # 15°  
  41.      [0,79,86,91],  # 16°  
  42.      [0,79,86,91],  # 17°  
  43.      [0,79,86,90],  # 18°  
  44.      [0,79,85,90],  # 19°  
  45.      [0,79,85,90],  # 20°  
  46.      [0,79,85,90],  # 21°  
  47.      [0,79,85,89],  # 22°  
  48.      [0,79,84,89],  # 23°  
  49.      [0,79,84,89],  # 24°
  50.      [0,79,84,89],  # 25°  
  51.      [0,79,84,89],  # 26°  
  52.      [0,79,83,88],  # 27°  
  53.      [0,79,83,88],  # 28°  
  54.      [0,79,83,88],  # 29°  
  55.      [0,79,83,88],  # 30°  
  56.      [0,79,83,88],  # 31°  
  57.      [0,79,83,88],  # 32°  
  58.      [0,79,82,88],  # 33°  
  59.      [0,79,82,87],  # 34°  
  60.      [0,79,82,87],  # 35°  
  61.      [0,79,82,87],  # 36°  
  62.      [0,79,82,87],  # 37°  
  63.      [0,79,82,87],  # 38°  
  64.      [0,79,82,87],  # 39°  
  65.      [0,79,82,87],  # 40°  
  66.      [0,79,81,87],  # 41°  
  67.      [0,79,81,87],  # 42°  
  68.      [0,79,81,87],  # 43°  
  69.      [0,79,81,87],  # 44°  
  70.      [0,79,81,86],  # 45°  
  71.      [0,79,81,86],  # 46°  
  72.      [0,79,81,86],  # 47°  
  73.      [0,79,80,86],  # 48°  
  74.      [0,79,80,86],  # 49°  
  75.      [0,79,80,86]   # 50°
  76. ]
  77.  
  78. rtemp = round(temp)
  79. rhum = round(hum)
  80. if (rtemp <= 0) or (rtemp > 50):
  81.      mindex = 0
  82. else:
  83.      for i in range(1,4):
  84.           if (rhum < mtab[rtemp][i]):
  85.                mindex = i-1
  86.                break
  87.      else:
  88.           mindex = 3
  89. print (mindex)
Advertisement
Add Comment
Please, Sign In to add comment