Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
54203a8
Plot line traces without mapbox as vector graphic
danielfeismann Aug 6, 2025
a8133e2
fmt
danielfeismann Aug 6, 2025
e9f8a12
update notebook
danielfeismann Aug 6, 2025
09d27b1
Merge branch 'main' into df/#360-vector-traces
danielfeismann Aug 10, 2025
a171e3b
Merge branch 'main' into df/#360-vector-traces
danielfeismann Aug 11, 2025
7f557e9
Merge branch 'main' into df/#360-vector-traces
danielfeismann Aug 11, 2025
23cdc24
poetry
danielfeismann Aug 11, 2025
53853db
fix write_image
danielfeismann Aug 14, 2025
bcf658b
Merge branch 'main' into df/#360-vector-traces
danielfeismann Aug 19, 2025
afd7a49
poetry
danielfeismann Aug 19, 2025
8329c31
Merge branch 'main' into df/#360-vector-traces
danielfeismann Aug 22, 2025
9e9fe2e
Merge branch 'main' into df/#360-vector-traces
danielfeismann Sep 16, 2025
4a2d261
Merge branch 'main' into df/#360-vector-traces
danielfeismann Sep 22, 2025
b4ac745
some little adaptions from main
danielfeismann Sep 22, 2025
86338f8
flake8 version pre-commit-config
danielfeismann Sep 22, 2025
526f1f4
more simplifications
danielfeismann Sep 22, 2025
04ba77d
even more simplifications
danielfeismann Sep 24, 2025
7355f2e
clean up notebooks
danielfeismann Sep 24, 2025
194689d
Revert "clean up notebooks"
danielfeismann Sep 24, 2025
3199caf
Revert "even more simplifications"
danielfeismann Sep 24, 2025
ffd8080
even more simplifications
danielfeismann Sep 24, 2025
e3f1fed
Merge branch 'main' into df/#360-vector-traces
danielfeismann Sep 26, 2025
a350a29
Merge branch 'main' into df/#360-vector-traces
danielfeismann Oct 17, 2025
2f5d94b
Merge branch 'main' into df/#360-vector-traces
danielfeismann Oct 30, 2025
7ca01dc
Merge branch 'main' into df/#360-vector-traces
danielfeismann Nov 28, 2025
07a383b
Merge branch 'main' into df/#360-vector-traces
danielfeismann Dec 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ All notable changes to this project will be documented in this file.
- Add colored Line Trace to plotting [#348](https://github.com/ie3-institute/pypsdm/issues/348)
- Add colored Node Trace to plotting [#349](https://github.com/ie3-institute/pypsdm/issues/349)
- Added Dependabot Patch Merge Automation [#399](https://github.com/ie3-institute/pypsdm/issues/399)
- Add functionality to plot line traces without mapbox as vector graphic [#360](https://github.com/ie3-institute/pypsdm/issues/360)

### Changed
- Move `NBVAL` to dev dependencies [#374](https://github.com/ie3-institute/pypsdm/issues/374)
Expand Down
161 changes: 161 additions & 0 deletions docs/nbs/plotting_utilities_trace_vector_graphic.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "initial_id",
"metadata": {},
"outputs": [],
"source": [
"# NBVAL_SKIP\n",
"# Some jupyter notebook magic to reload modules automatically when they change\n",
"# not necessary for this specific notebook but useful in general\n",
"%load_ext autoreload\n",
"%autoreload 2\n",
"\n",
"# Gives you high resolution images within the notebook\n",
"%config InlineBackend.figure_format = 'retina'"
]
},
{
"cell_type": "markdown",
"id": "e5d8cd1a4adf4f11",
"metadata": {},
"source": [
"# Plotting Line traces as Vector Graphic (High Quality)\n",
"Since plotting line and node traces on a map, e.g. OpenStreetMap, using `Scattermapbox` the output will be rendered not as vector graphic.\n",
"\n",
"Setting `use_mapbox = False` allows to use `Scatter` which will output as vector graphic and thus allows to save figures in .svg or .pdf format."
]
},
{
"cell_type": "markdown",
"id": "3ed885bf22427a4a",
"metadata": {},
"source": [
"## Load Data"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "81678c770f5da613",
"metadata": {},
"outputs": [],
"source": [
"from definitions import ROOT_DIR\n",
"import os\n",
"\n",
"# The PSDM specific input models can be imported from the pypsdm.models.input and\n",
"# pypsdm.models.result. The `GridWithResults` container is located in pypsdm.models.gwr\n",
"from pypsdm.models.gwr import GridWithResults\n",
"\n",
"grid_path = os.path.join(ROOT_DIR, \"tests\", \"resources\", \"simbench\", \"input\")\n",
"result_path = os.path.join(ROOT_DIR, \"tests\", \"resources\", \"simbench\", \"results\")\n",
"\n",
"# IO data models in general have a from_csv method to parse psdm files\n",
"gwr = GridWithResults.from_csv(grid_path, result_path)"
]
},
{
"cell_type": "markdown",
"id": "ca40b9b6b739fa82",
"metadata": {},
"source": [
"## Get Line Results and Calculate Utilisation"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "275adf2cb67a9d37",
"metadata": {},
"outputs": [],
"source": [
"# NBVAL_CHECK_OUTPUT\n",
"line_input_data = gwr.lines\n",
"line_utilization = gwr.lines_res.utilisation(line_input_data, side=\"a\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "64515d7eab450b23",
"metadata": {},
"outputs": [],
"source": [
"# NBVAL_CHECK_OUTPUT\n",
"import pandas as pd\n",
"\n",
"specific_time = pd.to_datetime(\"2016-01-02 12:00:00\")\n",
"# filter for timestamp\n",
"filtered_data = line_utilization.loc[[specific_time]].to_dict()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d8629a2a57260668",
"metadata": {},
"outputs": [],
"source": [
"from pypsdm.plots.grid import create_zoom_box, grid_plot\n",
"\n",
"# zoom_box allows to focus on certain parts of your plot\n",
"zoom_box = create_zoom_box(53.665, 11.35, 53.62, 11.38)\n",
"\n",
"# to remove the axes and lat / lon grid simply set show_axes = False or remove the parameter\n",
"fig_svg = grid_plot(\n",
" gwr.grid,\n",
" cmap_lines=\"Jet\",\n",
" cmap_line_values=filtered_data,\n",
" cbar_line_title=\"Line Utilisation\",\n",
" zoom_box=zoom_box,\n",
" show_axes=True,\n",
" use_mapbox=False,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b28859b912d9c22c",
"metadata": {},
"outputs": [],
"source": [
"fig_svg"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2ba2dbff4e8bd18a",
"metadata": {},
"outputs": [],
"source": [
"# Plot can be saved as svg or other vector format\n",
"# fig_svg.write_image('save_as_svg.svg')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading