system_assignation/hub/helpers/monthly_values.py

51 lines
1.2 KiB
Python
Raw Normal View History

"""
2023-05-31 13:51:35 -04:00
Monthly values module
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Pilar Monsalvete pilar_monsalvete@yahoo.es
"""
2023-08-07 12:32:33 -04:00
import hub.helpers.constants as cte
class MonthlyValues:
2023-05-31 13:51:35 -04:00
"""
Monthly values class
"""
2023-08-07 12:32:33 -04:00
@staticmethod
def get_mean_values(values):
2023-05-31 13:51:35 -04:00
"""
2023-08-07 12:32:33 -04:00
Calculates the mean values for each month from a list with hourly values
:return: [float] x 12
:param values: [float] x 8760
2023-05-31 13:51:35 -04:00
"""
2023-08-07 12:32:33 -04:00
out = []
if values is not None:
hour = 0
2023-08-07 12:32:33 -04:00
for month in cte.DAYS_A_MONTH:
total = 0
for j in range(0, cte.DAYS_A_MONTH[month]):
for k in range(0, 24):
total += values[hour] / 24 / cte.DAYS_A_MONTH[month]
hour += 1
2023-08-07 12:32:33 -04:00
out.append(total)
return out
2023-08-07 12:32:33 -04:00
@staticmethod
def get_total_month(values):
2023-05-31 13:51:35 -04:00
"""
Calculates the total value for each month
2023-08-07 12:32:33 -04:00
:return: [float] x 12
:param values: [float] x 8760
2023-05-31 13:51:35 -04:00
"""
2023-08-07 12:32:33 -04:00
out = []
if values is not None:
hour = 0
2023-08-07 12:32:33 -04:00
for month in cte.DAYS_A_MONTH:
total = 0
for j in range(0, cte.DAYS_A_MONTH[month]):
for k in range(0, 24):
total += values[hour]
hour += 1
2023-08-07 12:32:33 -04:00
out.append(total)
return out