Ejemplo n.º 1
0
def MTD(dictionary, months_ago):  #month to date
    month_total_dict = calc.monthly_daily_totals(dictionary, months_ago,
                                                 'distance_miles')
    if month_total_dict.keys():
        return month_total_dict[max(month_total_dict.keys(
        ))]  #finds highest date, uses that date to find value
    else:
        return 0
def graph_per_month_total(master_dict,choice_dict,unit_dict):
    input2 = 'distance_miles'

    graph_dict = {}
    for choice in choice_dict:
        graph_dict[choice] = calc.monthly_daily_totals(master_dict.copy(),choice_dict[choice],input2) #calculates monthly totals for number of months chosen
        #returns dictionary of all computed values - keys eliminated in the monthly_daily_totals function
    for date_range,choice in zip(graph_dict,choice_dict): #for each month, graph values. Choice dict used for labels
        plt.plot(list(graph_dict[date_range].keys()),list(graph_dict[date_range].values()),label=(get_time.what_month(get_time.FOM(choice_dict[choice]).month)+" "+str(get_time.FOM(choice_dict[choice]).year)))

    plt.style.use('dark_background')
    plt.rcParams['lines.linewidth'] = 1
    plt.ylim(ymin=0)
    plt.title('Monthly Totals - '+' Unit: ' + input2)
    plt.legend()
    plt.show()
Ejemplo n.º 3
0
def print_statements(master_dict):
    now = datetime.datetime.now()
    past = datetime.datetime(now.year, now.month -
                             (0 - 1), 1) - (datetime.timedelta(days=1))
    LOM = datetime.datetime(past.year,
                            past.month,
                            past.day,
                            hour=23,
                            minute=59,
                            second=59)
    days_remaining = LOM.day - now.day
    runs_per_week = 3

    this_month_full = calc.monthly_daily_totals(master_dict.copy(), 0,
                                                'distance_miles')
    last_month_full = calc.monthly_daily_totals(master_dict.copy(), 1,
                                                'distance_miles')

    this_month = MTD(master_dict.copy(), 0)
    last_month = MTD(master_dict.copy(), 1)

    month_difference = this_month - last_month

    runs_remain = math.ceil(days_remaining * (runs_per_week / 7))

    monthly_dict = calc.monthly_stats(master_dict.copy())
    max_miles = 0
    for month in monthly_dict:
        if monthly_dict[month]['miles_ran'] > max_miles:
            max_miles = int(monthly_dict[month]['miles_ran'])
            most_miles_month = month

    print("MONTHLY")
    print("**********")
    print("Miles Ran This Month: " + str(this_month))
    print("Runs This Month: " + str(len(this_month_full)))
    print("Miles Ran Last Month: " + str(last_month))
    print("Runs Last Month: " + str(len(last_month_full)))
    print("Days in Month Remaining: " + str(days_remaining))
    print("Last Month vs This Month: " +
          str("{0:.2f}".format(month_difference)))
    print("Runs Remain in Month (" + str(runs_per_week) + " per week): " +
          str(runs_remain))
    print()
    print("GOALS")
    print("Goal of 50 Miles per Month: " +
          str("{0:.2f}".format(this_month - 50)))
    print("MPR to Match 50m Goal: " +
          str("{0:.2f}".format((50 - this_month) / runs_remain)))
    print("MPR to Match Last Month: " +
          str("{0:.2f}".format(abs(month_difference / runs_remain))))
    print("Most Mile Month: " + monthly_dict[most_miles_month]['date_human'])
    print("Most Miles Ran in a month: " + str(max_miles))
    print("MPR to Match Highest Month: " +
          str("{0:.2f}".format((max_miles - this_month) / runs_remain)))

    weekly_dict = calc.weekly_stats(master_dict.copy())

    max_weekly_miles = 0
    for week in weekly_dict:
        if weekly_dict[week]['miles_ran'] > max_weekly_miles:
            max_weekly_miles = int(weekly_dict[week]['miles_ran'])
            most_miles_week = week

    print()
    print("WEEKLY")
    print("********")
    print("Miles This Week: " + str(current_miles))
    print("Most Mile Week: " + str(weekly_dict[most_miles_week]['date_human']))
    print("Most Miles Run in a Week: " + str(max_weekly_miles))
    print("Miles to Match Highest Week: " +
          str(float(max_weekly_miles) - float(current_miles)))

    #this year
    ytd_dict = master_dict.copy()
    for key in list(ytd_dict):
        if key < get_time.FOY():
            del ytd_dict[key]
    ytd_miles = []
    for run in ytd_dict:
        ytd_miles.append(float(ytd_dict[run]['distance_miles']))
    miles_this_year = sum(ytd_miles)

    #last year
    timestamp = datetime.datetime.now()
    past_ytd_dict = master_dict.copy()
    for key in list(past_ytd_dict):
        if key < get_time.PFOY():
            del past_ytd_dict[key]
        if key > datetime.datetime(
                timestamp.year - 1, timestamp.month,
                timestamp.day):  #get date this time last year
            del past_ytd_dict[key]
    pytd_miles = []
    for run in past_ytd_dict:
        pytd_miles.append(float(past_ytd_dict[run]['distance_miles']))
    miles_last_year_this_time = sum(pytd_miles)

    goal_2018 = 600
    MPD = goal_2018 / 365
    day_of_year = LOM.timetuple().tm_yday
    target_miles = MPD * day_of_year
    remaining_ytd_miles = miles_this_year - target_miles

    print()
    print("YEAR TO DATE")
    print("**********")
    print("Miles Ran This Year: " + str(miles_this_year))
    print("Miles Ran Last Year by now: " + str(miles_last_year_this_time))
    print("Miles Behind Last Year: " +
          str("{0:.2f}".format(miles_this_year - miles_last_year_this_time)))
    print("2018 Goal for today: " + str(("{0:.2f}".format(target_miles))))
    print("Miles Behind YTD Goal: " +
          str(("{0:.2f}".format(remaining_ytd_miles))))
    print("MPR to YTD Goal by End of Month: " +
          str(("{0:.2f}".format(abs(remaining_ytd_miles) / runs_remain))))
