enerdata 1.1.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- enerdata/__init__.py +2 -0
- enerdata/calendars/__init__.py +20 -0
- enerdata/contracts/__init__.py +3 -0
- enerdata/contracts/contract.py +127 -0
- enerdata/contracts/electrical_seasons.py +376 -0
- enerdata/contracts/normalized_power.py +145 -0
- enerdata/contracts/tariff.py +1278 -0
- enerdata/cups/__init__.py +1 -0
- enerdata/cups/cups.py +29 -0
- enerdata/datetime/__init__.py +2 -0
- enerdata/datetime/holidays.py +7 -0
- enerdata/datetime/solar_hour.py +17 -0
- enerdata/datetime/station.py +12 -0
- enerdata/datetime/timezone.py +3 -0
- enerdata/datetime/work_and_holidays.py +18 -0
- enerdata/metering/__init__.py +1 -0
- enerdata/metering/measure.py +63 -0
- enerdata/metering/meter.py +27 -0
- enerdata/profiles/__init__.py +30 -0
- enerdata/profiles/data/coefficients_HIDRO_RE.csv +13 -0
- enerdata/profiles/data/coefficients_RE.xlsx +0 -0
- enerdata/profiles/profile.py +702 -0
- enerdata-1.1.6.dist-info/METADATA +26 -0
- enerdata-1.1.6.dist-info/RECORD +28 -0
- enerdata-1.1.6.dist-info/WHEEL +5 -0
- enerdata-1.1.6.dist-info/licenses/LICENSE +22 -0
- enerdata-1.1.6.dist-info/top_level.txt +2 -0
- spec/__init__.py +1 -0
enerdata/__init__.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
from datetime import date
|
|
3
|
+
from workalendar.europe import Spain
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class REECalendar(Spain):
|
|
7
|
+
"""Specific calendar for REE in Spain.
|
|
8
|
+
|
|
9
|
+
The holidays are the same in Spain but only the ones which are not
|
|
10
|
+
changeble and not fixed in a day.
|
|
11
|
+
"""
|
|
12
|
+
include_epiphany = False
|
|
13
|
+
include_good_friday = False
|
|
14
|
+
|
|
15
|
+
# Add epiphany
|
|
16
|
+
def get_fixed_holidays(self, year):
|
|
17
|
+
days = super(REECalendar, self).get_fixed_holidays(year)
|
|
18
|
+
if year >= 2022:
|
|
19
|
+
days.append((date(year, 1, 6), "Día de Reyes"))
|
|
20
|
+
return days
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
from datetime import date, timedelta
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
CONTRACT_STATES = [
|
|
5
|
+
'draft',
|
|
6
|
+
'validate',
|
|
7
|
+
'pending',
|
|
8
|
+
'active',
|
|
9
|
+
'contract',
|
|
10
|
+
'new_contract',
|
|
11
|
+
'modcontract',
|
|
12
|
+
'unpayed',
|
|
13
|
+
'off',
|
|
14
|
+
'down'
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class Interval(object):
|
|
19
|
+
def __init__(self, start, end, modification, changes):
|
|
20
|
+
self.start = start
|
|
21
|
+
self.end = end
|
|
22
|
+
self.modification = modification
|
|
23
|
+
self.changes = changes
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class Contract(object):
|
|
27
|
+
"""Contract object.
|
|
28
|
+
"""
|
|
29
|
+
def __init__(self):
|
|
30
|
+
self.code = None
|
|
31
|
+
self.state = 'draft'
|
|
32
|
+
self.modifications = []
|
|
33
|
+
self.contracted_power = 0
|
|
34
|
+
|
|
35
|
+
def modify(self, modcontract, overwrite=False):
|
|
36
|
+
assert isinstance(modcontract, Modification)
|
|
37
|
+
if overwrite:
|
|
38
|
+
self.modifications[-1] = modcontract
|
|
39
|
+
else:
|
|
40
|
+
if self.modifications:
|
|
41
|
+
old_mod = self.modifications[-1]
|
|
42
|
+
assert modcontract.start_date > old_mod.start_date
|
|
43
|
+
old_mod.end_date = modcontract.start_date - timedelta(days=1)
|
|
44
|
+
old_mod.next = modcontract
|
|
45
|
+
modcontract.previous = old_mod
|
|
46
|
+
old_mod.state = 'down'
|
|
47
|
+
modcontract.version = old_mod.version + 1
|
|
48
|
+
self.modifications.append(modcontract)
|
|
49
|
+
self.apply_modification(modcontract)
|
|
50
|
+
|
|
51
|
+
def get_modifications(self, start_date, end_date):
|
|
52
|
+
mods = []
|
|
53
|
+
# Get the modifications between dates
|
|
54
|
+
for m in self.modifications:
|
|
55
|
+
if m.start_date <= start_date and (
|
|
56
|
+
m.end_date is None or m.end_date >= end_date):
|
|
57
|
+
mods.append(m)
|
|
58
|
+
elif start_date <= m.start_date <= end_date:
|
|
59
|
+
mods.append(m)
|
|
60
|
+
return mods
|
|
61
|
+
|
|
62
|
+
def get_intervals(self, start_date, end_date, changes=None):
|
|
63
|
+
intervals = []
|
|
64
|
+
previous_mod = None
|
|
65
|
+
for m in self.get_modifications(start_date, end_date):
|
|
66
|
+
diff = {}
|
|
67
|
+
if previous_mod:
|
|
68
|
+
diff = previous_mod.diff(m, changes)
|
|
69
|
+
if diff or previous_mod is None:
|
|
70
|
+
mod_end_date = m.end_date or end_date
|
|
71
|
+
interval = Interval(
|
|
72
|
+
start=max(start_date, m.start_date),
|
|
73
|
+
end=min(mod_end_date, end_date),
|
|
74
|
+
changes=diff,
|
|
75
|
+
modification=m
|
|
76
|
+
)
|
|
77
|
+
intervals.append(interval)
|
|
78
|
+
else:
|
|
79
|
+
intervals[-1].end = min(m.end_date, end_date)
|
|
80
|
+
previous_mod = m
|
|
81
|
+
return intervals
|
|
82
|
+
|
|
83
|
+
def get_changes(self, modification):
|
|
84
|
+
changes = {}
|
|
85
|
+
local_vals = vars(self)
|
|
86
|
+
mod_vals = vars(modification)
|
|
87
|
+
for attr, value in mod_vals.items():
|
|
88
|
+
if attr in local_vals:
|
|
89
|
+
if value != local_vals[attr]:
|
|
90
|
+
changes[attr] = {'old': local_vals[attr], 'new': value}
|
|
91
|
+
return changes
|
|
92
|
+
|
|
93
|
+
def apply_changes(self, changes):
|
|
94
|
+
for attr, value in changes.items():
|
|
95
|
+
setattr(self, attr, value['new'])
|
|
96
|
+
|
|
97
|
+
def apply_modification(self, modification):
|
|
98
|
+
changes = self.get_changes(modification)
|
|
99
|
+
self.apply_changes(changes)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class Modification(object):
|
|
103
|
+
def __init__(self, start_date=None):
|
|
104
|
+
if start_date is None:
|
|
105
|
+
start_date = date.today()
|
|
106
|
+
self.start_date = start_date
|
|
107
|
+
self.end_date = None
|
|
108
|
+
self.previous = None
|
|
109
|
+
self.next = None
|
|
110
|
+
self.contracted_power = 0
|
|
111
|
+
self.state = 'draft'
|
|
112
|
+
self.version = 1
|
|
113
|
+
|
|
114
|
+
def diff(self, modification, filter=None):
|
|
115
|
+
changes = {}
|
|
116
|
+
local_vals = vars(self)
|
|
117
|
+
if modification is None:
|
|
118
|
+
mod_vals = local_vals.copy()
|
|
119
|
+
else:
|
|
120
|
+
mod_vals = vars(modification)
|
|
121
|
+
if filter is not None:
|
|
122
|
+
mod_vals = dict((k, v) for k, v in mod_vals.items() if k in filter)
|
|
123
|
+
for attr, value in mod_vals.items():
|
|
124
|
+
if attr in local_vals:
|
|
125
|
+
if value != local_vals[attr]:
|
|
126
|
+
changes[attr] = {'old': local_vals[attr], 'new': value}
|
|
127
|
+
return changes
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
import copy
|
|
3
|
+
|
|
4
|
+
ELECTRIC_ZONES = {
|
|
5
|
+
'1': 'Peninsular',
|
|
6
|
+
'2': 'Balearic Islands',
|
|
7
|
+
'3': 'Canary Islands',
|
|
8
|
+
'4': 'Ceuta',
|
|
9
|
+
'5': 'Melilla',
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
# Tariffs from BOE-A-2020-1066 (https://www.boe.es/eli/es/cir/2020/01/15/3)
|
|
13
|
+
TARIFFS_START_DATE_STR = '2021-06-01'
|
|
14
|
+
|
|
15
|
+
# month/day
|
|
16
|
+
DAYTYPE_BY_ELECTRIC_ZONE_CIR03_2020 = {
|
|
17
|
+
# Península
|
|
18
|
+
'1': {
|
|
19
|
+
'A': [('01/01', '02/29'), ('07/01', '07/31'), ('12/01', '12/31')], # Alta: enero, febrero, julio y diciembre
|
|
20
|
+
'B': [('03/01', '03/31'), ('11/01', '11/30')], # Media Alta: marzo y noviembre
|
|
21
|
+
'B1': [('06/01', '06/30'), ('08/01', '09/30')], # Media: junio, agosto y septiembre
|
|
22
|
+
'C': [('04/01', '05/31'), ('10/01', '10/31')], # Baja: abril, mayo y octubre
|
|
23
|
+
'D': []
|
|
24
|
+
},
|
|
25
|
+
# Balearic Islands
|
|
26
|
+
'2': {
|
|
27
|
+
'A': [('06/01', '09/30')], # Alta: junio, julio, agosto y septiembre
|
|
28
|
+
'B': [('05/01', '05/31'), ('10/01', '10/31')], # Media Alta: mayo y octubre
|
|
29
|
+
'B1': [('01/01', '02/29'), ('12/01', '12/31')], # Media: enero, febrero y diciembre
|
|
30
|
+
'C': [('03/01', '04/30'), ('11/01', '11/30')], # Baja: marzo, abril y noviembre
|
|
31
|
+
'D': []
|
|
32
|
+
},
|
|
33
|
+
# Canary Islands
|
|
34
|
+
'3': {
|
|
35
|
+
'A': [('07/01', '10/31')], # Alta: julio, agosto, septiembre y octubre
|
|
36
|
+
'B': [('11/01', '12/31')], # Media Alta: noviembre y diciembre
|
|
37
|
+
'B1': [('01/01', '03/31')], # Media: enero, febrero y marzo
|
|
38
|
+
'C': [('04/01', '06/30')], # Baja: abril, mayo y junio
|
|
39
|
+
'D': []
|
|
40
|
+
},
|
|
41
|
+
# Ceuta
|
|
42
|
+
'4': {
|
|
43
|
+
'A': [('01/01', '02/29'), ('08/01', '08/31'), ('09/01', '09/30')], # Alta: enero, febrero, agosto y septiembre
|
|
44
|
+
'B': [('07/01', '07/31'), ('10/01', '10/31')], # Media Alta: julio y octubre
|
|
45
|
+
'B1': [('03/01', '03/31'), ('11/01', '12/31')], # Media: marzo, noviembre y diciembre
|
|
46
|
+
'C': [('04/01', '06/30')], # Baja: abril, mayo y junio
|
|
47
|
+
'D': []
|
|
48
|
+
},
|
|
49
|
+
# Melilla
|
|
50
|
+
'5': {
|
|
51
|
+
'A': [('01/01', '01/31'), ('07/01', '09/30')], # Alta: enero, julio, agosto y septiembre
|
|
52
|
+
'B': [('02/01', '02/29'), ('12/01', '12/31')], # Media Alta: febrero y diciembre
|
|
53
|
+
'B1': [('06/01', '06/30'), ('10/01', '11/30')], # Media: junio, octubre y noviembre
|
|
54
|
+
'C': [('03/01', '05/31')], # Baja: marzo, abril y mayo
|
|
55
|
+
'D': []
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# 2 period discrimination for Zone
|
|
60
|
+
PERIODS_2x_BY_ELECTRIC_ZONE_CIR03_2020 = {
|
|
61
|
+
# Zone 1: Península
|
|
62
|
+
'1': {
|
|
63
|
+
'A': [
|
|
64
|
+
[(8, 24)], # P1
|
|
65
|
+
[(0, 8)] # P2
|
|
66
|
+
],
|
|
67
|
+
'D': [
|
|
68
|
+
[], # P1
|
|
69
|
+
[(0, 24)] # P2
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
# All day types are the same
|
|
75
|
+
PERIODS_2x_BY_ELECTRIC_ZONE_CIR03_2020['1'].update(
|
|
76
|
+
{'B': copy.deepcopy(PERIODS_2x_BY_ELECTRIC_ZONE_CIR03_2020['1']['A']),
|
|
77
|
+
'B1': copy.deepcopy(PERIODS_2x_BY_ELECTRIC_ZONE_CIR03_2020['1']['A']),
|
|
78
|
+
'C': copy.deepcopy(PERIODS_2x_BY_ELECTRIC_ZONE_CIR03_2020['1']['A'])}
|
|
79
|
+
)
|
|
80
|
+
# All 5 Zones are the same
|
|
81
|
+
PERIODS_2x_BY_ELECTRIC_ZONE_CIR03_2020.update(
|
|
82
|
+
{'2': copy.deepcopy(PERIODS_2x_BY_ELECTRIC_ZONE_CIR03_2020['1']),
|
|
83
|
+
'3': copy.deepcopy(PERIODS_2x_BY_ELECTRIC_ZONE_CIR03_2020['1']),
|
|
84
|
+
'4': copy.deepcopy(PERIODS_2x_BY_ELECTRIC_ZONE_CIR03_2020['1']),
|
|
85
|
+
'5': copy.deepcopy(PERIODS_2x_BY_ELECTRIC_ZONE_CIR03_2020['1'])}
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
# 3 period discrimination for Zone
|
|
89
|
+
PERIODS_3x_BY_ELECTRIC_ZONE_CIR03_2020 = {
|
|
90
|
+
# Zone 1: Península
|
|
91
|
+
'1': {
|
|
92
|
+
'A': [
|
|
93
|
+
[(10, 14), (18, 22)], # P1
|
|
94
|
+
[(8, 10), (14, 18), (22, 24)], # P2
|
|
95
|
+
[(0, 8)] # P3
|
|
96
|
+
],
|
|
97
|
+
'D': [
|
|
98
|
+
[], # P1
|
|
99
|
+
[], # P2
|
|
100
|
+
[(0, 24)] # P3
|
|
101
|
+
|
|
102
|
+
]
|
|
103
|
+
},
|
|
104
|
+
'4': {
|
|
105
|
+
'A': [
|
|
106
|
+
[(11, 15), (19, 23)], # P1
|
|
107
|
+
[(8, 11), (15, 19), (23, 24)], # P2
|
|
108
|
+
[(0, 8)] # P3
|
|
109
|
+
],
|
|
110
|
+
'D': [
|
|
111
|
+
[], # P1
|
|
112
|
+
[], # P2
|
|
113
|
+
[(0, 24)] # P3
|
|
114
|
+
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
# All day types are the same
|
|
120
|
+
PERIODS_3x_BY_ELECTRIC_ZONE_CIR03_2020['1'].update(
|
|
121
|
+
{'B': copy.deepcopy(PERIODS_3x_BY_ELECTRIC_ZONE_CIR03_2020['1']['A']),
|
|
122
|
+
'B1': copy.deepcopy(PERIODS_3x_BY_ELECTRIC_ZONE_CIR03_2020['1']['A']),
|
|
123
|
+
'C': copy.deepcopy(PERIODS_3x_BY_ELECTRIC_ZONE_CIR03_2020['1']['A'])}
|
|
124
|
+
)
|
|
125
|
+
PERIODS_3x_BY_ELECTRIC_ZONE_CIR03_2020['4'].update(
|
|
126
|
+
{'B': copy.deepcopy(PERIODS_3x_BY_ELECTRIC_ZONE_CIR03_2020['1']['A']),
|
|
127
|
+
'B1': copy.deepcopy(PERIODS_3x_BY_ELECTRIC_ZONE_CIR03_2020['1']['A']),
|
|
128
|
+
'C': copy.deepcopy(PERIODS_3x_BY_ELECTRIC_ZONE_CIR03_2020['1']['A'])}
|
|
129
|
+
)
|
|
130
|
+
# Zones 1, 2 and 3 are the same
|
|
131
|
+
PERIODS_3x_BY_ELECTRIC_ZONE_CIR03_2020.update(
|
|
132
|
+
{'2': copy.deepcopy(PERIODS_3x_BY_ELECTRIC_ZONE_CIR03_2020['1']),
|
|
133
|
+
'3': copy.deepcopy(PERIODS_3x_BY_ELECTRIC_ZONE_CIR03_2020['1'])}
|
|
134
|
+
)
|
|
135
|
+
# Zones 4 and 5 are the same
|
|
136
|
+
PERIODS_3x_BY_ELECTRIC_ZONE_CIR03_2020.update(
|
|
137
|
+
{'5': copy.deepcopy(PERIODS_3x_BY_ELECTRIC_ZONE_CIR03_2020['4'])}
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
# 6 period discrimination for Zone/dayType
|
|
141
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020 = {
|
|
142
|
+
# Zone 1: Península
|
|
143
|
+
'1': {
|
|
144
|
+
'A': [
|
|
145
|
+
[(9, 14), (18, 22)], # P1
|
|
146
|
+
[(8, 9), (14, 18), (22, 24)], # P2
|
|
147
|
+
[], # P3
|
|
148
|
+
[], # P4
|
|
149
|
+
[], # P5
|
|
150
|
+
[(0, 8)] # P6
|
|
151
|
+
],
|
|
152
|
+
'B': [
|
|
153
|
+
[], # P1
|
|
154
|
+
[(9, 14), (18, 22)], # P2
|
|
155
|
+
[(8, 9), (14, 18), (22, 24)], # P3
|
|
156
|
+
[], # P4
|
|
157
|
+
[], # P5
|
|
158
|
+
[(0, 8)] # P6
|
|
159
|
+
],
|
|
160
|
+
'B1': [
|
|
161
|
+
[], # P1
|
|
162
|
+
[], # P2
|
|
163
|
+
[(9, 14), (18, 22)], # P3
|
|
164
|
+
[(8, 9), (14, 18), (22, 24)], # P4
|
|
165
|
+
[], # P5
|
|
166
|
+
[(0, 8)] # P6
|
|
167
|
+
],
|
|
168
|
+
'C': [
|
|
169
|
+
[], # P1
|
|
170
|
+
[], # P2
|
|
171
|
+
[], # P3
|
|
172
|
+
[(9, 14), (18, 22)], # P4
|
|
173
|
+
[(8, 9), (14, 18), (22, 24)], # P5
|
|
174
|
+
[(0, 8)] # P6
|
|
175
|
+
],
|
|
176
|
+
'D': [
|
|
177
|
+
[], # P1
|
|
178
|
+
[], # P2
|
|
179
|
+
[], # P3
|
|
180
|
+
[], # P4
|
|
181
|
+
[], # P5
|
|
182
|
+
[(0, 24)] # P6
|
|
183
|
+
],
|
|
184
|
+
},
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
# Zone 2: Balearic Islands
|
|
188
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020.update(
|
|
189
|
+
{'2': copy.deepcopy(PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['1'].copy())}
|
|
190
|
+
)
|
|
191
|
+
# A: P1 and P2 are different from Zone 1
|
|
192
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['2']['A'][0] = [(10, 15), (18, 22)]
|
|
193
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['2']['A'][1] = [(8, 10), (15, 18), (22, 24)]
|
|
194
|
+
# B: P2 and P3 are different from Zone 1
|
|
195
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['2']['B'][1] = [(10, 15), (18, 22)]
|
|
196
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['2']['B'][2] = [(8, 10), (15, 18), (22, 24)]
|
|
197
|
+
# B1: P3 and P4 are different from Zone 1
|
|
198
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['2']['B1'][2] = [(10, 15), (18, 22)]
|
|
199
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['2']['B1'][3] = [(8, 10), (15, 18), (22, 24)]
|
|
200
|
+
# C: P4 and P5 are different from Zone 1
|
|
201
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['2']['C'][3] = [(10, 15), (18, 22)]
|
|
202
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['2']['C'][4] = [(8, 10), (15, 18), (22, 24)]
|
|
203
|
+
|
|
204
|
+
# Zone 3: Canary Islands
|
|
205
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020.update(
|
|
206
|
+
{'3': copy.deepcopy(PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['2'])}
|
|
207
|
+
)
|
|
208
|
+
# A: P2 and P3 are different from Zone 2
|
|
209
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['3']['A'][1] = []
|
|
210
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['3']['A'][2] = [(8, 10), (15, 18), (22, 24)]
|
|
211
|
+
# B1: P2 and P3 are different from Zone 2
|
|
212
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['3']['B1'][1] = [(10, 15), (18, 22)]
|
|
213
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['3']['B1'][2] = []
|
|
214
|
+
|
|
215
|
+
# Zone 4: Ceuta
|
|
216
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020.update(
|
|
217
|
+
{'4': copy.deepcopy(PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['3'])}
|
|
218
|
+
)
|
|
219
|
+
# A: P1, P3 and P4 are different from Zone 3
|
|
220
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['4']['A'][0] = [(10, 15), (19, 23)]
|
|
221
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['4']['A'][2] = []
|
|
222
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['4']['A'][3] = [(8, 10), (15, 19), (23, 24)]
|
|
223
|
+
# B: P2 and P3 are different from Zone 3
|
|
224
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['4']['B'][1] = [(10, 15), (19, 23)]
|
|
225
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['4']['B'][2] = [(8, 10), (15, 19), (23, 24)]
|
|
226
|
+
# B1: P2 and P4 are different from Zone 3
|
|
227
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['4']['B1'][1] = [(10, 15), (19, 23)]
|
|
228
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['4']['B1'][3] = [(8, 10), (15, 19), (23, 24)]
|
|
229
|
+
# C: P3, P4 and P5 are different from Zone 3
|
|
230
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['4']['C'][2] = [(10, 15), (19, 23)]
|
|
231
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['4']['C'][3] = []
|
|
232
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['4']['C'][4] = [(8, 10), (15, 19), (23, 24)]
|
|
233
|
+
|
|
234
|
+
# Zone 5: Melilla
|
|
235
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020.update(
|
|
236
|
+
{'5': copy.deepcopy(PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['4'])}
|
|
237
|
+
)
|
|
238
|
+
# A: P2 and P4 are different from Zone 4
|
|
239
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['5']['A'][1] = [(8, 10), (15, 19), (23, 24)]
|
|
240
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['5']['A'][3] = []
|
|
241
|
+
# B1: P2 and P3 are different from Zone 4
|
|
242
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['5']['B1'][1] = []
|
|
243
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['5']['B1'][2] = [(10, 15), (19, 23)]
|
|
244
|
+
# C: P3 and P4 are different from Zone 4
|
|
245
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['5']['C'][2] = []
|
|
246
|
+
PERIODS_6x_BY_ELECTRIC_ZONE_CIR03_2020['5']['C'][3] = [(10, 15), (19, 23)]
|
|
247
|
+
|
|
248
|
+
# Old tariffs from BOE-A-2001-20850 (https://www.boe.es/eli/es/rd/2001/10/26/1164)
|
|
249
|
+
# month/day
|
|
250
|
+
DAYTYPE_BY_ELECTRIC_ZONE = {
|
|
251
|
+
# Península
|
|
252
|
+
'1': {
|
|
253
|
+
'A': [('01/01', '02/29'), ('12/01', '12/31')],
|
|
254
|
+
'A1': [('06/16', '07/31')],
|
|
255
|
+
'B': [('06/01', '06/15'), ('09/01', '09/30')],
|
|
256
|
+
'B1': [('03/01', '03/31'), ('11/01', '11/30')],
|
|
257
|
+
'C': [('04/01', '05/31'), ('10/01', '10/31')],
|
|
258
|
+
'D': [('08/01', '08/31')]
|
|
259
|
+
},
|
|
260
|
+
# Balearic Islands
|
|
261
|
+
'2': {
|
|
262
|
+
'A': [('06/01', '09/30')],
|
|
263
|
+
'B1': [('01/01', '02/29'), ('05/01', '05/31'), ('10/01', '10/31')],
|
|
264
|
+
'C': [('03/01', '03/31'), ('11/01', '12/31')],
|
|
265
|
+
'D': [('04/01', '04/30')]
|
|
266
|
+
},
|
|
267
|
+
# Canary Islands
|
|
268
|
+
'3': {
|
|
269
|
+
'A': [('09/01', '12/31')],
|
|
270
|
+
'B': [('07/01', '08/31')],
|
|
271
|
+
'B1': [('01/01', '02/29')],
|
|
272
|
+
'C': [('03/01', '04/30'), ('06/01', '06/30')],
|
|
273
|
+
'D': [('05/01', '05/31')]
|
|
274
|
+
},
|
|
275
|
+
# Ceuta
|
|
276
|
+
'4': {
|
|
277
|
+
'A': [('01/01', '02/29'), ('08/01', '08/31'), ('12/01', '12/31')],
|
|
278
|
+
'B': [('07/01', '07/31'), ('09/01', '09/30')],
|
|
279
|
+
'B1': [('03/01', '03/31'), ('11/01', '11/30')],
|
|
280
|
+
'C': [('04/01', '04/30'), ('06/01', '06/30'), ('10/01', '10/31')],
|
|
281
|
+
'D': [('05/01', '05/31')]
|
|
282
|
+
},
|
|
283
|
+
# Melilla
|
|
284
|
+
'5': {
|
|
285
|
+
'A': [('01/01', '02/29')],
|
|
286
|
+
'A1': [('07/01', '08/31')],
|
|
287
|
+
'B': [('06/01', '06/30'), ('09/01', '09/30')],
|
|
288
|
+
'B1': [('03/01', '03/31'), ('12/01', '12/31')],
|
|
289
|
+
'C': [('04/01', '04/30'), ('10/01', '11/30')],
|
|
290
|
+
'D': [('05/01', '05/31')]
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
# 6 periods for Zone/dayType
|
|
295
|
+
PERIODS_6x_BY_ELECTRIC_ZONE = {
|
|
296
|
+
# Zone 1: Península
|
|
297
|
+
'1': {
|
|
298
|
+
'A': [
|
|
299
|
+
[(10, 13), (18, 21)], # P1
|
|
300
|
+
[(8, 10), (13, 18), (21, 24)], # P2
|
|
301
|
+
[], # P3
|
|
302
|
+
[], # P4
|
|
303
|
+
[], # P5
|
|
304
|
+
[(0, 8)], # P6
|
|
305
|
+
],
|
|
306
|
+
'A1': [
|
|
307
|
+
[(11, 19)],
|
|
308
|
+
[(8, 11), (19, 24)],
|
|
309
|
+
[],
|
|
310
|
+
[],
|
|
311
|
+
[],
|
|
312
|
+
[(0, 8)],
|
|
313
|
+
],
|
|
314
|
+
'B': [
|
|
315
|
+
[],
|
|
316
|
+
[],
|
|
317
|
+
[(9, 15)],
|
|
318
|
+
[(8, 9), (15, 24)],
|
|
319
|
+
[],
|
|
320
|
+
[(0, 8)],
|
|
321
|
+
],
|
|
322
|
+
'B1': [
|
|
323
|
+
[],
|
|
324
|
+
[],
|
|
325
|
+
[(16, 22)],
|
|
326
|
+
[(8, 16), (22, 24)],
|
|
327
|
+
[],
|
|
328
|
+
[(0, 8)],
|
|
329
|
+
],
|
|
330
|
+
'C': [
|
|
331
|
+
[],
|
|
332
|
+
[],
|
|
333
|
+
[],
|
|
334
|
+
[],
|
|
335
|
+
[(8, 24)],
|
|
336
|
+
[(0, 8)],
|
|
337
|
+
],
|
|
338
|
+
'D': [
|
|
339
|
+
[],
|
|
340
|
+
[],
|
|
341
|
+
[],
|
|
342
|
+
[],
|
|
343
|
+
[],
|
|
344
|
+
[(0, 24)],
|
|
345
|
+
],
|
|
346
|
+
},
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
# Zone 2 and 3: Balearic and Canary Islands
|
|
350
|
+
PERIODS_6x_BY_ELECTRIC_ZONE.update(
|
|
351
|
+
{'2': copy.deepcopy(PERIODS_6x_BY_ELECTRIC_ZONE['1'].copy())}
|
|
352
|
+
)
|
|
353
|
+
# A:P1 and A:P2
|
|
354
|
+
PERIODS_6x_BY_ELECTRIC_ZONE['2']['A'][0] = [(11, 14), (18, 21)]
|
|
355
|
+
PERIODS_6x_BY_ELECTRIC_ZONE['2']['A'][1] = [(8, 11), (14, 18), (21, 24)]
|
|
356
|
+
# Zone 3 == Zone 2
|
|
357
|
+
PERIODS_6x_BY_ELECTRIC_ZONE.update(
|
|
358
|
+
{'3': copy.deepcopy(PERIODS_6x_BY_ELECTRIC_ZONE['2'])}
|
|
359
|
+
)
|
|
360
|
+
|
|
361
|
+
# Zone 4: Ceuta
|
|
362
|
+
PERIODS_6x_BY_ELECTRIC_ZONE.update(
|
|
363
|
+
{'4': copy.deepcopy(PERIODS_6x_BY_ELECTRIC_ZONE['1'])}
|
|
364
|
+
)
|
|
365
|
+
# A:P1 and A:P2
|
|
366
|
+
PERIODS_6x_BY_ELECTRIC_ZONE['4']['A'][0] = [(12, 15), (20, 23)]
|
|
367
|
+
PERIODS_6x_BY_ELECTRIC_ZONE['4']['A'][1] = [(8, 12), (15, 20), (23, 24)]
|
|
368
|
+
|
|
369
|
+
# B1:P3 and B1:P4
|
|
370
|
+
PERIODS_6x_BY_ELECTRIC_ZONE['4']['B1'][2] = [(17, 23)]
|
|
371
|
+
PERIODS_6x_BY_ELECTRIC_ZONE['4']['B1'][3] = [(8, 17), (23, 24)]
|
|
372
|
+
|
|
373
|
+
# Zone 5: Melilla
|
|
374
|
+
PERIODS_6x_BY_ELECTRIC_ZONE.update(
|
|
375
|
+
{'5': copy.deepcopy(PERIODS_6x_BY_ELECTRIC_ZONE['4'])}
|
|
376
|
+
)
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
NORMALIZED_POWERS = {
|
|
2
|
+
191: ('1x127', '1.5'),
|
|
3
|
+
200: ('1x133', '1.5'),
|
|
4
|
+
330: ('1x220', '1.5'),
|
|
5
|
+
345: ('1x230', '1.5'),
|
|
6
|
+
381: ('1x127', '3'),
|
|
7
|
+
399: ('1x133', '3'),
|
|
8
|
+
445: ('1x127', '3.5'),
|
|
9
|
+
466: ('1x133', '3.5'),
|
|
10
|
+
572: ('3x220/127', '1.5'),
|
|
11
|
+
598: ('3x230/133', '1.5'),
|
|
12
|
+
635: ('1x127', '5'),
|
|
13
|
+
660: ('1x220', '3'),
|
|
14
|
+
665: ('1x133', '5'),
|
|
15
|
+
690: ('1x230', '3'),
|
|
16
|
+
770: ('1x220', '3.5'),
|
|
17
|
+
805: ('1x230', '3.5'),
|
|
18
|
+
953: ('1x127', '7.5'),
|
|
19
|
+
987: ('3x380/220', '1.5'),
|
|
20
|
+
998: ('1x133', '7.5'),
|
|
21
|
+
1039: ('3x400/230', '1.5'),
|
|
22
|
+
1100: ('1x220', '5'),
|
|
23
|
+
1143: ('3x220/127', '3'),
|
|
24
|
+
1150: ('1x230', '5'),
|
|
25
|
+
1195: ('3x230/133', '3'),
|
|
26
|
+
1270: ('1x127', '10'),
|
|
27
|
+
1330: ('1x133', '10'),
|
|
28
|
+
1334: ('3x220/127', '3.5'),
|
|
29
|
+
1394: ('3x230/133', '3.5'),
|
|
30
|
+
1650: ('1x220', '7.5'),
|
|
31
|
+
1725: ('1x230', '7.5'),
|
|
32
|
+
1905: ('1x127', '15'),
|
|
33
|
+
1975: ('3x380/220', '3'),
|
|
34
|
+
1992: ('3x230/133', '5'),
|
|
35
|
+
1995: ('1x133', '15'),
|
|
36
|
+
2078: ('3x400/230', '3'),
|
|
37
|
+
2200: ('1x220', '10'),
|
|
38
|
+
2300: ('1x230', '10'),
|
|
39
|
+
2304: ('3x380/220', '3.5'),
|
|
40
|
+
2425: ('3x400/230', '3.5'),
|
|
41
|
+
2540: ('1x127', '20'),
|
|
42
|
+
2660: ('1x133', '20'),
|
|
43
|
+
2858: ('3x220/127', '7.5'),
|
|
44
|
+
2988: ('3x230/133', '7.5'),
|
|
45
|
+
3175: ('1x127', '25'),
|
|
46
|
+
3291: ('3x380/220', '5'),
|
|
47
|
+
3300: ('1x220', '15'),
|
|
48
|
+
3325: ('1x133', '25'),
|
|
49
|
+
3450: ('1x230', '15'),
|
|
50
|
+
3464: ('3x400/230', '5'),
|
|
51
|
+
3810: ('1x127', '30'),
|
|
52
|
+
3811: ('3x220/127', '10'),
|
|
53
|
+
3984: ('3x230/133', '10'),
|
|
54
|
+
3990: ('1x133', '30'),
|
|
55
|
+
4400: ('1x220', '20'),
|
|
56
|
+
4445: ('1x127', '35'),
|
|
57
|
+
4600: ('1x230', '20'),
|
|
58
|
+
4655: ('1x133', '35'),
|
|
59
|
+
4936: ('3x380/220', '7.5'),
|
|
60
|
+
5080: ('1x127', '40'),
|
|
61
|
+
5196: ('3x400/230', '7.5'),
|
|
62
|
+
5320: ('1x133', '40'),
|
|
63
|
+
5500: ('1x220', '25'),
|
|
64
|
+
5715: ('1x127', '45'),
|
|
65
|
+
5716: ('3x220/127', '15'),
|
|
66
|
+
5750: ('1x230', '25'),
|
|
67
|
+
5976: ('3x230/133', '15'),
|
|
68
|
+
5985: ('1x133', '45'),
|
|
69
|
+
6350: ('1x127', '50'),
|
|
70
|
+
6582: ('3x380/220', '10'),
|
|
71
|
+
6600: ('1x220', '30'),
|
|
72
|
+
6650: ('1x133', '50'),
|
|
73
|
+
6900: ('1x230', '30'),
|
|
74
|
+
6928: ('3x400/230', '10'),
|
|
75
|
+
7621: ('3x220/127', '20'),
|
|
76
|
+
7700: ('1x220', '35'),
|
|
77
|
+
7967: ('3x230/133', '20'),
|
|
78
|
+
8001: ('1x127', '63'),
|
|
79
|
+
8050: ('1x230', '35'),
|
|
80
|
+
8379: ('1x133', '63'),
|
|
81
|
+
8800: ('1x220', '40'),
|
|
82
|
+
9200: ('1x230', '40'),
|
|
83
|
+
9526: ('3x220/127', '25'),
|
|
84
|
+
9873: ('3x380/220', '15'),
|
|
85
|
+
9900: ('1x220', '45'),
|
|
86
|
+
9959: ('3x230/133', '25'),
|
|
87
|
+
10350: ('1x230', '45'),
|
|
88
|
+
10392: ('3x400/230', '15'),
|
|
89
|
+
11000: ('1x220', '50'),
|
|
90
|
+
11432: ('3x220/127', '30'),
|
|
91
|
+
11500: ('1x230', '50'),
|
|
92
|
+
11951: ('3x230/133', '30'),
|
|
93
|
+
13164: ('3x380/220', '20'),
|
|
94
|
+
13337: ('3x220/127', '35'),
|
|
95
|
+
13856: ('3x400/230', '20'),
|
|
96
|
+
13860: ('1x220', '63'),
|
|
97
|
+
13943: ('3x230/133', '35'),
|
|
98
|
+
14490: ('1x230', '63'),
|
|
99
|
+
15242: ('3x220/127', '40'),
|
|
100
|
+
15935: ('3x230/133', '40'),
|
|
101
|
+
16454: ('3x380/220', '25'),
|
|
102
|
+
17147: ('3x220/127', '45'),
|
|
103
|
+
17321: ('3x400/230', '25'),
|
|
104
|
+
17927: ('3x230/133', '45'),
|
|
105
|
+
19053: ('3x220/127', '50'),
|
|
106
|
+
19745: ('3x380/220', '30'),
|
|
107
|
+
19919: ('3x230/133', '50'),
|
|
108
|
+
20785: ('3x400/230', '30'),
|
|
109
|
+
23036: ('3x380/220', '35'),
|
|
110
|
+
24006: ('3x220/127', '63'),
|
|
111
|
+
24249: ('3x400/230', '35'),
|
|
112
|
+
25097: ('3x230/133', '63'),
|
|
113
|
+
26327: ('3x380/220', '40'),
|
|
114
|
+
27713: ('3x400/230', '40'),
|
|
115
|
+
29618: ('3x380/220', '45'),
|
|
116
|
+
31177: ('3x400/230', '45'),
|
|
117
|
+
32909: ('3x380/220', '50'),
|
|
118
|
+
34641: ('3x400/230', '50'),
|
|
119
|
+
41465: ('3x380/220', '63'),
|
|
120
|
+
43648: ('3x400/230', '63')
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
NOT_NORMALIZED_100 = dict([(p, (None, None)) for p in range(100, 15001, 100)
|
|
124
|
+
if p not in NORMALIZED_POWERS])
|
|
125
|
+
|
|
126
|
+
ALL_POWERS = NOT_NORMALIZED_100.copy()
|
|
127
|
+
ALL_POWERS.update(NORMALIZED_POWERS)
|
|
128
|
+
|
|
129
|
+
class NormalizedPower(object):
|
|
130
|
+
|
|
131
|
+
def get_volt_int(self, pot):
|
|
132
|
+
volt_int = ALL_POWERS.get(pot, None)
|
|
133
|
+
if volt_int is None:
|
|
134
|
+
raise ValueError('The given power is not normalized')
|
|
135
|
+
return volt_int
|
|
136
|
+
|
|
137
|
+
def is_normalized(self, pot):
|
|
138
|
+
return pot in ALL_POWERS
|
|
139
|
+
|
|
140
|
+
def get_norm_powers(self, pot_min, pot_max):
|
|
141
|
+
for norm_pow in sorted(ALL_POWERS):
|
|
142
|
+
if pot_min < norm_pow <= pot_max:
|
|
143
|
+
yield norm_pow
|
|
144
|
+
elif norm_pow > pot_max:
|
|
145
|
+
break
|