scripts/* revise imports
This commit is contained in:
parent
bb9bbf295a
commit
e59d2c4162
@ -88,24 +88,21 @@ It further adds extendable ``generators`` and ``storage_units`` with **zero** ca
|
|||||||
- additional open- and combined-cycle gas turbines (if ``OCGT`` and/or ``CCGT`` is listed in the config setting ``electricity: extendable_carriers``)
|
- additional open- and combined-cycle gas turbines (if ``OCGT`` and/or ``CCGT`` is listed in the config setting ``electricity: extendable_carriers``)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
import pandas as pd
|
|
||||||
idx = pd.IndexSlice
|
|
||||||
|
|
||||||
import numpy as np
|
|
||||||
import xarray as xr
|
|
||||||
|
|
||||||
import geopandas as gpd
|
|
||||||
|
|
||||||
from vresutils.costdata import annuity
|
from vresutils.costdata import annuity
|
||||||
from vresutils.load import timeseries_opsd
|
from vresutils.load import timeseries_opsd
|
||||||
from vresutils import transfer as vtransfer
|
from vresutils import transfer as vtransfer
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import pandas as pd
|
||||||
|
import numpy as np
|
||||||
|
import xarray as xr
|
||||||
|
import geopandas as gpd
|
||||||
import pypsa
|
import pypsa
|
||||||
import powerplantmatching as ppm
|
import powerplantmatching as ppm
|
||||||
|
|
||||||
|
idx = pd.IndexSlice
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def normed(s): return s/s.sum()
|
def normed(s): return s/s.sum()
|
||||||
|
|
||||||
|
@ -36,14 +36,13 @@ Description
|
|||||||
-----------
|
-----------
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from vresutils.graph import voronoi_partition_pts
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from operator import attrgetter
|
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import geopandas as gpd
|
import geopandas as gpd
|
||||||
|
|
||||||
from vresutils.graph import voronoi_partition_pts
|
|
||||||
|
|
||||||
import pypsa
|
import pypsa
|
||||||
import logging
|
import logging
|
||||||
|
@ -64,7 +64,6 @@ import xarray as xr
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
import geokit as gk
|
import geokit as gk
|
||||||
from osgeo import gdal
|
|
||||||
from scipy.sparse import vstack
|
from scipy.sparse import vstack
|
||||||
import pycountry as pyc
|
import pycountry as pyc
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
@ -56,7 +56,6 @@ Description
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import atlite
|
import atlite
|
||||||
import pandas as pd
|
|
||||||
import geopandas as gpd
|
import geopandas as gpd
|
||||||
from vresutils import hydro as vhydro
|
from vresutils import hydro as vhydro
|
||||||
import logging
|
import logging
|
||||||
|
@ -37,7 +37,6 @@ Description
|
|||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import atlite
|
import atlite
|
||||||
from osgeo import gdal
|
|
||||||
import geokit as gk
|
import geokit as gk
|
||||||
|
|
||||||
def determine_cutout_xXyY(cutout_name):
|
def determine_cutout_xXyY(cutout_name):
|
||||||
|
@ -51,7 +51,6 @@ Replacing '/summaries/' with '/plots/' creates nice colored maps of the results.
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
from six import iteritems
|
from six import iteritems
|
||||||
from itertools import product
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
import pypsa
|
import pypsa
|
||||||
|
@ -15,20 +15,11 @@ Description
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import pypsa
|
|
||||||
|
|
||||||
from _helpers import load_network, aggregate_p, aggregate_costs
|
from _helpers import load_network, aggregate_p, aggregate_costs
|
||||||
from vresutils import plot as vplot
|
|
||||||
|
|
||||||
import os
|
|
||||||
import pypsa
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import geopandas as gpd
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from itertools import product, chain
|
from six.moves import zip
|
||||||
from six.moves import map, zip
|
|
||||||
from six import itervalues, iterkeys
|
|
||||||
from collections import OrderedDict as odict
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import cartopy.crs as ccrs
|
import cartopy.crs as ccrs
|
||||||
@ -36,7 +27,6 @@ import matplotlib.pyplot as plt
|
|||||||
import matplotlib as mpl
|
import matplotlib as mpl
|
||||||
from matplotlib.patches import Circle, Ellipse
|
from matplotlib.patches import Circle, Ellipse
|
||||||
from matplotlib.legend_handler import HandlerPatch
|
from matplotlib.legend_handler import HandlerPatch
|
||||||
import seaborn as sns
|
|
||||||
to_rgba = mpl.colors.colorConverter.to_rgba
|
to_rgba = mpl.colors.colorConverter.to_rgba
|
||||||
|
|
||||||
def make_handler_map_to_scale_circles_as_in(ax, dont_resize_actively=False):
|
def make_handler_map_to_scale_circles_as_in(ax, dont_resize_actively=False):
|
||||||
@ -92,7 +82,7 @@ def plot_map(n, ax=None, attribute='p_nom', opts={}):
|
|||||||
line_widths_exp = dict(Line=n.lines.s_nom_opt, Link=n.links.p_nom_opt)
|
line_widths_exp = dict(Line=n.lines.s_nom_opt, Link=n.links.p_nom_opt)
|
||||||
line_widths_cur = dict(Line=n.lines.s_nom_min, Link=n.links.p_nom_min)
|
line_widths_cur = dict(Line=n.lines.s_nom_min, Link=n.links.p_nom_min)
|
||||||
else:
|
else:
|
||||||
raise 'plotting of {} has not been implemented yet'.format(plot)
|
raise 'plotting of {} has not been implemented yet'.format(attribute)
|
||||||
|
|
||||||
|
|
||||||
line_colors_with_alpha = \
|
line_colors_with_alpha = \
|
||||||
@ -140,7 +130,7 @@ def plot_map(n, ax=None, attribute='p_nom', opts={}):
|
|||||||
handles.append(plt.Line2D([0],[0],color=line_colors['exp'],
|
handles.append(plt.Line2D([0],[0],color=line_colors['exp'],
|
||||||
linewidth=s*1e3/linewidth_factor))
|
linewidth=s*1e3/linewidth_factor))
|
||||||
labels.append("{} GW".format(s))
|
labels.append("{} GW".format(s))
|
||||||
l1 = l1_1 = ax.legend(handles, labels,
|
l1_1 = ax.legend(handles, labels,
|
||||||
loc="upper left", bbox_to_anchor=(0.24, 1.01),
|
loc="upper left", bbox_to_anchor=(0.24, 1.01),
|
||||||
frameon=False,
|
frameon=False,
|
||||||
labelspacing=0.8, handletextpad=1.5,
|
labelspacing=0.8, handletextpad=1.5,
|
||||||
|
@ -32,7 +32,6 @@ Description
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
links_p_nom = pd.read_html('https://en.wikipedia.org/wiki/List_of_HVDC_projects', header=0, match="SwePol")[0]
|
links_p_nom = pd.read_html('https://en.wikipedia.org/wiki/List_of_HVDC_projects', header=0, match="SwePol")[0]
|
||||||
|
@ -78,21 +78,14 @@ The rule :mod:`simplify_network` does up to four things:
|
|||||||
4. Optionally, if an integer were provided for the wildcard ``{simpl}`` (e.g. ``networks/elec_s500.nc``), the network is clustered to this number of clusters with the routines from the ``cluster_network`` rule with the function ``cluster_network.cluster(...)``. This step is usually skipped!
|
4. Optionally, if an integer were provided for the wildcard ``{simpl}`` (e.g. ``networks/elec_s500.nc``), the network is clustered to this number of clusters with the routines from the ``cluster_network`` rule with the function ``cluster_network.cluster(...)``. This step is usually skipped!
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import pandas as pd
|
from cluster_network import clustering_for_n_clusters, cluster_regions
|
||||||
idx = pd.IndexSlice
|
from add_electricity import load_costs
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
logger = logging.getLogger(__name__)
|
import pandas as pd
|
||||||
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import scipy as sp
|
import scipy as sp
|
||||||
from scipy.sparse.csgraph import connected_components, dijkstra
|
from scipy.sparse.csgraph import connected_components, dijkstra
|
||||||
import xarray as xr
|
|
||||||
import geopandas as gpd
|
|
||||||
import shapely
|
|
||||||
import networkx as nx
|
|
||||||
|
|
||||||
from six import iteritems
|
from six import iteritems
|
||||||
from six.moves import reduce
|
from six.moves import reduce
|
||||||
@ -101,8 +94,9 @@ import pypsa
|
|||||||
from pypsa.io import import_components_from_dataframe, import_series_from_dataframe
|
from pypsa.io import import_components_from_dataframe, import_series_from_dataframe
|
||||||
from pypsa.networkclustering import busmap_by_stubs, aggregategenerators, aggregateoneport
|
from pypsa.networkclustering import busmap_by_stubs, aggregategenerators, aggregateoneport
|
||||||
|
|
||||||
from cluster_network import clustering_for_n_clusters, cluster_regions
|
|
||||||
from add_electricity import load_costs
|
logger = logging.getLogger(__name__)
|
||||||
|
idx = pd.IndexSlice
|
||||||
|
|
||||||
def simplify_network_to_380(n):
|
def simplify_network_to_380(n):
|
||||||
## All goes to v_nom == 380
|
## All goes to v_nom == 380
|
||||||
|
@ -82,7 +82,6 @@ import pandas as pd
|
|||||||
import logging
|
import logging
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
import gc
|
import gc
|
||||||
import os
|
|
||||||
|
|
||||||
import pypsa
|
import pypsa
|
||||||
from pypsa.descriptors import free_output_series_dataframes
|
from pypsa.descriptors import free_output_series_dataframes
|
||||||
|
@ -40,20 +40,17 @@ Description
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import numpy as np
|
|
||||||
import pandas as pd
|
|
||||||
import logging
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
from solve_network import patch_pyomo_tmpdir, prepare_network, solve_network
|
from solve_network import patch_pyomo_tmpdir, prepare_network, solve_network
|
||||||
|
|
||||||
|
import logging
|
||||||
import pypsa
|
import pypsa
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# Detect running outside of snakemake and mock snakemake for testing
|
# Detect running outside of snakemake and mock snakemake for testing
|
||||||
if 'snakemake' not in globals():
|
if 'snakemake' not in globals():
|
||||||
from vresutils.snakemake import MockSnakemake, Dict
|
from vresutils.snakemake import MockSnakemake
|
||||||
snakemake = MockSnakemake(
|
snakemake = MockSnakemake(
|
||||||
wildcards=dict(network='elec', simpl='', clusters='45', lv='1.25', opts='Co2L-3H'),
|
wildcards=dict(network='elec', simpl='', clusters='45', lv='1.25', opts='Co2L-3H'),
|
||||||
input=["networks/{network}_s{simpl}_{clusters}_lv{lv}_{opts}.nc"],
|
input=["networks/{network}_s{simpl}_{clusters}_lv{lv}_{opts}.nc"],
|
||||||
|
Loading…
Reference in New Issue
Block a user