Consumption in kWh per sector for whole grid

        Returns
        -------
        :pandas:`pandas.Series<series>`
            Indexed by demand sector
336483
def consumption(self):
        
        consumption = defaultdict(float)
        for load in self.graph.nodes_by_attribute('load'):
            for sector, val in load.consumption.items():
                consumption[sector] += val

        return pd.Series(consumption)
1279435
def consumed_in_month(self):
        
        month_end = core_utils.month_end(datetime.date(self.price_estimate.year, self.price_estimate.month, 1))
        return self._get_consumed(month_end)
1005006
def peak_load(self):
        
        if self._peak_load is None:
            self._peak_load = sum(
                [_.peak_load.sum()
                 for _ in self.graph.nodes_by_attribute('load')])

        return self._peak_load
718431
def ramp_limits(network):
    
    carrier = ['coal', 'biomass', 'gas', 'oil', 'waste', 'lignite',
                       'uranium', 'geothermal']
    data = {'start_up_cost':[77, 57, 42, 57, 57, 77, 50, 57], #€/MW
            'start_up_fuel':[4.3, 2.8, 1.45, 2.8, 2.8, 4.3, 16.7, 2.8], #MWh/MW
            'min_up_time':[5, 2, 3, 2, 2, 5, 12, 2], 
            'min_down_time':[7, 2, 2, 2, 2, 7, 17, 2], 
# =============================================================================
#             'ramp_limit_start_up':[0.4, 0.4, 0.4, 0.4, 0.4, 0.6, 0.5, 0.4], 
#             'ramp_limit_shut_down':[0.4, 0.4, 0.4, 0.4, 0.4, 0.6, 0.5, 0.4] 
# =============================================================================
            'p_min_pu':[0.33, 0.38, 0.4, 0.38, 0.38, 0.5, 0.45, 0.38]
            }
    df = pd.DataFrame(data, index=carrier)
    fuel_costs = network.generators.marginal_cost.groupby(
            network.generators.carrier).mean()[carrier]
    df['start_up_fuel'] = df['start_up_fuel'] * fuel_costs
    df['start_up_cost'] = df['start_up_cost'] + df['start_up_fuel']
    df.drop('start_up_fuel', axis=1, inplace=True)
    for tech in df.index:
        for limit in df.columns:
            network.generators.loc[network.generators.carrier == tech, 
                                   limit] = df.loc[tech, limit]
    network.generators.start_up_cost = network.generators.start_up_cost\
                                        *network.generators.p_nom
    network.generators.committable = True
309097
def gas(self):
        """"""
        usage = self._state['gasUsage']
        return Usage(usage.get('avgDayValue'),
                     usage.get('avgValue'),
                     usage.get('dayCost'),
                     usage.get('dayUsage'),
                     usage.get('isSmart'),
                     usage.get('meterReading'),
                     usage.get('value'))
992727
def gen_WS_DF(df_WS_data):
    
    df_fs = gen_FS_DF(df_WS_data)

    list_index = [('mean', 'T2'), ('max', 'T2'), ('min', 'T2'),
                  ('mean', 'U10'), ('max', 'U10'), ('min', 'U10'),
                  ('mean', 'RH2'), ('max', 'RH2'), ('min', 'RH2'),
                  ('mean', 'Kdown')]

    list_const = [getattr(const, attr)
                  for attr in ['T_MEAN', 'T_MAX', 'T_MIN',
                               'WIND_MEAN', 'WIND_MAX', 'WIND_MIN',
                               'RH_MEAN', 'RH_MAX', 'RH_MIN',
                               'SOLAR_RADIATION_GLOBAL']]
    list_ws = [df_fs.loc[idx] * cst
               for idx, cst
               in zip(list_index, list_const)]
    df_ws = pd.concat(list_ws, axis=1).sum(axis=1).unstack().dropna()

    return df_ws
1165459
def forecast(self, horizon, **kwargs):
        ''''''
        return DataFrame({ name: series.forecast(horizon, **kwargs) \
            for name, series in self.groups.iteritems() })
1058674
def frequencies_iter(self):
        
        df = self.to_dataframe()
        n = float(len(self))
        for var, sign in it.product(df.columns, [-1, 1]):
            f = len(df[df[var] == sign]) / n
            if f > 0:
                yield Literal(var, sign), f
