8
8
import pandas as pd
9
9
10
10
from .mappings import PSRTYPE_MAPPINGS , DOCSTATUS , BSNTYPE , Area
11
- from .series_parsers import _extract_timeseries , _resolution_to_timedelta , _parse_datetimeindex , _parse_timeseries_generic
11
+ from .series_parsers import _extract_timeseries , _resolution_to_timedelta , _parse_datetimeindex , _parse_timeseries_generic ,\
12
+ _parse_timeseries_generic_whole
12
13
13
14
warnings .filterwarnings ('ignore' , category = XMLParsedAsHTMLWarning )
14
15
@@ -223,7 +224,7 @@ def parse_installed_capacity_per_plant(xml_text):
223
224
return df
224
225
225
226
226
- def parse_water_hydro (xml_text , tz ):
227
+ def parse_water_hydro (xml_text ):
227
228
"""
228
229
Parameters
229
230
----------
@@ -233,13 +234,8 @@ def parse_water_hydro(xml_text, tz):
233
234
-------
234
235
pd.Series
235
236
"""
236
- all_series = []
237
- for soup in _extract_timeseries (xml_text ):
238
- all_series .append (_parse_water_hydro_timeseries (soup , tz = tz ))
239
-
240
- series = pd .concat (all_series )
241
237
242
- return series
238
+ return _parse_timeseries_generic_whole ( xml_text )
243
239
244
240
245
241
def parse_crossborder_flows (xml_text ):
@@ -683,17 +679,7 @@ def _parse_load_timeseries(soup):
683
679
-------
684
680
pd.Series
685
681
"""
686
- positions = []
687
- prices = []
688
- for point in soup .find_all ('point' ):
689
- positions .append (int (point .find ('position' ).text ))
690
- prices .append (float (point .find ('quantity' ).text ))
691
-
692
- series = pd .Series (index = positions , data = prices )
693
- series = series .sort_index ()
694
- series .index = _parse_datetimeindex (soup )
695
-
696
- return series
682
+ return _parse_timeseries_generic (soup )
697
683
698
684
def _parse_generation_timeseries (soup , per_plant : bool = False , include_eic : bool = False ) -> pd .Series :
699
685
"""
@@ -708,19 +694,7 @@ def _parse_generation_timeseries(soup, per_plant: bool = False, include_eic: boo
708
694
-------
709
695
pd.Series
710
696
"""
711
- positions = []
712
- quantities = []
713
- for point in soup .find_all ('point' ):
714
- positions .append (int (point .find ('position' ).text ))
715
- quantity = point .find ('quantity' )
716
- if quantity is None :
717
- raise LookupError (
718
- f'No quantity found in this point, it should have one: { point } ' )
719
- quantities .append (float (quantity .text ))
720
-
721
- series = pd .Series (index = positions , data = quantities )
722
- series = series .sort_index ()
723
- series .index = _parse_datetimeindex (soup )
697
+ series = _parse_timeseries_generic (soup )
724
698
725
699
# Check if there is a psrtype, if so, get it.
726
700
_psrtype = soup .find ('psrtype' )
@@ -763,34 +737,6 @@ def _parse_generation_timeseries(soup, per_plant: bool = False, include_eic: boo
763
737
764
738
return series
765
739
766
- def _parse_water_hydro_timeseries (soup , tz ):
767
- """
768
- Parses timeseries for water reservoirs and hydro storage plants
769
-
770
- Parameters
771
- ----------
772
- soup : bs4.element.tag
773
-
774
- Returns
775
- -------
776
- pd.Series
777
- """
778
-
779
- positions = []
780
- quantities = []
781
- for point in soup .find_all ('point' ):
782
- positions .append (int (point .find ('position' ).text ))
783
- quantity = point .find ('quantity' )
784
- if quantity is None :
785
- raise LookupError (
786
- f'No quantity found in this point, it should have one: { point } ' )
787
- quantities .append (float (quantity .text ))
788
- series = pd .Series (index = positions , data = quantities )
789
- series = series .sort_index ()
790
- series .index = _parse_datetimeindex (soup , tz )
791
-
792
- return series
793
-
794
740
def _parse_installed_capacity_per_plant (soup ):
795
741
"""
796
742
Parameters
0 commit comments