Пример #1
0
from scipy.stats import norm

from general_setup import smooth_data,median_over_months,sum_over_patterns,filter_for_specific_day,plot_me
from load_data import good_XXth_data,bad_XXth_data,bad_nth_data

# Good medians
good_XXth_medians = median_over_months(good_XXth_data)
good_XXth_medians_smooth = smooth_data(good_XXth_medians, 5)

# The day of interest
only_11th = filter_for_specific_day(good_XXth_data, '11th')
only_11th_medians_smooth = good_XXth_medians_smooth[['year','11th']]

# Bad sums
sum_bad_XXth = sum_over_patterns(bad_XXth_data, new_name='badth')

# Sum of good and bad
sum_bad_XXth_and_11th = sum_over_patterns(only_11th.merge(bad_XXth_data, on='year'), new_name='allth')
sum_bad_XXth_and_11th_medians = median_over_months(sum_bad_XXth_and_11th)
sum_bad_XXth_and_11th_medians_smooth = smooth_data(sum_bad_XXth_and_11th_medians, 5)

# Difference between good and sum of bad and good (not necessarily equal to sum of bad alone)
sum_XXth_minus_bad_medians = sum_bad_XXth_and_11th_medians.copy()
sum_XXth_minus_bad_medians.columns = ['year', 'diffth']
sum_XXth_minus_bad_medians['diffth'] = sum_bad_XXth_and_11th_medians['allth'] - good_XXth_medians['11th']
sum_XXth_minus_bad_medians_smooth = smooth_data(sum_XXth_minus_bad_medians)

# Sum of good and nth
sum_bad_11th_and_nth = sum_over_patterns(only_11th.merge(bad_nth_data, on='year'), new_name='allth')
sum_bad_11th_and_nth_medians = median_over_months(sum_bad_11th_and_nth)
Пример #2
0
from scipy.stats import norm

from general_setup import smooth_data, median_over_months, sum_over_patterns, filter_for_specific_day, plot_me
from load_data import good_XXth_data, bad_XXth_data, bad_nth_data

# Good medians
good_XXth_medians = median_over_months(good_XXth_data)
good_XXth_medians_smooth = smooth_data(good_XXth_medians, 5)

# The day of interest
only_11th = filter_for_specific_day(good_XXth_data, '11th')
only_11th_medians_smooth = good_XXth_medians_smooth[['year', '11th']]

# Bad sums
sum_bad_XXth = sum_over_patterns(bad_XXth_data, new_name='badth')

# Sum of good and bad
sum_bad_XXth_and_11th = sum_over_patterns(only_11th.merge(bad_XXth_data,
                                                          on='year'),
                                          new_name='allth')
sum_bad_XXth_and_11th_medians = median_over_months(sum_bad_XXth_and_11th)
sum_bad_XXth_and_11th_medians_smooth = smooth_data(
    sum_bad_XXth_and_11th_medians, 5)

# Difference between good and sum of bad and good (not necessarily equal to sum of bad alone)
sum_XXth_minus_bad_medians = sum_bad_XXth_and_11th_medians.copy()
sum_XXth_minus_bad_medians.columns = ['year', 'diffth']
sum_XXth_minus_bad_medians['diffth'] = sum_bad_XXth_and_11th_medians[
    'allth'] - good_XXth_medians['11th']
sum_XXth_minus_bad_medians_smooth = smooth_data(sum_XXth_minus_bad_medians)
Пример #3
0
old_style_medians_smooth = smooth_data(old_style_medians)

# Extract new-style days
only_2nd = filter_for_specific_day(good_XXth_data, '2nd')
only_3rd = filter_for_specific_day(good_XXth_data, '3rd')
only_22nd = filter_for_specific_day(good_XXth_data, '22nd')
only_23rd = filter_for_specific_day(good_XXth_data, '23rd')

# Extract old-style days
only_2d = filter_for_specific_day(old_style_data, '2d')
only_3d = filter_for_specific_day(old_style_data, '3d')
only_22d = filter_for_specific_day(old_style_data, '22d')
only_23d = filter_for_specific_day(old_style_data, '23d')

# Sum old and new style
sum_2nd_2d = sum_over_patterns(only_2nd.merge(only_2d, on='year'), new_name='2xx')
sum_3rd_3d = sum_over_patterns(only_3rd.merge(only_3d, on='year'), new_name='3xx')
sum_22nd_22d = sum_over_patterns(only_22nd.merge(only_22d, on='year'), new_name='22xx')
sum_23rd_23d = sum_over_patterns(only_23rd.merge(only_23d, on='year'), new_name='23xx')

# Merge data
sum_new_old = merge_data(sum_2nd_2d, sum_3rd_3d, sum_22nd_22d, sum_23rd_23d)
sum_new_old_medians = median_over_months(sum_new_old)
sum_new_old_medians_smooth = smooth_data(sum_new_old_medians)

# Plot new-style
ax = plot_me(good_XXth_medians_smooth)
ax.plot(good_XXth_medians_smooth['year'], good_XXth_medians_smooth['2nd'], 'g-', linewidth=4)
ax.plot(good_XXth_medians_smooth['year'], good_XXth_medians_smooth['3rd'], 'r-', linewidth=4)
ax.plot(good_XXth_medians_smooth['year'], good_XXth_medians_smooth['22nd'], 'c-', linewidth=4)
ax.plot(good_XXth_medians_smooth['year'], good_XXth_medians_smooth['23rd'], 'm-', linewidth=4)
Пример #4
0
old_style_medians_smooth = smooth_data(old_style_medians)

# Extract new-style days
only_2nd = filter_for_specific_day(good_XXth_data, '2nd')
only_3rd = filter_for_specific_day(good_XXth_data, '3rd')
only_22nd = filter_for_specific_day(good_XXth_data, '22nd')
only_23rd = filter_for_specific_day(good_XXth_data, '23rd')

# Extract old-style days
only_2d = filter_for_specific_day(old_style_data, '2d')
only_3d = filter_for_specific_day(old_style_data, '3d')
only_22d = filter_for_specific_day(old_style_data, '22d')
only_23d = filter_for_specific_day(old_style_data, '23d')

# Sum old and new style
sum_2nd_2d = sum_over_patterns(only_2nd.merge(only_2d, on='year'),
                               new_name='2xx')
sum_3rd_3d = sum_over_patterns(only_3rd.merge(only_3d, on='year'),
                               new_name='3xx')
sum_22nd_22d = sum_over_patterns(only_22nd.merge(only_22d, on='year'),
                                 new_name='22xx')
sum_23rd_23d = sum_over_patterns(only_23rd.merge(only_23d, on='year'),
                                 new_name='23xx')

# Merge data
sum_new_old = merge_data(sum_2nd_2d, sum_3rd_3d, sum_22nd_22d, sum_23rd_23d)
sum_new_old_medians = median_over_months(sum_new_old)
sum_new_old_medians_smooth = smooth_data(sum_new_old_medians)

# Plot new-style
ax = plot_me(good_XXth_medians_smooth)
ax.plot(good_XXth_medians_smooth['year'],