From 7c530f98f22abbe03d2bb4afa36506700e1e0000 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Wed, 7 Sep 2022 15:09:39 +0200 Subject: [PATCH 001/119] Create docs-check.yml Checks links in documentation upon pull request. Uses Sphinx build, see: https://github.com/marketplace/actions/sphinx-build --- .github/workflows/docs-check.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/workflows/docs-check.yml diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml new file mode 100644 index 000000000..b8165acbe --- /dev/null +++ b/.github/workflows/docs-check.yml @@ -0,0 +1,12 @@ +name: "Pull Request Docs Check" +on: +- [pull] + +jobs: + docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: ammaraskar/sphinx-action@master + with: + docs-folder: "doc/" From 77b453e048d3fe09fcbe35542a0377c1e5c7fcbb Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Wed, 7 Sep 2022 15:38:01 +0200 Subject: [PATCH 002/119] Update docs-check.yml --- .github/workflows/docs-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index b8165acbe..ee122b348 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -1,6 +1,6 @@ name: "Pull Request Docs Check" on: -- [pull] +- pull_request jobs: docs: From 0eae0c67c193a1c9e093279135d6ada4695fac01 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Wed, 7 Sep 2022 15:43:54 +0200 Subject: [PATCH 003/119] Update docs-check.yml --- .github/workflows/docs-check.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index ee122b348..f6858728b 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -9,4 +9,5 @@ jobs: - uses: actions/checkout@v1 - uses: ammaraskar/sphinx-action@master with: + build-command: "sphinx-build source build" docs-folder: "doc/" From eca0569fc51a41085090cb0457bb1584a0b8afc8 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Wed, 7 Sep 2022 19:33:41 +0200 Subject: [PATCH 004/119] Create Makefile --- doc/Makefile | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 doc/Makefile diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 000000000..d4bb2cbb9 --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) From f24c3c084cccc48482e36de74d1ada4198a71140 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Wed, 7 Sep 2022 19:39:16 +0200 Subject: [PATCH 005/119] Update Makefile --- doc/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/Makefile b/doc/Makefile index d4bb2cbb9..40a347972 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -3,10 +3,10 @@ # You can set these variables from the command line, and also # from the environment for the first two. -SPHINXOPTS ?= -SPHINXBUILD ?= sphinx-build -SOURCEDIR = . -BUILDDIR = _build +SPHINXOPTS += +SPHINXBUILD = sphinx-build +SOURCEDIR = source +BUILDDIR = build # Put it first so that "make" without argument is like "make help". help: From 4ba6c26bea2849762046be0a764fca5a45c41405 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Wed, 7 Sep 2022 19:42:34 +0200 Subject: [PATCH 006/119] Create make.bat --- doc/make.bat | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 doc/make.bat diff --git a/doc/make.bat b/doc/make.bat new file mode 100644 index 000000000..4d9eb83d9 --- /dev/null +++ b/doc/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% + +:end +popd From d32cfc35e9a08c30980fadf5b73bbdc52a191ddd Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Wed, 7 Sep 2022 19:46:01 +0200 Subject: [PATCH 007/119] Create requirements.txt --- doc/requirements.txt | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 doc/requirements.txt diff --git a/doc/requirements.txt b/doc/requirements.txt new file mode 100644 index 000000000..2ab4cbbb3 --- /dev/null +++ b/doc/requirements.txt @@ -0,0 +1,26 @@ +demandlib +networkx >= 2.5.0 +geopy >= 2.0.0 +pandas >= 1.2.0 +pyproj >= 3.0.0 +pypsa >=0.17.0 +pyomo >= 6.0 +multiprocess +workalendar +egoio >= 0.4.7 +matplotlib >= 3.3.0 +plotly +dash == 2.0.0 +werkzeug==2.0.3 +jupyter_dash +pypower +sklearn +docutils == 0.16.0 +sphinx >= 4.3.0, < 5.1.0 +sphinx_rtd_theme >=0.5.2 +sphinx-autodoc-typehints +geopandas >= 0.9.0 +Footer +© 2022 GitHub, Inc. +Footer navigation +Terms From 4c366c6294ef72a3a6bc407480d12932eb7f517b Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Wed, 7 Sep 2022 19:48:26 +0200 Subject: [PATCH 008/119] Update requirements.txt --- doc/requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/requirements.txt b/doc/requirements.txt index 2ab4cbbb3..76f9f38e4 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -21,6 +21,5 @@ sphinx_rtd_theme >=0.5.2 sphinx-autodoc-typehints geopandas >= 0.9.0 Footer -© 2022 GitHub, Inc. Footer navigation Terms From 6becba7c5dd9ac52af279ec4491692d82442b626 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Wed, 7 Sep 2022 19:49:43 +0200 Subject: [PATCH 009/119] Update requirements.txt --- doc/requirements.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/doc/requirements.txt b/doc/requirements.txt index 76f9f38e4..34b13a347 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -20,6 +20,3 @@ sphinx >= 4.3.0, < 5.1.0 sphinx_rtd_theme >=0.5.2 sphinx-autodoc-typehints geopandas >= 0.9.0 -Footer -Footer navigation -Terms From d6e2f422846bb1773e9606e702468cb9571b52a3 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Wed, 7 Sep 2022 19:55:21 +0200 Subject: [PATCH 010/119] Update make.bat --- doc/make.bat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/make.bat b/doc/make.bat index 4d9eb83d9..7893348a1 100644 --- a/doc/make.bat +++ b/doc/make.bat @@ -7,8 +7,8 @@ REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) -set SOURCEDIR=source -set BUILDDIR=build +set SOURCEDIR=. +set BUILDDIR=_build if "%1" == "" goto help From 0e1bb3c68fa7fce6cc0f6d60cf113498dbaaf4e6 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Wed, 7 Sep 2022 19:55:53 +0200 Subject: [PATCH 011/119] Update Makefile --- doc/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/Makefile b/doc/Makefile index 40a347972..d89186dab 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -5,8 +5,8 @@ # from the environment for the first two. SPHINXOPTS += SPHINXBUILD = sphinx-build -SOURCEDIR = source -BUILDDIR = build +SOURCEDIR = . +BUILDDIR = _build # Put it first so that "make" without argument is like "make help". help: From 4697e84955177102db48d9d281e3a9f2c014248e Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Thu, 8 Sep 2022 09:30:03 +0200 Subject: [PATCH 012/119] Update Makefile --- doc/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/Makefile b/doc/Makefile index d89186dab..d4bb2cbb9 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -3,8 +3,8 @@ # You can set these variables from the command line, and also # from the environment for the first two. -SPHINXOPTS += -SPHINXBUILD = sphinx-build +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build SOURCEDIR = . BUILDDIR = _build From 37ab10d9bda54b3a48fb2cc3ea9fd30dc69a894b Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Thu, 8 Sep 2022 09:34:32 +0200 Subject: [PATCH 013/119] Update Makefile --- doc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Makefile b/doc/Makefile index d4bb2cbb9..d4588f4cd 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -5,7 +5,7 @@ # from the environment for the first two. SPHINXOPTS ?= SPHINXBUILD ?= sphinx-build -SOURCEDIR = . +SOURCEDIR = BUILDDIR = _build # Put it first so that "make" without argument is like "make help". From bbf89efc4303572dd60d450924a3a7e3f6c4e2b9 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Thu, 8 Sep 2022 10:54:46 +0200 Subject: [PATCH 014/119] Create links.yml --- .github/workflows/links.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/links.yml diff --git a/.github/workflows/links.yml b/.github/workflows/links.yml new file mode 100644 index 000000000..4a3ffc2f7 --- /dev/null +++ b/.github/workflows/links.yml @@ -0,0 +1,27 @@ +name: Links + +on: + repository_dispatch: + workflow_dispatch: + schedule: + - cron: "00 18 * * *" + +jobs: + linkChecker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Link Checker + id: lychee + uses: lycheeverse/lychee-action@v1.5.1 + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + + - name: Create Issue From File + if: steps.lychee.outputs.exit_code != 0 + uses: peter-evans/create-issue-from-file@v4 + with: + title: Link Checker Report + content-filepath: ./lychee/out.md + labels: report, automated issue From 520724cdd8ab5c039635b95dfe31d9870f81ceed Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Thu, 8 Sep 2022 10:57:29 +0200 Subject: [PATCH 015/119] Create action.yml --- action.yml | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 action.yml diff --git a/action.yml b/action.yml new file mode 100644 index 000000000..4fed8b920 --- /dev/null +++ b/action.yml @@ -0,0 +1,61 @@ +name: "Lychee Broken Link Checker" +description: "Quickly check links in Markdown, HTML, and text files" +inputs: + args: + description: "Lychee arguments (https://github.com/lycheeverse/lychee#commandline-parameters)" + default: "--verbose --no-progress './**/*.md' './**/*.html'" + required: false + debug: + description: "Enable debug output in action (set -x). Helpful for troubleshooting." + default: false + required: false + fail: + description: "Fail entire pipeline on error (i.e. when lychee exit code is not 0)" + default: false + required: false + format: + description: "Summary output format (e.g. json)" + default: "markdown" + required: false + jobSummary: + description: "Write Github job summary at the end of the job (written on Markdown output only)" + default: true + required: false + lycheeVersion: + description: "Use custom version of lychee link checker" + default: 0.10.1 + required: false + output: + description: "Summary output file path" + default: "lychee/out.md" + required: false +outputs: + exit_code: + description: "The exit code returned from Lychee" + value: ${{ steps.lychee.outputs.exit_code }} +runs: + using: "composite" + steps: + - name: Install lychee + run: | + curl -sLO 'https://github.com/lycheeverse/lychee/releases/download/v${{ inputs.LYCHEEVERSION }}/lychee-v${{ inputs.LYCHEEVERSION }}-x86_64-unknown-linux-gnu.tar.gz' + tar -xvzf lychee-v${{ inputs.LYCHEEVERSION }}-x86_64-unknown-linux-gnu.tar.gz + install -t $HOME/.local/bin -D lychee + echo "$HOME/.local/bin" >> $GITHUB_PATH + shell: bash + - name: Run lychee + run: ${{ github.action_path }}/entrypoint.sh + id: lychee + env: + # https://github.com/actions/runner/issues/665 + INPUT_GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }} + INPUT_ARGS: ${{ inputs.ARGS }} + INPUT_DEBUG: ${{ inputs.DEBUG }} + INPUT_FAIL: ${{ inputs.FAIL }} + INPUT_FORMAT: ${{ inputs.FORMAT }} + INPUT_JOBSUMMARY: ${{ inputs.JOBSUMMARY }} + INPUT_OUTPUT: ${{ inputs.OUTPUT }} + shell: bash +branding: + icon: "external-link" + color: "purple" From 2b34c5cba26b6915d61c76188c9efe7fda3b4378 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Fri, 9 Sep 2022 07:09:35 +0200 Subject: [PATCH 016/119] Update docs-check.yml --- .github/workflows/docs-check.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index f6858728b..ee122b348 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -9,5 +9,4 @@ jobs: - uses: actions/checkout@v1 - uses: ammaraskar/sphinx-action@master with: - build-command: "sphinx-build source build" docs-folder: "doc/" From a55fc456a727e8f7675fdc1e00772cc2e422aa2e Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Fri, 9 Sep 2022 07:12:49 +0200 Subject: [PATCH 017/119] Delete action.yml --- action.yml | 61 ------------------------------------------------------ 1 file changed, 61 deletions(-) delete mode 100644 action.yml diff --git a/action.yml b/action.yml deleted file mode 100644 index 4fed8b920..000000000 --- a/action.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: "Lychee Broken Link Checker" -description: "Quickly check links in Markdown, HTML, and text files" -inputs: - args: - description: "Lychee arguments (https://github.com/lycheeverse/lychee#commandline-parameters)" - default: "--verbose --no-progress './**/*.md' './**/*.html'" - required: false - debug: - description: "Enable debug output in action (set -x). Helpful for troubleshooting." - default: false - required: false - fail: - description: "Fail entire pipeline on error (i.e. when lychee exit code is not 0)" - default: false - required: false - format: - description: "Summary output format (e.g. json)" - default: "markdown" - required: false - jobSummary: - description: "Write Github job summary at the end of the job (written on Markdown output only)" - default: true - required: false - lycheeVersion: - description: "Use custom version of lychee link checker" - default: 0.10.1 - required: false - output: - description: "Summary output file path" - default: "lychee/out.md" - required: false -outputs: - exit_code: - description: "The exit code returned from Lychee" - value: ${{ steps.lychee.outputs.exit_code }} -runs: - using: "composite" - steps: - - name: Install lychee - run: | - curl -sLO 'https://github.com/lycheeverse/lychee/releases/download/v${{ inputs.LYCHEEVERSION }}/lychee-v${{ inputs.LYCHEEVERSION }}-x86_64-unknown-linux-gnu.tar.gz' - tar -xvzf lychee-v${{ inputs.LYCHEEVERSION }}-x86_64-unknown-linux-gnu.tar.gz - install -t $HOME/.local/bin -D lychee - echo "$HOME/.local/bin" >> $GITHUB_PATH - shell: bash - - name: Run lychee - run: ${{ github.action_path }}/entrypoint.sh - id: lychee - env: - # https://github.com/actions/runner/issues/665 - INPUT_GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }} - INPUT_ARGS: ${{ inputs.ARGS }} - INPUT_DEBUG: ${{ inputs.DEBUG }} - INPUT_FAIL: ${{ inputs.FAIL }} - INPUT_FORMAT: ${{ inputs.FORMAT }} - INPUT_JOBSUMMARY: ${{ inputs.JOBSUMMARY }} - INPUT_OUTPUT: ${{ inputs.OUTPUT }} - shell: bash -branding: - icon: "external-link" - color: "purple" From d32bc709cad9631eda8fc4f965d5cf02d31a2297 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Fri, 9 Sep 2022 07:14:12 +0200 Subject: [PATCH 018/119] Delete links.yml --- .github/workflows/links.yml | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 .github/workflows/links.yml diff --git a/.github/workflows/links.yml b/.github/workflows/links.yml deleted file mode 100644 index 4a3ffc2f7..000000000 --- a/.github/workflows/links.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Links - -on: - repository_dispatch: - workflow_dispatch: - schedule: - - cron: "00 18 * * *" - -jobs: - linkChecker: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Link Checker - id: lychee - uses: lycheeverse/lychee-action@v1.5.1 - env: - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - - - name: Create Issue From File - if: steps.lychee.outputs.exit_code != 0 - uses: peter-evans/create-issue-from-file@v4 - with: - title: Link Checker Report - content-filepath: ./lychee/out.md - labels: report, automated issue From 8c8e6d30be8d3e1e23db9331a4f7384d781cda48 Mon Sep 17 00:00:00 2001 From: Malte Jahn Date: Wed, 14 Sep 2022 15:00:53 +0200 Subject: [PATCH 019/119] Adding sphinx autoapi Sphinx autoapi is added, through this no manual running of sphinx-autodoc is needed. --- doc/api.rst | 17 -------- doc/api/edisgo.flex_opt.rst | 58 -------------------------- doc/api/edisgo.io.rst | 42 ------------------- doc/api/edisgo.network.rst | 50 ---------------------- doc/api/edisgo.opf.rst | 44 -------------------- doc/api/edisgo.tools.rst | 82 ------------------------------------- doc/api/edisgo_class.rst | 5 --- doc/conf.py | 4 ++ doc/index.rst | 1 - rtd_requirements.txt | 1 + setup.py | 1 + 11 files changed, 6 insertions(+), 299 deletions(-) delete mode 100644 doc/api.rst delete mode 100644 doc/api/edisgo.flex_opt.rst delete mode 100644 doc/api/edisgo.io.rst delete mode 100644 doc/api/edisgo.network.rst delete mode 100644 doc/api/edisgo.opf.rst delete mode 100644 doc/api/edisgo.tools.rst delete mode 100644 doc/api/edisgo_class.rst diff --git a/doc/api.rst b/doc/api.rst deleted file mode 100644 index 89ce73c1e..000000000 --- a/doc/api.rst +++ /dev/null @@ -1,17 +0,0 @@ -.. _api: - -API -=== - -.. make doc-string generated documentation appear here - -.. toctree:: - :maxdepth: 2 - :glob: - - api/edisgo_class - api/edisgo.network - api/edisgo.flex_opt - api/edisgo.io - api/edisgo.opf - api/edisgo.tools diff --git a/doc/api/edisgo.flex_opt.rst b/doc/api/edisgo.flex_opt.rst deleted file mode 100644 index 8abea6d10..000000000 --- a/doc/api/edisgo.flex_opt.rst +++ /dev/null @@ -1,58 +0,0 @@ -edisgo.flex\_opt package -======================== - -edisgo.flex\_opt.charging\_strategies module --------------------------------------------- - -.. automodule:: edisgo.flex_opt.charging_strategies - :members: - :undoc-members: - :show-inheritance: - -edisgo.flex\_opt.check\_tech\_constraints module ------------------------------------------------- - -.. automodule:: edisgo.flex_opt.check_tech_constraints - :members: - :undoc-members: - :show-inheritance: - -edisgo.flex\_opt.costs module ------------------------------ - -.. automodule:: edisgo.flex_opt.costs - :members: - :undoc-members: - :show-inheritance: - -edisgo.flex\_opt.exceptions module ----------------------------------- - -.. automodule:: edisgo.flex_opt.exceptions - :members: - :undoc-members: - :show-inheritance: - -edisgo.flex\_opt.q\_control module ------------------------------------ - -.. automodule:: edisgo.flex_opt.q_control - :members: - :undoc-members: - :show-inheritance: - -edisgo.flex\_opt.reinforce\_grid module ---------------------------------------- - -.. automodule:: edisgo.flex_opt.reinforce_grid - :members: - :undoc-members: - :show-inheritance: - -edisgo.flex\_opt.reinforce\_measures module -------------------------------------------- - -.. automodule:: edisgo.flex_opt.reinforce_measures - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/api/edisgo.io.rst b/doc/api/edisgo.io.rst deleted file mode 100644 index 75a1d860c..000000000 --- a/doc/api/edisgo.io.rst +++ /dev/null @@ -1,42 +0,0 @@ -edisgo.io package -================= - -edisgo.io.ding0\_import module ------------------------------- - -.. automodule:: edisgo.io.ding0_import - :members: - :undoc-members: - :show-inheritance: - -edisgo.io.electromobility\_import module ----------------------------------------- - -.. automodule:: edisgo.io.electromobility_import - :members: - :undoc-members: - :show-inheritance: - -edisgo.io.generators\_import module ------------------------------------ - -.. automodule:: edisgo.io.generators_import - :members: - :undoc-members: - :show-inheritance: - -edisgo.io.pypsa\_io module --------------------------- - -.. automodule:: edisgo.io.pypsa_io - :members: - :undoc-members: - :show-inheritance: - -edisgo.io.timeseries\_import module ------------------------------------ - -.. automodule:: edisgo.io.timeseries_import - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/api/edisgo.network.rst b/doc/api/edisgo.network.rst deleted file mode 100644 index a139b7408..000000000 --- a/doc/api/edisgo.network.rst +++ /dev/null @@ -1,50 +0,0 @@ -edisgo.network package -====================== - -edisgo.network.components module --------------------------------- - -.. automodule:: edisgo.network.components - :members: - :undoc-members: - :show-inheritance: - -edisgo.network.electromobility module -------------------------------------- - -.. automodule:: edisgo.network.electromobility - :members: - :undoc-members: - :show-inheritance: - -edisgo.network.grids module ---------------------------- - -.. automodule:: edisgo.network.grids - :members: - :undoc-members: - :show-inheritance: - -edisgo.network.results module ------------------------------ - -.. automodule:: edisgo.network.results - :members: - :undoc-members: - :show-inheritance: - -edisgo.network.timeseries module --------------------------------- - -.. automodule:: edisgo.network.timeseries - :members: - :undoc-members: - :show-inheritance: - -edisgo.network.topology module ------------------------------- - -.. automodule:: edisgo.network.topology - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/api/edisgo.opf.rst b/doc/api/edisgo.opf.rst deleted file mode 100644 index db421aadf..000000000 --- a/doc/api/edisgo.opf.rst +++ /dev/null @@ -1,44 +0,0 @@ -edisgo.opf package -================== - -edisgo.opf.run\_mp\_opf module ----------------------------------- - -.. automodule:: edisgo.opf.run_mp_opf - :members: - :undoc-members: - :show-inheritance: - -edisgo.opf.timeseries\_reduction module -------------------------------------------- - -.. automodule:: edisgo.opf.timeseries_reduction - :members: - :undoc-members: - :show-inheritance: - -edisgo.opf.results package ------------------------------ - -.. automodule:: edisgo.opf.results.opf_expand_network - :members: - :undoc-members: - :show-inheritance: - -.. automodule:: edisgo.opf.results.opf_result_class - :members: - :undoc-members: - :show-inheritance: - -edisgo.opf.util package ----------------------------------- - -.. automodule:: edisgo.opf.util.plot_solutions - :members: - :undoc-members: - :show-inheritance: - -.. automodule:: edisgo.opf.util.scenario_settings - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/api/edisgo.tools.rst b/doc/api/edisgo.tools.rst deleted file mode 100644 index 1bc306a87..000000000 --- a/doc/api/edisgo.tools.rst +++ /dev/null @@ -1,82 +0,0 @@ -edisgo.tools package -==================== - -edisgo.tools.config module ---------------------------- - -.. automodule:: edisgo.tools.config - :members: - :undoc-members: - :show-inheritance: - -edisgo.tools.geo module ------------------------- - -.. automodule:: edisgo.tools.geo - :members: - :undoc-members: - :show-inheritance: - -edisgo.tools.geopandas\_helper module ----------------------------------------- - -.. automodule:: edisgo.tools.geopandas_helper - :members: - :undoc-members: - :show-inheritance: - -edisgo.tools.logger module ----------------------------------------- - -.. automodule:: edisgo.tools.logger - :members: - :undoc-members: - :show-inheritance: - -edisgo.tools.networkx\_helper module ----------------------------------------- - -.. automodule:: edisgo.tools.networkx_helper - :members: - :undoc-members: - :show-inheritance: - -edisgo.tools.plots module --------------------------- - -.. automodule:: edisgo.tools.plots - :members: - :undoc-members: - :show-inheritance: - -edisgo.tools.powermodels\_io module -------------------------------------- - -.. automodule:: edisgo.tools.powermodels_io - :members: - :undoc-members: - :show-inheritance: - -edisgo.tools.preprocess\_pypsa\_opf\_structure module ------------------------------------------------------- - -.. automodule:: edisgo.tools.preprocess_pypsa_opf_structure - :members: - :undoc-members: - :show-inheritance: - -edisgo.tools.tools module --------------------------- - -.. automodule:: edisgo.tools.tools - :members: - :undoc-members: - :show-inheritance: - -Module contents ---------------- - -.. automodule:: edisgo.tools - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/api/edisgo_class.rst b/doc/api/edisgo_class.rst deleted file mode 100644 index e231b15d7..000000000 --- a/doc/api/edisgo_class.rst +++ /dev/null @@ -1,5 +0,0 @@ -EDisGo class -============ - -.. autoclass:: edisgo.EDisGo - :members: diff --git a/doc/conf.py b/doc/conf.py index 688f95197..2b4b44b7f 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -46,6 +46,7 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ + "autoapi.extension", "sphinx.ext.autodoc", "sphinx.ext.intersphinx", "sphinx.ext.todo", @@ -56,6 +57,9 @@ "sphinx.ext.extlinks", # enables external links with a key "sphinx_autodoc_typehints", ] +# Autoapi settings +autoapi_type = "python" +autoapi_dirs = ["../edisgo"] # Napoleon settings napoleon_google_docstring = True diff --git a/doc/index.rst b/doc/index.rst index c02d20c37..0ff3cb798 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -69,6 +69,5 @@ Contents definitions_and_units configs equipment - api whatsnew genindex diff --git a/rtd_requirements.txt b/rtd_requirements.txt index 34b13a347..a18e231f2 100644 --- a/rtd_requirements.txt +++ b/rtd_requirements.txt @@ -20,3 +20,4 @@ sphinx >= 4.3.0, < 5.1.0 sphinx_rtd_theme >=0.5.2 sphinx-autodoc-typehints geopandas >= 0.9.0 +sphinx-autoapi diff --git a/setup.py b/setup.py index 40052998d..c68e18ac9 100644 --- a/setup.py +++ b/setup.py @@ -72,6 +72,7 @@ def read(fname): "jupyter_contrib_nbextensions", "sphinx_rtd_theme", "sphinx-autodoc-typehints", + "sphinx-autoapi", "pre-commit", "black", "isort", From 6ed4f235280b992d0253d930f5750fe835f79019 Mon Sep 17 00:00:00 2001 From: Malte Jahn Date: Wed, 21 Sep 2022 12:37:15 +0200 Subject: [PATCH 020/119] Improve setup_logger - When resetting loggers with setup logging only clear handlers which are not a NullHandler - Clearing the handlers of loggers which are set with setup_logger --- edisgo/tools/logger.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/edisgo/tools/logger.py b/edisgo/tools/logger.py index 93381c9c3..58436a316 100644 --- a/edisgo/tools/logger.py +++ b/edisgo/tools/logger.py @@ -11,6 +11,7 @@ def setup_logger( file_name=None, log_dir=None, loggers=None, + grid_id=None, stream_output=sys.stdout, debug_message=False, reset_loggers=False, @@ -104,6 +105,7 @@ def setup_logger( reset_loggers : bool If True the handlers of all loggers are cleared before configuring the loggers. + Only use if you know what you do, it could be dangerous. Examples -------- @@ -151,7 +153,11 @@ def create_home_dir(): ] for logger in existing_loggers: - logger.handlers.clear() + for handler in logger.handlers: + if not isinstance(handler, logging.NullHandler): + if debug_message: + print(f"Removed {handler} of Logger: {logger}") + logger.removeHandler(handler) loglevel_dict = { "debug": logging.DEBUG, @@ -184,6 +190,9 @@ def create_home_dir(): logger = logging.getLogger(logger_name) logger.propagate = False + # clear existing handlers for the logger + logger.handlers.clear() + if logger_file_level < logger_stream_level: logger.setLevel(logger_file_level) else: From df17f65929388293fb6364dd8cbbc99807986c92 Mon Sep 17 00:00:00 2001 From: Malte Jahn Date: Wed, 21 Sep 2022 12:39:33 +0200 Subject: [PATCH 021/119] Add MVGrid_ID to logging messages The MVGrid_ID is added to the logging messages of the logger "edisgo". --- edisgo/edisgo.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/edisgo/edisgo.py b/edisgo/edisgo.py index cc97ad06f..1785e1844 100755 --- a/edisgo/edisgo.py +++ b/edisgo/edisgo.py @@ -138,6 +138,36 @@ def __init__(self, **kwargs): generator_scenario=kwargs.pop("generator_scenario"), **kwargs ) + # add MVGrid id to logging messages of logger "edisgo" + log_grid_id = kwargs.get("log_grid_id", True) + if log_grid_id: + + def add_grid_id_filter(record): + record.grid_id = self.topology.id + return True + + file_formatter = logging.Formatter( + "%(asctime)s - %(name)s - %(levelname)s - " + "MVGrid(%(grid_id)s): %(message)s" + ) + stream_formatter = logging.Formatter( + "%(name)s - %(levelname)s - MVGrid(%(grid_id)s): %(message)s" + ) + + logger_edisgo = logging.getLogger("edisgo") + for handler in logger_edisgo.handlers: + if isinstance(logger_edisgo.handlers[0], logging.StreamHandler): + handler.setFormatter(stream_formatter) + elif isinstance(logger_edisgo.handlers[0], logging.FileHandler): + handler.setFormatter(file_formatter) + else: + raise ValueError( + "Disable the log_grid_id function when using other" + " handlers than StreamHandler or FileHandler" + ) + handler.filters.clear() + handler.addFilter(add_grid_id_filter) + @property def config(self): """ From 9d3f250ded3ad4e474eff0655d73df311944b1ee Mon Sep 17 00:00:00 2001 From: Malte Jahn Date: Wed, 21 Sep 2022 13:49:43 +0200 Subject: [PATCH 022/119] Fix bug - Import of setup_logger is missing - Set sleep time between dash plot to 2 seconds --- examples/edisgo_simple_example.ipynb | 3 ++- examples/plot_example.ipynb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/edisgo_simple_example.ipynb b/examples/edisgo_simple_example.ipynb index 99fcafb64..bce136817 100755 --- a/examples/edisgo_simple_example.ipynb +++ b/examples/edisgo_simple_example.ipynb @@ -74,7 +74,8 @@ "import networkx as nx\n", "import pandas as pd\n", "\n", - "from edisgo import EDisGo" + "from edisgo import EDisGo\n", + "from edisgo.tools.logger import setup_logger" ] }, { diff --git a/examples/plot_example.ipynb b/examples/plot_example.ipynb index e8f95025b..361037c7e 100755 --- a/examples/plot_example.ipynb +++ b/examples/plot_example.ipynb @@ -355,7 +355,7 @@ "outputs": [], "source": [ "plot_dash(edisgo_objects={\"edisgo_analyzed\": edisgo_analyzed, \"edisgo_reinforced\": edisgo_reinforced})\n", - "time.sleep(1)" + "time.sleep(2)" ] }, { From 1d3bece66c34bdc692fb2f22129fe9c4e7965897 Mon Sep 17 00:00:00 2001 From: Malte Jahn Date: Wed, 21 Sep 2022 13:56:01 +0200 Subject: [PATCH 023/119] Remove unused parameter in setup_logger --- edisgo/tools/logger.py | 1 - 1 file changed, 1 deletion(-) diff --git a/edisgo/tools/logger.py b/edisgo/tools/logger.py index 58436a316..5b1a62a55 100644 --- a/edisgo/tools/logger.py +++ b/edisgo/tools/logger.py @@ -11,7 +11,6 @@ def setup_logger( file_name=None, log_dir=None, loggers=None, - grid_id=None, stream_output=sys.stdout, debug_message=False, reset_loggers=False, From 45a327412f4abb7699072ac9c9d56ddd59b9b555 Mon Sep 17 00:00:00 2001 From: Maike Held Date: Mon, 26 Sep 2022 10:30:25 +0200 Subject: [PATCH 024/119] Changed pandas link in conf.py --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 688f95197..7331a6d32 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -73,7 +73,7 @@ # Dictionary of external links extlinks = { "pandas": ( - "http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.%s.html", + "http://pandas.pydata.org/pandas-doc/stable/reference/api/pandas.%s.html", "pandas.", ), "geopandas": ( From 23d128606670502945e7e1d62e3efb27b0c37e6d Mon Sep 17 00:00:00 2001 From: Maike Held Date: Mon, 26 Sep 2022 10:36:56 +0200 Subject: [PATCH 025/119] Changed link to check docs-check.yml --- doc/conf.py | 2 +- edisgo/edisgo.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 7331a6d32..688f95197 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -73,7 +73,7 @@ # Dictionary of external links extlinks = { "pandas": ( - "http://pandas.pydata.org/pandas-doc/stable/reference/api/pandas.%s.html", + "http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.%s.html", "pandas.", ), "geopandas": ( diff --git a/edisgo/edisgo.py b/edisgo/edisgo.py index cc97ad06f..2a80b471a 100755 --- a/edisgo/edisgo.py +++ b/edisgo/edisgo.py @@ -51,7 +51,7 @@ class EDisGo: Otherwise defines which scenario of future generator park to use and invokes grid integration of these generators. Possible options are 'nep2035' and 'ego100'. These are scenarios from the research project - `open_eGo `_ (see + `open_eGo `_ (see `final report `_ From cc4e4c61ec3c6c2e2a6dd3c0b2d0e25bd8210335 Mon Sep 17 00:00:00 2001 From: Maike Held Date: Mon, 26 Sep 2022 10:44:36 +0200 Subject: [PATCH 026/119] Moved requirements.txt to doc folder --- .readthedocs.yml | 2 +- doc/requirements.txt | 22 ---------------------- rtd_requirements.txt | 22 ---------------------- 3 files changed, 1 insertion(+), 45 deletions(-) delete mode 100644 doc/requirements.txt delete mode 100644 rtd_requirements.txt diff --git a/.readthedocs.yml b/.readthedocs.yml index 86c001e07..b04220b84 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -20,4 +20,4 @@ formats: all python: version: "3.8" install: - - requirements: rtd_requirements.txt + - requirements: requirements.txt diff --git a/doc/requirements.txt b/doc/requirements.txt deleted file mode 100644 index 34b13a347..000000000 --- a/doc/requirements.txt +++ /dev/null @@ -1,22 +0,0 @@ -demandlib -networkx >= 2.5.0 -geopy >= 2.0.0 -pandas >= 1.2.0 -pyproj >= 3.0.0 -pypsa >=0.17.0 -pyomo >= 6.0 -multiprocess -workalendar -egoio >= 0.4.7 -matplotlib >= 3.3.0 -plotly -dash == 2.0.0 -werkzeug==2.0.3 -jupyter_dash -pypower -sklearn -docutils == 0.16.0 -sphinx >= 4.3.0, < 5.1.0 -sphinx_rtd_theme >=0.5.2 -sphinx-autodoc-typehints -geopandas >= 0.9.0 diff --git a/rtd_requirements.txt b/rtd_requirements.txt deleted file mode 100644 index 34b13a347..000000000 --- a/rtd_requirements.txt +++ /dev/null @@ -1,22 +0,0 @@ -demandlib -networkx >= 2.5.0 -geopy >= 2.0.0 -pandas >= 1.2.0 -pyproj >= 3.0.0 -pypsa >=0.17.0 -pyomo >= 6.0 -multiprocess -workalendar -egoio >= 0.4.7 -matplotlib >= 3.3.0 -plotly -dash == 2.0.0 -werkzeug==2.0.3 -jupyter_dash -pypower -sklearn -docutils == 0.16.0 -sphinx >= 4.3.0, < 5.1.0 -sphinx_rtd_theme >=0.5.2 -sphinx-autodoc-typehints -geopandas >= 0.9.0 From cb96614315bcb7ff3b7ef52548c816dee7164bf3 Mon Sep 17 00:00:00 2001 From: Maike Held Date: Mon, 26 Sep 2022 11:01:03 +0200 Subject: [PATCH 027/119] Changed link to correct link again --- edisgo/edisgo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edisgo/edisgo.py b/edisgo/edisgo.py index 2a80b471a..cc97ad06f 100755 --- a/edisgo/edisgo.py +++ b/edisgo/edisgo.py @@ -51,7 +51,7 @@ class EDisGo: Otherwise defines which scenario of future generator park to use and invokes grid integration of these generators. Possible options are 'nep2035' and 'ego100'. These are scenarios from the research project - `open_eGo `_ (see + `open_eGo `_ (see `final report `_ From c35dc0435bd59f2dfb68b2fa48126c334f243bf2 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Mon, 26 Sep 2022 11:25:29 +0200 Subject: [PATCH 028/119] Create requirements.txt --- doc/requirements.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 doc/requirements.txt diff --git a/doc/requirements.txt b/doc/requirements.txt new file mode 100644 index 000000000..34b13a347 --- /dev/null +++ b/doc/requirements.txt @@ -0,0 +1,22 @@ +demandlib +networkx >= 2.5.0 +geopy >= 2.0.0 +pandas >= 1.2.0 +pyproj >= 3.0.0 +pypsa >=0.17.0 +pyomo >= 6.0 +multiprocess +workalendar +egoio >= 0.4.7 +matplotlib >= 3.3.0 +plotly +dash == 2.0.0 +werkzeug==2.0.3 +jupyter_dash +pypower +sklearn +docutils == 0.16.0 +sphinx >= 4.3.0, < 5.1.0 +sphinx_rtd_theme >=0.5.2 +sphinx-autodoc-typehints +geopandas >= 0.9.0 From 538355d5ace03e22e1807a6d30851ea638fd7d40 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Mon, 26 Sep 2022 15:45:54 +0200 Subject: [PATCH 029/119] Update Makefile --- doc/Makefile | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/doc/Makefile b/doc/Makefile index d4588f4cd..ef8f3cca3 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -1,20 +1,30 @@ +LINKCHECKDIR = build/linkcheck + +.PHONY: checklinks + checklinks: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(LINKCHECKDIR) + @echo + @echo "Check finished. Report is in $(LINKCHECKDIR)." + + + # Minimal makefile for Sphinx documentation # # You can set these variables from the command line, and also # from the environment for the first two. -SPHINXOPTS ?= -SPHINXBUILD ?= sphinx-build -SOURCEDIR = -BUILDDIR = _build +#SPHINXOPTS ?= +#SPHINXBUILD ?= sphinx-build +#SOURCEDIR = +#BUILDDIR = _build # Put it first so that "make" without argument is like "make help". -help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) +#help: +# @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -.PHONY: help Makefile +#.PHONY: help Makefile # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) +#%: Makefile +# @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) From 8a510d1268c6f77004f7aa1184c8c9868fe4306b Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Mon, 26 Sep 2022 16:07:06 +0200 Subject: [PATCH 030/119] Update Makefile --- doc/Makefile | 107 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 103 insertions(+), 4 deletions(-) diff --git a/doc/Makefile b/doc/Makefile index ef8f3cca3..9a7b8a8a7 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -1,10 +1,109 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = build/html +LINKSDIR = source/link LINKCHECKDIR = build/linkcheck +SPHINXAUTOBUILD = sphinx-autobuild + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source + +ALLSPHINXLIVEOPTS = $(ALLSPHINXOPTS) -q \ + -p 0 \ + -H 0.0.0.0 \ + -B \ + --delay 1 \ + --ignore "*.swp" \ + --ignore "*.pdf" \ + --ignore "*.log" \ + --ignore "*.out" \ + --ignore "*.toc" \ + --ignore "*.aux" \ + --ignore "*.idx" \ + --ignore "*.ind" \ + --ignore "*.ilg" \ + --ignore "*.tex" \ + --watch source + +.PHONY: help +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + +.PHONY: clean +clean: + rm -rf $(BUILDDIR)/* + +.PHONY: link +link: + @read -p "Enter a Unique Link Name: " link_name; \ + read -p "Enter the link text the user sees: " link_text; \ + read -p "Enter the URL: " link_url; \ + read -p "Enter the .py file name (use_lower_case_and_underscore of link name): " file_name; \ + echo "The link name is: " $$link_name; \ + echo "The link text is: " $$link_text; \ + echo "The URL is: " $$link_url; \ + echo "Creating the file: " $(LINKSDIR)/$$file_name".py"; \ + echo "Enter the link in content as :xref:\`"$$link_name"\`"; \ + echo "The user will see:" $$link_text; \ + echo "Make sure you build and test the link."; \ + echo "import link\n\nen_us_user_text = \"$$link_text\" \n\n\ +links.xref_links.update({\"$$link_name\": (en_us_user_text, \"$$link_url\")})" \ + > $(LINKSDIR)/$$file_name".py" \ + +.PHONY: html +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR) + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)." + + +.PHONY: livehtml +livehtml: + $(SPHINXAUTOBUILD) -b html $(ALLSPHINXLIVEOPTS) $(BUILDDIR) + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)." + + +.PHONY: fasthtml +fasthtml: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR) -j 16 + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)." .PHONY: checklinks - checklinks: - $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(LINKCHECKDIR) - @echo - @echo "Check finished. Report is in $(LINKCHECKDIR)." +checklinks: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(LINKCHECKDIR) + @echo + @echo "Check finished. Report is in $(LINKCHECKDIR)." + + +.PHONY: latex +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +.PHONY: latexpdf +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." +LINKCHECKDIR = build/linkcheck From 284aadf84bb8886231b46d9f0d58e2989e9c2adc Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Tue, 27 Sep 2022 09:22:37 +0200 Subject: [PATCH 031/119] Update Makefile --- doc/Makefile | 127 ++++----------------------------------------------- 1 file changed, 9 insertions(+), 118 deletions(-) diff --git a/doc/Makefile b/doc/Makefile index 9a7b8a8a7..d4bb2cbb9 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -1,129 +1,20 @@ -# Makefile for Sphinx documentation -# - -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = sphinx-build -PAPER = -BUILDDIR = build/html -LINKSDIR = source/link -LINKCHECKDIR = build/linkcheck -SPHINXAUTOBUILD = sphinx-autobuild - -# Internal variables. -PAPEROPT_a4 = -D latex_paper_size=a4 -PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source -# the i18n builder cannot share the environment and doctrees with the others -I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source - -ALLSPHINXLIVEOPTS = $(ALLSPHINXOPTS) -q \ - -p 0 \ - -H 0.0.0.0 \ - -B \ - --delay 1 \ - --ignore "*.swp" \ - --ignore "*.pdf" \ - --ignore "*.log" \ - --ignore "*.out" \ - --ignore "*.toc" \ - --ignore "*.aux" \ - --ignore "*.idx" \ - --ignore "*.ind" \ - --ignore "*.ilg" \ - --ignore "*.tex" \ - --watch source - -.PHONY: help -help: - @echo "Please use \`make ' where is one of" - @echo " html to make standalone HTML files" - @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" - @echo " latexpdf to make LaTeX files and run them through pdflatex" - -.PHONY: clean -clean: - rm -rf $(BUILDDIR)/* - -.PHONY: link -link: - @read -p "Enter a Unique Link Name: " link_name; \ - read -p "Enter the link text the user sees: " link_text; \ - read -p "Enter the URL: " link_url; \ - read -p "Enter the .py file name (use_lower_case_and_underscore of link name): " file_name; \ - echo "The link name is: " $$link_name; \ - echo "The link text is: " $$link_text; \ - echo "The URL is: " $$link_url; \ - echo "Creating the file: " $(LINKSDIR)/$$file_name".py"; \ - echo "Enter the link in content as :xref:\`"$$link_name"\`"; \ - echo "The user will see:" $$link_text; \ - echo "Make sure you build and test the link."; \ - echo "import link\n\nen_us_user_text = \"$$link_text\" \n\n\ -links.xref_links.update({\"$$link_name\": (en_us_user_text, \"$$link_url\")})" \ - > $(LINKSDIR)/$$file_name".py" \ - -.PHONY: html -html: - $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR) - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)." - - -.PHONY: livehtml -livehtml: - $(SPHINXAUTOBUILD) -b html $(ALLSPHINXLIVEOPTS) $(BUILDDIR) - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)." - - -.PHONY: fasthtml -fasthtml: - $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR) -j 16 - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)." - -.PHONY: checklinks -checklinks: - $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(LINKCHECKDIR) - @echo - @echo "Check finished. Report is in $(LINKCHECKDIR)." - - -.PHONY: latex -latex: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo - @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." - @echo "Run \`make' in that directory to run these through (pdf)latex" \ - "(use \`make latexpdf' here to do that automatically)." - -.PHONY: latexpdf -latexpdf: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo "Running LaTeX files through pdflatex..." - $(MAKE) -C $(BUILDDIR)/latex all-pdf - @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." -LINKCHECKDIR = build/linkcheck - - - # Minimal makefile for Sphinx documentation # # You can set these variables from the command line, and also # from the environment for the first two. -#SPHINXOPTS ?= -#SPHINXBUILD ?= sphinx-build -#SOURCEDIR = -#BUILDDIR = _build +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = . +BUILDDIR = _build # Put it first so that "make" without argument is like "make help". -#help: -# @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -#.PHONY: help Makefile +.PHONY: help Makefile # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -#%: Makefile -# @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) From 6a9126fb3a6b78fdefa28d4633853493ffe806e9 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Tue, 27 Sep 2022 09:34:28 +0200 Subject: [PATCH 032/119] Update docs-check.yml --- .github/workflows/docs-check.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index ee122b348..784fb07fa 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -1,12 +1,12 @@ -name: "Pull Request Docs Check" -on: -- pull_request +name: "Docs Check [Push]" +on: [push] jobs: docs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - - uses: ammaraskar/sphinx-action@master - with: + run: | + sphinx-build . -b linkcheck -d _build/doctrees _build/html + with: docs-folder: "doc/" From 3baab90ec69044c6916ad5a8d49da8e396a7d4b8 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Tue, 27 Sep 2022 09:49:32 +0200 Subject: [PATCH 033/119] Update docs-check.yml --- .github/workflows/docs-check.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index 784fb07fa..61bc5bddd 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -2,11 +2,10 @@ name: "Docs Check [Push]" on: [push] jobs: - docs: + build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - run: | - sphinx-build . -b linkcheck -d _build/doctrees _build/html - with: - docs-folder: "doc/" + - name: Check doc links + - run: | + cd doc + sphinx-build . -b linkcheck -d _build/doctrees _build/html From 21ef76b84f1f15f2c86d3b148f051ba73b504816 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Tue, 27 Sep 2022 09:53:10 +0200 Subject: [PATCH 034/119] Update docs-check.yml --- .github/workflows/docs-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index 61bc5bddd..534525f1c 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -6,6 +6,6 @@ jobs: runs-on: ubuntu-latest steps: - name: Check doc links - - run: | + run: | cd doc sphinx-build . -b linkcheck -d _build/doctrees _build/html From 7c81b903b8bb51b9aa3d4f9c2ce7362284f88f25 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Tue, 27 Sep 2022 09:56:00 +0200 Subject: [PATCH 035/119] Update docs-check.yml --- .github/workflows/docs-check.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index 534525f1c..797b19a21 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -7,5 +7,4 @@ jobs: steps: - name: Check doc links run: | - cd doc sphinx-build . -b linkcheck -d _build/doctrees _build/html From 7f5f8950520a87b699e153219b61d23b56ce9db5 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Tue, 27 Sep 2022 09:58:55 +0200 Subject: [PATCH 036/119] Update docs-check.yml --- .github/workflows/docs-check.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index 797b19a21..6be677aad 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -4,6 +4,9 @@ on: [push] jobs: build: runs-on: ubuntu-latest + defaults: + run: + working-directory: ./doc steps: - name: Check doc links run: | From e6ed5e8b1518663fcf12c5b3b17d47df9995b2d2 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Tue, 27 Sep 2022 09:59:37 +0200 Subject: [PATCH 037/119] Update docs-check.yml --- .github/workflows/docs-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index 6be677aad..872055997 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -6,7 +6,7 @@ jobs: runs-on: ubuntu-latest defaults: run: - working-directory: ./doc + working-directory: doc steps: - name: Check doc links run: | From 12be4c0c13dfdaec07710da8cffe04c0e1ab51e4 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Tue, 27 Sep 2022 10:22:24 +0200 Subject: [PATCH 038/119] Update docs-check.yml --- .github/workflows/docs-check.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index 872055997..797b19a21 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -4,9 +4,6 @@ on: [push] jobs: build: runs-on: ubuntu-latest - defaults: - run: - working-directory: doc steps: - name: Check doc links run: | From 6ce578101257f55aa5fc1c185c4cf870d76b1af9 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Tue, 27 Sep 2022 10:23:37 +0200 Subject: [PATCH 039/119] Update docs-check.yml --- .github/workflows/docs-check.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index 797b19a21..db539cdcd 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -6,5 +6,6 @@ jobs: runs-on: ubuntu-latest steps: - name: Check doc links + working-directory: ./doc run: | sphinx-build . -b linkcheck -d _build/doctrees _build/html From be273af57854de7316ac81f6fcdea2f78a3b22b9 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Tue, 27 Sep 2022 10:24:09 +0200 Subject: [PATCH 040/119] Update docs-check.yml --- .github/workflows/docs-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index db539cdcd..144af2101 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -6,6 +6,6 @@ jobs: runs-on: ubuntu-latest steps: - name: Check doc links - working-directory: ./doc + working-directory: doc run: | sphinx-build . -b linkcheck -d _build/doctrees _build/html From 2a49f063082e4978fd5e1e7e8598669a4da0f9f7 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Tue, 27 Sep 2022 10:24:52 +0200 Subject: [PATCH 041/119] Update docs-check.yml --- .github/workflows/docs-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index 144af2101..56530513b 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -6,6 +6,6 @@ jobs: runs-on: ubuntu-latest steps: - name: Check doc links - working-directory: doc + working-directory: doc/ run: | sphinx-build . -b linkcheck -d _build/doctrees _build/html From ee3c18478c4857eecf5d98b362b1a1575ed3dd89 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Tue, 27 Sep 2022 10:26:56 +0200 Subject: [PATCH 042/119] Update docs-check.yml --- .github/workflows/docs-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index 56530513b..aa47916dc 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -6,6 +6,6 @@ jobs: runs-on: ubuntu-latest steps: - name: Check doc links - working-directory: doc/ + working-directory: doc/conf.py run: | sphinx-build . -b linkcheck -d _build/doctrees _build/html From e1f37f7e3725003493c85d54b7c88c8b6745a2af Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Tue, 27 Sep 2022 10:30:58 +0200 Subject: [PATCH 043/119] Update docs-check.yml --- .github/workflows/docs-check.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index aa47916dc..7ea63f362 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -1,11 +1,13 @@ -name: "Docs Check [Push]" +name: "Docs link check" on: [push] jobs: build: runs-on: ubuntu-latest steps: + - name: Checkout repo + uses: actions/checkout@v2 - name: Check doc links - working-directory: doc/conf.py + working-directory: doc run: | sphinx-build . -b linkcheck -d _build/doctrees _build/html From 98b938b95b370d60bea98209f92e4149249f3e2f Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Tue, 27 Sep 2022 10:35:37 +0200 Subject: [PATCH 044/119] Update docs-check.yml --- .github/workflows/docs-check.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index 7ea63f362..d48125eb6 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -4,10 +4,11 @@ on: [push] jobs: build: runs-on: ubuntu-latest + defaults: + run: + shell: bash + working-directory: doc steps: - - name: Checkout repo - uses: actions/checkout@v2 - name: Check doc links - working-directory: doc run: | sphinx-build . -b linkcheck -d _build/doctrees _build/html From 49660ed6172c042b8b7b89122d5220249312c3be Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Tue, 27 Sep 2022 10:39:31 +0200 Subject: [PATCH 045/119] Update docs-check.yml --- .github/workflows/docs-check.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index d48125eb6..3f2cba214 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -4,11 +4,11 @@ on: [push] jobs: build: runs-on: ubuntu-latest - defaults: - run: - shell: bash - working-directory: doc steps: + - name: Check out repository + uses: actions/checkout@v3 + - name: Use local my-action + uses: ./doc/conf.py - name: Check doc links run: | sphinx-build . -b linkcheck -d _build/doctrees _build/html From a68c17edab7f538639875e3716e4408df4156322 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Tue, 27 Sep 2022 10:45:55 +0200 Subject: [PATCH 046/119] Update docs-check.yml --- .github/workflows/docs-check.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index 3f2cba214..8287ed315 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -5,10 +5,11 @@ jobs: build: runs-on: ubuntu-latest steps: - - name: Check out repository - uses: actions/checkout@v3 - - name: Use local my-action - uses: ./doc/conf.py + - name: Display the path + run: | + import os + print(os.environ['PATH']) + shell: python - name: Check doc links run: | sphinx-build . -b linkcheck -d _build/doctrees _build/html From 09b75abc106a7a1240cf351ac33e152a5848e86e Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Tue, 27 Sep 2022 10:47:14 +0200 Subject: [PATCH 047/119] Update docs-check.yml --- .github/workflows/docs-check.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index 8287ed315..bbc20ee89 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -5,11 +5,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - name: Display the path - run: | - import os - print(os.environ['PATH']) - shell: python - name: Check doc links run: | sphinx-build . -b linkcheck -d _build/doctrees _build/html + shell: python From 214d38156255d737768b04d549adc91d7375494b Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Tue, 27 Sep 2022 10:57:25 +0200 Subject: [PATCH 048/119] Update docs-check.yml --- .github/workflows/docs-check.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index bbc20ee89..a91b3638a 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -5,7 +5,8 @@ jobs: build: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v3 - name: Check doc links run: | sphinx-build . -b linkcheck -d _build/doctrees _build/html - shell: python + working-directory: doc From 179e0378e2a8eaeb9dedb5635b04a6c3f16075ad Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Tue, 27 Sep 2022 11:00:22 +0200 Subject: [PATCH 049/119] Update docs-check.yml --- .github/workflows/docs-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index a91b3638a..1eaaabc90 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -9,4 +9,4 @@ jobs: - name: Check doc links run: | sphinx-build . -b linkcheck -d _build/doctrees _build/html - working-directory: doc + working-directory: ./doc From 843f269cbff09b2d307d0a6c0e17cc3200c83956 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Tue, 27 Sep 2022 11:15:18 +0200 Subject: [PATCH 050/119] Update docs-check.yml --- .github/workflows/docs-check.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index 1eaaabc90..c83c829b9 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -6,6 +6,13 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: 16.13.x + cache: npm + - name: Install + run: npm ci - name: Check doc links run: | sphinx-build . -b linkcheck -d _build/doctrees _build/html From 176de0f061af02c9cdd679d0324e3333da8f2ffe Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Tue, 27 Sep 2022 11:18:08 +0200 Subject: [PATCH 051/119] Update docs-check.yml --- .github/workflows/docs-check.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index c83c829b9..1eaaabc90 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -6,13 +6,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: 16.13.x - cache: npm - - name: Install - run: npm ci - name: Check doc links run: | sphinx-build . -b linkcheck -d _build/doctrees _build/html From 7bed5865d97f9a76e04314dec047d5da85238803 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Wed, 28 Sep 2022 05:38:04 +0200 Subject: [PATCH 052/119] Update dev_notes.rst Added description of how to check external links in doc --- doc/dev_notes.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/doc/dev_notes.rst b/doc/dev_notes.rst index a0bf6d811..b05a23a7a 100644 --- a/doc/dev_notes.rst +++ b/doc/dev_notes.rst @@ -82,3 +82,17 @@ And then you build the html docs on your computer with .. code-block:: bash sphinx-build -E -a doc/ doc/_html + +To check if external links in the documentation work, change into the doc repository + +.. code-block:: bash + + cd doc + +and run the following command + +.. code-block:: bash + + sphinx-build . -b linkcheck -d _build/doctrees _build/html + + From 4f5dae3f13e7e14596da6759e0829cf2d309731a Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Thu, 29 Sep 2022 19:52:26 +0200 Subject: [PATCH 053/119] Update docs-check.yml --- .github/workflows/docs-check.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index 1eaaabc90..63f3d078c 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -8,5 +8,6 @@ jobs: - uses: actions/checkout@v3 - name: Check doc links run: | + apt-get install python3-sphinx sphinx-build . -b linkcheck -d _build/doctrees _build/html working-directory: ./doc From 76d20c235120c9bb2271e3a232d215ba27e7cc02 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Thu, 29 Sep 2022 20:00:31 +0200 Subject: [PATCH 054/119] Update docs-check.yml --- .github/workflows/docs-check.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index 63f3d078c..f25a8cf7d 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -8,6 +8,7 @@ jobs: - uses: actions/checkout@v3 - name: Check doc links run: | - apt-get install python3-sphinx + sudo apt-get update + sudo apt-get install python3-sphinx sphinx-build . -b linkcheck -d _build/doctrees _build/html working-directory: ./doc From 8259009783c18d022ea674c8ae9470ee4eaf7d15 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Thu, 29 Sep 2022 20:03:35 +0200 Subject: [PATCH 055/119] Update docs-check.yml --- .github/workflows/docs-check.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index f25a8cf7d..4d8f9953d 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -6,6 +6,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - name: Install dependencies + run: | + sudo apt install pandoc + python -m pip install --upgrade pip + pip install -r rtd_requirements.txt - name: Check doc links run: | sudo apt-get update From f7e22882b18fab333ff12808135bd3ad5d64e7c9 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Thu, 29 Sep 2022 20:09:38 +0200 Subject: [PATCH 056/119] Add files via upload --- rtd_requirements.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 rtd_requirements.txt diff --git a/rtd_requirements.txt b/rtd_requirements.txt new file mode 100644 index 000000000..afc7a3f38 --- /dev/null +++ b/rtd_requirements.txt @@ -0,0 +1,22 @@ +demandlib +networkx >= 2.5.0 +geopy >= 2.0.0 +pandas >= 1.2.0 +pyproj >= 3.0.0 +pypsa >=0.17.0 +pyomo >= 6.0 +multiprocess +workalendar +egoio >= 0.4.7 +matplotlib >= 3.3.0 +pypower +sklearn +beautifulsoup4 +plotly +dash == 2.6.0 +werkzeug==2.2.0 +jupyter_dash +docutils == 0.16.0 +sphinx >= 4.3.0, < 5.1.0 +sphinx_rtd_theme >=0.5.2 +sphinx-autodoc-typehints From c7a53fa094da29f543dc0da7881c7003c9eb9798 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Thu, 29 Sep 2022 20:13:30 +0200 Subject: [PATCH 057/119] Update docs-check.yml --- .github/workflows/docs-check.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml index 4d8f9953d..0f188ab70 100644 --- a/.github/workflows/docs-check.yml +++ b/.github/workflows/docs-check.yml @@ -13,7 +13,5 @@ jobs: pip install -r rtd_requirements.txt - name: Check doc links run: | - sudo apt-get update - sudo apt-get install python3-sphinx sphinx-build . -b linkcheck -d _build/doctrees _build/html working-directory: ./doc From 454c2e18b7c4f2f3ec4677092757a1fc546587ad Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Fri, 30 Sep 2022 06:03:32 +0200 Subject: [PATCH 058/119] Delete requirements.txt --- doc/requirements.txt | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 doc/requirements.txt diff --git a/doc/requirements.txt b/doc/requirements.txt deleted file mode 100644 index 34b13a347..000000000 --- a/doc/requirements.txt +++ /dev/null @@ -1,22 +0,0 @@ -demandlib -networkx >= 2.5.0 -geopy >= 2.0.0 -pandas >= 1.2.0 -pyproj >= 3.0.0 -pypsa >=0.17.0 -pyomo >= 6.0 -multiprocess -workalendar -egoio >= 0.4.7 -matplotlib >= 3.3.0 -plotly -dash == 2.0.0 -werkzeug==2.0.3 -jupyter_dash -pypower -sklearn -docutils == 0.16.0 -sphinx >= 4.3.0, < 5.1.0 -sphinx_rtd_theme >=0.5.2 -sphinx-autodoc-typehints -geopandas >= 0.9.0 From 2ef0c1c6fe781700c4a2c4da747dba8db411cd41 Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Fri, 30 Sep 2022 06:12:04 +0200 Subject: [PATCH 059/119] Update rtd_requirements.txt --- rtd_requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/rtd_requirements.txt b/rtd_requirements.txt index afc7a3f38..27cd554b2 100644 --- a/rtd_requirements.txt +++ b/rtd_requirements.txt @@ -20,3 +20,4 @@ docutils == 0.16.0 sphinx >= 4.3.0, < 5.1.0 sphinx_rtd_theme >=0.5.2 sphinx-autodoc-typehints +geopandas From eabb1df5b9f3d79d4dba7b74ab8da216eb209f29 Mon Sep 17 00:00:00 2001 From: Maike Held Date: Fri, 30 Sep 2022 06:46:06 +0200 Subject: [PATCH 060/119] Corrected links --- doc/conf.py | 2 +- edisgo/network/components.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 688f95197..509a3e151 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -73,7 +73,7 @@ # Dictionary of external links extlinks = { "pandas": ( - "http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.%s.html", + "https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.%s.html", "pandas.", ), "geopandas": ( diff --git a/edisgo/network/components.py b/edisgo/network/components.py index 601471666..e04c019bc 100644 --- a/edisgo/network/components.py +++ b/edisgo/network/components.py @@ -200,7 +200,7 @@ def _network_component_df(self): Returns -------- - :pandas:`pandas.DataFrame` + :pandas:`pandas.DataFrame` See :attr:`~.network.topology.Topology.loads_df` for more information. """ From 6d70cb8facf284cfabc782516d0aebed67425bed Mon Sep 17 00:00:00 2001 From: Maike Held Date: Fri, 30 Sep 2022 07:08:55 +0200 Subject: [PATCH 061/119] Corrected links --- edisgo/io/electromobility_import.py | 2 +- edisgo/network/components.py | 6 +++--- edisgo/network/topology.py | 7 ++++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/edisgo/io/electromobility_import.py b/edisgo/io/electromobility_import.py index 20ba4d708..b03d7a4eb 100644 --- a/edisgo/io/electromobility_import.py +++ b/edisgo/io/electromobility_import.py @@ -306,7 +306,7 @@ def read_gpkg_potential_charging_parks(path, edisgo_obj, **kwargs): Returns ------- - :geopandas:`geodataframe` + :geopandas:`GeoDataFrame` GeoDataFrame with AGS, charging use case (home, work, public or hpc), user centric weight and geometry. diff --git a/edisgo/network/components.py b/edisgo/network/components.py index e04c019bc..3dbc3e9af 100644 --- a/edisgo/network/components.py +++ b/edisgo/network/components.py @@ -330,7 +330,7 @@ def _network_component_df(self): Returns -------- - :pandas:`pandas.DataFrame` + :pandas:`pandas.DataFrame` See :attr:`~.network.topology.Topology.generators_df` for more information. @@ -486,7 +486,7 @@ def _network_component_df(self): Returns -------- - :pandas:`pandas.DataFrame` + :pandas:`pandas.DataFrame` See :attr:`~.network.topology.Topology.storage_units_df` for more information. @@ -583,7 +583,7 @@ def _network_component_df(self): Returns -------- - :pandas:`pandas.DataFrame` + :pandas:`pandas.DataFrame` See :attr:`~.network.topology.Topology.switches_df` for more information. diff --git a/edisgo/network/topology.py b/edisgo/network/topology.py index 382388a1d..5a03cbe78 100755 --- a/edisgo/network/topology.py +++ b/edisgo/network/topology.py @@ -1607,7 +1607,7 @@ def update_number_of_parallel_lines(self, lines_num_parallel): Parameters ------------ - lines_num_parallel : :pandas:`pandas.Series` + lines_num_parallel : :pandas:`pandas.Series` Index contains identifiers of lines to update as in index of :py:attr:`~lines_df` and values of series contain corresponding new number of parallel lines. @@ -2412,6 +2412,11 @@ def _connect_mv_bus_to_target_object( return target_obj["repr"] + # ToDo: :networkx:`networkx.Graph` doesn't exist anymore because: + # "The ordered variants of graph classes in this module are deprecated and will be + # removed in version 3.0." + # Changed link to :networkx:`networkx.Graph<>` + # Needs to be verified if that is correct def to_graph(self): """ Returns graph representation of the grid. From a1feb74fd28c51addfeea922d2601dc38ab1abf4 Mon Sep 17 00:00:00 2001 From: Maike Held Date: Fri, 30 Sep 2022 07:18:02 +0200 Subject: [PATCH 062/119] Corrected links --- edisgo/edisgo.py | 12 ++++++------ edisgo/network/grids.py | 2 +- edisgo/network/results.py | 2 +- edisgo/network/topology.py | 3 ++- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/edisgo/edisgo.py b/edisgo/edisgo.py index 6a7f5edc5..90754700e 100755 --- a/edisgo/edisgo.py +++ b/edisgo/edisgo.py @@ -435,15 +435,15 @@ def set_time_series_reactive_power_control( Type of reactive power control to apply. Currently the only option is 'fixed_coshpi'. See :func:`~.network.timeseries.TimeSeries.fixed_cosphi` for further information. - generators_parametrisation : str or :pandas:`pandas.DataFrame` + generators_parametrisation : str or :pandas:`pandas.DataFrame` See parameter `generators_parametrisation` in :func:`~.network.timeseries.TimeSeries.fixed_cosphi` for further information. Here, per default, the option 'default' is used. - loads_parametrisation : str or :pandas:`pandas.DataFrame` + loads_parametrisation : str or :pandas:`pandas.DataFrame` See parameter `loads_parametrisation` in :func:`~.network.timeseries.TimeSeries.fixed_cosphi` for further information. Here, per default, the option 'default' is used. - storage_units_parametrisation : str or :pandas:`pandas.DataFrame` + storage_units_parametrisation : str or :pandas:`pandas.DataFrame` See parameter `storage_units_parametrisation` in :func:`~.network.timeseries.TimeSeries.fixed_cosphi` for further information. Here, per default, the option 'default' is used. @@ -997,16 +997,16 @@ def add_component( comp_type : str Type of added component. Can be 'bus', 'line', 'load', 'generator', or 'storage_unit'. - ts_active_power : :pandas:`pandas.Series` or None + ts_active_power : :pandas:`pandas.Series` or None Active power time series of added component. Index of the series must contain all time steps in :attr:`~.network.timeseries.TimeSeries.timeindex`. Values are active power per time step in MW. Defaults to None in which case no time series is set. - ts_reactive_power : :pandas:`pandas.Series` or str or None + ts_reactive_power : :pandas:`pandas.Series` or str or None Possible options are: - * :pandas:`pandas.Series` + * :pandas:`pandas.Series` Reactive power time series of added component. Index of the series must contain all time steps in diff --git a/edisgo/network/grids.py b/edisgo/network/grids.py index d2dcfc082..e6a948574 100644 --- a/edisgo/network/grids.py +++ b/edisgo/network/grids.py @@ -79,7 +79,7 @@ def graph(self): Returns ------- - :networkx:`networkx.Graph` + :networkx:`networkx.Graph<>` Graph representation of the grid as networkx Ordered Graph, where lines are represented by edges in the graph, and buses and transformers are represented by nodes. diff --git a/edisgo/network/results.py b/edisgo/network/results.py index 29e717902..5f98506da 100755 --- a/edisgo/network/results.py +++ b/edisgo/network/results.py @@ -323,7 +323,7 @@ def equipment_changes(self): Returns ------- - :pandas:`pandas.DataFrame` + :pandas:`pandas.DataFrame` Dataframe holding information on added, changed and removed lines and transformers. For more information on the dataframe see input parameter `df`. diff --git a/edisgo/network/topology.py b/edisgo/network/topology.py index 5a03cbe78..8a97390f4 100755 --- a/edisgo/network/topology.py +++ b/edisgo/network/topology.py @@ -2417,13 +2417,14 @@ def _connect_mv_bus_to_target_object( # removed in version 3.0." # Changed link to :networkx:`networkx.Graph<>` # Needs to be verified if that is correct + # Same problem in network.grids line 82 def to_graph(self): """ Returns graph representation of the grid. Returns ------- - :networkx:`networkx.Graph` + :networkx:`networkx.Graph<>` Graph representation of the grid as networkx Ordered Graph, where lines are represented by edges in the graph, and buses and transformers are represented by nodes. From 42b792db34877ec6dbb50c1016892936575da1f8 Mon Sep 17 00:00:00 2001 From: Maike Held Date: Fri, 30 Sep 2022 07:29:18 +0200 Subject: [PATCH 063/119] Corrected links --- edisgo/io/pypsa_io.py | 1 - edisgo/network/components.py | 2 +- edisgo/network/timeseries.py | 14 +++++++------- edisgo/network/topology.py | 2 +- edisgo/tools/networkx_helper.py | 2 +- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/edisgo/io/pypsa_io.py b/edisgo/io/pypsa_io.py index 4f3e2df3a..a774992e8 100755 --- a/edisgo/io/pypsa_io.py +++ b/edisgo/io/pypsa_io.py @@ -805,7 +805,6 @@ def process_pfa_results(edisgo, pypsa, timesteps, dtype="float"): edisgo : :class:`~.EDisGo` pypsa : :pypsa:`pypsa.Network` The PyPSA `Network container - `_ timesteps : :pandas:`pandas.DatetimeIndex` or \ :pandas:`pandas.Timestamp` Time steps for which latest power flow analysis was conducted and diff --git a/edisgo/network/components.py b/edisgo/network/components.py index 3dbc3e9af..980fe58a4 100644 --- a/edisgo/network/components.py +++ b/edisgo/network/components.py @@ -583,7 +583,7 @@ def _network_component_df(self): Returns -------- - :pandas:`pandas.DataFrame` + :pandas:`pandas.DataFrame` See :attr:`~.network.topology.Topology.switches_df` for more information. diff --git a/edisgo/network/timeseries.py b/edisgo/network/timeseries.py index d8abbfad8..bae29f29f 100644 --- a/edisgo/network/timeseries.py +++ b/edisgo/network/timeseries.py @@ -1199,7 +1199,7 @@ def predefined_fluctuating_generators_by_technology( Parameters ---------- edisgo_object : :class:`~.EDisGo` - ts_generators : str or :pandas:`pandas.DataFrame` + ts_generators : str or :pandas:`pandas.DataFrame` Defines which technology-specific or technology and weather cell specific active power time series to use. Possible options are: @@ -1214,7 +1214,7 @@ def predefined_fluctuating_generators_by_technology( :func:`edisgo.io.timeseries_import.import_feedin_timeseries` for more information. - * :pandas:`pandas.DataFrame` + * :pandas:`pandas.DataFrame` DataFrame with self-provided feed-in time series per technology or per technology and weather cell ID normalized to a nominal capacity @@ -1330,7 +1330,7 @@ def predefined_dispatchable_generators_by_technology( Parameters ---------- edisgo_object : :class:`~.EDisGo` - ts_generators : :pandas:`pandas.DataFrame` + ts_generators : :pandas:`pandas.DataFrame` DataFrame with self-provided active power time series of each type of dispatchable generator normalized to a nominal capacity of 1. Columns contain the technology type as string, e.g. 'gas', 'coal'. @@ -1563,7 +1563,7 @@ def fixed_cosphi( Parameters ----------- - generators_parametrisation : str or :pandas:`pandas.DataFrame` or \ + generators_parametrisation : str or :pandas:`pandas.DataFrame` or \ None Sets fixed cosphi parameters for generators. Possible options are: @@ -1575,7 +1575,7 @@ def fixed_cosphi( components behave inductive or capacitive, given in the config section `reactive_power_mode`, are used. - * :pandas:`pandas.DataFrame` + * :pandas:`pandas.DataFrame` DataFrame with fix cosphi parametrisation for specified generators. Columns are: @@ -1602,10 +1602,10 @@ def fixed_cosphi( No reactive power time series are set. Default: None. - loads_parametrisation : str or :pandas:`pandas.DataFrame` or None + loads_parametrisation : str or :pandas:`pandas.DataFrame` or None Sets fixed cosphi parameters for loads. The same options as for parameter `generators_parametrisation` apply. - storage_units_parametrisation : str or :pandas:`pandas.DataFrame` \ + storage_units_parametrisation : str or :pandas:`pandas.DataFrame` \ or None Sets fixed cosphi parameters for storage units. The same options as for parameter `generators_parametrisation` apply. diff --git a/edisgo/network/topology.py b/edisgo/network/topology.py index 8a97390f4..52509b719 100755 --- a/edisgo/network/topology.py +++ b/edisgo/network/topology.py @@ -2417,7 +2417,7 @@ def _connect_mv_bus_to_target_object( # removed in version 3.0." # Changed link to :networkx:`networkx.Graph<>` # Needs to be verified if that is correct - # Same problem in network.grids line 82 + # Same problem in network.grids line 82 and tools.networkx_helper line 30 def to_graph(self): """ Returns graph representation of the grid. diff --git a/edisgo/tools/networkx_helper.py b/edisgo/tools/networkx_helper.py index c352fca9a..38fedfb75 100644 --- a/edisgo/tools/networkx_helper.py +++ b/edisgo/tools/networkx_helper.py @@ -27,7 +27,7 @@ def translate_df_to_graph( Returns ------- - :networkx:`networkx.Graph` + :networkx:`networkx.Graph<>` Graph representation of the grid as networkx Ordered Graph, where lines are represented by edges in the graph, and buses and transformers are represented by nodes. From 7f0a9c48766fc6c41734ad54d54a98d8b4100e01 Mon Sep 17 00:00:00 2001 From: Maike Held Date: Fri, 30 Sep 2022 07:46:07 +0200 Subject: [PATCH 064/119] Corrected links --- edisgo/network/topology.py | 3 ++- edisgo/tools/plots.py | 2 +- edisgo/tools/pseudo_coordinates.py | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/edisgo/network/topology.py b/edisgo/network/topology.py index 52509b719..81d3ede4d 100755 --- a/edisgo/network/topology.py +++ b/edisgo/network/topology.py @@ -2417,7 +2417,8 @@ def _connect_mv_bus_to_target_object( # removed in version 3.0." # Changed link to :networkx:`networkx.Graph<>` # Needs to be verified if that is correct - # Same problem in network.grids line 82 and tools.networkx_helper line 30 + # Same problem in network.grids line 82 and tools.networkx_helper line 30, + # tools.plots line 1444, tools.pseudo_coordinates lines 33, 41, 201, 209 def to_graph(self): """ Returns graph representation of the grid. diff --git a/edisgo/tools/plots.py b/edisgo/tools/plots.py index 07c040422..e069e9879 100644 --- a/edisgo/tools/plots.py +++ b/edisgo/tools/plots.py @@ -1441,7 +1441,7 @@ def chosen_graph( Returns ------- - (:networkx:`networkx.Graph`, :class:`~.network.grids.Grid` or bool) + (:networkx:`networkx.Graph<>`, :class:`~.network.grids.Grid` or bool) Tuple with the first entry being the networkx graph of the selected grid and the second entry the grid to use as root node. See :py:func:`~edisgo.tools.plots.draw_plotly` for more information. diff --git a/edisgo/tools/pseudo_coordinates.py b/edisgo/tools/pseudo_coordinates.py index a42654ec9..8d0f7cfe9 100644 --- a/edisgo/tools/pseudo_coordinates.py +++ b/edisgo/tools/pseudo_coordinates.py @@ -30,7 +30,7 @@ def _make_coordinates(graph_root: Graph, branch_detour_factor: float) -> Graph: Parameters ---------- - graph_root : :networkx:`networkx.Graph` + graph_root : :networkx:`networkx.Graph<>` Graph object to generate pseudo coordinates for (with equidistant coordinates). branch_detour_factor : float @@ -38,7 +38,7 @@ def _make_coordinates(graph_root: Graph, branch_detour_factor: float) -> Graph: Returns ------- - :networkx:`networkx.Graph` + :networkx:`networkx.Graph<>` Graph with equidistant pseudo coordinates for all nodes. """ @@ -198,7 +198,7 @@ def make_pseudo_coordinates_graph(G: Graph, branch_detour_factor: float) -> Grap Parameters ---------- - G : :networkx:`networkx.Graph` + G : :networkx:`networkx.Graph<>` Graph object to generate pseudo coordinates for. branch_detour_factor : float @@ -206,7 +206,7 @@ def make_pseudo_coordinates_graph(G: Graph, branch_detour_factor: float) -> Grap Returns ------- - :networkx:`networkx.Graph` + :networkx:`networkx.Graph<>` Graph with pseudo coordinates for all nodes. """ From 4ba80c83a9894c8f67142e0b6dbbf8112868ae8c Mon Sep 17 00:00:00 2001 From: Maike Held Date: Fri, 30 Sep 2022 09:30:40 +0200 Subject: [PATCH 065/119] Corrected links --- edisgo/edisgo.py | 2 +- edisgo/network/timeseries.py | 2 +- edisgo/network/topology.py | 3 ++- edisgo/tools/plots.py | 10 +++++----- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/edisgo/edisgo.py b/edisgo/edisgo.py index 90754700e..43bd56fb6 100755 --- a/edisgo/edisgo.py +++ b/edisgo/edisgo.py @@ -610,7 +610,7 @@ def to_graph(self): Returns ------- - :networkx:`networkx.Graph` + :networkx:`networkx.Graph<>` Graph representation of the grid as networkx Ordered Graph, where lines are represented by edges in the graph, and buses and transformers are represented by nodes. diff --git a/edisgo/network/timeseries.py b/edisgo/network/timeseries.py index bae29f29f..a1b5aa05f 100644 --- a/edisgo/network/timeseries.py +++ b/edisgo/network/timeseries.py @@ -1330,7 +1330,7 @@ def predefined_dispatchable_generators_by_technology( Parameters ---------- edisgo_object : :class:`~.EDisGo` - ts_generators : :pandas:`pandas.DataFrame` + ts_generators : :pandas:`pandas.DataFrame` DataFrame with self-provided active power time series of each type of dispatchable generator normalized to a nominal capacity of 1. Columns contain the technology type as string, e.g. 'gas', 'coal'. diff --git a/edisgo/network/topology.py b/edisgo/network/topology.py index 81d3ede4d..a2d2861a6 100755 --- a/edisgo/network/topology.py +++ b/edisgo/network/topology.py @@ -2418,7 +2418,8 @@ def _connect_mv_bus_to_target_object( # Changed link to :networkx:`networkx.Graph<>` # Needs to be verified if that is correct # Same problem in network.grids line 82 and tools.networkx_helper line 30, - # tools.plots line 1444, tools.pseudo_coordinates lines 33, 41, 201, 209 + # tools.plots line 1444, tools.pseudo_coordinates lines 33, 41, 201, 209, + # edisgo line 613 def to_graph(self): """ Returns graph representation of the grid. diff --git a/edisgo/tools/plots.py b/edisgo/tools/plots.py index e069e9879..85eca050a 100644 --- a/edisgo/tools/plots.py +++ b/edisgo/tools/plots.py @@ -53,7 +53,7 @@ def histogram(data, **kwargs): Parameters ---------- - data : :pandas:`pandas.DataFrame` + data : :pandas:`pandas.DataFrame` Data to be plotted, e.g. voltage or current (`v_res` or `i_res` from :class:`network.results.Results`). Index of the dataframe must be a :pandas:`pandas.DatetimeIndex`. @@ -300,12 +300,12 @@ def mv_grid_topology( * 'charging_park' Plots nodes with charging stations in red. - line_load : :pandas:`pandas.DataFrame` or None + line_load : :pandas:`pandas.DataFrame` or None Dataframe with current results from power flow analysis in A. Index of the dataframe is a :pandas:`pandas.DatetimeIndex`, columns are the line representatives. Only needs to be provided when parameter `line_color` is set to 'loading'. Default: None. - grid_expansion_costs : :pandas:`pandas.DataFrame` or None + grid_expansion_costs : :pandas:`pandas.DataFrame` or None Dataframe with network expansion costs in kEUR. See `grid_expansion_costs` in :class:`~.network.results.Results` for more information. Only needs to be provided when parameter `line_color` is set to 'expansion_costs'. @@ -324,7 +324,7 @@ def mv_grid_topology( background_map : :obj:`Boolean` If True map is drawn in the background. This also requires the contextily package to be installed. Default: True. - voltage : :pandas:`pandas.DataFrame` + voltage : :pandas:`pandas.DataFrame` Dataframe with voltage results from power flow analysis in p.u.. Index of the dataframe is a :pandas:`pandas.DatetimeIndex`, columns are the bus representatives. Only needs to be provided when @@ -350,7 +350,7 @@ def mv_grid_topology( If provided line width is set according to the nominal apparent power of the lines. If line width is None a default line width of 2 is used for each line. Default: None. - curtailment_df : :pandas:`pandas.DataFrame` + curtailment_df : :pandas:`pandas.DataFrame` Dataframe with curtailed power per time step and node. Columns of the dataframe correspond to buses and index to the time step. Only needs to be provided if `node_color` is set to 'curtailment'. From 6c56a9a41e6e40f4dc611a8cb22807fc9822528f Mon Sep 17 00:00:00 2001 From: maike93he <56869935+maike93he@users.noreply.github.com> Date: Fri, 30 Sep 2022 09:31:06 +0200 Subject: [PATCH 066/119] Update quickstart.rst --- doc/quickstart.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/quickstart.rst b/doc/quickstart.rst index 035ea4988..0e70ca6f6 100644 --- a/doc/quickstart.rst +++ b/doc/quickstart.rst @@ -182,7 +182,7 @@ details are provided in :ref:`usage-details`. Further examples can be found in t All following examples assume you have a ding0 grid topology (directory containing csv files, defining the grid topology) in a directory "ding0_example_grid" in the directory from where you run your example. If you do not have an example grid, you -can download one `here `_. +can download one `here `_. Aside from grid topology data you may eventually need a dataset on future installation of power plants. You may therefore use the scenarios developed in From 4f250f4dad2c755de65e27f5d09d830fa60b3fe8 Mon Sep 17 00:00:00 2001 From: Maike Held Date: Fri, 30 Sep 2022 14:05:28 +0200 Subject: [PATCH 067/119] Corrected links --- doc/usage_details.rst | 2 +- edisgo/io/pypsa_io.py | 2 +- edisgo/network/topology.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/usage_details.rst b/doc/usage_details.rst index 42795d644..32f2b644c 100644 --- a/doc/usage_details.rst +++ b/doc/usage_details.rst @@ -158,7 +158,7 @@ of the whole topology or each single grid can be retrieved as follows: # Get graph representation for LV grid lv_grid.graph -The returned graph is a :networkx:`networkx.Graph`, where lines are represented +The returned graph is a :networkx:`networkx.Graph<>`, where lines are represented by edges in the graph, and buses and transformers are represented by nodes. Component time series diff --git a/edisgo/io/pypsa_io.py b/edisgo/io/pypsa_io.py index a774992e8..3c438f414 100755 --- a/edisgo/io/pypsa_io.py +++ b/edisgo/io/pypsa_io.py @@ -347,7 +347,7 @@ def set_seed(edisgo_obj, pypsa_network): """ Set initial guess for the Newton-Raphson algorithm. - In `PyPSA `_ an + In `PyPSA `_ an initial guess for the Newton-Raphson algorithm used in the power flow analysis can be provided to speed up calculations. For PQ buses, which besides the slack bus, is the only bus type in diff --git a/edisgo/network/topology.py b/edisgo/network/topology.py index a2d2861a6..9e79ed4f1 100755 --- a/edisgo/network/topology.py +++ b/edisgo/network/topology.py @@ -2419,7 +2419,7 @@ def _connect_mv_bus_to_target_object( # Needs to be verified if that is correct # Same problem in network.grids line 82 and tools.networkx_helper line 30, # tools.plots line 1444, tools.pseudo_coordinates lines 33, 41, 201, 209, - # edisgo line 613 + # edisgo line 613, usage_details.rst line 161 def to_graph(self): """ Returns graph representation of the grid. From e903183ed8b6fae8b40707080ce2e01d2d827c87 Mon Sep 17 00:00:00 2001 From: Kilian Helfenbein Date: Fri, 4 Nov 2022 13:29:20 +0100 Subject: [PATCH 068/119] if the step size of the time series of the edisgo object differs from the simbev step size, the edisgo time series is now resampled when apllying an charging strategy --- edisgo/edisgo.py | 5 +++++ edisgo/flex_opt/charging_strategies.py | 15 +++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/edisgo/edisgo.py b/edisgo/edisgo.py index 55797eb97..18b19b1a5 100755 --- a/edisgo/edisgo.py +++ b/edisgo/edisgo.py @@ -1559,6 +1559,11 @@ def apply_charging_strategy(self, strategy="dumb", **kwargs): in :attr:`~.network.timeseries.TimeSeries.loads_reactive_power` is set to 0 Mvar. + If the time series of the edisgo object and the SimBEV data are provided with + different time steps, then the time series of the edisgo object are + automatically resampled to match the SimBEV data. See + :func:`edisgo.apply_charging_strategy`. + Parameters ---------- strategy : str diff --git a/edisgo/flex_opt/charging_strategies.py b/edisgo/flex_opt/charging_strategies.py index 9946fc227..91e0e2d8f 100644 --- a/edisgo/flex_opt/charging_strategies.py +++ b/edisgo/flex_opt/charging_strategies.py @@ -107,12 +107,15 @@ def charging_strategy( ) simbev_timedelta = timeindex[1] - timeindex[0] - assert edisgo_timedelta == simbev_timedelta, ( - "The step size of the time series of the edisgo object differs from the" - f"simbev step size. The edisgo time delta is {edisgo_timedelta}, while" - f" the simbev time delta is {simbev_timedelta}. Make sure to use a " - f"matching step size." - ) + if edisgo_timedelta != simbev_timedelta: + logger.warning( + "The step size of the time series of the edisgo object differs from the" + f"simbev step size. The edisgo time delta is {edisgo_timedelta}, while" + f" the simbev time delta is {simbev_timedelta}. The edisgo time series " + f"will be resampled accordingly." + ) + + edisgo_obj.resample_timeseries(freq=f"{edisgo_obj.electromobility.stepsize}Min") if strategy == "dumb": # "dumb" charging From a7dbd807d5a031c58e5c1dc092a897ff892ff3e7 Mon Sep 17 00:00:00 2001 From: Kilian Helfenbein Date: Fri, 4 Nov 2022 13:33:49 +0100 Subject: [PATCH 069/119] test new code fragment; added type hinting --- edisgo/flex_opt/charging_strategies.py | 16 ++++++++++++---- tests/flex_opt/test_charging_strategy.py | 1 - 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/edisgo/flex_opt/charging_strategies.py b/edisgo/flex_opt/charging_strategies.py index 91e0e2d8f..065b91737 100644 --- a/edisgo/flex_opt/charging_strategies.py +++ b/edisgo/flex_opt/charging_strategies.py @@ -1,8 +1,16 @@ +from __future__ import annotations + import logging +from numbers import Number +from typing import TYPE_CHECKING + import numpy as np import pandas as pd +if TYPE_CHECKING: + from edisgo import EDisGo + RELEVANT_CHARGING_STRATEGIES_COLUMNS = { "dumb": [ "park_start_timesteps", @@ -40,10 +48,10 @@ # wrong results if the timeindex of the edisgo object is not continuously # (e.g. 2 weeks of the year) def charging_strategy( - edisgo_obj, - strategy="dumb", - timestamp_share_threshold=0.2, - minimum_charging_capacity_factor=0.1, + edisgo_obj: EDisGo, + strategy: str = "dumb", + timestamp_share_threshold: Number = 0.2, + minimum_charging_capacity_factor: Number = 0.1, ): """ Applies charging strategy to set EV charging time series at charging parks. diff --git a/tests/flex_opt/test_charging_strategy.py b/tests/flex_opt/test_charging_strategy.py index 8908a30c2..4731138b4 100644 --- a/tests/flex_opt/test_charging_strategy.py +++ b/tests/flex_opt/test_charging_strategy.py @@ -23,7 +23,6 @@ def setup_class(cls): timeindex = pd.date_range("1/1/2011", periods=24 * 7, freq="H") cls.edisgo_obj.set_timeindex(timeindex) - cls.edisgo_obj.resample_timeseries() cls.edisgo_obj.import_electromobility(cls.simbev_path, cls.tracbev_path) def test_charging_strategy(self): From 3d85799962b09d2f39f10c2bd6b54d3ab0f71560 Mon Sep 17 00:00:00 2001 From: birgits Date: Wed, 9 Nov 2022 17:37:59 +0100 Subject: [PATCH 070/119] Adapt docstring --- edisgo/edisgo.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/edisgo/edisgo.py b/edisgo/edisgo.py index 18b19b1a5..7c7bc4a1e 100755 --- a/edisgo/edisgo.py +++ b/edisgo/edisgo.py @@ -1559,10 +1559,11 @@ def apply_charging_strategy(self, strategy="dumb", **kwargs): in :attr:`~.network.timeseries.TimeSeries.loads_reactive_power` is set to 0 Mvar. - If the time series of the edisgo object and the SimBEV data are provided with - different time steps, then the time series of the edisgo object are - automatically resampled to match the SimBEV data. See - :func:`edisgo.apply_charging_strategy`. + If the frequency of time series data in :class:`~.network.timeseries.TimeSeries` + (checked using :attr:`~.network.timeseries.timeindex`) differs from the + frequency of SimBEV data, then the time series in + :class:`~.network.timeseries.TimeSeries` automatically resampled to match the + SimBEV data frequency. Parameters ---------- From 25dca6e3f3778746fcc443b02a5bbbab25877b30 Mon Sep 17 00:00:00 2001 From: birgits Date: Wed, 9 Nov 2022 17:38:23 +0100 Subject: [PATCH 071/119] Add resampling test --- tests/network/test_timeseries.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/network/test_timeseries.py b/tests/network/test_timeseries.py index 9e276e1a6..cabd0047e 100644 --- a/tests/network/test_timeseries.py +++ b/tests/network/test_timeseries.py @@ -8,7 +8,11 @@ import pandas as pd import pytest -from pandas.util.testing import assert_frame_equal, assert_series_equal +from pandas.util.testing import ( + assert_frame_equal, + assert_index_equal, + assert_series_equal, +) from edisgo import EDisGo from edisgo.network import timeseries @@ -2317,6 +2321,7 @@ def test_resample_timeseries(self): len_timeindex_orig = len(self.edisgo.timeseries.timeindex) mean_value_orig = self.edisgo.timeseries.generators_active_power.mean() + index_orig = self.edisgo.timeseries.timeindex.copy() # test up-sampling self.edisgo.timeseries.resample_timeseries() @@ -2332,6 +2337,9 @@ def test_resample_timeseries(self): atol=1e-5, ) ).all() + # check if index is the same after resampled back + self.edisgo.timeseries.resample_timeseries(freq="1h") + assert_index_equal(self.edisgo.timeseries.timeindex, index_orig) # same tests for down-sampling self.edisgo.timeseries.resample_timeseries(freq="2h") From 3c01a2bc5b57a8ad1034eeb2e53b5f4f74202e14 Mon Sep 17 00:00:00 2001 From: Kilian Helfenbein Date: Thu, 10 Nov 2022 14:44:00 +0100 Subject: [PATCH 072/119] added new whatsnew file --- doc/whatsnew/v0-2-1.rst | 9 +++++++++ setup.py | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 doc/whatsnew/v0-2-1.rst diff --git a/doc/whatsnew/v0-2-1.rst b/doc/whatsnew/v0-2-1.rst new file mode 100644 index 000000000..776de4723 --- /dev/null +++ b/doc/whatsnew/v0-2-1.rst @@ -0,0 +1,9 @@ +Release v0.2.1 +================ + +Release date: , + +Changes +------- + +* diff --git a/setup.py b/setup.py index 00ad2f08d..322d08b22 100644 --- a/setup.py +++ b/setup.py @@ -78,7 +78,7 @@ def read(fname): setup( name="eDisGo", - version="0.2.0", + version="0.2.1dev", packages=find_packages(), url="https://github.com/openego/eDisGo", license="GNU Affero General Public License v3.0", From ccc2c19527d7d404cbf0049860fbd5c1cf437201 Mon Sep 17 00:00:00 2001 From: Birgit Schachler Date: Wed, 30 Nov 2022 17:14:09 +0100 Subject: [PATCH 073/119] Fix docstring --- edisgo/network/heat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edisgo/network/heat.py b/edisgo/network/heat.py index ba3d4d859..001c859d8 100644 --- a/edisgo/network/heat.py +++ b/edisgo/network/heat.py @@ -100,7 +100,7 @@ def thermal_storage_units_df(self): Charging and discharging efficiency in p.u.. state_of_charge_initial : float - Initial state of charge in MWh. + Initial state of charge in p.u.. Returns ------- From 541d9ceed98c8d2ad3c027731626d02d59d7fb3e Mon Sep 17 00:00:00 2001 From: Malte Jahn Date: Thu, 1 Dec 2022 15:18:36 +0100 Subject: [PATCH 074/119] Bugfix #342 - Changed pyomo version - Pyomo 6.4.3 makes problems with pypsa --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 322d08b22..c861120d2 100644 --- a/setup.py +++ b/setup.py @@ -39,7 +39,7 @@ def read(fname): "pyproj >= 3.0.0", "shapely >= 1.7.0", "pypsa >= 0.17.0, <= 0.20.1", - "pyomo >= 6.0", + "pyomo <= 6.4.2", # Problem with PyPSA 20.1 fixed in newest PyPSA release "multiprocess", "workalendar", "sqlalchemy < 1.4.0", From b7b31ad3eebf69ea57079c46211c441bb68833e5 Mon Sep 17 00:00:00 2001 From: Kilian Helfenbein Date: Tue, 3 Jan 2023 09:54:03 +0100 Subject: [PATCH 075/119] added re-resampling --- edisgo/edisgo.py | 4 +++- edisgo/flex_opt/charging_strategies.py | 13 ++++++++++--- edisgo/network/timeseries.py | 4 +++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/edisgo/edisgo.py b/edisgo/edisgo.py index 7c7bc4a1e..da9e654cd 100755 --- a/edisgo/edisgo.py +++ b/edisgo/edisgo.py @@ -2262,7 +2262,9 @@ def check_integrity(self): logging.info("Integrity check finished. Please pay attention to warnings.") - def resample_timeseries(self, method: str = "ffill", freq: str = "15min"): + def resample_timeseries( + self, method: str = "ffill", freq: str | pd.Timedelta = "15min" + ): """ Resamples all generator, load and storage time series to a desired resolution. diff --git a/edisgo/flex_opt/charging_strategies.py b/edisgo/flex_opt/charging_strategies.py index 065b91737..f607ef248 100644 --- a/edisgo/flex_opt/charging_strategies.py +++ b/edisgo/flex_opt/charging_strategies.py @@ -115,15 +115,19 @@ def charging_strategy( ) simbev_timedelta = timeindex[1] - timeindex[0] - if edisgo_timedelta != simbev_timedelta: + resample = edisgo_timedelta != simbev_timedelta + + if resample: logger.warning( "The step size of the time series of the edisgo object differs from the" f"simbev step size. The edisgo time delta is {edisgo_timedelta}, while" f" the simbev time delta is {simbev_timedelta}. The edisgo time series " - f"will be resampled accordingly." + f"will be resampled accordingly before applying the charging strategy. " + f"After applying the charging strategy the time series will be resampled " + f"to it's original state." ) - edisgo_obj.resample_timeseries(freq=f"{edisgo_obj.electromobility.stepsize}Min") + edisgo_obj.resample_timeseries(freq=simbev_timedelta) if strategy == "dumb": # "dumb" charging @@ -303,6 +307,9 @@ def charging_strategy( else: raise ValueError(f"Strategy {strategy} has not yet been implemented.") + if resample: + edisgo_obj.resample_timeseries(freq=edisgo_timedelta) + # set reactive power time series to 0 Mvar # fmt: off edisgo_obj.timeseries.add_component_time_series( diff --git a/edisgo/network/timeseries.py b/edisgo/network/timeseries.py index d5c58068b..7cba12179 100644 --- a/edisgo/network/timeseries.py +++ b/edisgo/network/timeseries.py @@ -2088,7 +2088,9 @@ def _check_if_components_exist( return set(component_names) - set(comps_not_in_network) return component_names - def resample_timeseries(self, method: str = "ffill", freq: str = "15min"): + def resample_timeseries( + self, method: str = "ffill", freq: str | pd.Timedelta = "15min" + ): """ Resamples all generator, load and storage time series to a desired resolution. From 1b07c5684b42161f9e6bcde601e6620f535dee2a Mon Sep 17 00:00:00 2001 From: birgits Date: Mon, 9 Jan 2023 20:08:07 +0100 Subject: [PATCH 076/119] Change type naming from loads to conventional_loads --- edisgo/flex_opt/q_control.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/edisgo/flex_opt/q_control.py b/edisgo/flex_opt/q_control.py index c36a325f1..a6e98578e 100644 --- a/edisgo/flex_opt/q_control.py +++ b/edisgo/flex_opt/q_control.py @@ -101,7 +101,7 @@ def _get_component_dict(): comp_dict = { "generators": "gen", "storage_units": "storage", - "loads": "load", + "conventional_loads": "load", "charging_points": "cp", "heat_pumps": "hp", } @@ -123,8 +123,8 @@ def _fixed_cosphi_default_power_factor(comp_df, component_type, configs): All components must have the same `component_type`. component_type : str The component type determines the reactive power factor and mode used. - Possible options are 'generators', 'storage_units', 'loads', 'charging_points', - and 'heat_pumps'. + Possible options are 'generators', 'storage_units', 'conventional_loads', + 'charging_points', and 'heat_pumps'. configs : :class:`~.tools.config.Config` eDisGo configuration data. @@ -150,8 +150,8 @@ def _fixed_cosphi_default_power_factor(comp_df, component_type, configs): else: raise ValueError( "Given 'component_type' is not valid. Valid options are " - "'generators','storage_units', 'loads', 'charging_points', and " - "'heat_pumps'." + "'generators','storage_units', 'conventional_loads', 'charging_points', " + "and 'heat_pumps'." ) @@ -170,8 +170,8 @@ def _fixed_cosphi_default_reactive_power_sign(comp_df, component_type, configs): All components must have the same `component_type`. component_type : str The component type determines the reactive power factor and mode used. - Possible options are 'generators', 'storage_units', 'loads', 'charging_points', - and 'heat_pumps'. + Possible options are 'generators', 'storage_units', 'conventional_loads', + 'charging_points', and 'heat_pumps'. configs : :class:`~.tools.config.Config` eDisGo configuration data. @@ -187,7 +187,7 @@ def _fixed_cosphi_default_reactive_power_sign(comp_df, component_type, configs): q_sign_dict = { "generators": get_q_sign_generator, "storage_units": get_q_sign_generator, - "loads": get_q_sign_load, + "conventional_loads": get_q_sign_load, "charging_points": get_q_sign_load, "heat_pumps": get_q_sign_load, } @@ -207,6 +207,6 @@ def _fixed_cosphi_default_reactive_power_sign(comp_df, component_type, configs): else: raise ValueError( "Given 'component_type' is not valid. Valid options are " - "'generators','storage_units', 'loads', 'charging_points', and " - "'heat_pumps'." + "'generators','storage_units', 'conventional_loads', 'charging_points', " + "and 'heat_pumps'." ) From 8730413222aa5aac1ac7f386df675c003e690385 Mon Sep 17 00:00:00 2001 From: birgits Date: Mon, 9 Jan 2023 20:09:04 +0100 Subject: [PATCH 077/119] Fix failing tests resulting from new type name --- tests/flex_opt/test_q_control.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/flex_opt/test_q_control.py b/tests/flex_opt/test_q_control.py index bba452920..daad21046 100644 --- a/tests/flex_opt/test_q_control.py +++ b/tests/flex_opt/test_q_control.py @@ -113,7 +113,7 @@ def test__fixed_cosphi_default_power_factor( # test for component_type="loads" pf = q_control._fixed_cosphi_default_power_factor( - comp_df=df, component_type="loads", configs=config + comp_df=df, component_type="conventional_loads", configs=config ) assert pf.shape == (3,) @@ -176,9 +176,9 @@ def test__fixed_cosphi_default_reactive_power_sign( [-1.0, -1.0, -1.0], ).all() - # test for component_type="loads" + # test for component_type="conventional_loads" pf = q_control._fixed_cosphi_default_reactive_power_sign( - comp_df=df, component_type="loads", configs=config + comp_df=df, component_type="conventional_loads", configs=config ) assert pf.shape == (3,) From 5ae537ebe3537b1b22284a4430db594b4336cc9b Mon Sep 17 00:00:00 2001 From: birgits Date: Mon, 9 Jan 2023 20:09:37 +0100 Subject: [PATCH 078/119] Bugfix differentiation of different load types when setting up reactive power time series --- edisgo/network/timeseries.py | 95 +++++++++++++++++++++++++++--------- 1 file changed, 71 insertions(+), 24 deletions(-) diff --git a/edisgo/network/timeseries.py b/edisgo/network/timeseries.py index d5c58068b..041290592 100644 --- a/edisgo/network/timeseries.py +++ b/edisgo/network/timeseries.py @@ -898,10 +898,10 @@ def _worst_case_conventional_load(self, cases, df, configs): # reactive power # get worst case configurations for each load power_factor = q_control._fixed_cosphi_default_power_factor( - df, "loads", configs + df, "conventional_loads", configs ) q_sign = q_control._fixed_cosphi_default_reactive_power_sign( - df, "loads", configs + df, "conventional_loads", configs ) # write reactive power configuration to TimeSeriesRaw self.time_series_raw.q_control.drop(df.index, errors="ignore", inplace=True) @@ -1570,12 +1570,35 @@ def _get_q_sign_and_power_factor_per_component( components_df, edisgo_object.topology.buses_df ) components_names = df.index - q_sign = q_control._fixed_cosphi_default_reactive_power_sign( - df, type, edisgo_object.config - ) - power_factor = q_control._fixed_cosphi_default_power_factor( - df, type, edisgo_object.config - ) + if type == "loads": + q_sign = pd.Series(dtype=float) + power_factor = pd.Series(dtype=float) + for load_type in df["type"].unique(): + q_sign = pd.concat( + [ + q_sign, + q_control._fixed_cosphi_default_reactive_power_sign( + df[df["type"] == load_type], f"{load_type}s", + edisgo_object.config + ), + ] + ) + power_factor = pd.concat( + [ + power_factor, + q_control._fixed_cosphi_default_power_factor( + df[df["type"] == load_type], f"{load_type}s", + edisgo_object.config + ), + ] + ) + else: + q_sign = q_control._fixed_cosphi_default_reactive_power_sign( + df, type, edisgo_object.config + ) + power_factor = q_control._fixed_cosphi_default_power_factor( + df, type, edisgo_object.config + ) elif isinstance(parametrisation, pd.DataFrame): # check if all given components exist in network and only use existing components_names = list( @@ -1597,14 +1620,26 @@ def _get_q_sign_and_power_factor_per_component( components_df.loc[comps, :], edisgo_object.topology.buses_df, ) - q_sign = pd.concat( - [ - q_sign, - q_control._fixed_cosphi_default_reactive_power_sign( - df, type, edisgo_object.config - ), - ] - ) + if type == "loads": + for load_type in df["type"].unique(): + q_sign = pd.concat( + [ + q_sign, + q_control._fixed_cosphi_default_reactive_power_sign( + df[df["type"] == load_type], f"{load_type}s", + edisgo_object.config + ), + ] + ) + else: + q_sign = pd.concat( + [ + q_sign, + q_control._fixed_cosphi_default_reactive_power_sign( + df, type, edisgo_object.config + ), + ] + ) else: q_sign = pd.concat( [ @@ -1618,14 +1653,26 @@ def _get_q_sign_and_power_factor_per_component( components_df.loc[comps, :], edisgo_object.topology.buses_df, ) - power_factor = pd.concat( - [ - power_factor, - q_control._fixed_cosphi_default_power_factor( - df, type, edisgo_object.config - ), - ] - ) + if type == "loads": + for load_type in df["type"].unique(): + power_factor = pd.concat( + [ + power_factor, + q_control._fixed_cosphi_default_power_factor( + df[df["type"] == load_type], f"{load_type}s", + edisgo_object.config + ), + ] + ) + else: + power_factor = pd.concat( + [ + power_factor, + q_control._fixed_cosphi_default_power_factor( + df, type, edisgo_object.config + ), + ] + ) else: power_factor = pd.concat( [ From 9ad68cb634d7ba51079daf415db771bdb3c8b671 Mon Sep 17 00:00:00 2001 From: birgits Date: Mon, 9 Jan 2023 20:10:04 +0100 Subject: [PATCH 079/119] Expand fixed_cosphi test to test for heat pumps and charging points --- tests/network/test_timeseries.py | 47 ++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/tests/network/test_timeseries.py b/tests/network/test_timeseries.py index 9e276e1a6..c4c866442 100644 --- a/tests/network/test_timeseries.py +++ b/tests/network/test_timeseries.py @@ -1878,6 +1878,41 @@ def test_fixed_cosphi(self): self.edisgo.set_time_series_manual( storage_units_p=pd.DataFrame({"Storage_1": ts_wind}, index=timeindex) ) + # create heat pumps and charging points in MV and LV + df_cp = pd.DataFrame( + { + "bus": [ + "Bus_BranchTee_MVGrid_1_2", + "Bus_BranchTee_MVGrid_1_2", + "Bus_BranchTee_LVGrid_1_5", + "Bus_BranchTee_LVGrid_1_5", + ], + "p_set": [0.1, 0.2, 0.3, 0.4], + "type": [ + "charging_point", + "heat_pump", + "charging_point", + "heat_pump", + ], + }, + index=["CP1", "HP1", "CP2", "HP2"], + ) + self.edisgo.topology.loads_df = pd.concat( + [ + self.edisgo.topology.loads_df, + df_cp, + ] + ) + self.edisgo.set_time_series_manual( + loads_p=pd.DataFrame( + { + "CP1": ts_wind, + "HP1": ts_wind, + "CP2": ts_wind, + "HP2": ts_wind + }, + index=timeindex) + ) # test different options (default, Dataframe with default, Dataframe with # different settings) - None is already tested in eDisGo class tests @@ -1896,7 +1931,8 @@ def test_fixed_cosphi(self): ), loads_parametrisation=pd.DataFrame( { - "components": [[load_1], [load_2, load_3]], + "components": [[load_1, "CP1", "HP1", "CP2", "HP2"], + [load_2, load_3]], "mode": ["default", "capacitive"], "power_factor": ["default", 0.98], }, @@ -1905,7 +1941,7 @@ def test_fixed_cosphi(self): storage_units_parametrisation="default", ) assert self.edisgo.timeseries.generators_reactive_power.shape == (3, 1) - assert self.edisgo.timeseries.loads_reactive_power.shape == (3, 3) + assert self.edisgo.timeseries.loads_reactive_power.shape == (3, 7) assert self.edisgo.timeseries.storage_units_reactive_power.shape == (3, 1) assert ( np.isclose( @@ -1920,6 +1956,13 @@ def test_fixed_cosphi(self): * np.tan(np.arccos(0.95)), ) ).all() + assert ( + np.isclose( + self.edisgo.timeseries.loads_reactive_power.loc[ + :, ["CP1", "HP1", "CP2", "HP2"]], + 0.0 + ) + ).all() assert ( ( np.isclose( From af7d714db531569cec053736df03c5591cbd0790 Mon Sep 17 00:00:00 2001 From: birgits Date: Mon, 9 Jan 2023 20:47:18 +0100 Subject: [PATCH 080/119] Bugfix initialisation of GeoDataFrame changed with geopandas 0.12.0 --- edisgo/tools/tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edisgo/tools/tools.py b/edisgo/tools/tools.py index 6a063db73..d2202dbcd 100644 --- a/edisgo/tools/tools.py +++ b/edisgo/tools/tools.py @@ -490,7 +490,7 @@ def get_weather_cells_intersecting_with_grid_district(edisgo_obj): f"Grid district geometry is of type {type(mv_geom)}." " Only Shapely Polygon or MultiPolygon are accepted." ) - mv_geom_gdf = gpd.GeoDataFrame(m, crs=f"EPSG:{srid}", columns=["geometry"]) + mv_geom_gdf = gpd.GeoDataFrame(data={"geometry": [m]}, crs=f"EPSG:{srid}") return set( np.append( From f6d80b0b9830f8514287e16c2294b4438c3a6820 Mon Sep 17 00:00:00 2001 From: birgits Date: Mon, 9 Jan 2023 21:09:59 +0100 Subject: [PATCH 081/119] Bugfix initialisation of GeoDataFrame changed with geopandas 0.12.0 --- examples/electromobility_example.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/electromobility_example.ipynb b/examples/electromobility_example.ipynb index a81e8ef32..341dae69d 100644 --- a/examples/electromobility_example.ipynb +++ b/examples/electromobility_example.ipynb @@ -305,7 +305,7 @@ "outputs": [], "source": [ "mv_grid_gdf = gpd.GeoDataFrame(\n", - " pd.DataFrame(data=edisgo.topology.grid_district[\"geom\"], columns=[\"geometry\"]),\n", + " pd.DataFrame(data={\"geometry\": [edisgo.topology.grid_district[\"geom\"]]}),\n", " crs=f\"EPSG:{edisgo.topology.grid_district['srid']}\",\n", ")\n", "\n", From 94597e173c6d256f2f12f2ca2896fd4f38d59eb1 Mon Sep 17 00:00:00 2001 From: birgits Date: Tue, 10 Jan 2023 21:06:28 +0100 Subject: [PATCH 082/119] Fix docstring message on resampling and move text block to Notes section --- edisgo/edisgo.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/edisgo/edisgo.py b/edisgo/edisgo.py index da9e654cd..0f6faa9d9 100755 --- a/edisgo/edisgo.py +++ b/edisgo/edisgo.py @@ -1559,12 +1559,6 @@ def apply_charging_strategy(self, strategy="dumb", **kwargs): in :attr:`~.network.timeseries.TimeSeries.loads_reactive_power` is set to 0 Mvar. - If the frequency of time series data in :class:`~.network.timeseries.TimeSeries` - (checked using :attr:`~.network.timeseries.timeindex`) differs from the - frequency of SimBEV data, then the time series in - :class:`~.network.timeseries.TimeSeries` automatically resampled to match the - SimBEV data frequency. - Parameters ---------- strategy : str @@ -1607,6 +1601,15 @@ def apply_charging_strategy(self, strategy="dumb", **kwargs): capacity of 22 kW and a minimum_charging_capacity_factor of 0.1 this would result in a minimum charging power of 2.2 kW. Default: 0.1. + Notes + ------ + If the frequency of time series data in :class:`~.network.timeseries.TimeSeries` + (checked using :attr:`~.network.timeseries.TimeSeries.timeindex`) differs from + the frequency of SimBEV data, then the time series in + :class:`~.network.timeseries.TimeSeries` is first automatically resampled to + match the SimBEV data frequency and after determining the charging demand time + series resampled back to the original frequency. + """ charging_strategy(self, strategy=strategy, **kwargs) From 177fd807e573825f1c4d728105426c68f06a6b5d Mon Sep 17 00:00:00 2001 From: birgits Date: Tue, 10 Jan 2023 21:07:54 +0100 Subject: [PATCH 083/119] Minor changes to logging message --- edisgo/flex_opt/charging_strategies.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/edisgo/flex_opt/charging_strategies.py b/edisgo/flex_opt/charging_strategies.py index f607ef248..b792242c8 100644 --- a/edisgo/flex_opt/charging_strategies.py +++ b/edisgo/flex_opt/charging_strategies.py @@ -119,12 +119,13 @@ def charging_strategy( if resample: logger.warning( - "The step size of the time series of the edisgo object differs from the" - f"simbev step size. The edisgo time delta is {edisgo_timedelta}, while" - f" the simbev time delta is {simbev_timedelta}. The edisgo time series " + f"The frequency of the time series data of the edisgo object differs from " + f"the simbev time series frequency. The edisgo frequency is " + f"{edisgo_timedelta}, while the simbev frequency is {simbev_timedelta}. " + f"The edisgo time series data " f"will be resampled accordingly before applying the charging strategy. " - f"After applying the charging strategy the time series will be resampled " - f"to it's original state." + f"After applying the charging strategy all time series will be resampled " + f"to the original frequency of the edisgo time series data." ) edisgo_obj.resample_timeseries(freq=simbev_timedelta) From 68f9fd61479c142c6da2a28daa4a553eddbd5ab9 Mon Sep 17 00:00:00 2001 From: birgits Date: Tue, 10 Jan 2023 21:08:21 +0100 Subject: [PATCH 084/119] Expand charging strategy test to check if resampling works as expected --- tests/flex_opt/test_charging_strategy.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/tests/flex_opt/test_charging_strategy.py b/tests/flex_opt/test_charging_strategy.py index 4731138b4..c0165fc79 100644 --- a/tests/flex_opt/test_charging_strategy.py +++ b/tests/flex_opt/test_charging_strategy.py @@ -25,14 +25,14 @@ def setup_class(cls): cls.edisgo_obj.import_electromobility(cls.simbev_path, cls.tracbev_path) - def test_charging_strategy(self): + def test_charging_strategy(self, caplog): charging_demand_lst = [] + ts = self.edisgo_obj.timeseries + for strategy in self.charging_strategies: charging_strategy(self.edisgo_obj, strategy=strategy) - ts = self.edisgo_obj.timeseries - # Check if all charging points have a valid chargingdemand_kWh > 0 df = ts.charging_points_active_power(self.edisgo_obj).loc[ :, (ts.charging_points_active_power(self.edisgo_obj) <= 0).any(axis=0) @@ -49,7 +49,8 @@ def test_charging_strategy(self): self.edisgo_obj, strategy="dumb", timestamp_share_threshold=0.5 ) - ts = self.edisgo_obj.timeseries + # Check if resampling warning is raised + assert "The frequency of the time series data of the edisgo object differs" in caplog.text # Check if all charging points have a valid chargingdemand_kWh > 0 df = ts.charging_points_active_power(self.edisgo_obj).loc[ @@ -63,8 +64,6 @@ def test_charging_strategy(self): self.edisgo_obj, strategy="reduced", minimum_charging_capacity_factor=0.5 ) - ts = self.edisgo_obj.timeseries - # Check if all charging points have a valid chargingdemand_kWh > 0 df = ts.charging_points_active_power(self.edisgo_obj).loc[ :, (ts.charging_points_active_power(self.edisgo_obj) <= 0).any(axis=0) @@ -82,3 +81,13 @@ def test_charging_strategy(self): (_.round(4) == charging_demand_lst[0].round(4)).all() for _ in charging_demand_lst ) + + # ##################### check time index ##################### + assert ts._loads_active_power.index.freqstr == "H" + # change time index to quarter-hourly + timeindex = pd.date_range("1/1/2011", periods=24 * 7, freq="0.25H") + self.edisgo_obj.set_timeindex(timeindex) + charging_strategy( + self.edisgo_obj, strategy="dumb" + ) + assert ts._loads_active_power.index.freqstr == "15T" From 9a7e2678cf427fb9d520bea28a9457aacbab55eb Mon Sep 17 00:00:00 2001 From: birgits Date: Tue, 10 Jan 2023 21:08:49 +0100 Subject: [PATCH 085/119] Fix sphinx requirements to be the same as in rtd_requirements --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c861120d2..95946bc97 100644 --- a/setup.py +++ b/setup.py @@ -64,7 +64,8 @@ def read(fname): dev_requirements = [ "pytest", "pytest-notebook", - "sphinx_rtd_theme", + "sphinx >= 4.3.0, < 5.1.0", + "sphinx_rtd_theme >=0.5.2", "sphinx-autodoc-typehints", "pre-commit", "black", From 3fb367f6dc2beeec7cfdc42ebe2aef5a6eb1899b Mon Sep 17 00:00:00 2001 From: birgits Date: Tue, 10 Jan 2023 22:18:59 +0100 Subject: [PATCH 086/119] Change warnings.warn to logger.warning to be logged in logger --- edisgo/network/topology.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/edisgo/network/topology.py b/edisgo/network/topology.py index 78cf9e84f..53f8ce567 100755 --- a/edisgo/network/topology.py +++ b/edisgo/network/topology.py @@ -3,7 +3,6 @@ import logging import os import random -import warnings from zipfile import ZipFile @@ -927,7 +926,7 @@ def _check_bus_for_removal(self, bus_name): """ # check if bus is part of topology if bus_name not in self.buses_df.index: - warnings.warn( + logger.warning( "Bus of name {} not in Topology. Cannot be removed.".format(bus_name) ) return False @@ -969,7 +968,7 @@ def _check_line_for_removal(self, line_name): """ # check if line is part of topology if line_name not in self.lines_df.index: - warnings.warn( + logger.warning( "Line of name {} not in Topology. Cannot be " "removed.".format(line_name) ) @@ -1339,7 +1338,7 @@ def _get_line_data(): # if type of line is specified calculate x, r and s_nom if type_info is not None: if x is not None or r is not None or b is not None or s_nom is not None: - warnings.warn( + logger.warning( "When line 'type_info' is provided when creating a new " "line, x, r, b and s_nom are calculated and provided " "parameters are overwritten." @@ -1370,7 +1369,7 @@ def _get_line_data(): "Newly added line has no line resistance and/or reactance." ) if s_nom is None: - warnings.warn("Newly added line has no nominal power.") + logger.warning("Newly added line has no nominal power.") new_line_df = pd.DataFrame( data={ @@ -1545,7 +1544,7 @@ def remove_line(self, name): """ if not self._check_line_for_removal(name): - warnings.warn( + logger.warning( f"Removal of line {name} would create isolated node. Remove all " "connected elements first to remove bus." ) @@ -1589,7 +1588,7 @@ def remove_bus(self, name): conn_comp = self.get_connected_components_from_bus(name) conn_comp_types = [k for k, v in conn_comp.items() if not v.empty] if len(conn_comp_types) > 0: - warnings.warn( + logger.warning( f"Bus {name} is not isolated and therefore not removed. Remove all " f"connected elements ({conn_comp_types}) first to remove bus." ) @@ -2079,7 +2078,7 @@ def _choose_random_substation_id(): else: # ToDo # lv_grid = _choose_random_substation_id() - # warnings.warn( + # logger.warning( # "Given mvlv_subst_id does not exist, wherefore a random " # "LV Grid ({}) to connect in is chosen.".format( # lv_grid.id @@ -2091,7 +2090,7 @@ def _choose_random_substation_id(): # if no MV/LV substation ID is given, choose random LV grid else: lv_grid = _choose_random_substation_id() - warnings.warn( + logger.warning( "Component has no mvlv_subst_id. It is therefore allocated " f"to a random LV Grid ({lv_grid.id})." ) From 4ee13523f6badb4855e851b8c96ca3949ea96a17 Mon Sep 17 00:00:00 2001 From: birgits Date: Tue, 10 Jan 2023 22:53:02 +0100 Subject: [PATCH 087/119] Adapt tests to change to logger.warning --- tests/network/test_topology.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/tests/network/test_topology.py b/tests/network/test_topology.py index d4582811b..2e5d3d14c 100644 --- a/tests/network/test_topology.py +++ b/tests/network/test_topology.py @@ -398,7 +398,7 @@ def test_add_storage_unit(self): with pytest.raises(ValueError, match=msg): self.topology.add_storage_unit(bus="Unknown_bus", p_nom=1, control="PQ") - def test_add_line(self): + def test_add_line(self, caplog): """Test add_line method""" len_df_before = len(self.topology.lines_df) @@ -422,7 +422,7 @@ def test_add_line(self): "line, x, r, b and s_nom are calculated and provided " "parameters are overwritten." ) - with pytest.warns(UserWarning, match=msg): + with caplog.at_level(logging.WARNING): name = self.topology.add_line( bus0=bus0, bus1=bus1, @@ -431,6 +431,7 @@ def test_add_line(self): type_info="NA2XS2Y 3x1x185 RM/25", x=2, ) + assert msg in caplog.text assert len_df_before + 2 == len(self.topology.lines_df) assert name == "Line_Bus_BranchTee_MVGrid_1_8_Bus_BranchTee_LVGrid_1_10" assert np.isclose(self.topology.lines_df.at[name, "s_nom"], 6.18342) @@ -502,11 +503,12 @@ def test_add_bus(self): assert self.topology.buses_df.at[name, "lv_grid_id"] == 1 assert self.topology.buses_df.at[name, "mv_grid_id"] == 1 - def test_check_bus_for_removal(self): + def test_check_bus_for_removal(self, caplog): # test warning if line does not exist msg = "Bus of name TestBus not in Topology. Cannot be removed." - with pytest.warns(UserWarning, match=msg): + with caplog.at_level(logging.WARNING): self.topology._check_bus_for_removal("TestBus") + assert msg in caplog.text return_value = self.topology._check_bus_for_removal("TestBus") assert not return_value @@ -532,12 +534,13 @@ def test_check_bus_for_removal(self): ) assert return_value - def test_check_line_for_removal(self): + def test_check_line_for_removal(self, caplog): # test warning if line does not exist msg = "Line of name TestLine not in Topology. Cannot be removed." - with pytest.warns(UserWarning, match=msg): + with caplog.at_level(logging.WARNING): self.topology._check_line_for_removal("TestLine") + assert msg in caplog.text return_value = self.topology._check_line_for_removal("TestLine") assert not return_value @@ -673,13 +676,14 @@ def test_remove_storage_unit(self): assert bus in self.topology.buses_df.index assert (connected_lines.index.isin(self.topology.lines_df.index)).all() - def test_remove_line(self): + def test_remove_line(self, caplog): """Test remove_line method""" # test try removing line that cannot be removed msg = "Removal of line Line_30000010 would create isolated node." - with pytest.warns(UserWarning, match=msg): + with caplog.at_level(logging.WARNING): self.topology.remove_line("Line_30000010") + assert msg in caplog.text # test remove line in cycle (no bus is removed) # add line to create ring @@ -715,16 +719,17 @@ def test_remove_line(self): assert "Bus_BranchTee_LVGrid_3_6" not in self.topology.buses_df.index assert "Bus_BranchTee_LVGrid_3_5" in self.topology.buses_df.index - def test_remove_bus(self): + def test_remove_bus(self, caplog): """Test remove_bus method""" # test bus cannot be removed msg = ( "Bus Bus_BranchTee_LVGrid_4_2 is not isolated and " - "therefore not removed. Remove all connected elements *" + "therefore not removed. Remove all connected elements " ) - with pytest.warns(UserWarning, match=msg): + with caplog.at_level(logging.WARNING): self.topology.remove_bus("Bus_BranchTee_LVGrid_4_2") + assert msg in caplog.text # test bus can be removed # create isolated bus From 07aa609ff3f3d6d7b4e94a5c179e997b4a698ee3 Mon Sep 17 00:00:00 2001 From: birgits Date: Wed, 11 Jan 2023 19:21:55 +0100 Subject: [PATCH 088/119] Fix broken or redirected external links --- doc/conf.py | 2 +- doc/dev_notes.rst | 2 +- doc/index.rst | 2 +- doc/quickstart.rst | 8 ++++---- doc/whatsnew/v0-2-0.rst | 2 +- edisgo/config/config_db_tables_default.cfg | 2 +- edisgo/config/config_grid_default.cfg | 2 +- edisgo/config/config_grid_expansion_default.cfg | 2 +- edisgo/config/config_opf_julia_default.cfg | 2 +- edisgo/config/config_system.cfg | 2 +- edisgo/config/config_timeseries_default.cfg | 2 +- edisgo/network/heat.py | 8 ++++---- edisgo/tools/config.py | 2 +- edisgo/tools/tools.py | 2 +- examples/edisgo_simple_example.ipynb | 8 ++++---- examples/electromobility_example.ipynb | 2 +- 16 files changed, 25 insertions(+), 25 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index cf8056c5c..3b63125c8 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -5,7 +5,7 @@ It is developed in the project open_eGo: https://openegoproject.wordpress.com DINGO lives at github: https://github.com/openego/dingo/ -The documentation is available on RTD: http://edisgo.readthedocs.io""" +The documentation is available on RTD: https://edisgo.readthedocs.io/en/dev/""" __copyright__ = "Reiner Lemoine Institut gGmbH" __license__ = "GNU Affero General Public License Version 3 (AGPL-3.0)" diff --git a/doc/dev_notes.rst b/doc/dev_notes.rst index f571743ed..5ddfaa324 100644 --- a/doc/dev_notes.rst +++ b/doc/dev_notes.rst @@ -63,7 +63,7 @@ Code standards * **pytest**: Make sure that all pytest tests are passing and add tests for every new code base * **Documentation of `@property` functions**: Put documentation of getter and setter both in Docstring of getter, see - `on Stackoverflow `_ + `on Stackoverflow `_ * Order of public/private/protected methods, property decorators, etc. in a class: TBD diff --git a/doc/index.rst b/doc/index.rst index c02d20c37..2795fcf3d 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -15,7 +15,7 @@ The toolbox currently includes: * `ding0 `_ tool for synthetic medium and low voltage grid topologies for the whole of Germany - * `OpenEnergy DataBase (oedb) `_ for + * `OpenEnergy DataBase (oedb) `_ for feed-in time series of fluctuating renewables and scenarios for future power plant park of Germany * `demandlib `_ for electrical load time series diff --git a/doc/quickstart.rst b/doc/quickstart.rst index 0e70ca6f6..4264fae14 100644 --- a/doc/quickstart.rst +++ b/doc/quickstart.rst @@ -91,7 +91,7 @@ The steps required to set up HSL are also described in the Here is a short version for reference: First, you need to obtain an academic license for HSL Solvers. -Under http://www.hsl.rl.ac.uk/ipopt/ download the sources for Coin-HSL Full (Stable). +Under https://www.hsl.rl.ac.uk/ipopt/ download the sources for Coin-HSL Full (Stable). You will need to provide an institutional e-mail to gain access. Unpack the tar.gz: @@ -188,12 +188,12 @@ Aside from grid topology data you may eventually need a dataset on future installation of power plants. You may therefore use the scenarios developed in the `open_eGo `_ project that are available in the -`OpenEnergy DataBase (oedb) `_ -hosted on the `OpenEnergy Platform (OEP) `_. +`OpenEnergy DataBase (oedb) `_ +hosted on the `OpenEnergy Platform (OEP) `_. eDisGo provides an interface to the oedb using the package `ego.io `_. ego.io gives you a python SQL-Alchemy representations of the oedb and access to it by using the -`oedialect `_, an SQL-Alchemy dialect +`oedialect `_, an SQL-Alchemy dialect used by the OEP. You can run a worst-case scenario as follows: diff --git a/doc/whatsnew/v0-2-0.rst b/doc/whatsnew/v0-2-0.rst index 3a71a61dd..23e37ceb0 100644 --- a/doc/whatsnew/v0-2-0.rst +++ b/doc/whatsnew/v0-2-0.rst @@ -11,7 +11,7 @@ Changes * added Windows installation yml and documentation * added automatic testing for Windows `#317 `_ * dropped support for python 3.7 -* added functionality to set up different loggers with individual logging levels and where to write output `#295 `_ +* added functionality to set up different loggers with individual logging levels and where to write output `#295 `_ * added integrity checks of eDisGo object `#231 `_ * added functionality to save to and load from zip archive `#216 `_ * added option to not raise error in case power flow did not converge `#207 `_ diff --git a/edisgo/config/config_db_tables_default.cfg b/edisgo/config/config_db_tables_default.cfg index 316461ff9..051e7447b 100644 --- a/edisgo/config/config_db_tables_default.cfg +++ b/edisgo/config/config_db_tables_default.cfg @@ -4,7 +4,7 @@ # It is developed in the project open_eGo: https://openegoproject.wordpress.com # # eDisGo lives on github: https://github.com/openego/edisgo/ -# The documentation is available on RTD: http://edisgo.readthedocs.io +# The documentation is available on RTD: https://edisgo.readthedocs.io/en/dev/ [data_source] diff --git a/edisgo/config/config_grid_default.cfg b/edisgo/config/config_grid_default.cfg index 2a0405381..9b60f6d65 100644 --- a/edisgo/config/config_grid_default.cfg +++ b/edisgo/config/config_grid_default.cfg @@ -4,7 +4,7 @@ # It is developed in the project open_eGo: https://openegoproject.wordpress.com # # eDisGo lives on github: https://github.com/openego/edisgo/ -# The documentation is available on RTD: http://edisgo.readthedocs.io +# The documentation is available on RTD: https://edisgo.readthedocs.io/en/dev/ # Config file to specify parameters used when connecting new generators to the grid and # where to position disconnecting points. diff --git a/edisgo/config/config_grid_expansion_default.cfg b/edisgo/config/config_grid_expansion_default.cfg index a82e027c9..d57fd40b9 100644 --- a/edisgo/config/config_grid_expansion_default.cfg +++ b/edisgo/config/config_grid_expansion_default.cfg @@ -4,7 +4,7 @@ # It is developed in the project open_eGo: https://openegoproject.wordpress.com # # eDisGo lives on github: https://github.com/openego/edisgo/ -# The documentation is available on RTD: http://edisgo.readthedocs.io +# The documentation is available on RTD: https://edisgo.readthedocs.io/en/dev/ [grid_expansion_standard_equipment] diff --git a/edisgo/config/config_opf_julia_default.cfg b/edisgo/config/config_opf_julia_default.cfg index 178998de0..5a24d842e 100644 --- a/edisgo/config/config_opf_julia_default.cfg +++ b/edisgo/config/config_opf_julia_default.cfg @@ -4,7 +4,7 @@ # It is developed in the project open_eGo: https://openegoproject.wordpress.com # # eDisGo lives on github: https://github.com/openego/edisgo/ -# The documentation is available on RTD: http://edisgo.readthedocs.io +# The documentation is available on RTD: https://edisgo.readthedocs.io/en/dev/ # This file contains path to julia binary and path to project.toml containing correct julia environment # julia dir should be in users directory diff --git a/edisgo/config/config_system.cfg b/edisgo/config/config_system.cfg index 97b6a181b..cee1fe430 100644 --- a/edisgo/config/config_system.cfg +++ b/edisgo/config/config_system.cfg @@ -4,7 +4,7 @@ # It is developed in the project open_eGo: https://openegoproject.wordpress.com # # eDisGo lives on github: https://github.com/openego/edisgo/ -# The documentation is available on RTD: http://edisgo.readthedocs.io +# The documentation is available on RTD: https://edisgo.readthedocs.io/en/dev/ # # CAUTION: This is an internal config file, do not modify unless you know what # you are doing! diff --git a/edisgo/config/config_timeseries_default.cfg b/edisgo/config/config_timeseries_default.cfg index 4a7f3516e..30322b7c0 100644 --- a/edisgo/config/config_timeseries_default.cfg +++ b/edisgo/config/config_timeseries_default.cfg @@ -4,7 +4,7 @@ # It is developed in the project open_eGo: https://openegoproject.wordpress.com # # eDisGo lives on github: https://github.com/openego/edisgo/ -# The documentation is available on RTD: http://edisgo.readthedocs.io +# The documentation is available on RTD: https://edisgo.readthedocs.io/en/dev/ # This file contains relevant data to generate load and feed-in time series. # Scale factors are used in worst-case scenarios. diff --git a/edisgo/network/heat.py b/edisgo/network/heat.py index 001c859d8..0c0efed29 100644 --- a/edisgo/network/heat.py +++ b/edisgo/network/heat.py @@ -164,7 +164,7 @@ def set_cop(self, edisgo_object, ts_cop, heat_pump_names=None): Parameters ---------- edisgo_object : :class:`~.EDisGo` - ts_cop : str or :pandas:`pandas.DataFrame` + ts_cop : str or :pandas:`pandas.DataFrame` Defines option used to set COP time series. Possible options are: @@ -179,7 +179,7 @@ def set_cop(self, edisgo_object, ts_cop, heat_pump_names=None): Using information on which weather cell each heat pump is in, the weather cell specific time series are mapped to each heat pump. - * :pandas:`pandas.DataFrame` + * :pandas:`pandas.DataFrame` DataFrame with self-provided COP time series per heat pump. See :py:attr:`~cop_df` on information on the required dataframe format. @@ -219,7 +219,7 @@ def set_heat_demand(self, edisgo_object, ts_heat_demand, heat_pump_names=None): Parameters ---------- edisgo_object : :class:`~.EDisGo` - ts_heat_demand : str or :pandas:`pandas.DataFrame` + ts_heat_demand : str or :pandas:`pandas.DataFrame` Defines option used to set heat demand time series. Possible options are: @@ -232,7 +232,7 @@ def set_heat_demand(self, edisgo_object, ts_heat_demand, heat_pump_names=None): :func:`edisgo.io.timeseries_import.heat_demand_oedb` for more information. - * :pandas:`pandas.DataFrame` + * :pandas:`pandas.DataFrame` DataFrame with self-provided heat demand time series per heat pump. See :py:attr:`~heat_demand_df` on information on the required diff --git a/edisgo/tools/config.py b/edisgo/tools/config.py index c33f5bf66..54fc08a33 100644 --- a/edisgo/tools/config.py +++ b/edisgo/tools/config.py @@ -4,7 +4,7 @@ It is developed in the project open_eGo: https://openegoproject.wordpress.com eDisGo lives on github: https://github.com/openego/edisgo/ -The documentation is available on RTD: http://edisgo.readthedocs.io +The documentation is available on RTD: https://edisgo.readthedocs.io/en/dev/ Based on code by oemof developing group diff --git a/edisgo/tools/tools.py b/edisgo/tools/tools.py index d2202dbcd..2310a05fe 100644 --- a/edisgo/tools/tools.py +++ b/edisgo/tools/tools.py @@ -508,7 +508,7 @@ def get_directory_size(start_dir): Walks through all files and sub-directories within a given directory and calculate the sum of size of all files in the directory. - See: https://stackoverflow.com/a/1392549/13491957 + See https://stackoverflow.com/questions/1392413/calculating-a-directorys-size-using-python/1392549#1392549 Parameters ---------- diff --git a/examples/edisgo_simple_example.ipynb b/examples/edisgo_simple_example.ipynb index 60a89cbcc..982b021a2 100644 --- a/examples/edisgo_simple_example.ipynb +++ b/examples/edisgo_simple_example.ipynb @@ -24,7 +24,7 @@ "### Learn more about eDisGo\n", "\n", "* __[eDisGo Source Code](https://github.com/openego/eDisGo)__\n", - "* __[eDisGo Documentation](http://edisgo.readthedocs.io/en/dev/)__\n", + "* __[eDisGo Documentation](https://edisgo.readthedocs.io/en/dev/)__\n", "\n", "### Table of Contents\n", "\n", @@ -103,7 +103,7 @@ "### Settings \n", "\n", "The class **EDisGo** serves as the top-level API for\n", - "setting up your scenario, invocation of data import, power flow analysis, grid reinforcement and flexibility measures. It also provides access to all relevant data. See the [class documentation](http://edisgo.readthedocs.io/en/dev/api/edisgo.grid.html#edisgo.grid.network.EDisGo) for more information.\n", + "setting up your scenario, invocation of data import, power flow analysis, grid reinforcement and flexibility measures. It also provides access to all relevant data. See the [class documentation](https://edisgo.readthedocs.io/en/dev/api/edisgo.grid.html#edisgo.grid.network.EDisGo) for more information.\n", "\n", "To set up a scenario to do a worst-case analysis that considers the heavy load flow and reverse power flow cases used in distribution grid planning, you simply have to provide a grid and call the function`set_time_series_worst_case_analysis`, which is both explained in the following two sections. \n", "\n", @@ -583,7 +583,7 @@ "* Reinforce lines in LV grid due to voltage issues\n", "* Reinforce transformers and lines due to overloading issues\n", "\n", - "Reinforcement of transformers and lines due to overloading issues is performed twice, once in the beginning and again after fixing voltage problems, as the changed power flows after reinforcing the grid may lead to new overloading issues. (For further explanation see the [documentation](http://edisgo.readthedocs.io/en/dev/features_in_detail.html#automatic-grid-expansion).)\n", + "Reinforcement of transformers and lines due to overloading issues is performed twice, once in the beginning and again after fixing voltage problems, as the changed power flows after reinforcing the grid may lead to new overloading issues. (For further explanation see the [documentation](https://edisgo.readthedocs.io/en/dev/features_in_detail.html#automatic-grid-expansion).)\n", "\n", "After each reinforcement step a non-linear power flow analyses is conducted using PyPSA. Let's do a power flow analysis before the reinforcement to see how many over-loading and voltage issues there are." ] @@ -764,7 +764,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "An overview of the assumptions used to calculate grid expansion costs can be found in the [documentation]( http://edisgo.readthedocs.io/en/dev/features_in_detail.html#grid-expansion-costs).\n", + "An overview of the assumptions used to calculate grid expansion costs can be found in the [documentation]( https://edisgo.readthedocs.io/en/dev/features_in_detail.html#grid-expansion-costs).\n", "\n", "You can also view grid expansion costs for equipment in the MV using the following plot:" ] diff --git a/examples/electromobility_example.ipynb b/examples/electromobility_example.ipynb index 341dae69d..6dfa189f3 100644 --- a/examples/electromobility_example.ipynb +++ b/examples/electromobility_example.ipynb @@ -12,7 +12,7 @@ "**Learn more about eDisGo**\n", "\n", "* __[eDisGo Source Code](https://github.com/openego/eDisGo)__\n", - "* __[eDisGo Documentation](http://edisgo.readthedocs.io/en/dev/)__" + "* __[eDisGo Documentation](https://edisgo.readthedocs.io/en/dev/)__" ] }, { From 7f5b25722c0763e2d51f43a97f49b977467a482b Mon Sep 17 00:00:00 2001 From: birgits Date: Wed, 11 Jan 2023 19:22:08 +0100 Subject: [PATCH 089/119] Fix docstring error --- edisgo/io/pypsa_io.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edisgo/io/pypsa_io.py b/edisgo/io/pypsa_io.py index 3c438f414..815bfae79 100755 --- a/edisgo/io/pypsa_io.py +++ b/edisgo/io/pypsa_io.py @@ -804,7 +804,7 @@ def process_pfa_results(edisgo, pypsa, timesteps, dtype="float"): ---------- edisgo : :class:`~.EDisGo` pypsa : :pypsa:`pypsa.Network` - The PyPSA `Network container + The PyPSA network to retrieve results from. timesteps : :pandas:`pandas.DatetimeIndex` or \ :pandas:`pandas.Timestamp` Time steps for which latest power flow analysis was conducted and From 35c6b88397c54904fcbaedb3870514fe8e027d77 Mon Sep 17 00:00:00 2001 From: birgits Date: Wed, 11 Jan 2023 19:22:23 +0100 Subject: [PATCH 090/119] Minor change to documentation --- doc/dev_notes.rst | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/doc/dev_notes.rst b/doc/dev_notes.rst index 5ddfaa324..91e0cc637 100644 --- a/doc/dev_notes.rst +++ b/doc/dev_notes.rst @@ -83,13 +83,8 @@ And then you build the html docs on your computer with sphinx-build -E -a doc/ doc/_html -To check if external links in the documentation work, change into the doc repository - -.. code-block:: bash - - cd doc - -and run the following command +To manually check if external links in the documentation work, change into the doc +repository and run the following command (internal links are not checked by this): .. code-block:: bash From 46550d877404618c6eec9bbacf6f5ac994174e05 Mon Sep 17 00:00:00 2001 From: birgits Date: Wed, 11 Jan 2023 19:22:42 +0100 Subject: [PATCH 091/119] Adapt extlinks to avoid sphinx warnings --- doc/conf.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 3b63125c8..a8000bfe5 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -74,25 +74,25 @@ extlinks = { "pandas": ( "https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.%s.html", - "pandas.", + "pandas.%s", ), "geopandas": ( "https://geopandas.org/en/stable/docs/reference/api/geopandas.%s.html", - "geopandas.", + "geopandas.%s", ), "networkx": ( - "https://networkx.github.io/documentation/stable/reference/classes/" + "https://networkx.org/documentation/stable/reference/classes/" "graph.html#%s", - "networkx.", + "networkx.%s", ), "sqlalchemy": ( "http://docs.sqlalchemy.org/en/latest/orm/session_basics.html%s", - "SQLAlchemy session object", + "sqlalchemy.%s", ), - "shapely": ("https://shapely.readthedocs.io/en/latest/manual.html#%s", "shapely."), - "ding0": ("https://dingo.readthedocs.io/en/dev/api/ding0.html#%s", "Ding0"), - "pypsa": ("https://pypsa.readthedocs.io/en/latest/components.html#%s", "pypsa"), - "plotly": ("https://plotly.com/python-api-reference/generated/%s.html", "plotly"), + "shapely": ("https://shapely.readthedocs.io/en/latest/manual.html#%s", "shapely.%s"), + "ding0": ("https://dingo.readthedocs.io/en/dev/api/ding0.html#%s", "ding0.%s"), + "pypsa": ("https://pypsa.readthedocs.io/en/latest/components.html#%s", "pypsa.%s"), + "plotly": ("https://plotly.com/python-api-reference/generated/%s.html", "plotly.%s"), } # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] From 4e3532566231e38b1660f029f561844140b8d2bf Mon Sep 17 00:00:00 2001 From: birgits Date: Wed, 11 Jan 2023 19:44:21 +0100 Subject: [PATCH 092/119] Delete old ToDo --- edisgo/network/topology.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/edisgo/network/topology.py b/edisgo/network/topology.py index c98f8f680..19df7ada9 100755 --- a/edisgo/network/topology.py +++ b/edisgo/network/topology.py @@ -2464,14 +2464,6 @@ def _connect_mv_bus_to_target_object( return target_obj["repr"] - # ToDo: :networkx:`networkx.Graph` doesn't exist anymore because: - # "The ordered variants of graph classes in this module are deprecated and will be - # removed in version 3.0." - # Changed link to :networkx:`networkx.Graph<>` - # Needs to be verified if that is correct - # Same problem in network.grids line 82 and tools.networkx_helper line 30, - # tools.plots line 1444, tools.pseudo_coordinates lines 33, 41, 201, 209, - # edisgo line 613, usage_details.rst line 161 def to_graph(self): """ Returns graph representation of the grid. From 14597b0d127b2837b8c45ee565ee87f3cca868ce Mon Sep 17 00:00:00 2001 From: birgits Date: Wed, 11 Jan 2023 19:55:15 +0100 Subject: [PATCH 093/119] Fix requirements file name --- .readthedocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index b04220b84..86c001e07 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -20,4 +20,4 @@ formats: all python: version: "3.8" install: - - requirements: requirements.txt + - requirements: rtd_requirements.txt From daaa3160d96cb6aac3b9ef796f48541cf35dcff0 Mon Sep 17 00:00:00 2001 From: birgits Date: Wed, 11 Jan 2023 19:55:32 +0100 Subject: [PATCH 094/119] Remove geopandas from rtd requirements again --- rtd_requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/rtd_requirements.txt b/rtd_requirements.txt index 0c6ccdb24..3181b6945 100644 --- a/rtd_requirements.txt +++ b/rtd_requirements.txt @@ -20,4 +20,3 @@ docutils == 0.16.0 sphinx >= 4.3.0, < 5.1.0 sphinx_rtd_theme >=0.5.2 sphinx-autodoc-typehints -geopandas From b206f9a142249c75f61245c112eb9e84e2cfdfff Mon Sep 17 00:00:00 2001 From: birgits Date: Mon, 30 Jan 2023 17:03:10 +0100 Subject: [PATCH 095/119] Move resampling to helper function so it can be used by other classes as well --- edisgo/tools/tools.py | 72 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/edisgo/tools/tools.py b/edisgo/tools/tools.py index 2310a05fe..00a07f2d2 100644 --- a/edisgo/tools/tools.py +++ b/edisgo/tools/tools.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import logging import os @@ -631,3 +633,73 @@ def add_line_susceptance( ) return edisgo_obj + + +def resample( + object, freq_orig, method: str = "ffill", + freq: str | pd.Timedelta = "15min" +): + """ + Resamples all time series data in given object to a desired resolution. + + Parameters + ---------- + object : :class:`~.network.timeseries.TimeSeries` + Object of which to resample time series data. + freq_orig : :pandas:`pandas.Timedelta` + Frequency of original time series data. + method : str, optional + See `method` parameter in :attr:`~.EDisGo.resample_timeseries` for more + information. + freq : str, optional + See `freq` parameter in :attr:`~.EDisGo.resample_timeseries` for more + information. + + """ + + # add time step at the end of the time series in case of up-sampling so that + # last time interval in the original time series is still included + df_dict = {} + for attr in object._attributes: + if not getattr(object, attr).empty: + df_dict[attr] = getattr(object, attr) + if pd.Timedelta(freq) < freq_orig: # up-sampling + new_dates = pd.DatetimeIndex([df_dict[attr].index[-1] + freq_orig]) + else: # down-sampling + new_dates = pd.DatetimeIndex([df_dict[attr].index[-1]]) + df_dict[attr] = ( + df_dict[attr] + .reindex(df_dict[attr].index.union(new_dates).unique().sort_values()) + .ffill() + ) + + # resample time series + if pd.Timedelta(freq) < freq_orig: # up-sampling + if method == "interpolate": + for attr in df_dict.keys(): + setattr( + object, + attr, + df_dict[attr].resample(freq, closed="left").interpolate().iloc[:-1], + ) + elif method == "ffill": + for attr in df_dict.keys(): + setattr( + object, attr, df_dict[attr].resample(freq, closed="left").ffill().iloc[:-1] + ) + elif method == "bfill": + for attr in df_dict.keys(): + setattr( + object, attr, df_dict[attr].resample(freq, closed="left").bfill().iloc[:-1] + ) + else: + raise NotImplementedError( + f"Resampling method {method} is not implemented." + ) + else: # down-sampling + for attr in df_dict.keys(): + setattr( + object, + attr, + df_dict[attr].resample(freq).mean(), + ) From 65287306157b4e2c2fb62e77dd87d5cec3ea0be9 Mon Sep 17 00:00:00 2001 From: birgits Date: Mon, 30 Jan 2023 17:25:35 +0100 Subject: [PATCH 096/119] Running pre-commit hooks over all files --- doc/conf.py | 13 ++++++--- doc/dev_notes.rst | 6 ++-- edisgo/network/timeseries.py | 36 +++++++++++++----------- edisgo/tools/tools.py | 23 ++++++++------- setup.py | 2 +- tests/flex_opt/test_charging_strategy.py | 9 +++--- tests/network/test_timeseries.py | 21 +++++++------- 7 files changed, 60 insertions(+), 50 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index a8000bfe5..592b09816 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -81,18 +81,23 @@ "geopandas.%s", ), "networkx": ( - "https://networkx.org/documentation/stable/reference/classes/" - "graph.html#%s", + "https://networkx.org/documentation/stable/reference/classes/" "graph.html#%s", "networkx.%s", ), "sqlalchemy": ( "http://docs.sqlalchemy.org/en/latest/orm/session_basics.html%s", "sqlalchemy.%s", ), - "shapely": ("https://shapely.readthedocs.io/en/latest/manual.html#%s", "shapely.%s"), + "shapely": ( + "https://shapely.readthedocs.io/en/latest/manual.html#%s", + "shapely.%s", + ), "ding0": ("https://dingo.readthedocs.io/en/dev/api/ding0.html#%s", "ding0.%s"), "pypsa": ("https://pypsa.readthedocs.io/en/latest/components.html#%s", "pypsa.%s"), - "plotly": ("https://plotly.com/python-api-reference/generated/%s.html", "plotly.%s"), + "plotly": ( + "https://plotly.com/python-api-reference/generated/%s.html", + "plotly.%s", + ), } # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] diff --git a/doc/dev_notes.rst b/doc/dev_notes.rst index 91e0cc637..c4188f7db 100644 --- a/doc/dev_notes.rst +++ b/doc/dev_notes.rst @@ -82,12 +82,10 @@ And then you build the html docs on your computer with .. code-block:: bash sphinx-build -E -a doc/ doc/_html - + To manually check if external links in the documentation work, change into the doc repository and run the following command (internal links are not checked by this): - + .. code-block:: bash sphinx-build . -b linkcheck -d _build/doctrees _build/html - - diff --git a/edisgo/network/timeseries.py b/edisgo/network/timeseries.py index 52ca4fa40..b4be0707b 100644 --- a/edisgo/network/timeseries.py +++ b/edisgo/network/timeseries.py @@ -1578,8 +1578,9 @@ def _get_q_sign_and_power_factor_per_component( [ q_sign, q_control._fixed_cosphi_default_reactive_power_sign( - df[df["type"] == load_type], f"{load_type}s", - edisgo_object.config + df[df["type"] == load_type], + f"{load_type}s", + edisgo_object.config, ), ] ) @@ -1587,8 +1588,9 @@ def _get_q_sign_and_power_factor_per_component( [ power_factor, q_control._fixed_cosphi_default_power_factor( - df[df["type"] == load_type], f"{load_type}s", - edisgo_object.config + df[df["type"] == load_type], + f"{load_type}s", + edisgo_object.config, ), ] ) @@ -1620,14 +1622,18 @@ def _get_q_sign_and_power_factor_per_component( components_df.loc[comps, :], edisgo_object.topology.buses_df, ) + default_func = ( + q_control._fixed_cosphi_default_reactive_power_sign + ) if type == "loads": for load_type in df["type"].unique(): q_sign = pd.concat( [ q_sign, - q_control._fixed_cosphi_default_reactive_power_sign( - df[df["type"] == load_type], f"{load_type}s", - edisgo_object.config + default_func( + df[df["type"] == load_type], + f"{load_type}s", + edisgo_object.config, ), ] ) @@ -1635,9 +1641,7 @@ def _get_q_sign_and_power_factor_per_component( q_sign = pd.concat( [ q_sign, - q_control._fixed_cosphi_default_reactive_power_sign( - df, type, edisgo_object.config - ), + default_func(df, type, edisgo_object.config), ] ) else: @@ -1653,14 +1657,16 @@ def _get_q_sign_and_power_factor_per_component( components_df.loc[comps, :], edisgo_object.topology.buses_df, ) + default_func = q_control._fixed_cosphi_default_power_factor if type == "loads": for load_type in df["type"].unique(): power_factor = pd.concat( [ power_factor, - q_control._fixed_cosphi_default_power_factor( - df[df["type"] == load_type], f"{load_type}s", - edisgo_object.config + default_func( + df[df["type"] == load_type], + f"{load_type}s", + edisgo_object.config, ), ] ) @@ -1668,9 +1674,7 @@ def _get_q_sign_and_power_factor_per_component( power_factor = pd.concat( [ power_factor, - q_control._fixed_cosphi_default_power_factor( - df, type, edisgo_object.config - ), + default_func(df, type, edisgo_object.config), ] ) else: diff --git a/edisgo/tools/tools.py b/edisgo/tools/tools.py index 00a07f2d2..908349055 100644 --- a/edisgo/tools/tools.py +++ b/edisgo/tools/tools.py @@ -510,7 +510,9 @@ def get_directory_size(start_dir): Walks through all files and sub-directories within a given directory and calculate the sum of size of all files in the directory. - See https://stackoverflow.com/questions/1392413/calculating-a-directorys-size-using-python/1392549#1392549 + See also + `stackoverflow `_. Parameters ---------- @@ -636,8 +638,7 @@ def add_line_susceptance( def resample( - object, freq_orig, method: str = "ffill", - freq: str | pd.Timedelta = "15min" + object, freq_orig, method: str = "ffill", freq: str | pd.Timedelta = "15min" ): """ Resamples all time series data in given object to a desired resolution. @@ -669,8 +670,8 @@ def resample( new_dates = pd.DatetimeIndex([df_dict[attr].index[-1]]) df_dict[attr] = ( df_dict[attr] - .reindex(df_dict[attr].index.union(new_dates).unique().sort_values()) - .ffill() + .reindex(df_dict[attr].index.union(new_dates).unique().sort_values()) + .ffill() ) # resample time series @@ -685,17 +686,19 @@ def resample( elif method == "ffill": for attr in df_dict.keys(): setattr( - object, attr, df_dict[attr].resample(freq, closed="left").ffill().iloc[:-1] + object, + attr, + df_dict[attr].resample(freq, closed="left").ffill().iloc[:-1], ) elif method == "bfill": for attr in df_dict.keys(): setattr( - object, attr, df_dict[attr].resample(freq, closed="left").bfill().iloc[:-1] + object, + attr, + df_dict[attr].resample(freq, closed="left").bfill().iloc[:-1], ) else: - raise NotImplementedError( - f"Resampling method {method} is not implemented." - ) + raise NotImplementedError(f"Resampling method {method} is not implemented.") else: # down-sampling for attr in df_dict.keys(): setattr( diff --git a/setup.py b/setup.py index 95946bc97..acb6e423b 100644 --- a/setup.py +++ b/setup.py @@ -39,7 +39,7 @@ def read(fname): "pyproj >= 3.0.0", "shapely >= 1.7.0", "pypsa >= 0.17.0, <= 0.20.1", - "pyomo <= 6.4.2", # Problem with PyPSA 20.1 fixed in newest PyPSA release + "pyomo <= 6.4.2", # Problem with PyPSA 20.1 fixed in newest PyPSA release "multiprocess", "workalendar", "sqlalchemy < 1.4.0", diff --git a/tests/flex_opt/test_charging_strategy.py b/tests/flex_opt/test_charging_strategy.py index c0165fc79..452889934 100644 --- a/tests/flex_opt/test_charging_strategy.py +++ b/tests/flex_opt/test_charging_strategy.py @@ -50,7 +50,10 @@ def test_charging_strategy(self, caplog): ) # Check if resampling warning is raised - assert "The frequency of the time series data of the edisgo object differs" in caplog.text + assert ( + "The frequency of the time series data of the edisgo object differs" + in caplog.text + ) # Check if all charging points have a valid chargingdemand_kWh > 0 df = ts.charging_points_active_power(self.edisgo_obj).loc[ @@ -87,7 +90,5 @@ def test_charging_strategy(self, caplog): # change time index to quarter-hourly timeindex = pd.date_range("1/1/2011", periods=24 * 7, freq="0.25H") self.edisgo_obj.set_timeindex(timeindex) - charging_strategy( - self.edisgo_obj, strategy="dumb" - ) + charging_strategy(self.edisgo_obj, strategy="dumb") assert ts._loads_active_power.index.freqstr == "15T" diff --git a/tests/network/test_timeseries.py b/tests/network/test_timeseries.py index 5d32b4c9f..9290981d3 100644 --- a/tests/network/test_timeseries.py +++ b/tests/network/test_timeseries.py @@ -1909,13 +1909,9 @@ def test_fixed_cosphi(self): ) self.edisgo.set_time_series_manual( loads_p=pd.DataFrame( - { - "CP1": ts_wind, - "HP1": ts_wind, - "CP2": ts_wind, - "HP2": ts_wind - }, - index=timeindex) + {"CP1": ts_wind, "HP1": ts_wind, "CP2": ts_wind, "HP2": ts_wind}, + index=timeindex, + ) ) # test different options (default, Dataframe with default, Dataframe with @@ -1935,8 +1931,10 @@ def test_fixed_cosphi(self): ), loads_parametrisation=pd.DataFrame( { - "components": [[load_1, "CP1", "HP1", "CP2", "HP2"], - [load_2, load_3]], + "components": [ + [load_1, "CP1", "HP1", "CP2", "HP2"], + [load_2, load_3], + ], "mode": ["default", "capacitive"], "power_factor": ["default", 0.98], }, @@ -1963,8 +1961,9 @@ def test_fixed_cosphi(self): assert ( np.isclose( self.edisgo.timeseries.loads_reactive_power.loc[ - :, ["CP1", "HP1", "CP2", "HP2"]], - 0.0 + :, ["CP1", "HP1", "CP2", "HP2"] + ], + 0.0, ) ).all() assert ( From 09801426bfedaf664e30ba2f67f8eadcdbe0a89d Mon Sep 17 00:00:00 2001 From: birgits Date: Mon, 30 Jan 2023 17:26:19 +0100 Subject: [PATCH 097/119] Fix link --- edisgo/tools/powermodels_io.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edisgo/tools/powermodels_io.py b/edisgo/tools/powermodels_io.py index d8e4d503c..fa04f0ee3 100644 --- a/edisgo/tools/powermodels_io.py +++ b/edisgo/tools/powermodels_io.py @@ -159,7 +159,7 @@ def ppc2pm(ppc, psa_net): # pragma: no cover converter from pypower datastructure to powermodels dictionary, adapted from pandapower to powermodels converter: - https://github.com/e2nIEE/pandapower/blob/develop/pandapower/converter/powermodels/to_pm.py + https://github.com/e2nIEE/pandapower/blob/develop/pandapower/converter/pandamodels/to_pm.py :param ppc: :return: From c907a37286c880d2b399aa4c40982ab657995b8f Mon Sep 17 00:00:00 2001 From: birgits Date: Mon, 30 Jan 2023 17:26:49 +0100 Subject: [PATCH 098/119] Use new helper function in TimeSeries.resample --- edisgo/network/timeseries.py | 55 ++++++------------------------------ 1 file changed, 9 insertions(+), 46 deletions(-) diff --git a/edisgo/network/timeseries.py b/edisgo/network/timeseries.py index b4be0707b..5f4513b1c 100644 --- a/edisgo/network/timeseries.py +++ b/edisgo/network/timeseries.py @@ -15,6 +15,7 @@ from edisgo.tools.tools import ( assign_voltage_level_to_component, get_weather_cells_intersecting_with_grid_district, + resample, ) if TYPE_CHECKING: @@ -2157,22 +2158,15 @@ def resample_timeseries( """ - # add time step at the end of the time series in case of up-sampling so that - # last time interval in the original time series is still included - attrs = self._attributes - freq_orig = self.timeindex[1] - self.timeindex[0] - df_dict = {} - for attr in attrs: - df_dict[attr] = getattr(self, attr) - if pd.Timedelta(freq) < freq_orig: # up-sampling - new_dates = pd.DatetimeIndex([df_dict[attr].index[-1] + freq_orig]) - else: # down-sampling - new_dates = pd.DatetimeIndex([df_dict[attr].index[-1]]) - df_dict[attr] = ( - df_dict[attr] - .reindex(df_dict[attr].index.union(new_dates).unique().sort_values()) - .ffill() + if len(self.timeindex) < 2: + logger.warning( + "Data cannot be resampled as it only contains one time step." ) + return + + freq_orig = self.timeindex[1] - self.timeindex[0] + + resample(self, freq_orig, method, freq) # create new index if pd.Timedelta(freq) < freq_orig: # up-sampling @@ -2192,37 +2186,6 @@ def resample_timeseries( # set new timeindex self._timeindex = index - # resample time series - if pd.Timedelta(freq) < freq_orig: # up-sampling - if method == "interpolate": - for attr in attrs: - setattr( - self, - attr, - df_dict[attr].resample(freq, closed="left").interpolate(), - ) - elif method == "ffill": - for attr in attrs: - setattr( - self, attr, df_dict[attr].resample(freq, closed="left").ffill() - ) - elif method == "bfill": - for attr in attrs: - setattr( - self, attr, df_dict[attr].resample(freq, closed="left").bfill() - ) - else: - raise NotImplementedError( - f"Resampling method {method} is not implemented." - ) - else: # down-sampling - for attr in attrs: - setattr( - self, - attr, - df_dict[attr].resample(freq).mean(), - ) - class TimeSeriesRaw: """ From 3305c426be968c557e430769144a1758b3165f55 Mon Sep 17 00:00:00 2001 From: birgits Date: Mon, 30 Jan 2023 17:36:46 +0100 Subject: [PATCH 099/119] Add previous changes to whats new --- doc/whatsnew/v0-2-1.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/whatsnew/v0-2-1.rst b/doc/whatsnew/v0-2-1.rst index 776de4723..76386724b 100644 --- a/doc/whatsnew/v0-2-1.rst +++ b/doc/whatsnew/v0-2-1.rst @@ -6,4 +6,7 @@ Release date: , Changes ------- -* +* Added automatic resampling when applying a charging strategy `#332 `_ +* Added MV grid ID to logging output `#309 `_ +* Added automatic link checking `#297 `_ +* Bug fix `#346 `_ From 6ab1b658b35e6f5aab8411b0218d436efe480df6 Mon Sep 17 00:00:00 2001 From: Malte Jahn Date: Thu, 2 Feb 2023 12:55:29 +0100 Subject: [PATCH 100/119] Fixes bug - Probably pypsa set columns.name = 'name' to df ``` > assert_frame_equal( edisgo_obj_loaded.results.i_res, edisgo_obj.results.i_res, check_freq=False ) E AssertionError: DataFrame.columns are different E E Attribute "names" are different E [left]: [None] E [right]: ['name'] ``` --- tests/test_edisgo.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_edisgo.py b/tests/test_edisgo.py index b2f8402c2..8e712700b 100755 --- a/tests/test_edisgo.py +++ b/tests/test_edisgo.py @@ -1594,7 +1594,10 @@ def test_import_edisgo_from_files(self): assert edisgo_obj_loaded.config._data == edisgo_obj.config._data # check results assert_frame_equal( - edisgo_obj_loaded.results.i_res, edisgo_obj.results.i_res, check_freq=False + edisgo_obj_loaded.results.i_res, + edisgo_obj.results.i_res, + check_freq=False, + check_names=False, ) # check electromobility assert_frame_equal( From fb599e46ce95b5622733ac22bf6f7a17ef940465 Mon Sep 17 00:00:00 2001 From: Malte Jahn Date: Thu, 2 Feb 2023 15:08:38 +0100 Subject: [PATCH 101/119] Solves Issue #348 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index acb6e423b..b2c50a9b1 100644 --- a/setup.py +++ b/setup.py @@ -35,7 +35,7 @@ def read(fname): "networkx >= 2.5.0", "geopy >= 2.0.0", "pandas >= 1.2.0", - "geopandas >= 0.9.0", + "geopandas >= 0.12.0", "pyproj >= 3.0.0", "shapely >= 1.7.0", "pypsa >= 0.17.0, <= 0.20.1", From 33d249056e158ba35ca45a569dc4ab7c249807e8 Mon Sep 17 00:00:00 2001 From: Malte Jahn Date: Mon, 31 Oct 2022 15:35:31 +0100 Subject: [PATCH 102/119] Adjust import_ding0_grid to new ding0 grids --- edisgo/io/ding0_import.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/edisgo/io/ding0_import.py b/edisgo/io/ding0_import.py index 43b49a150..6632b5dda 100644 --- a/edisgo/io/ding0_import.py +++ b/edisgo/io/ding0_import.py @@ -74,8 +74,6 @@ def sort_hvmv_transformer_buses(transformers_df): edisgo_obj.topology.buses_df = grid.buses[edisgo_obj.topology.buses_df.columns] edisgo_obj.topology.lines_df = grid.lines[edisgo_obj.topology.lines_df.columns] - grid.loads = grid.loads.drop(columns="p_set").rename(columns={"peak_load": "p_set"}) - edisgo_obj.topology.loads_df = grid.loads[edisgo_obj.topology.loads_df.columns] # set loads without type information to be conventional loads # this is done, as ding0 currently does not provide information on the type of load @@ -85,7 +83,7 @@ def sort_hvmv_transformer_buses(transformers_df): (edisgo_obj.topology.loads_df.type.isnull()) | (edisgo_obj.topology.loads_df.type == "") ].index - edisgo_obj.topology.loads_df.loc[loads_without_type, "type"] = "conventional_load" + # drop slack generator from generators slack = grid.generators.loc[grid.generators.control == "Slack"].index grid.generators.drop(slack, inplace=True) From 5830a8ebc79acf9c4a175f34a46f8c5f98513d4a Mon Sep 17 00:00:00 2001 From: Malte Jahn Date: Fri, 3 Feb 2023 08:50:55 +0100 Subject: [PATCH 103/119] Add ding0 legacy import --- edisgo/io/ding0_import.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/edisgo/io/ding0_import.py b/edisgo/io/ding0_import.py index 6632b5dda..a5adf48dc 100644 --- a/edisgo/io/ding0_import.py +++ b/edisgo/io/ding0_import.py @@ -15,7 +15,7 @@ logger = logging.getLogger(__name__) -def import_ding0_grid(path, edisgo_obj): +def import_ding0_grid(path, edisgo_obj, legacy_ding0_grids=False): """ Import an eDisGo network topology from `Ding0 data `_. @@ -73,6 +73,11 @@ def sort_hvmv_transformer_buses(transformers_df): # write dataframes to edisgo_obj edisgo_obj.topology.buses_df = grid.buses[edisgo_obj.topology.buses_df.columns] edisgo_obj.topology.lines_df = grid.lines[edisgo_obj.topology.lines_df.columns] + if legacy_ding0_grids: + logger.debug("Use ding0 legacy grid import.") + grid.loads = grid.loads.drop(columns="p_set").rename( + columns={"peak_load": "p_set"} + ) edisgo_obj.topology.loads_df = grid.loads[edisgo_obj.topology.loads_df.columns] # set loads without type information to be conventional loads @@ -83,6 +88,10 @@ def sort_hvmv_transformer_buses(transformers_df): (edisgo_obj.topology.loads_df.type.isnull()) | (edisgo_obj.topology.loads_df.type == "") ].index + if legacy_ding0_grids: + edisgo_obj.topology.loads_df.loc[ + loads_without_type, "type" + ] = "conventional_load" # drop slack generator from generators slack = grid.generators.loc[grid.generators.control == "Slack"].index From 74be6291e38727e6ad5ad4dfaa6850e2c9ba87ae Mon Sep 17 00:00:00 2001 From: Malte Jahn Date: Wed, 15 Feb 2023 09:54:19 +0100 Subject: [PATCH 104/119] Improve ding0 legacy import --- edisgo/io/ding0_import.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/edisgo/io/ding0_import.py b/edisgo/io/ding0_import.py index a5adf48dc..dd226dff4 100644 --- a/edisgo/io/ding0_import.py +++ b/edisgo/io/ding0_import.py @@ -15,7 +15,7 @@ logger = logging.getLogger(__name__) -def import_ding0_grid(path, edisgo_obj, legacy_ding0_grids=False): +def import_ding0_grid(path, edisgo_obj, legacy_ding0_grids=True): """ Import an eDisGo network topology from `Ding0 data `_. @@ -30,7 +30,8 @@ def import_ding0_grid(path, edisgo_obj, legacy_ding0_grids=False): Path to ding0 network csv files. edisgo_obj: :class:`~.EDisGo` The eDisGo data container object. - + legacy_ding0_grids: `bool` + Allow import of old ding0 grids. Default: True """ def sort_transformer_buses(transformers_df): @@ -78,7 +79,9 @@ def sort_hvmv_transformer_buses(transformers_df): grid.loads = grid.loads.drop(columns="p_set").rename( columns={"peak_load": "p_set"} ) - + # edisgo_obj.topology.buses_df["in_building"] = False + else: + edisgo_obj.topology.buses_df["in_building"] = False edisgo_obj.topology.loads_df = grid.loads[edisgo_obj.topology.loads_df.columns] # set loads without type information to be conventional loads # this is done, as ding0 currently does not provide information on the type of load @@ -92,7 +95,9 @@ def sort_hvmv_transformer_buses(transformers_df): edisgo_obj.topology.loads_df.loc[ loads_without_type, "type" ] = "conventional_load" - + # edisgo_obj.topology.loads_df.replace( + # to_replace=["agricultural","retail"], value="cts", inplace=True + # ) # drop slack generator from generators slack = grid.generators.loc[grid.generators.control == "Slack"].index grid.generators.drop(slack, inplace=True) From 78a010c1e0ece8823da65ccc8d2a140a6a594558 Mon Sep 17 00:00:00 2001 From: Malte Jahn Date: Wed, 15 Feb 2023 11:32:55 +0100 Subject: [PATCH 105/119] Rename retail to cts --- edisgo/io/ding0_import.py | 7 +++---- edisgo/io/timeseries_import.py | 2 +- tests/io/test_timeseries_import.py | 4 ++-- tests/network/test_timeseries.py | 12 ++++++------ 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/edisgo/io/ding0_import.py b/edisgo/io/ding0_import.py index dd226dff4..9d2bb28f2 100644 --- a/edisgo/io/ding0_import.py +++ b/edisgo/io/ding0_import.py @@ -79,7 +79,6 @@ def sort_hvmv_transformer_buses(transformers_df): grid.loads = grid.loads.drop(columns="p_set").rename( columns={"peak_load": "p_set"} ) - # edisgo_obj.topology.buses_df["in_building"] = False else: edisgo_obj.topology.buses_df["in_building"] = False edisgo_obj.topology.loads_df = grid.loads[edisgo_obj.topology.loads_df.columns] @@ -95,9 +94,9 @@ def sort_hvmv_transformer_buses(transformers_df): edisgo_obj.topology.loads_df.loc[ loads_without_type, "type" ] = "conventional_load" - # edisgo_obj.topology.loads_df.replace( - # to_replace=["agricultural","retail"], value="cts", inplace=True - # ) + edisgo_obj.topology.loads_df.replace( + to_replace=["retail"], value="cts", inplace=True + ) # drop slack generator from generators slack = grid.generators.loc[grid.generators.control == "Slack"].index grid.generators.drop(slack, inplace=True) diff --git a/edisgo/io/timeseries_import.py b/edisgo/io/timeseries_import.py index b5587425c..a81eb1ce3 100644 --- a/edisgo/io/timeseries_import.py +++ b/edisgo/io/timeseries_import.py @@ -174,7 +174,7 @@ def load_time_series_demandlib(config_data, timeindex): elec_demand.rename( columns={ - "g0": "retail", + "g0": "cts", "h0": "residential", "l0": "agricultural", "i0": "industrial", diff --git a/tests/io/test_timeseries_import.py b/tests/io/test_timeseries_import.py index 22dda37a7..109b43a2e 100644 --- a/tests/io/test_timeseries_import.py +++ b/tests/io/test_timeseries_import.py @@ -40,9 +40,9 @@ def test_import_load_timeseries(self): timeindex = pd.date_range("1/1/2018", periods=8760, freq="H") load = timeseries_import.load_time_series_demandlib(self.config, timeindex) assert ( - load.columns == ["retail", "residential", "agricultural", "industrial"] + load.columns == ["cts", "residential", "agricultural", "industrial"] ).all() - assert np.isclose(load.loc[timeindex[453], "retail"], 8.33507e-05) + assert np.isclose(load.loc[timeindex[453], "cts"], 8.33507e-05) assert np.isclose(load.loc[timeindex[13], "residential"], 1.73151e-04) assert np.isclose(load.loc[timeindex[6328], "agricultural"], 1.01346e-04) assert np.isclose(load.loc[timeindex[4325], "industrial"], 9.91768e-05) diff --git a/tests/network/test_timeseries.py b/tests/network/test_timeseries.py index 9290981d3..2fd0d5c8a 100644 --- a/tests/network/test_timeseries.py +++ b/tests/network/test_timeseries.py @@ -1526,7 +1526,7 @@ def test_predefined_conventional_loads_by_sector(self, caplog): # define expected profiles profiles = pd.DataFrame( index=index, - columns=["retail", "residential", "agricultural", "industrial"], + columns=["cts", "residential", "agricultural", "industrial"], data=[ [0.0000597, 0.0000782, 0.0000654, 0.0000992], [0.0000526, 0.0000563, 0.0000611, 0.0000992], @@ -1589,7 +1589,7 @@ def test_predefined_conventional_loads_by_sector(self, caplog): self.edisgo.topology.loads_df.loc[ "Load_retail_LVGrid_9_14", "annual_consumption" ] - * profiles["retail"] + * profiles["cts"] ).values, atol=1e-4, ).all() @@ -1645,7 +1645,7 @@ def test_predefined_conventional_loads_by_sector(self, caplog): # test manual - all profiles = pd.DataFrame( index=index, - columns=["retail", "residential", "agricultural", "industrial"], + columns=["cts", "residential", "agricultural", "industrial"], data=[ [0.003, 0.02, 0.00, 0.1], [0.004, 0.01, 0.10, 0.2], @@ -1683,7 +1683,7 @@ def test_predefined_conventional_loads_by_sector(self, caplog): self.edisgo.topology.loads_df.loc[ "Load_retail_LVGrid_9_14", "annual_consumption" ] - * profiles["retail"] + * profiles["cts"] ).values, ).all() assert np.isclose( @@ -1701,7 +1701,7 @@ def test_predefined_conventional_loads_by_sector(self, caplog): profiles_new = ( pd.DataFrame( index=index, - columns=["retail", "residential", "agricultural", "industrial"], + columns=["cts", "residential", "agricultural", "industrial"], data=[ [0.003, 0.02, 0.00, 0.1], [0.004, 0.01, 0.10, 0.2], @@ -1742,7 +1742,7 @@ def test_predefined_conventional_loads_by_sector(self, caplog): self.edisgo.topology.loads_df.loc[ "Load_retail_LVGrid_9_14", "annual_consumption" ] - * profiles["retail"] + * profiles["cts"] ).values, ).all() assert np.isclose( From 4f2456420fa1b523b6801a4c6a51b02ca6d89943 Mon Sep 17 00:00:00 2001 From: Malte Jahn Date: Tue, 28 Feb 2023 14:47:41 +0100 Subject: [PATCH 106/119] Change requirements - Make only jupyterlab as requierement (Installing jupyter notebooks with pip leads to problems) - Remove pinning dash version (The problems why the version was pinned have been fixed.) - Remove Werkzeug as requirement, it is installed when dash or jupyter_dash is installed --- rtd_requirements.txt | 3 +-- setup.py | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/rtd_requirements.txt b/rtd_requirements.txt index 3181b6945..c66544f6d 100644 --- a/rtd_requirements.txt +++ b/rtd_requirements.txt @@ -13,8 +13,7 @@ pypower scikit-learn beautifulsoup4 plotly -dash == 2.6.0 -werkzeug==2.2.0 +dash jupyter_dash docutils == 0.16.0 sphinx >= 4.3.0, < 5.1.0 diff --git a/setup.py b/setup.py index acb6e423b..454f1dbfc 100644 --- a/setup.py +++ b/setup.py @@ -53,12 +53,10 @@ def read(fname): "beautifulsoup4", "contextily", "descartes", - "jupyter", "jupyterlab", "plotly", - "dash==2.6.0", + "dash", "jupyter_dash", - "werkzeug==2.2.0", ] dev_requirements = [ From b124c5538928f7ad3307530451ecf8bfd30f9c89 Mon Sep 17 00:00:00 2001 From: birgits Date: Mon, 6 Mar 2023 20:32:07 +0100 Subject: [PATCH 107/119] Add function to get buses downstream --- edisgo/tools/tools.py | 55 +++++++++++++++++++++++++++++++++++++++ tests/tools/test_tools.py | 20 ++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/edisgo/tools/tools.py b/edisgo/tools/tools.py index 908349055..cc8ac3b7d 100644 --- a/edisgo/tools/tools.py +++ b/edisgo/tools/tools.py @@ -417,6 +417,61 @@ def get_path_length_to_station(edisgo_obj): return edisgo_obj.topology.buses_df.path_length_to_station +def get_downstream_buses(edisgo_obj, comp_name, comp_type="bus"): + """ + Returns all buses downstream (farther away from station) of the given bus or line. + + In case a bus is given, returns all buses downstream of the given bus plus the + given bus itself. + In case a line is given, returns all buses downstream of the bus that is closer to + the station (thus only one bus of the line is included in the returned buses). + + Parameters + ------------ + edisgo_obj : EDisGo object + comp_name : str + Name of bus or line (as in index of :attr:`~.network.topology.Topology.buses_df` + or :attr:`~.network.topology.Topology.lines_df`) to get downstream buses for. + comp_type : str + Can be either 'bus' or 'line'. Default: 'bus'. + + Returns + ------- + list(str) + List of buses (as in index of :attr:`~.network.topology.Topology.buses_df`) + downstream of the given component. + + """ + graph = edisgo_obj.topology.to_graph() + station_node = edisgo_obj.topology.transformers_hvmv_df.bus1.values[0] + + if comp_type == "bus": + # get upstream bus to determine which edge to remove to create subgraph + bus = comp_name + path_to_station = nx.shortest_path(graph, station_node, comp_name) + bus_upstream = path_to_station[-2] + elif comp_type == "line": + # get bus further downstream to determine which buses downstream are affected + bus0 = edisgo_obj.topology.lines_df.at[comp_name, "bus0"] + bus1 = edisgo_obj.topology.lines_df.at[comp_name, "bus1"] + path_to_station_bus0 = nx.shortest_path(graph, station_node, bus0) + path_to_station_bus1 = nx.shortest_path(graph, station_node, bus1) + bus = bus0 if len(path_to_station_bus0) > len(path_to_station_bus1) else bus1 + bus_upstream = bus0 if bus == bus1 else bus1 + else: + return None + + # remove edge between bus and next bus upstream + graph.remove_edge(bus, bus_upstream) + + # get subgraph containing relevant bus + subgraphs = list(graph.subgraph(c) for c in nx.connected_components(graph)) + for subgraph in subgraphs: + if bus in subgraph.nodes(): + return list(subgraph.nodes()) + return None + + def assign_voltage_level_to_component(df, buses_df): """ Adds column with specification of voltage level component is in. diff --git a/tests/tools/test_tools.py b/tests/tools/test_tools.py index 9e9f5fabb..80a3e6897 100644 --- a/tests/tools/test_tools.py +++ b/tests/tools/test_tools.py @@ -236,6 +236,26 @@ def test_assign_feeder(self): .any() ) + def test_get_downstream_buses(self): + + # ######## test with LV bus ######## + buses_downstream = tools.get_downstream_buses( + self.edisgo, "BusBar_MVGrid_1_LVGrid_1_LV" + ) + + lv_grid = self.edisgo.topology.get_lv_grid(1) + assert len(buses_downstream) == len(lv_grid.buses_df) + assert all([_ in buses_downstream for _ in lv_grid.buses_df.index]) + + # ######## test with MV line ######## + buses_downstream = tools.get_downstream_buses( + self.edisgo, "Line_10010", comp_type="line" + ) + + lv_grid = self.edisgo.topology.get_lv_grid(5) + assert len(buses_downstream) == len(lv_grid.buses_df) + 4 + assert all([_ in buses_downstream for _ in lv_grid.buses_df.index]) + def test_get_weather_cells_intersecting_with_grid_district(self): weather_cells = tools.get_weather_cells_intersecting_with_grid_district( self.edisgo From 52f1fd0e691d501b88d2364e7381121a7ef08956 Mon Sep 17 00:00:00 2001 From: Malte Jahn Date: Thu, 23 Mar 2023 13:40:14 +0100 Subject: [PATCH 108/119] Exclude some files from the api --- doc/conf.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 2b4b44b7f..fe8864d0b 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -56,11 +56,27 @@ "sphinx.ext.napoleon", # enable Napoleon Sphinx v>1.3 "sphinx.ext.extlinks", # enables external links with a key "sphinx_autodoc_typehints", + "sphinx.ext.inheritance_diagram", ] # Autoapi settings autoapi_type = "python" autoapi_dirs = ["../edisgo"] - +autoapi_options = [ + "members", + "undoc-members", + "private-members", + "show-inheritance", + "show-inheritance-diagram", + "show-module-summary", + "special-members", + "imported-members", +] +# Files to ignore when building api documentation +autoapi_ignore = [ + "*/flex_opt/curtailment.py", + "*/flex_opt/storage_positioning.py", + "*/opf/*", +] # Napoleon settings napoleon_google_docstring = True napoleon_numpy_docstring = True From bcdd150b90e3657c607f2a9efce880a0053fec56 Mon Sep 17 00:00:00 2001 From: Malte Jahn Date: Thu, 23 Mar 2023 13:45:43 +0100 Subject: [PATCH 109/119] Transform to autoapi --- doc/api/edisgo.flex_opt.rst | 0 doc/api/edisgo.network.rst | 0 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 doc/api/edisgo.flex_opt.rst delete mode 100644 doc/api/edisgo.network.rst diff --git a/doc/api/edisgo.flex_opt.rst b/doc/api/edisgo.flex_opt.rst deleted file mode 100644 index e69de29bb..000000000 diff --git a/doc/api/edisgo.network.rst b/doc/api/edisgo.network.rst deleted file mode 100644 index e69de29bb..000000000 From b6f095fdde9f210cebb6be6ea3510565ed48d2cb Mon Sep 17 00:00:00 2001 From: Malte Jahn Date: Thu, 23 Mar 2023 13:48:41 +0100 Subject: [PATCH 110/119] Add sphinx-autoapi to rtd_requirements.txt --- rtd_requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/rtd_requirements.txt b/rtd_requirements.txt index c66544f6d..e74f2f058 100644 --- a/rtd_requirements.txt +++ b/rtd_requirements.txt @@ -19,3 +19,4 @@ docutils == 0.16.0 sphinx >= 4.3.0, < 5.1.0 sphinx_rtd_theme >=0.5.2 sphinx-autodoc-typehints +sphinx-autoapi From b5465ea2da2a7216808c3ee4b4ec026f2d305d9d Mon Sep 17 00:00:00 2001 From: Malte Jahn Date: Thu, 23 Mar 2023 16:06:16 +0100 Subject: [PATCH 111/119] Fix failing plotly tests --- edisgo/tools/plots.py | 1 - 1 file changed, 1 deletion(-) diff --git a/edisgo/tools/plots.py b/edisgo/tools/plots.py index 85eca050a..168b05cca 100644 --- a/edisgo/tools/plots.py +++ b/edisgo/tools/plots.py @@ -1543,7 +1543,6 @@ def plot_dash_app( app = JupyterDash(__name__) # Workaround to use standard python logging with plotly dash - logger.handlers.pop() if debug: app.logger.disabled = False app.logger.setLevel(logging.DEBUG) From 9638bd7d21c633b07f8c54022abb917b9353129f Mon Sep 17 00:00:00 2001 From: Malte Jahn Date: Fri, 24 Mar 2023 10:11:32 +0100 Subject: [PATCH 112/119] Fix bug in logging add grid id. - Before: File formatter was overwritten with stream formatter - Now: Add grid_id dynamically through index of the colon of the existing formatter --- edisgo/edisgo.py | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/edisgo/edisgo.py b/edisgo/edisgo.py index 8384854f8..3767d0323 100755 --- a/edisgo/edisgo.py +++ b/edisgo/edisgo.py @@ -166,26 +166,15 @@ def add_grid_id_filter(record): record.grid_id = self.topology.id return True - file_formatter = logging.Formatter( - "%(asctime)s - %(name)s - %(levelname)s - " - "MVGrid(%(grid_id)s): %(message)s" - ) - stream_formatter = logging.Formatter( - "%(name)s - %(levelname)s - MVGrid(%(grid_id)s): %(message)s" - ) - logger_edisgo = logging.getLogger("edisgo") for handler in logger_edisgo.handlers: - if isinstance(logger_edisgo.handlers[0], logging.StreamHandler): - handler.setFormatter(stream_formatter) - elif isinstance(logger_edisgo.handlers[0], logging.FileHandler): - handler.setFormatter(file_formatter) - else: - raise ValueError( - "Disable the log_grid_id function when using other" - " handlers than StreamHandler or FileHandler" - ) - handler.filters.clear() + fmt = handler.formatter._fmt + colon_idx = fmt.index(":") + formatter_str = ( + f"{fmt[:colon_idx]} - MVGrid(%(grid_id)s){fmt[colon_idx:]}" + ) + formatter = logging.Formatter(formatter_str) + handler.setFormatter(formatter) handler.addFilter(add_grid_id_filter) @property From 91715de8712b3251110215d21a684cfa01910978 Mon Sep 17 00:00:00 2001 From: Malte Jahn Date: Fri, 24 Mar 2023 11:42:27 +0100 Subject: [PATCH 113/119] Fix bug with broken link --- edisgo/network/topology.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edisgo/network/topology.py b/edisgo/network/topology.py index 19df7ada9..e6e79169e 100755 --- a/edisgo/network/topology.py +++ b/edisgo/network/topology.py @@ -2284,7 +2284,7 @@ def _connect_mv_bus_to_target_object( * repr : str Name of line or bus to connect to. * shp : :shapely:`Shapely Point object` or \ - :shapely:`Shapely Line object` + :shapely:`Shapely Line object` Geometry of line or bus to connect to. line_type : str From 50330dd5e765de7ce7fd54dcf6e507926b6dd57a Mon Sep 17 00:00:00 2001 From: birgits Date: Fri, 24 Mar 2023 12:43:27 +0100 Subject: [PATCH 114/119] Remove private functions from API doc --- doc/conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 1f38dd319..a15c618cf 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -64,7 +64,6 @@ autoapi_options = [ "members", "undoc-members", - "private-members", "show-inheritance", "show-inheritance-diagram", "show-module-summary", From aa5d032117e0d0b6bba272c6b4e8430f6780f5ce Mon Sep 17 00:00:00 2001 From: birgits Date: Fri, 24 Mar 2023 14:33:10 +0100 Subject: [PATCH 115/119] Exclude imported-members so that warning cross-reference 'EDisGo': edisgo.edisgo.EDisGo, edisgo.EDisGo is fixed --- doc/conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index a15c618cf..09b2687a6 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -68,7 +68,6 @@ "show-inheritance-diagram", "show-module-summary", "special-members", - "imported-members", ] # Files to ignore when building api documentation autoapi_ignore = [ From abf879d8f0217c5b0055aa40435f398949c1d009 Mon Sep 17 00:00:00 2001 From: birgits Date: Fri, 24 Mar 2023 14:33:26 +0100 Subject: [PATCH 116/119] Reference to API does not work anymore --- doc/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/index.rst b/doc/index.rst index e9cd4847d..dfebb4369 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -45,7 +45,7 @@ See :ref:`quickstart` for the first steps. A deeper guide is provided in :ref:`usage-details`. Methodologies are explained in detail in :ref:`features-in-detail`. For those of you who want to contribute see :ref:`dev-notes` and the -:ref:`api` reference. +API reference. eDisGo was initially developed in the `open_eGo `_ research project as part of From b08d71cff4516559ee395ddee9dac20348252d96 Mon Sep 17 00:00:00 2001 From: birgits Date: Fri, 24 Mar 2023 14:49:05 +0100 Subject: [PATCH 117/119] Adapt instructions on how to build docs --- doc/dev_notes.rst | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/doc/dev_notes.rst b/doc/dev_notes.rst index c4188f7db..a47df0032 100644 --- a/doc/dev_notes.rst +++ b/doc/dev_notes.rst @@ -70,22 +70,15 @@ Code standards Documentation ------------- -Build the docs locally by first setting up the sphinx environment with (executed -from top-level folder) +You can build the docs locally as follows (executed from top-level eDisGo directory): .. code-block:: bash - sphinx-apidoc -f -o doc/api edisgo + sphinx-build -E -a -b html ./doc/ -And then you build the html docs on your computer with +To manually check if external links in the documentation work, you can run the following command (internal links are not checked by this): .. code-block:: bash - sphinx-build -E -a doc/ doc/_html + sphinx-build ./doc/ -b linkcheck -d _build/doctrees _build/html -To manually check if external links in the documentation work, change into the doc -repository and run the following command (internal links are not checked by this): - -.. code-block:: bash - - sphinx-build . -b linkcheck -d _build/doctrees _build/html From 038faafc64587eff42baf00a7bca68dfb39a6474 Mon Sep 17 00:00:00 2001 From: Malte Jahn Date: Fri, 24 Mar 2023 16:06:33 +0100 Subject: [PATCH 118/119] Don't show module attributes --- doc/conf.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/conf.py b/doc/conf.py index 09b2687a6..1b6abf3ff 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -75,6 +75,18 @@ "*/flex_opt/storage_positioning.py", "*/opf/*", ] + + +def skip_autoapi_parts(app, what, name, obj, skip, options): + if obj.type == "data": + skip = True + return skip + + +def setup(sphinx): + sphinx.connect("autoapi-skip-member", skip_autoapi_parts) + + # Napoleon settings napoleon_google_docstring = True napoleon_numpy_docstring = True From 1f6b36e97bd8a8ff873e6a78689064bb2d957d5c Mon Sep 17 00:00:00 2001 From: birgits Date: Sun, 2 Apr 2023 15:39:10 +0200 Subject: [PATCH 119/119] Update version number and add whats new --- doc/conf.py | 2 +- doc/whatsnew.rst | 1 + doc/whatsnew/v0-2-1.rst | 2 +- setup.py | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 1b6abf3ff..67e7741a2 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -153,7 +153,7 @@ def setup(sphinx): # built documents. # # The short X.Y version. -version = "0.2.0" +version = "0.2.1" # The full version, including alpha/beta/rc tags. release = version diff --git a/doc/whatsnew.rst b/doc/whatsnew.rst index cc3471a19..48f93776e 100644 --- a/doc/whatsnew.rst +++ b/doc/whatsnew.rst @@ -8,6 +8,7 @@ Changelog for each release. :local: :backlinks: top +.. include:: whatsnew/v0-2-1.rst .. include:: whatsnew/v0-2-0.rst .. include:: whatsnew/v0-1-1.rst .. include:: whatsnew/v0-1-0.rst diff --git a/doc/whatsnew/v0-2-1.rst b/doc/whatsnew/v0-2-1.rst index 76386724b..4a4d5b787 100644 --- a/doc/whatsnew/v0-2-1.rst +++ b/doc/whatsnew/v0-2-1.rst @@ -1,7 +1,7 @@ Release v0.2.1 ================ -Release date: , +Release date: April 2, 2023 Changes ------- diff --git a/setup.py b/setup.py index cedd26fc8..581e7b5f6 100644 --- a/setup.py +++ b/setup.py @@ -78,7 +78,7 @@ def read(fname): setup( name="eDisGo", - version="0.2.1dev", + version="0.2.1", packages=find_packages(), url="https://github.com/openego/eDisGo", license="GNU Affero General Public License v3.0",