1
1
import pandas as pd
2
2
from datetime import datetime
3
3
4
- from ..utilities .message import Message ,CodegreenDataError
5
- from ..utilities import metadata as meta
4
+ from ..utilities .message import Message , CodegreenDataError
5
+ from ..utilities import metadata as meta
6
6
from . import entsoe as et
7
7
8
- def energy (country ,start_time ,end_time ,type = "generation" ,interval60 = True )-> dict :
9
- """
8
+
9
+ def energy (country , start_time , end_time , type = "generation" , interval60 = True ) -> dict :
10
+ """
10
11
Returns hourly time series of energy production mix for a specified country and time range.
11
12
12
13
This method fetches the energy data for the specified country between the specified duration.
@@ -15,30 +16,30 @@ def energy(country,start_time,end_time,type="generation",interval60=True)-> dict
15
16
16
17
For example, if the source is ENTSOE, the data contains:
17
18
18
- ========================== ========== ================================================================
19
- Column type Description
20
- ========================== ========== ================================================================
21
- startTimeUTC datetime Start date in UTC (60 min interval)
22
- Biomass float64
23
- Fossil Hard coal float64
24
- Geothermal float64
25
- ....more energy sources float64
26
- **renewableTotal** float64 The total based on all renewable sources
27
- renewableTotalWS float64 The total production using only Wind and Solar energy sources
28
- nonRenewableTotal float64
29
- total float64 Total using all energy sources
30
- percentRenewable int64
31
- percentRenewableWS int64 Percentage of energy produced using only wind and solar energy
32
- Wind_per int64 Percentages of individual energy sources
33
- Solar_per int64
34
- Nuclear_per int64
35
- Hydroelectricity_per int64
36
- Geothermal_per int64
37
- Natural Gas_per int64
38
- Petroleum_per int64
39
- Coal_per int64
40
- Biomass_per int64
41
- ========================== ========== ================================================================
19
+ ========================== ========== ================================================================
20
+ Column type Description
21
+ ========================== ========== ================================================================
22
+ startTimeUTC datetime Start date in UTC (60 min interval)
23
+ Biomass float64
24
+ Fossil Hard coal float64
25
+ Geothermal float64
26
+ ....more energy sources float64
27
+ **renewableTotal** float64 The total based on all renewable sources
28
+ renewableTotalWS float64 The total production using only Wind and Solar energy sources
29
+ nonRenewableTotal float64
30
+ total float64 Total using all energy sources
31
+ percentRenewable int64
32
+ percentRenewableWS int64 Percentage of energy produced using only wind and solar energy
33
+ Wind_per int64 Percentages of individual energy sources
34
+ Solar_per int64
35
+ Nuclear_per int64
36
+ Hydroelectricity_per int64
37
+ Geothermal_per int64
38
+ Natural Gas_per int64
39
+ Petroleum_per int64
40
+ Coal_per int64
41
+ Biomass_per int64
42
+ ========================== ========== ================================================================
42
43
43
44
Note : fields marked bold are calculated based on the data fetched.
44
45
@@ -53,25 +54,27 @@ def energy(country,start_time,end_time,type="generation",interval60=True)-> dict
53
54
- `time_interval` : the time interval of the DataFrame
54
55
:rtype: dict
55
56
"""
56
- if not isinstance (country , str ):
57
- raise ValueError ("Invalid country" )
58
- if not isinstance (start_time ,datetime ):
59
- raise ValueError ("Invalid start date" )
60
- if not isinstance (end_time , datetime ):
61
- raise ValueError ("Invalid end date" )
62
- if type not in [' generation' , ' forecast' ]:
63
- raise ValueError (Message .INVALID_ENERGY_TYPE )
64
- # check start<end and both are not same
65
-
66
- if ( start_time > end_time ) :
67
- raise ValueError ("Invalid time.End time should be greater than start time" )
57
+ if not isinstance (country , str ):
58
+ raise ValueError ("Invalid country" )
59
+ if not isinstance (start_time , datetime ):
60
+ raise ValueError ("Invalid start date" )
61
+ if not isinstance (end_time , datetime ):
62
+ raise ValueError ("Invalid end date" )
63
+ if type not in [" generation" , " forecast" ]:
64
+ raise ValueError (Message .INVALID_ENERGY_TYPE )
65
+ # check start<end and both are not same
66
+
67
+ if start_time > end_time :
68
+ raise ValueError ("Invalid time.End time should be greater than start time" )
68
69
69
- e_source = meta .get_country_energy_source (country )
70
- if e_source == "ENTSOE" :
71
- if type == "generation" :
72
- return et .get_actual_production_percentage (country ,start_time ,end_time ,interval60 )
73
- elif type == "forecast" :
74
- return et .get_forecast_percent_renewable (country ,start_time ,end_time )
75
- else :
76
- raise CodegreenDataError (Message .NO_ENERGY_SOURCE )
77
- return None
70
+ e_source = meta .get_country_energy_source (country )
71
+ if e_source == "ENTSOE" :
72
+ if type == "generation" :
73
+ return et .get_actual_production_percentage (
74
+ country , start_time , end_time , interval60
75
+ )
76
+ elif type == "forecast" :
77
+ return et .get_forecast_percent_renewable (country , start_time , end_time )
78
+ else :
79
+ raise CodegreenDataError (Message .NO_ENERGY_SOURCE )
80
+ return None
0 commit comments