Merge pull request #898 from koen-vg/custom-projection
Add several map projection options
This commit is contained in:
commit
2db564eabf
@ -773,6 +773,13 @@ plotting:
|
|||||||
color_geomap:
|
color_geomap:
|
||||||
ocean: white
|
ocean: white
|
||||||
land: white
|
land: white
|
||||||
|
projection:
|
||||||
|
name: "EqualEarth"
|
||||||
|
# See https://scitools.org.uk/cartopy/docs/latest/reference/projections.html for alternatives, for example:
|
||||||
|
# name: "LambertConformal"
|
||||||
|
# central_longitude: 10.
|
||||||
|
# central_latitude: 50.
|
||||||
|
# standard_parallels: [35, 65]
|
||||||
eu_node_location:
|
eu_node_location:
|
||||||
x: -5.5
|
x: -5.5
|
||||||
y: 46.
|
y: 46.
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
,Unit,Values,Description
|
,Unit,Values,Description
|
||||||
map,,,
|
map,,,
|
||||||
-- boundaries,°,"[x1,x2,y1,y2]",Boundaries of the map plots in degrees latitude (y) and longitude (x)
|
-- boundaries,°,"[x1,x2,y1,y2]",Boundaries of the map plots in degrees latitude (y) and longitude (x)
|
||||||
|
projection,,,,
|
||||||
|
-- name,--,"Valid Cartopy projection name","See https://scitools.org.uk/cartopy/docs/latest/reference/projections.html for list of available projections."
|
||||||
|
-- args,--,--,"Other entries under 'projection' are passed as keyword arguments to the projection constructor, e.g. ``central_longitude: 10.``."
|
||||||
costs_max,bn Euro,float,Upper y-axis limit in cost bar plots.
|
costs_max,bn Euro,float,Upper y-axis limit in cost bar plots.
|
||||||
costs_threshold,bn Euro,float,Threshold below which technologies will not be shown in cost bar plots.
|
costs_threshold,bn Euro,float,Threshold below which technologies will not be shown in cost bar plots.
|
||||||
energy_max,TWh,float,Upper y-axis limit in energy bar plots.
|
energy_max,TWh,float,Upper y-axis limit in energy bar plots.
|
||||||
|
Can't render this file because it has a wrong number of fields in line 4.
|
@ -35,6 +35,8 @@ Upcoming Release
|
|||||||
|
|
||||||
* Add support for the linopy ``io_api`` option; set to ``"direct"`` to increase model reading and writing performance for the highs and gurobi solvers.
|
* Add support for the linopy ``io_api`` option; set to ``"direct"`` to increase model reading and writing performance for the highs and gurobi solvers.
|
||||||
|
|
||||||
|
* Add the option to customise map projection in plotting config.
|
||||||
|
|
||||||
|
|
||||||
PyPSA-Eur 0.9.0 (5th January 2024)
|
PyPSA-Eur 0.9.0 (5th January 2024)
|
||||||
==================================
|
==================================
|
||||||
|
@ -170,7 +170,7 @@ def plot_map(
|
|||||||
line_widths = line_widths.replace(line_lower_threshold, 0)
|
line_widths = line_widths.replace(line_lower_threshold, 0)
|
||||||
link_widths = link_widths.replace(line_lower_threshold, 0)
|
link_widths = link_widths.replace(line_lower_threshold, 0)
|
||||||
|
|
||||||
fig, ax = plt.subplots(subplot_kw={"projection": ccrs.EqualEarth()})
|
fig, ax = plt.subplots(subplot_kw={"projection": proj})
|
||||||
fig.set_size_inches(7, 6)
|
fig.set_size_inches(7, 6)
|
||||||
|
|
||||||
n.plot(
|
n.plot(
|
||||||
@ -358,7 +358,6 @@ def plot_h2_map(network, regions):
|
|||||||
n.links.bus0 = n.links.bus0.str.replace(" H2", "")
|
n.links.bus0 = n.links.bus0.str.replace(" H2", "")
|
||||||
n.links.bus1 = n.links.bus1.str.replace(" H2", "")
|
n.links.bus1 = n.links.bus1.str.replace(" H2", "")
|
||||||
|
|
||||||
proj = ccrs.EqualEarth()
|
|
||||||
regions = regions.to_crs(proj.proj4_init)
|
regions = regions.to_crs(proj.proj4_init)
|
||||||
|
|
||||||
fig, ax = plt.subplots(figsize=(7, 6), subplot_kw={"projection": proj})
|
fig, ax = plt.subplots(figsize=(7, 6), subplot_kw={"projection": proj})
|
||||||
@ -568,7 +567,7 @@ def plot_ch4_map(network):
|
|||||||
"biogas": "seagreen",
|
"biogas": "seagreen",
|
||||||
}
|
}
|
||||||
|
|
||||||
fig, ax = plt.subplots(figsize=(7, 6), subplot_kw={"projection": ccrs.EqualEarth()})
|
fig, ax = plt.subplots(figsize=(7, 6), subplot_kw={"projection": proj})
|
||||||
|
|
||||||
n.plot(
|
n.plot(
|
||||||
bus_sizes=bus_sizes,
|
bus_sizes=bus_sizes,
|
||||||
@ -679,7 +678,7 @@ def plot_map_without(network):
|
|||||||
# Drop non-electric buses so they don't clutter the plot
|
# Drop non-electric buses so they don't clutter the plot
|
||||||
n.buses.drop(n.buses.index[n.buses.carrier != "AC"], inplace=True)
|
n.buses.drop(n.buses.index[n.buses.carrier != "AC"], inplace=True)
|
||||||
|
|
||||||
fig, ax = plt.subplots(figsize=(7, 6), subplot_kw={"projection": ccrs.EqualEarth()})
|
fig, ax = plt.subplots(figsize=(7, 6), subplot_kw={"projection": proj})
|
||||||
|
|
||||||
# PDF has minimum width, so set these to zero
|
# PDF has minimum width, so set these to zero
|
||||||
line_lower_threshold = 200.0
|
line_lower_threshold = 200.0
|
||||||
@ -993,7 +992,7 @@ def plot_map_perfect(
|
|||||||
link_widths[link_widths > line_upper_threshold] = line_upper_threshold
|
link_widths[link_widths > line_upper_threshold] = line_upper_threshold
|
||||||
|
|
||||||
for year in costs.columns:
|
for year in costs.columns:
|
||||||
fig, ax = plt.subplots(subplot_kw={"projection": ccrs.PlateCarree()})
|
fig, ax = plt.subplots(subplot_kw={"projection": proj})
|
||||||
fig.set_size_inches(7, 6)
|
fig.set_size_inches(7, 6)
|
||||||
fig.suptitle(year)
|
fig.suptitle(year)
|
||||||
|
|
||||||
@ -1082,6 +1081,10 @@ if __name__ == "__main__":
|
|||||||
if map_opts["boundaries"] is None:
|
if map_opts["boundaries"] is None:
|
||||||
map_opts["boundaries"] = regions.total_bounds[[0, 2, 1, 3]] + [-1, 1, -1, 1]
|
map_opts["boundaries"] = regions.total_bounds[[0, 2, 1, 3]] + [-1, 1, -1, 1]
|
||||||
|
|
||||||
|
proj_kwargs = snakemake.params.plotting.get("projection", dict(name="EqualEarth"))
|
||||||
|
proj_func = getattr(ccrs, proj_kwargs.pop("name"))
|
||||||
|
proj = proj_func(**proj_kwargs)
|
||||||
|
|
||||||
if snakemake.params["foresight"] == "perfect":
|
if snakemake.params["foresight"] == "perfect":
|
||||||
plot_map_perfect(
|
plot_map_perfect(
|
||||||
n,
|
n,
|
||||||
|
Loading…
Reference in New Issue
Block a user