comparison python/utils.py @ 973:4f3f88a27dae

minor
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Thu, 21 Dec 2017 23:26:00 -0500
parents 9897a13772fb
children 184f1dd307f9
comparison
equal deleted inserted replaced
972:b50145235f9e 973:4f3f88a27dae
78 return (k*stdev/tolerance)**2 78 return (k*stdev/tolerance)**2
79 79
80 def confidenceInterval(mean, stdev, nSamples, percentConfidence, trueStd = True, printLatex = False): 80 def confidenceInterval(mean, stdev, nSamples, percentConfidence, trueStd = True, printLatex = False):
81 '''if trueStd, use normal distribution, otherwise, Student 81 '''if trueStd, use normal distribution, otherwise, Student
82 82
83 Use otherwise t.interval or norm.interval 83 Use otherwise t.interval or norm.interval for the boundaries
84 ex: norm.interval(0.95, loc = 0., scale = 2.3/sqrt(11)) 84 ex: norm.interval(0.95)
85 t.interval(0.95, 10, loc=1.2, scale = 2.3/sqrt(nSamples)) 85 t.interval(0.95, nSamples-1)'''
86 loc is mean, scale is sigma/sqrt(n) (for Student, 10 is df)'''
87 from scipy.stats.distributions import norm, t 86 from scipy.stats.distributions import norm, t
88 if trueStd: 87 if trueStd:
89 k = round(norm.ppf(0.5+percentConfidence/200., 0, 1), 2) 88 k = round(norm.ppf(0.5+percentConfidence/200., 0, 1), 2)
90 else: # use Student 89 else: # use Student
91 k = round(t.ppf(0.5+percentConfidence/200., nSamples-1), 2) 90 k = round(t.ppf(0.5+percentConfidence/200., nSamples-1), 2)
912 Example: MONTREAL MCTAVISH 10761 911 Example: MONTREAL MCTAVISH 10761
913 MONTREALPIERRE ELLIOTT TRUDEAU INTL A 5415 912 MONTREALPIERRE ELLIOTT TRUDEAU INTL A 5415
914 see ftp://client_climate@ftp.tor.ec.gc.ca/Pub/Get_More_Data_Plus_de_donnees/Station%20Inventory%20EN.csv 913 see ftp://client_climate@ftp.tor.ec.gc.ca/Pub/Get_More_Data_Plus_de_donnees/Station%20Inventory%20EN.csv
915 914
916 To get daily data for 2010 and 2011, downloadECWeather(10761, [2010,2011], [], '/tmp') 915 To get daily data for 2010 and 2011, downloadECWeather(10761, [2010,2011], [], '/tmp')
917 To get hourly data for 2009 and 2012, January, March and October, downloadECWeather(10761, [2009,2012], [1,3,10], '/tmp')''' 916 To get hourly data for 2009 and 2012, January, March and October, downloadECWeather(10761, [2009,2012], [1,3,10], '/tmp')
917
918 for annee in `seq 2016 2017`;do wget --content-disposition "http://climat.meteo.gc.ca/climate_data/bulk_data_f.html?format=csv&stationID=10761&Year=${annee}&timeframe=2&submit=++T%C3%A9l%C3%A9charger+%0D%0Ades+donn%C3%A9es" ;done
919 for annee in `seq 2016 2017`;do for mois in `seq 1 12`;do wget --content-disposition "http://climat.meteo.gc.ca/climate_data/bulk_data_f.html?format=csv&stationID=10761&Year=${annee}&Month=${mois}&timeframe=1&submit=++T%C3%A9l%C3%A9charger+%0D%0Ades+donn%C3%A9es" ;done;done
920 '''
918 import urllib2 921 import urllib2
919 if english: 922 if english:
920 language = 'e' 923 language = 'e'
921 else: 924 else:
922 language = 'f' 925 language = 'f'