1119844
def plot_mv_grid_expansion_costs(self, **kwargs):
        
        if self.network.pypsa is not None and \
                self.network.results.grid_expansion_costs is not None:
            if isinstance(self, EDisGo):
                # convert index of grid expansion costs to str
                grid_expansion_costs = \
                    self.network.results.grid_expansion_costs.reset_index()
                grid_expansion_costs['index'] = \
                    grid_expansion_costs['index'].apply(lambda _: repr(_))
                grid_expansion_costs.set_index('index', inplace=True)
            else:
                grid_expansion_costs = \
                    self.network.results.grid_expansion_costs

            plots.mv_grid_topology(
                self.network.pypsa, self.network.config,
                line_color='expansion_costs',
                grid_expansion_costs=grid_expansion_costs,
                filename=kwargs.get('filename', None),
                grid_district_geom=kwargs.get('grid_district_geom', True),
                background_map=kwargs.get('background_map', True),
                limits_cb_lines=kwargs.get('limits_cb_lines', None),
                xlim=kwargs.get('xlim', None), ylim=kwargs.get('ylim', None),
                lines_cmap=kwargs.get('lines_cmap', 'inferno_r'),
                title=kwargs.get('title', ''),
                scaling_factor_line_width=kwargs.get(
                    'scaling_factor_line_width', None)
            )
        else:
            if self.network.pypsa is None:
                logging.warning("pypsa representation of MV grid needed to "
                                "plot grid expansion costs.")
            if self.network.results.grid_expansion_costs is None:
                logging.warning("Grid expansion cost results needed to plot "
                                "them.")
1121456
def kwds(self):
        '''
        '''
         # no dict(refs=self.refs, ..., kind=self.kind) in Python 2.0
        return _kwds(base=self.base, item=self.item,
                     leng=self.leng, refs=self.refs,
                     both=self.both, kind=self.kind, type=self.type)
863148
def MACD(Series, FAST, SLOW, MID):
    
    EMAFAST = EMA(Series, FAST)
    EMASLOW = EMA(Series, SLOW)
    DIFF = EMAFAST - EMASLOW
    DEA = EMA(DIFF, MID)
    MACD = (DIFF - DEA) * 2
    DICT = {'DIFF': DIFF, 'DEA': DEA, 'MACD': MACD}
    VAR = pd.DataFrame(DICT)
    return VAR
712567
def columns(self):
        
        return Index(np.array(self._gather_column_names(), dtype=np.bytes_), np.dtype(np.bytes_))
188972
def peak_generation_per_technology_and_weather_cell(self):
        
        peak_generation = defaultdict(float)
        for gen in self.generators:
            if hasattr(gen, 'weather_cell_id'):
                if (gen.type, gen.weather_cell_id) in peak_generation.keys():
                    peak_generation[gen.type, gen.weather_cell_id] += gen.nominal_capacity
                else:
                    peak_generation[gen.type, gen.weather_cell_id] = gen.nominal_capacity
            else:
                message = 'No weather cell ID found for ' \
                          'generator {}.'.format(repr(gen))
                raise KeyError(message)

        series_index = pd.MultiIndex.from_tuples(list(peak_generation.keys()),
                                                 names=['type', 'weather_cell_id'])

        return pd.Series(peak_generation, index=series_index)
159854
def _timeseries_component(self, series):
        
        # this is only called if the set_component function recognizes a pandas series
        # Todo: raise a warning if extrapolating from the end of the series.
        return lambda: np.interp(self.time(), series.index, series.values)
1158968
def peak_generation(self):
        
        cum_peak_generation = 0

        for lv_grid_district in self._lv_grid_districts:
            cum_peak_generation += lv_grid_district.lv_grid.station().peak_generation

        return cum_peak_generation
1052625
def COUNT(COND, N):
    
    return pd.Series(np.where(COND, 1, 0), index=COND.index).rolling(N).sum()
362667
def power(self):
        """"""
        power = self._state['powerUsage']
        return PowerUsage(power.get('avgDayValue'),
                          power.get('avgValue'),
                          power.get('dayCost'),
                          power.get('dayUsage'),
                          power.get('isSmart'),
                          power.get('meterReading'),
                          power.get('value'),
                          power.get('meterReadingLow'),
                          power.get('dayLowUsage'))