Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuevos indicadores de ESIOS (Enero 2025) #56

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading