Exemplo n.º 1
0
def set_time():
    period = request.args.get('period')
    yy = int(request.args.get('yy'))
    mm = int(request.args.get('mm'))
    dd = int(request.args.get('dd'))
    global the_data
    if period == 'year':
        the_data = Year(yy)
    elif period == 'month':
        the_data = Month(yy, mm)
    elif period == 'week':
        the_data = Week(yy, mm, dd)
    else:
        the_data = Day(yy, mm, dd)
    return the_data.info
Exemplo n.º 2
0
 def test_leap_year(self):
     self.assertTrue(Year(1996).is_leap_year())
Exemplo n.º 3
0
 def test_exceptional_century(self):
     self.assertTrue(Year(2400).is_leap_year())
Exemplo n.º 4
0
 def test_any_old_year(self):
     self.assertFalse(Year(1997).is_leap_year())
'''script to scrape and plot the temperatures for the year to date (2017)'''

from year import Year
from visualisation.scattergl_plot import plot_large_scatter

#plot temperatures of year to date (2017)
#initiate a 'year object' and load the data from the web
yeartwelve = Year('17')
yeartwelve.load_all_data()

#assign the temperature and date data into variables yeartemps and yeartimes
yeartemps = yeartwelve.get_all_temps()
yeartimes = yeartwelve.get_all_datetimes()

#plot using plotly
plot_large_scatter(yeartimes, yeartemps, 'Date', 'Temperature (C)',
                   'yeartemps')
Exemplo n.º 6
0
 def test_not_leap_year_if_divisible_by_100_but_not_by_400(self):
     year = Year(1900)
     self.assertFalse(year.is_leap())
Exemplo n.º 7
0
 def test_is_leap_year_if_divisible_by_400(self):
     year = Year(1600)
     self.assertTrue(year.is_leap())
Exemplo n.º 8
0
 def test_not_leap_year_if_not_divisible_by_4(self):
     year = Year(1997)
     self.assertFalse(year.is_leap())
Exemplo n.º 9
0
 def test_century(self):
     self.assertFalse(Year(1900).is_leap_year())
Exemplo n.º 10
0
 def test_non_leap_even_year(self):
     self.assertFalse(Year(1998).is_leap_year())
Exemplo n.º 11
0
 def _init_year(self, year):
     self.years[str(year)] = Year(self._generate_navy_url(year))
Exemplo n.º 12
0
from visualisation.scattergl_plot import plot_large_scatter
import numpy as np
from sklearn import linear_model
from visualisation.scattergl_plot import plot_two_scatters
from linear_regression_ttest import get_slope_t_statistic, get_two_sided_p_value

#create list of dates in two character string format (corresponds to the format of the web files)
YEARINTS = range(2, 17)  #years from 2002 to 2016 inclusive
YEARLIST = [str(yr).zfill(2) for yr in YEARINTS]  # string format of years

#load all years' data
average_temperatures = []
year_names = []
for year_string in YEARLIST:
    print year_string
    year_object = Year(year_string)
    year_object.load_all_data()
    temperatures = year_object.get_all_temps()
    average_temperatures.append(np.average(temperatures))
    year_names.append(float(year_string) + 2000)
print average_temperatures

# Create linear regression object
regr = linear_model.LinearRegression()
x_values = np.reshape(YEARINTS, (len(YEARINTS), 1))

# Fit the data
regr.fit(x_values, average_temperatures)

# make the best-fit line ("prediction")
y_pred = regr.predict(x_values)