Skip to content

Commit

Permalink
Merge pull request #56 from gisce/new_ree_demand_indicators
Browse files Browse the repository at this point in the history
Nuevos indicadores de ESIOS (Enero 2025)
  • Loading branch information
davidmunoznovoa authored Jan 27, 2025
2 parents 341a2ef + 9c98ac0 commit ad36a49
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python2.7-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
jobs:
build:

runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v2
Expand Down
14 changes: 12 additions & 2 deletions esios/indicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

class Indicator(base.RESTResource):
path = 'indicators'
time_trunc = 'hour'
time_agg = 'sum'

@base.apimethod
def get(self, start_date, end_date):
Expand All @@ -15,11 +17,12 @@ def get(self, start_date, end_date):
raise Exception('Start date must have time zone')
if end_date.tzinfo is None:
raise Exception('End date must have time zone')
time_trunc = 'hour'
time_trunc = self.time_trunc
time_agg = self.time_agg
start_date = start_date.isoformat()
end_date = end_date.isoformat()
params = base.get_params(
('start_date', 'end_date', 'time_trunc'), locals()
('start_date', 'end_date', 'time_trunc', 'time_agg'), locals()
)
request = http.Request('GET', self.get_url(), params)
return request, parsers.parse_json
Expand All @@ -28,6 +31,10 @@ def get(self, start_date, end_date):
class ProfilePVPC(Indicator):
pass

class DemandaDiariaElectricaPeninsularPrevista(Indicator):
path = 'indicators/460'
time_agg = 'average'


class ProfilePVPC20A(ProfilePVPC):
path = 'indicators/526'
Expand Down Expand Up @@ -224,6 +231,9 @@ class mhpPowerFactorControlFree(Indicator):
class mhpPowerFactorControl(Indicator):
path = 'indicators/1286'

class DemandaDiariaElectricaPeninsularReal(Indicator):
path = 'indicators/1293'
time_agg = 'average'

class mhpEnergyBalanceFree(Indicator):
path = 'indicators/1366'
Expand Down
28 changes: 28 additions & 0 deletions spec/indicators_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,21 @@
contain(u'Saldo horario neto de interconexión con Marruecos telemedidas')
)

with context('DemandaDiariaElectricaPeninsularPrevista'):
with it('Returns DemandaDiariaElectricaPeninsularPrevista instance'):
# 460
e = Esios(self.token)
# Hourly case
profile = DemandaDiariaElectricaPeninsularPrevista(e)
assert isinstance(profile, DemandaDiariaElectricaPeninsularPrevista)
data = profile.get(self.start_date, self.end_date)
expect(data['indicator']['short_name']).to(
equal(u'Previsión diaria')
)
expect(data['indicator']['name']).to(
contain(u'Previsión diaria de la demanda eléctrica peninsular')
)

with context('PMDSNP'):
with it('Returns pmd_snp instance'):
# 573
Expand Down Expand Up @@ -771,6 +786,19 @@
expect(data['indicator']['name']).to(
contain(u'Precio medio horario componente control factor potencia ')
)
with it('Returns DemandaDiariaElectricaPeninsularReal instance'):
# 1293
e = Esios(self.token)
# Hourly case
profile = DemandaDiariaElectricaPeninsularReal(e)
assert isinstance(profile, DemandaDiariaElectricaPeninsularReal)
data = profile.get(self.start_date, self.end_date)
expect(data['indicator']['short_name']).to(
equal(u'Demanda real')
)
expect(data['indicator']['name']).to(
contain(u'Demanda real')
)
with it('Returns mhpEnergyBalanceFree instance'):
#1366
e = Esios(self.token)
Expand Down

0 comments on commit ad36a49

Please sign in to comment.