2022-11-25 11:19:06 -05:00
|
|
|
"""
|
2023-05-31 13:51:35 -04:00
|
|
|
Monthly values module
|
2022-11-25 11:19:06 -05:00
|
|
|
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
|
2022-11-25 11:19:06 -05:00
|
|
|
|
|
|
|
|
|
|
|
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 = []
|
2022-11-25 11:19:06 -05:00
|
|
|
if values is not None:
|
2023-08-07 14:46:19 -04:00
|
|
|
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]
|
2023-08-07 14:46:19 -04:00
|
|
|
hour += 1
|
2023-08-07 12:32:33 -04:00
|
|
|
out.append(total)
|
2022-11-25 11:19:06 -05:00
|
|
|
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 = []
|
2022-11-25 11:19:06 -05:00
|
|
|
if values is not None:
|
2023-08-07 14:46:19 -04:00
|
|
|
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]
|
2023-08-07 14:46:19 -04:00
|
|
|
hour += 1
|
2023-08-07 12:32:33 -04:00
|
|
|
out.append(total)
|
2022-11-25 11:19:06 -05:00
|
|
|
return out
|