Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features/#450 add metadata kh #1122

Open
wants to merge 92 commits into
base: features/#450-add-metadata
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
960cb71
add metadata for grid.egon_emob_charging_infrastructure
khelfen Mar 14, 2023
f511030
add metadata for supply.egon_home_batteries (resolve open TODOs later)
khelfen Mar 15, 2023
b25298e
Merge branch 'features/#1095-mastr-status-quo' into features/#450-add…
khelfen Mar 15, 2023
d25091a
Merge branch 'features/#450-add-metadata' into features/#450-add-meta…
khelfen Mar 15, 2023
d133ac0
add metadata for mastr datasets
khelfen Mar 15, 2023
bfdb7c9
get deposit id from datasets.yml
khelfen Mar 15, 2023
edf2f8b
Rename 'license' to 'licenses'
ClaraBuettner Mar 13, 2023
092e825
Fix name
ClaraBuettner Mar 13, 2023
b397d2f
Fill metadata for static tables
ClaraBuettner Mar 13, 2023
7ae5374
Apply black and isort
ClaraBuettner Mar 13, 2023
6cbe3b4
Add gas sector sources and contributors
AmeliaNadal Mar 13, 2023
98f1081
Adjust metadata sources
AmeliaNadal Mar 13, 2023
61d9419
Add technology data and dsm source
ClaraBuettner Mar 14, 2023
0d1a921
Add metadata for generaotr and bus timeseries tables
ClaraBuettner Mar 14, 2023
b2b6bfb
Add time series meta data automised
ClaraBuettner Mar 15, 2023
5722f8a
Delete unused imports
ClaraBuettner Mar 15, 2023
962ba72
Add dsm sources
ClaraBuettner Mar 15, 2023
379be47
Apply black and isort
ClaraBuettner Mar 15, 2023
b0edc9c
Add vg250 to generator sources
ClaraBuettner Mar 15, 2023
3f33ae0
Update default values for meta data
ClaraBuettner Mar 15, 2023
3d9b1d3
Fix licenses list in metadata
ClaraBuettner Mar 15, 2023
fe77d98
Change contributors of egon-data source
ClaraBuettner Mar 15, 2023
314b780
Add era5 sources to line timeseries metadata
ClaraBuettner Mar 15, 2023
54e99b6
Remove unused sources
ClaraBuettner Mar 15, 2023
c7f66d5
add me to contributors function in metadata.py
khelfen Mar 16, 2023
ca8e815
add metadata to supply.egon_power_plants_pv_roof_building
khelfen Mar 16, 2023
8156167
add ev metadata
khelfen Mar 17, 2023
86a53bf
some small fixes in ev metadata
khelfen Mar 17, 2023
9ac915d
add basic structure for dsm metadata
khelfen Mar 17, 2023
725ba9e
Merge branch 'dev' into features/#450-add-metadata-kh
khelfen Mar 17, 2023
737c501
add metadata for dsm time series
khelfen Mar 17, 2023
87b712a
Merge branch 'features/#1095-mastr-status-quo' into features/#450-add…
khelfen Mar 17, 2023
f13f7df
Merge branch 'features/#1095-mastr-status-quo' into features/#450-add…
khelfen Mar 17, 2023
60c0f30
fix single quote error
khelfen Mar 17, 2023
01508a5
fix single quote error
khelfen Mar 17, 2023
e8052cb
minor bug fix
khelfen Mar 17, 2023
9343fbe
small fix
khelfen Mar 17, 2023
77ceae3
bug fix in metadata string
khelfen Mar 20, 2023
67a6496
Merge branch 'features/#1095-mastr-status-quo' into features/#450-add…
khelfen Mar 20, 2023
34a22b1
Merge branch 'features/#1095-mastr-status-quo' into features/#450-add…
khelfen Mar 20, 2023
0a702b7
Merge branch 'features/#1095-mastr-status-quo' into features/#450-add…
khelfen Mar 20, 2023
48d3469
small bug fix single quote in sql string
khelfen Mar 20, 2023
06fc083
correct contributors field
khelfen Mar 24, 2023
c5766ae
added metadata check with omi
khelfen Mar 24, 2023
6e4689f
Merge branch 'dev' of github.com:openego/eGon-data into features/#450…
khelfen Apr 3, 2023
07b2341
fix date string
khelfen Apr 3, 2023
f1ed5f0
minor fix
khelfen Apr 3, 2023
8b758da
Merge branch 'dev' into features/#450-add-metadata-kh
khelfen Apr 6, 2023
990e544
add sources to dsm time series tables metadata
khelfen Apr 13, 2023
99e3557
Added data documentation for gas, methane and H2 grid
pieterhexen Jul 19, 2023
20af1c0
Added gas related dataset documentation
pieterhexen Jul 20, 2023
1a5b783
Added rtd Data documentation for gas sector
pieterhexen Jul 21, 2023
86adabe
Add new subsection in about.rst
IlkaCu Aug 8, 2023
ec86353
Extend docs for eHV/HV grid topology
IlkaCu Aug 8, 2023
99240cf
Add documentation for electricity demand
IlkaCu Aug 16, 2023
5727030
Add docu for hydro and biomass
IlkaCu Aug 16, 2023
a2e53f2
Add documentation for DSM
KathiEsterl Aug 16, 2023
ebc7ae3
Prepare documentation of PV ground mounted
KathiEsterl Aug 16, 2023
9caa505
Merge remote
KathiEsterl Aug 16, 2023
5862733
Corrections concerning DSM
KathiEsterl Aug 16, 2023
ba46843
Corrections concerning DSM
KathiEsterl Aug 17, 2023
0a0f915
Documentation of PV ground mounted
KathiEsterl Aug 17, 2023
ecd51ea
Corrections concerning PV ground mounted
KathiEsterl Aug 17, 2023
972c81e
Corrections concerning DSM
KathiEsterl Aug 17, 2023
13e63ea
Corrections concerning PV ground mounted
KathiEsterl Aug 17, 2023
c9d7cc3
Correct link
KathiEsterl Aug 17, 2023
613c160
Merge branch 'dev' into rtd_gas
pieterhexen Aug 29, 2023
3b4d998
Solve merge conflicts
KathiEsterl Dec 8, 2023
28447c6
Correct leftover from merge conflict
KathiEsterl Dec 8, 2023
2c7e29d
Merge pull request #1147 from openego/documentation/#1141-rtd-docs-in…
KathiEsterl Dec 8, 2023
6f174c7
Merge pull request #1148 from openego/rtd_gas
pieterhexen Dec 11, 2023
f9f1dfe
Update changelog
nesnoj Jan 10, 2024
98f2ae1
Update zenodo URL of data-bundle
nesnoj Jan 10, 2024
07db06e
Merge pull request #1155 from openego/fixes/#1154-update-zenodo-link-…
nesnoj Jan 10, 2024
ee8961f
Update zenodo URLs of MaStR data (trial run - testing on sandbox)
nesnoj Jan 10, 2024
8a46671
Update changelog
nesnoj Jan 10, 2024
0481f11
Bump mastr dataset version to 0.0.2
nesnoj Jan 10, 2024
a735052
Update zenodo URLs of MaStR data
nesnoj Jan 10, 2024
f562094
Update docs
nesnoj Jan 10, 2024
f6ed482
Merge pull request #1158 from openego/fixes/#1153-update-zenodo-link-…
nesnoj Jan 11, 2024
bad66e7
documentation wind on-offshore
CarlosEpia Jan 11, 2024
891554f
Fix CRS in ERA5 transformation
nesnoj Jan 16, 2024
b05fb83
Update changelog
nesnoj Jan 16, 2024
7cf077b
Merge pull request #1160 from openego/fixes/#1159_era5_crs
nesnoj Jan 16, 2024
0d33a93
renamed metadata.py
khelfen Aug 22, 2024
14373af
Merge remote-tracking branch 'origin/features/#450-add-metadata' into…
khelfen Aug 22, 2024
39327ea
replace oep_metadata_version function
khelfen Aug 22, 2024
cfe1b13
remove zenodo sandbox from metadata strings
khelfen Aug 22, 2024
7a03d06
Merge pull request #1169 from openego/dev
khelfen Aug 23, 2024
173b574
add call to metadata function for mastr
khelfen Oct 14, 2024
6122eea
update dataset version
khelfen Oct 14, 2024
224aa7a
correct use of ' token in metadata
khelfen Oct 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -494,12 +494,12 @@ Changed
`#1073 <https://github.com/openego/eGon-data/issues/1073>`_
* Change hgv data source to use database
`#1086 <https://github.com/openego/eGon-data/issues/1086>`_
* Rename eMob MIT carrier names (use underscores)
`#1105 <https://github.com/openego/eGon-data/issues/1105>`_
* Change desposit ID for data_bundle download from zenodo sandbox
`#1110 <https://github.com/openego/eGon-data/issues/1110>`_
* Use MaStR geocoding results for pv rooftop to buildings mapping workflow
`#1095 <https://github.com/openego/eGon-data/issues/1095>`_
* Rename eMob MIT carrier names (use underscores)
`#1105 <https://github.com/openego/eGon-data/issues/1105>`_

