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 (jamie): Add call to process rainfall
def test_fahr_to_celius(): assert fahr_to_celsius(32) == 0
""" 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(ementzakis): Add a call to process rainfall
def test_fahro(): #print(fahr_to_celsius(0)+","+(160/9)) assert fahr_to_celsius(0)==(-160/9),"fahr 0 test"
def cel_test_zero(): fahr_to_celsius(32)==0
def cel_test_null(): fahr_to_celsius(0)==(-32/9)*5
def cel_test_neg(): fahr_to_celsius(-10)==-42*(5/9)
def test_fahr_cels_abs_zero_input(): assert fahr_to_celsius(-460) == -273