Ejemplo n.º 4
0
def Monthly(dictionary, runs_per_week):
    this_month_full = calc.monthly_daily_totals(master_dict.copy(), 0,
                                                'distance_miles')
    last_month_full = calc.monthly_daily_totals(master_dict.copy(), 1,
                                                'distance_miles')
    this_month = MTD(master_dict.copy(), 0)
    last_month = MTD(master_dict.copy(), 1)
    month_difference = this_month - last_month
    now = datetime.datetime.now()
    past = datetime.datetime(now.year, now.month -
                             (0 - 1), 1) - (datetime.timedelta(days=1))
    LOM = datetime.datetime(past.year,
                            past.month,
                            past.day,
                            hour=23,
                            minute=59,
                            second=59)
    days_remaining = LOM.day - now.day
    #runs_per_week = 3
    runs_remain = math.ceil(days_remaining * (runs_per_week / 7))
    monthly_dict = calc.monthly_stats(master_dict.copy())
    max_miles = 0
    for month in monthly_dict:
        if monthly_dict[month]['miles_ran'] > max_miles:
            max_miles = int(monthly_dict[month]['miles_ran'])
            most_miles_month = month

    print("Days in Month Remaining: " + str(days_remaining))
    print()
    print("GOALS")
    print("Most Mile Month: " + monthly_dict[most_miles_month]['date_human'])
    print("Most Miles Ran in a month: " + str(max_miles))

    #LABELS
    label111 = v['label111']
    label111.text = str("This Month")

    label112 = v['label112']
    label112.text = str("Run Count")

    label113 = v['label113']
    label113.text = str("Last Month")

    label114 = v['label114']
    label114.text = str("Run Count")

    label115 = v['label115']
    label115.text = str("Difference")

    label116 = v['label116']
    label116.text = str("Runs Remain")

    label117 = v['label117']
    label117.text = str("MPR Last Month")

    #
    #DATA
    label121 = v['label121']
    label121.text = format_text(this_month)

    label122 = v['label122']
    label122.text = format_text(len(this_month_full))

    label123 = v['label123']
    label123.text = format_text(last_month)

    label124 = v['label124']
    label124.text = format_text(len(last_month_full))

    label125 = v['label125']
    label125.text = format_text(month_difference)

    label126 = v['label126']
    label126.text = format_text(runs_remain)

    label127 = v['label127']
    label127.text = format_text(abs(month_difference / runs_remain))

    #

    label131 = v['label131']
    label131.text = str("50 Miles Goal")

    label132 = v['label132']
    label132.text = str("MPR to 50M")

    label133 = v['label133']
    #label133.text = str("MPR Last Month")
    label133.text = str("")

    label134 = v['label134']
    label134.text = str("Month Record")

    label135 = v['label135']
    label135.text = str("MPR to Record")

    label136 = v['label136']
    label136.text = str()

    label137 = v['label137']
    label137.text = str()

    #

    label141 = v['label141']
    label141.text = format_text(this_month - 50)

    label142 = v['label142']
    label142.text = format_text((50 - this_month) / runs_remain)

    label143 = v['label143']
    #label143.text = str("{0:.2f}".format(abs(month_difference/runs_remain)))
    label143.text = str("")

    label144 = v['label144']
    label144.text = str(max_miles)

    label145 = v['label145']
    label145.text = format_text((max_miles - this_month) / runs_remain)

    label146 = v['label146']
    label146.text = str()

    label147 = v['label147']
    label147.text = str()