.. _#799: https://github.com/openego/eGon-data/issues/799

Expand Down
214 changes: 209 additions & 5 deletions src/egon/data/datasets/DSM_cts_ind.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
sanity checks. See [#1120](https://github.com/openego/eGon-data/issues/1120)
for updates.
"""
import datetime
import json

from omi.dialects import get_dialect
from sqlalchemy import ARRAY, Column, Float, Integer, String
from sqlalchemy.ext.declarative import declarative_base
import geopandas as gpd
Expand All @@ -18,6 +22,15 @@
from egon.data.datasets import Dataset
from egon.data.datasets.electricity_demand.temporal import calc_load_curve
from egon.data.datasets.industry.temporal import identify_bus
from egon.data.metadata import (
context,
contributors,
generate_resource_fields_from_db_table,
license_odbl,
meta_metadata,
meta_metadata,
sources,
)

# CONSTANTS
# TODO: move to datasets.yml
Expand Down Expand Up @@ -128,7 +141,7 @@ def __init__(self, dependencies):
name=self.name,
version=self.version,
dependencies=self.dependencies,
tasks=(dsm_cts_ind_processing),
tasks=(dsm_cts_ind_processing,),
)


Expand Down Expand Up @@ -205,6 +218,195 @@ class EgonSitesIndLoadCurvesIndividualDsmTimeseries(Base):
e_min = Column(ARRAY(Float))


def add_metadata_individual():
targets = config.datasets()["DSM_CTS_industry"]["targets"]

targets = {
k: v for k, v in targets.items() if "dsm_timeseries" in v["table"]
}

title_dict = {
"egon_etrago_electricity_cts_dsm_timeseries": (
"DSM flexibility band time series for CTS"
),
"egon_osm_ind_load_curves_individual_dsm_timeseries": (
"DSM flexibility band time series for OSM industry sites"
),
"egon_demandregio_sites_ind_electricity_dsm_timeseries": (
"DSM flexibility band time series for demandregio industry sites"
),
"egon_sites_ind_load_curves_individual_dsm_timeseries": (
"DSM flexibility band time series for other industry sites"
),
}

description_dict = {
"egon_etrago_electricity_cts_dsm_timeseries": (
"DSM flexibility band time series for CTS in 1 h resolution "
"including available store capacity and power potential"
),
"egon_osm_ind_load_curves_individual_dsm_timeseries": (
"DSM flexibility band time series for OSM industry sites in 1 h "
"resolution including available store capacity and power potential"
),
"egon_demandregio_sites_ind_electricity_dsm_timeseries": (
"DSM flexibility band time series for demandregio industry sites "
"in 1 h resolution including available store capacity and power "
"potential"
),
"egon_sites_ind_load_curves_individual_dsm_timeseries": (
"DSM flexibility band time series for other industry sites in 1 h "
"resolution including available store capacity and power potential"
),
}

keywords_dict = {
"egon_etrago_electricity_cts_dsm_timeseries": ["cts"],
"egon_osm_ind_load_curves_individual_dsm_timeseries": [
"osm",
"industry",
],
"egon_demandregio_sites_ind_electricity_dsm_timeseries": [
"demandregio",
"industry",
],
"egon_sites_ind_load_curves_individual_dsm_timeseries": ["industry"],
}

primaryKey_dict = {
"egon_etrago_electricity_cts_dsm_timeseries": ["bus"],
"egon_osm_ind_load_curves_individual_dsm_timeseries": ["osm_id"],
"egon_demandregio_sites_ind_electricity_dsm_timeseries": [
"industrial_sites_id",
],
"egon_sites_ind_load_curves_individual_dsm_timeseries": ["site_id"],
}

sources_dict = {
"egon_etrago_electricity_cts_dsm_timeseries": [
sources()["nep2021"],
sources()["zensus"],
],
"egon_osm_ind_load_curves_individual_dsm_timeseries": [
sources()["hotmaps_industrial_sites"],
sources()["schmidt"],
sources()["seenergies"],
],
"egon_demandregio_sites_ind_electricity_dsm_timeseries": [
sources()["openstreetmap"],
],
"egon_sites_ind_load_curves_individual_dsm_timeseries": [
sources()["hotmaps_industrial_sites"],
sources()["openstreetmap"],
sources()["schmidt"],
sources()["seenergies"],
],
}

contris = contributors(["kh", "kh"])

contris[0]["date"] = "2023-03-17"

contris[0]["object"] = "metadata"
contris[1]["object"] = "dataset"

contris[0]["comment"] = "Add metadata to dataset."
contris[1]["comment"] = "Add workflow to generate dataset."

for t_dict in targets.values():
schema = t_dict["schema"]
table = t_dict["table"]
name = f"{schema}.{table}"

meta = {
"name": name,
"title": title_dict[table],
"id": "WILL_BE_SET_AT_PUBLICATION",
"description": description_dict[table],
"language": "en-US",
"keywords": ["dsm", "timeseries"] + keywords_dict[table],
"publicationDate": datetime.date.today().isoformat(),
"context": context(),
"spatial": {
"location": "none",
"extent": "Germany",
"resolution": "none",
},
"temporal": {
"referenceDate": "2011-01-01",
"timeseries": {
"start": "2011-01-01",
"end": "2011-12-31",
"resolution": "1 h",
"alignment": "left",
"aggregationType": "average",
},
},
"sources": [
sources()["egon-data"],
sources()["vg250"],
sources()["demandregio"],
]
+ sources_dict[table],
"licenses": [license_odbl("© eGon development team")],
"contributors": contris,
"resources": [
{
"profile": "tabular-data-resource",
"name": name,
"path": "None",
"format": "PostgreSQL",
"encoding": "UTF-8",
"schema": {
"fields": generate_resource_fields_from_db_table(
schema,
table,
),
"primaryKey": ["scn_name"] + primaryKey_dict[table],
},
"dialect": {"delimiter": "", "decimalSeparator": ""},
}
],
"review": {"path": "", "badge": ""},
"metaMetadata": meta_metadata(),
"_comment": {
"metadata": (
"Metadata documentation and explanation (https://"
"github.com/OpenEnergyPlatform/oemetadata/blob/master/"
"metadata/v141/metadata_key_description.md)"
),
"dates": (
"Dates and time must follow the ISO8601 including time "
"zone (YYYY-MM-DD or YYYY-MM-DDThh:mm:ss±hh)"
),
"units": "Use a space between numbers and units (100 m)",
"languages": (
"Languages must follow the IETF (BCP47) format (en-GB, "
"en-US, de-DE)"
),
"licenses": (
"License name must follow the SPDX License List "
"(https://spdx.org/licenses/)"
),
"review": (
"Following the OEP Data Review (https://github.com/"
"OpenEnergyPlatform/data-preprocessing/wiki)"
),
"none": "If not applicable use (none)",
},
}

dialect = get_dialect(meta_metadata()["metadataVersion"])()

meta = dialect.compile_and_render(dialect.parse(json.dumps(meta)))

db.submit_comment(
f"'{json.dumps(meta)}'",
schema,
table,
)


# Code
def cts_data_import(cts_cool_vent_ac_share):
"""
Expand Down Expand Up @@ -999,10 +1201,10 @@ def delete_dsm_entries(carrier):

# buses

sql = f"""
DELETE FROM {targets["bus"]["schema"]}.{targets["bus"]["table"]} b
WHERE (b.carrier LIKE '{carrier}');
"""
sql = (
f"DELETE FROM {targets['bus']['schema']}.{targets['bus']['table']} b "
f"WHERE (b.carrier LIKE '{carrier}');"
)
db.execute_sql(sql)

# links
Expand Down Expand Up @@ -1621,3 +1823,5 @@ def dsm_cts_ind_processing():
dsm_cts_ind()

dsm_cts_ind_individual()

add_metadata_individual()
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
EgonEvMvGridDistrict,
EgonEvPool,
EgonEvTrip,
add_metadata,
)
from egon.data.datasets.emobility.motorized_individual_travel.ev_allocation import ( # noqa: E501
allocate_evs_numbers,
Expand Down Expand Up @@ -475,5 +476,6 @@ def generate_model_data_tasks(scenario_name):
*generate_model_data_tasks(scenario_name="eGon2035"),
*generate_model_data_tasks(scenario_name="eGon100RE"),
},
add_metadata,
),
)
Loading
Loading