generated from Southampton-RSG-Training/dirac-version-control-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
climate_analysis.py
31 lines (23 loc) · 837 Bytes
/
climate_analysis.py
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
""" Climate Analysis Tools """
import sys
import temp_conversion
import signal
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
script = sys.argv[0]
assert len(sys.argv) == 2, script + ": requires filename"
filename = sys.argv[1]
climate_data = open(filename, 'r')
for line in climate_data:
data = line.split(',')
if data[0][0] == '#':
# don't want to process comment lines, which start with '#'
pass
else:
# extract our max temperature in Fahrenheit - 4th column
fahr = float(data[3])
# don't process invalid temperature readings of -9999
if fahr != -9999:
celsius = temp_conversion.fahr_to_celsius(fahr)
kelvin = temp_conversion.fahr_to_kelvin(fahr)
print(str(celsius)+", "+str(kelvin))
# TODO(smangham): Add call to process rainfall