Skip to content

Instantly share code, notes, and snippets.

@henhuy
henhuy / sankey.py
Created April 17, 2024 11:39
Sankey
import itertools
import pandas as pd
import numpy as np
import plotly.graph_objects as go
RESULTS_FILE = "/industry_scratch.csv"
data = pd.read_csv(RESULTS_FILE, delimiter=";")
@henhuy
henhuy / gist:4d6fcdf9c08466cd989830eb5f01d717
Created April 15, 2024 09:13
SPARQL databus collection files
from SPARQLWrapper import JSON, SPARQLWrapper2
DATABUS_ENDPOINT = "https://databus.openenergyplatform.org/sparql"
query = """
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
@henhuy
henhuy / storage_investment_v1_mp.py
Created September 20, 2023 07:41
Oemof.solph storage investment v1 as multi-period
# -*- coding: utf-8 -*-
"""
General description
-------------------
This example shows how to perform a capacity optimization for
an energy system with storage. The following energy system is modeled:
.. code-block:: text
@henhuy
henhuy / moss_registration.py
Last active December 7, 2022 11:15
MOSS registration of artifact
import requests
from urllib.parse import quote
MOSS_URL = "http://moss.tools.dbpedia.org/annotation-api-demo/submit"
METADATA_URL = "https://openenergy-platform.org/api/v0/schema/model_draft/tables/umas_ninja_pv_country_de_merra_2_nuts_2_corrected/meta/"
DATABUS_ARTIFACT = "https://energy.databus.dbpedia.org/henhuy/AP4/modex_capacity_factor"
DATABUS_VERSION = "https://energy.databus.dbpedia.org/henhuy/AP4/modex_capacity_factor/v1"
DATABUS_DATA = "https://energy.databus.dbpedia.org/henhuy/AP4/modex_capacity_factor/v1/modex_capacity_factor_type=metadata.json"
@henhuy
henhuy / postprocessing.py
Created October 7, 2022 09:33
Suggestion for oemof postprocessing refactoring
import abc
from typing import Union, List
class CalculationError(Exception):
"""Raised if something is wrong in calculation"""
class Calculator:
def __init__(self, scalar_params, scalar_results, sequences_params, sequences_results):
@henhuy
henhuy / pyproject.toml
Created April 27, 2022 11:15
Poetry wildcard git conflict
[tool.poetry]
name = "solphdep"
version = "0.1.0"
description = ""
authors = ["Henhuy <you@example.com>"]
[tool.poetry.dependencies]
python = "^3.7"
"oemof.solph" = "*"
oemoflex = { git = "https://git@github.com/rl-institut/oemoflex", branch = "dev"}
@henhuy
henhuy / big_data.py
Created May 28, 2021 09:16
Modex big data scenario
import requests
import json
import ijson
import rapidjson
import simplejson
CONNECTOR_URL = "https://modex.rl-institut.de/scenario/id/"
SCENARIO_ID = 42