Exemplo n.º 1
0
	def get_monthly_cycles(self):
		temp = {}
		if os.path.exists(os.path.dirname(os.path.abspath(__file__))+"/pv/"+self.lang+"/"+self.mp_title+".txt"):
			filename = "pv/"+self.lang+"/"+self.mp_title+".txt"
			with open(filename) as doc:
				for line in doc:
					cols = line.strip('\n').split("\t")
					timestamp = int(cols[0])
					hour_views = int(cols[2])

					dt = datetime.utcfromtimestamp(timestamp)

					if dt.strftime("%B_%Y") not in temp:
						temp[dt.strftime("%B_%Y")] = {}
						temp[dt.strftime("%B_%Y")]["hourly_totals"] = np.zeros(24).tolist()
						temp[dt.strftime("%B_%Y")]["hourly_num"] = np.zeros(24).tolist()
						temp[dt.strftime("%B_%Y")]["weekly_totals"] = np.zeros(7*24).tolist()
						temp[dt.strftime("%B_%Y")]["weekly_num"] = np.zeros(7*24).tolist()
					temp[dt.strftime("%B_%Y")]["hourly_totals"][dt.hour] += hour_views
					temp[dt.strftime("%B_%Y")]["hourly_num"][dt.hour] += 1
					
					temp[dt.strftime("%B_%Y")]["weekly_totals"][24*dt.weekday()+dt.hour] += hour_views
					temp[dt.strftime("%B_%Y")]["weekly_num"][24*dt.weekday()+dt.hour] += 1
					
		for month in temp:
			self.monthly_cycles[month] = {}		
			self.monthly_cycles[month]["hourly"] = calc_average(temp[month]["hourly_totals"],temp[month]["hourly_num"])
			self.monthly_cycles[month]["weekly"] = calc_average(temp[month]["weekly_totals"],temp[month]["weekly_num"])
Exemplo n.º 2
0
def mml9_damage(rnge, art):
    """
    Calculates MML9 damage.
    We assumes a switch from LRM to SRM at range 6.
    """
    if rnge <= 6:
        return 2 * calc_average(9, art)
    else:
        return calc_average(9, art)
Exemplo n.º 3
0
def hag20_damage(rnge):
    """
    Calculates HAG20 damage.
    """
    if rnge <= 8:
        return calc_average(20, 2)
    elif rnge <= 16:
        return calc_average(20, 0)
    else:
        return calc_average(20, -2)
Exemplo n.º 4
0
def atm12_damage(rnge):
    """
    Calculates ATM12 damage.
    We assumes a switch to HE at range 6, and normal at range 10.
    """
    if rnge <= 6:
        return 3 * calc_average(12, 2)
    elif rnge <= 10:
        return 2 * calc_average(12, 2)
    else:
        return calc_average(12, 2)
Exemplo n.º 5
0
	def get_cycles(self):
		hourly_totals = np.zeros(24).tolist()
		hourly_norm_totals = np.zeros(24).tolist()
		hourly_num = np.zeros(24).tolist()
		weekly_totals = np.zeros(7*24).tolist()
		weekly_norm_totals = np.zeros(7*24).tolist()
		weekly_num = np.zeros(7*24).tolist()

		hour_norm = np.zeros(24).tolist()
		week_norm = np.zeros(7*24).tolist()

		if os.path.exists(os.path.dirname(os.path.abspath(__file__))+"/pv/"+self.lang+"_total.txt"):
			filename = "pv/"+self.lang+"_total.txt"
			with open(filename) as doc:
				for line in doc:
					cols = line.strip('\n').split("\t")
					timestamp = int(cols[0])
					hour_views = int(cols[2])

					dt = datetime.utcfromtimestamp(timestamp)
					if dt.hour == 0 and sum(hour_norm) > 0:
						temp = [x/sum(hour_norm) for x in hour_norm]
						hour_norm = np.zeros(24).tolist()
						for x,views in enumerate(temp):
							hourly_norm_totals[x] += views

						if dt.weekday() == 0:
							temp_week = [x/sum(week_norm) for x in week_norm]
							week_norm = np.zeros(7*24).tolist()
							for x,views in enumerate(temp_week):
								weekly_norm_totals[x] += views

					hourly_totals[dt.hour] += hour_views
					hour_norm[dt.hour] = hour_views
					hourly_num[dt.hour] += 1
					
					weekly_totals[24*dt.weekday()+dt.hour] += hour_views
					week_norm[24*dt.weekday()+dt.hour] += hour_views
					weekly_num[24*dt.weekday()+dt.hour] += 1
		
		self.hourly = calc_average(hourly_totals,hourly_num)
		self.hourly_norm = calc_average(hourly_norm_totals,hourly_num)
		self.weekly = calc_average(weekly_totals,weekly_num)
		self.weekly_norm = calc_average(weekly_norm_totals,weekly_num)
Exemplo n.º 6
0
                     "T", 1, 8, 5, ""],
 "(IS) LB 10-X AC": ["LB10", "DB", [148, 19], 1, 400000,
                      2, (lambda x, y: 10), [0, 6, 12, 18],
                      "T", 1, 11, 6, ""],
 "(IS) LB 20-X AC": ["LB20", "DB", [237, 30], 1, 600000,
                      6, (lambda x, y: 20), [0, 4, 8, 12],
                      "T", 1, 14, 11, ""],
 "(IS) Light AC/2": ["LAC2", "DB", [30, 4], 1, 100000,
                      1, (lambda x, y: 2), [0, 6, 12, 18],
                      "T", 1, 4, 1, ""],
 "(IS) Light AC/5": ["LAC5", "DB", [62, 8], 1, 150000,
                      1, (lambda x, y: 5), [0, 5, 10, 15],
                      "T", 1, 5, 2, ""],
 "(IS) Rotary AC/2":
     ["RAC2", "DB", [118, 15], 1, 175000,
      6, (lambda x, y: 2 * calc_average(6, 0)), [0, 6, 12, 18],
      "T", 6, 8, 3, ""],
 "(IS) Rotary AC/5":
     ["RAC5", "DB", [247, 31], 1, 275000,
      6, (lambda x, y: 5 * calc_average(6, 0)), [0, 5, 10, 15],
      "T", 6, 10, 6, ""],
 "(IS) Ultra AC/2":
     ["UAC2", "DB", [56, 7], 1, 120000,
      2, (lambda x, y: 2 * calc_average(2, 0)), [3, 8, 17, 25],
      "T", 2, 7, 3, ""],
 "(IS) Ultra AC/5":
     ["UAC5", "DB", [112, 14], 1, 200000,
      2, (lambda x, y: 5 * calc_average(2, 0)), [2, 6, 13, 20],
      "T", 2, 9, 5, ""],
 "(IS) Ultra AC/10":
     ["UAC10", "DB", [210, 26], 1, 320000,