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