def crossborder_capacity(network, method, capacity_factor):
    """
    Adjust interconnector capacties.

    Parameters
    ----------
    network : :class:`pypsa.Network
        Overall container of PyPSA
    method : string
        Method of correction. Options are 'ntc_acer' and 'thermal_acer'.
        'ntc_acer' corrects all capacities according to values published by 
        the ACER in 2016.
        'thermal_acer' corrects certain capacities where our dataset most 
        likely overestimates the thermal capacity.
    capacity_factor : float
        branch capacity factor. Reduction by branch-capacity 
        factor is applied afterwards and shouln't effect ntc-values, which 
        already include (n-1)-security. To exclude the ntc-capacities from the 
        capacity factor, the crossborder-capacities are diveded by the factor 
        in this function. For thermal-acer this is excluded by setting branch
        capacity factors to one.
        

    """         
    if method == 'ntc_acer':
        cap_per_country = {'AT': 4900,
                           'CH': 2695,
                           'CZ': 1301,
                           'DK': 913,
                           'FR': 3593,
                           'LU': 2912,
                           'NL': 2811,
                           'PL': 280,
                           'SE': 217,
                           'CZAT': 574,
                           'ATCZ': 574,
                           'CZPL': 312,
                           'PLCZ': 312,
                           'ATCH': 979,
                           'CHAT': 979,
                           'CHFR': 2087,
                           'FRCH': 2087,
                           'FRLU': 364,
                           'LUFR': 364,
                           'SEDK': 1928,
                           'DKSE': 1928}

    elif method == 'thermal_acer':
        cap_per_country = {'CH': 12000,
                            'DK': 4000,
                            'SEDK': 3500,
                            'DKSE': 3500}
        capacity_factor = {'HV': 1, 'eHV':1}
    if not network.lines[network.lines.country != 'DE'].empty:
        weighting = network.lines.loc[network.lines.country!='DE', 's_nom'].\
                groupby(network.lines.country).transform(lambda x: x/x.sum())

    weighting_links = network.links.loc[network.links.country!='DE', 'p_nom'].\
                groupby(network.links.country).transform(lambda x: x/x.sum())
    network.lines["v_nom"] = network.lines.bus0.map(network.buses.v_nom)
    for country in cap_per_country:

        index_HV = network.lines[(network.lines.country == country) &(
                network.lines.v_nom == 110)].index
        index_eHV = network.lines[(network.lines.country == country) &(
                network.lines.v_nom > 110)].index
        index_links = network.links[network.links.country == country].index

        if not network.lines[network.lines.country == country].empty:
                network.lines.loc[index_HV, 's_nom'] = weighting[index_HV] * \
                    cap_per_country[country] / capacity_factor['HV']
                    
                network.lines.loc[index_eHV, 's_nom'] = \
                    weighting[index_eHV] * cap_per_country[country] /\
                                capacity_factor['eHV']

        if not network.links[network.links.country == country].empty:
                network.links.loc[index_links, 'p_nom'] = \
                                weighting_links[index_links] * cap_per_country\
                                [country] 
        if country == 'SE':
                network.links.loc[network.links.country == country, 'p_nom'] =\
                cap_per_country[country]

        if not network.lines[network.lines.country == (country+country)].empty:
            i_HV =  network.lines[(network.lines.v_nom == 110)&(
                    network.lines.country ==country+country)].index
            
            i_eHV =  network.lines[(network.lines.v_nom == 110)&(
                    network.lines.country ==country+country)].index

            network.lines.loc[i_HV, 's_nom'] = \
                                weighting[i_HV] * cap_per_country[country]/\
                                capacity_factor['HV']
            network.lines.loc[i_eHV, 's_nom'] = \
                                weighting[i_eHV] * cap_per_country[country]/\
                                capacity_factor['eHV']

        if not network.links[network.links.country == (country+country)].empty:
            i_links =  network.links[network.links.country ==
                                     (country+country)].index
            network.links.loc[i_links, 'p_nom'] = \
                weighting_links[i_links] * cap_per_country\
                [country]*capacity_factor