def _pypsa_generator_timeseries(network, timesteps, mode=None):
    """Timeseries in PyPSA compatible format for generator instances

    Parameters
    ----------
    network : Network
        The eDisGo grid topology model overall container
    timesteps : array_like
        Timesteps is an array-like object with entries of type
        :pandas:`pandas.Timestamp<timestamp>` specifying which time steps
        to export to pypsa representation and use in power flow analysis.
    mode : str, optional
        Specifically retrieve generator time series for MV or LV grid level or
        both. Either choose 'mv' or 'lv'.
        Defaults to None, which returns both timeseries for MV and LV in a
        single DataFrame.

    Returns
    -------
    :pandas:`pandas.DataFrame<dataframe>`
        Time series table in PyPSA format
    """

    mv_gen_timeseries_p_min = []
    mv_gen_timeseries_p_max = []
    lv_gen_timeseries_p_min = []
    lv_gen_timeseries_p_max = []

    # MV generator timeseries
    if mode is 'mv' or mode is None:
        for gen in network.mv_grid.graph.nodes_by_attribute('generator') + \
                network.mv_grid.graph.nodes_by_attribute('generator_aggr'):
            mv_gen_timeseries_p_min.append(gen.pypsa_timeseries('p').rename(
                repr(gen)).to_frame().loc[timesteps] / gen.nominal_capacity)
            mv_gen_timeseries_p_max.append(gen.pypsa_timeseries('p').rename(
                repr(gen)).to_frame().loc[timesteps] / gen.nominal_capacity)

    # LV generator timeseries
    if mode is 'lv' or mode is None:
        for lv_grid in network.mv_grid.lv_grids:
            for gen in lv_grid.graph.nodes_by_attribute('generator'):
                lv_gen_timeseries_p_min.append(gen.pypsa_timeseries('p').rename(
                    repr(gen)).to_frame().loc[timesteps] / gen.nominal_capacity)
                lv_gen_timeseries_p_max.append(gen.pypsa_timeseries('p').rename(
                    repr(gen)).to_frame().loc[timesteps] / gen.nominal_capacity)

    # Slack time series
    lv_gen_timeseries_p_min.append(
        pd.Series([-1] * len(timesteps), index=timesteps).rename(
            "Generator_slack").to_frame())
    lv_gen_timeseries_p_max.append(
        pd.Series([1] * len(timesteps), index=timesteps).rename(
            "Generator_slack").to_frame())

    gen_df_p_max = pd.concat(
        mv_gen_timeseries_p_max + lv_gen_timeseries_p_max, axis=1)
    gen_df_p_min = pd.concat(
        mv_gen_timeseries_p_min + lv_gen_timeseries_p_min, axis=1)

    return gen_df_p_min, gen_df_p_max
def _pypsa_generator_timeseries ( network , timesteps , mode = None ) : mv_gen_timeseries_p_min = [ ] mv_gen_timeseries_p_max = [ ] lv_gen_timeseries_p_min = [ ] lv_gen_timeseries_p_max = [ ] if mode is 'mv' or mode is None : for gen in network . mv_grid . graph . nodes_by_attribute ( 'generator' ) + network . mv_grid . graph . nodes_by_attribute ( 'generator_aggr' ) : mv_gen_timeseries_p_min . append ( gen . pypsa_timeseries ( 'p' ) . rename ( repr ( gen ) ) . to_frame ( ) . loc [ timesteps ] / gen . nominal_capacity ) mv_gen_timeseries_p_max . append ( gen . pypsa_timeseries ( 'p' ) . rename ( repr ( gen ) ) . to_frame ( ) . loc [ timesteps ] / gen . nominal_capacity ) if mode is 'lv' or mode is None : for lv_grid in network . mv_grid . lv_grids : for gen in lv_grid . graph . nodes_by_attribute ( 'generator' ) : lv_gen_timeseries_p_min . append ( gen . pypsa_timeseries ( 'p' ) . rename ( repr ( gen ) ) . to_frame ( ) . loc [ timesteps ] / gen . nominal_capacity ) lv_gen_timeseries_p_max . append ( gen . pypsa_timeseries ( 'p' ) . rename ( repr ( gen ) ) . to_frame ( ) . loc [ timesteps ] / gen . nominal_capacity ) lv_gen_timeseries_p_min . append ( pd . Series ( [ - 1 ] * len ( timesteps ) , index = timesteps ) . rename ( "Generator_slack" ) . to_frame ( ) ) lv_gen_timeseries_p_max . append ( pd . Series ( [ 1 ] * len ( timesteps ) , index = timesteps ) . rename ( "Generator_slack" ) . to_frame ( ) ) gen_df_p_max = pd . concat ( mv_gen_timeseries_p_max + lv_gen_timeseries_p_max , axis = 1 ) gen_df_p_min = pd . concat ( mv_gen_timeseries_p_min + lv_gen_timeseries_p_min , axis = 1 ) return gen_df_p_min , gen_df_p_max
Timeseries in PyPSA compatible format for generator instances

    Parameters
    ----------
    network : Network
        The eDisGo grid topology model overall container
    timesteps : array_like
        Timesteps is an array-like object with entries of type
        :pandas:`pandas.Timestamp<timestamp>` specifying which time steps
        to export to pypsa representation and use in power flow analysis.
    mode : str, optional
        Specifically retrieve generator time series for MV or LV grid level or
        both. Either choose 'mv' or 'lv'.
        Defaults to None, which returns both timeseries for MV and LV in a
        single DataFrame.

    Returns
    -------
    :pandas:`pandas.DataFrame<dataframe>`
        Time series table in PyPSA format