Passed
Pull Request — dev (#1344)
by
unknown
02:05
created

data.metadata.oem_datapackage_template()   A

Complexity

Conditions 3

Size

Total Lines 24
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 24
rs 10
c 0
b 0
f 0
cc 3
nop 0
1
from copy import deepcopy
2
3
from geoalchemy2 import Geometry
4
from omi.base import MetadataSpecification, get_metadata_specification
5
from omi.validation import parse_metadata, validate_metadata
6
from sqlalchemy import MetaData, Table
7
from sqlalchemy.dialects.postgresql.base import ischema_names
8
import importlib_resources
9
10
from egon.data import db, logger
11
from egon.data.datasets import Dataset
12
from egon.data.db import engine
13
from egon.data.metadata import settings
14
15
# Easy access to oemetadata schema, template and example Dicts
16
# Uses the oemetadata version specified in settings module
17
OEMetaData: MetadataSpecification = get_metadata_specification(
18
    settings.OEMETADATA_VERSION
19
)
20
21
22
def oem_datapackage_template() -> dict:
23
    """
24
    Provides a clean interface to the oemetadata template.
25
26
    the template is used to create a new metadata. It provides
27
    all oemetadata properties, including nested fields with empty
28
    -> "" values assigned
29
30
    Returns
31
    -------
32
    dict
33
        OEP metadata conform template for new metadata
34
    """
35
36
    template: dict
37
38
    if OEMetaData.template:
39
        template: dict = deepcopy(OEMetaData.template)
40
41
    if OEMetaData.example:
42
        template["@context"] = OEMetaData.example["@context"]
43
        template["metaMetadata"] = OEMetaData.example["metaMetadata"]
44
45
    return template
0 ignored issues
show
introduced by
The variable template does not seem to be defined in case OEMetaData.template on line 38 is False. Are you sure this can never be the case?
Loading history...
46
47
48
def context():
49
    """
50
    Project context information for metadata
51
52
    Returns
53
    -------
54
    dict
55
        OEP metadata conform data license information
56
    """
57
58
    return {
59
        "homepage": "https://ego-n.org/",
60
        "documentation": "https://egon-data.readthedocs.io/en/latest/",
61
        "sourceCode": "https://github.com/openego/eGon-data",
62
        "contact": "https://ego-n.org/partners/",
63
        "grantNo": "03EI1002",
64
        "fundingAgency": "Bundesministerium für Wirtschaft und Energie",
65
        "fundingAgencyLogo": "https://www.innovation-beratung-"
66
        "foerderung.de/INNO/Redaktion/DE/Bilder/"
67
        "Titelbilder/titel_foerderlogo_bmwi.jpg?"
68
        "__blob=normal&v=3",
69
        "publisherLogo": "https://ego-n.org/images/eGon_logo_"
70
        "noborder_transbg.svg",
71
    }
72
73
74
# TODO @jh-RLI: All licenses should be read from SPDX data license list
75
# -> especially the "name" prop
76
# -> see SPDX:oem licenseId:name / name:title / reference:path
77
# extend omi to provide list, makes sure licenses are compliant with oeplatform
78
# which is important for full data publication on the OEP.
79
# SPDX list is quite popular
80
# https://github.com/OpenEnergyPlatform/omi/blob/feature-126-add-yaml-and-template-based-metadata-creation/src/omi/data/licenses.json  # noqa: E501
81
def licenses_datenlizenz_deutschland(
82
    attribution=settings.EGON_ATTRIBUTION,
83
):
84
    """
85
    License information for Datenlizenz Deutschland
86
87
    Parameters
88
    ----------
89
    attribution : str
90
        Attribution for the dataset incl. © symbol, e.g. '© GeoBasis-DE / BKG'
91
92
    Returns
93
    -------
94
    dict
95
        OEP metadata conform data license information
96
    """
97
98
    return {
99
        "name": "dl-by-de/2.0",
100
        "title": "Datenlizenz Deutschland – Namensnennung – Version 2.0",
101
        "path": "www.govdata.de/dl-de/by-2-0",
102
        "instruction": (
103
            "Jede Nutzung ist unter den Bedingungen dieser „Datenlizenz "
104
            "Deutschland - Namensnennung - Version 2.0 zulässig.\nDie "
105
            "bereitgestellten Daten und Metadaten dürfen für die "
106
            "kommerzielle und nicht kommerzielle Nutzung insbesondere:"
107
            "(1) vervielfältigt, ausgedruckt, präsentiert, verändert, "
108
            "bearbeitet sowie an Dritte übermittelt werden;\n "
109
            "(2) mit eigenen Daten und Daten Anderer zusammengeführt und "
110
            "zu selbständigen neuen Datensätzen verbunden werden;\n "
111
            "(3) in interne und externe Geschäftsprozesse, Produkte und "
112
            "Anwendungen in öffentlichen und nicht öffentlichen "
113
            "elektronischen Netzwerken eingebunden werden.\n"
114
            "Bei der Nutzung ist sicherzustellen, dass folgende Angaben "
115
            "als Quellenvermerk enthalten sind:\n"
116
            "(1) Bezeichnung des Bereitstellers nach dessen Maßgabe,\n"
117
            "(2) der Vermerk Datenlizenz Deutschland – Namensnennung – "
118
            "Version 2.0 oder dl-de/by-2-0 mit Verweis auf den Lizenztext "
119
            "unter www.govdata.de/dl-de/by-2-0 sowie\n"
120
            "(3) einen Verweis auf den Datensatz (URI)."
121
            "Dies gilt nur soweit die datenhaltende Stelle die Angaben"
122
            "(1) bis (3) zum Quellenvermerk bereitstellt.\n"
123
            "Veränderungen, Bearbeitungen, neue Gestaltungen oder "
124
            "sonstige Abwandlungen sind im Quellenvermerk mit dem Hinweis "
125
            "zu versehen, dass die Daten geändert wurden."
126
        ),
127
        "attribution": attribution,
128
    }
129
130
131
def license_odbl(attribution=settings.EGON_ATTRIBUTION):
132
    """
133
    License information for Open Data Commons Open Database License (ODbL-1.0)
134
135
    Parameters
136
    ----------
137
    attribution : str
138
        Attribution for the dataset incl. © symbol, e.g.
139
        '© OpenStreetMap contributors'
140
141
    Returns
142
    -------
143
    dict
144
        OEP metadata conform data license information
145
    """
146
    return {
147
        "name": "ODbL-1.0",
148
        "title": "Open Data Commons Open Database License 1.0",
149
        "path": "https://opendatacommons.org/licenses/odbl/1.0/index.html",
150
        "instruction": "You are free: To Share, To Create, To Adapt; "
151
        "As long as you: Attribute, Share-Alike, Keep open!",
152
        "attribution": attribution,
153
    }
154
155
156
def license_ccby(attribution=settings.EGON_ATTRIBUTION):
157
    """
158
    License information for Creative Commons Attribution 4.0 International
159
    (CC-BY-4.0)
160
161
    Parameters
162
    ----------
163
    attribution : str
164
        Attribution for the dataset incl. © symbol, e.g. '© GeoBasis-DE / BKG'
165
166
    Returns
167
    -------
168
    dict
169
        OEP metadata conform data license information
170
    """
171
    return {
172
        "name": "CC-BY-4.0",
173
        "title": "Creative Commons Attribution 4.0 International",
174
        "path": "https://creativecommons.org/licenses/by/4.0/legalcode",
175
        "instruction": "You are free: To Share, To Create, To Adapt; "
176
        "As long as you: Attribute.",
177
        "attribution": attribution,
178
    }
179
180
181
def license_geonutzv(attribution=settings.EGON_ATTRIBUTION):
182
    """
183
    License information for GeoNutzV
184
185
    Parameters
186
    ----------
187
    attribution : str
188
        Attribution for the dataset incl. © symbol, e.g. '© GeoBasis-DE / BKG'
189
190
    Returns
191
    -------
192
    dict
193
        OEP metadata conform data license information
194
    """
195
    return {
196
        "name": "geonutzv-de-2013-03-19",
197
        "title": "Verordnung zur Festlegung der Nutzungsbestimmungen für die "
198
        "Bereitstellung von Geodaten des Bundes",
199
        "path": "https://www.gesetze-im-internet.de/geonutzv/",
200
        "instruction": "Geodaten und Geodatendienste, einschließlich "
201
        "zugehöriger Metadaten, werden für alle derzeit "
202
        "bekannten sowie für alle zukünftig bekannten Zwecke "
203
        "kommerzieller und nicht kommerzieller Nutzung "
204
        "geldleistungsfrei zur Verfügung gestellt, soweit "
205
        "durch besondere Rechtsvorschrift nichts anderes "
206
        "bestimmt ist oder vertragliche oder gesetzliche "
207
        "Rechte Dritter dem nicht entgegenstehen.",
208
        "attribution": attribution,
209
    }
210
211
212
def license_agpl(attribution=settings.EGON_ATTRIBUTION):
213
    """
214
    License information for GNU Affero General Public License v3.0
215
216
    Parameters
217
    ----------
218
    attribution : str
219
        Attribution for the dataset incl. © symbol, e.g. '© GeoBasis-DE / BKG'
220
221
    Returns
222
    -------
223
    dict
224
        OEP metadata conform data license information
225
    """
226
    return {
227
        "name": "AGPL-3.0 License",
228
        "title": "GNU Affero General Public License v3.0",
229
        "path": "https://www.gnu.org/licenses/agpl-3.0.de.html",
230
        "instruction": "Permissions of this strongest copyleft license are"
231
        "conditioned on making available complete source code of licensed "
232
        "works and modifications, which include larger works using a licensed"
233
        "work, under the same license. Copyright and license notices must be"
234
        "preserved. Contributors provide an express grant of patent rights."
235
        "When a modified version is used to provide a service over a network,"
236
        "the complete source code of the modified version must be made "
237
        "available.",
238
        "attribution": attribution,
239
    }
240
241
242
def license_dedl(attribution=settings.EGON_ATTRIBUTION):
243
    """
244
    License information for Data licence Germany – attribution – version 2.0
245
246
    Parameters
247
    ----------
248
    attribution : str
249
        Attribution for the dataset incl. © symbol, e.g. '© GeoBasis-DE / BKG'
250
251
    Returns
252
    -------
253
    dict
254
        OEP metadata conform data license information
255
    """
256
    return {
257
        "name": "DL-DE-BY-2.0",
258
        "title": "Data licence Germany – attribution – version 2.0",
259
        "path": "https://www.govdata.de/dl-de/by-2-0",
260
        "instruction": (
261
            "Any use will be permitted provided it fulfils the requirements of"
262
            ' this "Data licence Germany – attribution – Version 2.0". The '
263
            "data and meta-data provided may, for commercial and "
264
            "non-commercial use, in particular be copied, printed, presented, "
265
            "altered, processed and transmitted to third parties; be merged "
266
            "with own data and with the data of others and be combined to form"
267
            " new and independent datasets; be integrated in internal and "
268
            "external business processes, products and applications in public "
269
            "and non-public electronic networks. The user must ensure that the"
270
            " source note contains the following information: the name of the "
271
            'provider, the annotation "Data licence Germany – attribution – '
272
            'Version 2.0" or "dl-de/by-2-0" referring to the licence text '
273
            "available at www.govdata.de/dl-de/by-2-0, and a reference to the "
274
            "dataset (URI). This applies only if the entity keeping the data "
275
            "provides the pieces of information 1-3 for the source note. "
276
            "Changes, editing, new designs or other amendments must be marked "
277
            "as such in the source note."
278
        ),
279
        "attribution": attribution,
280
    }
281
282
283
def license_egon_data_odbl():
284
    """
285
    ODbL license with eGon data attribution
286
287
    Returns
288
    -------
289
    dict
290
        OEP metadata conform data license information for eGon tables
291
    """
292
    return license_odbl("© eGon development team")
293
294
295
# TODO @jh-RLI: Metadata schema.fields generation is a generic task and could
296
# be moved to OMI for others to also use it and reduce responsibilities in
297
# egon-data. Low prio as this here already works.
298
# High prio make sure this works with the oem v2 as schema is now at a
299
# different location.
300
def generate_resource_fields_from_sqla_model(model):
301
    """Generate a template for the resource fields for metadata from a SQL
302
    Alchemy model.
303
304
    For details on the fields see field 14.6.1 of `Open Energy Metadata
305
    <https://github.com/OpenEnergyPlatform/ oemetadata/blob/develop/metadata/
306
    v141/metadata_key_description.md>`_ standard.
307
    The fields `name` and `type` are automatically filled, the `description`
308
    and `unit` must be filled manually.
309
310
    Examples
311
    --------
312
    >>> from egon.data.metadata import generate_resource_fields_from_sqla_model
313
    >>> from egon.data.datasets.zensus_vg250 import Vg250Sta
314
    >>> resources = generate_resource_fields_from_sqla_model(Vg250Sta)
315
316
    Parameters
317
    ----------
318
    model : sqlalchemy.ext.declarative.declarative_base()
319
        SQLA model
320
321
    Returns
322
    -------
323
    list of dict
324
        Resource fields
325
    """
326
327
    return [
328
        {
329
            "name": col.name,
330
            "description": "",
331
            "type": str(col.type).lower(),
332
            "unit": "none",
333
        }
334
        for col in model.__table__.columns
335
    ]
336
337
338
def generate_resource_fields_from_db_table(schema, table, geom_columns=None):
339
    """Generate a template for the resource fields for metadata from a
340
    database table.
341
342
    For details on the fields see field 14.6.1 of `Open Energy Metadata
343
    <https://github.com/OpenEnergyPlatform/ oemetadata/blob/develop/metadata/
344
    v141/metadata_key_description.md>`_ standard.
345
    The fields `name` and `type` are automatically filled, the `description`
346
    and `unit` must be filled manually.
347
348
    Examples
349
    --------
350
    >>> from egon.data.metadata import generate_resource_fields_from_db_table
351
    >>> resources = generate_resource_fields_from_db_table(
352
    ...     'openstreetmap', 'osm_point', ['geom', 'geom_centroid']
353
    ... )  # doctest: +SKIP
354
355
    Parameters
356
    ----------
357
    schema : str
358
        The target table's database schema
359
    table : str
360
        Database table on which to put the given comment
361
    geom_columns : list of str
362
        Names of all geometry columns in the table. This is required to return
363
        Geometry data type for those columns as SQL Alchemy does not recognize
364
        them correctly. Defaults to ['geom'].
365
366
    Returns
367
    -------
368
    list of dict
369
        Resource fields
370
    """
371
372
    # handle geometry columns
373
    if geom_columns is None:
374
        geom_columns = ["geom"]
375
    for col in geom_columns:
376
        ischema_names[col] = Geometry
377
378
    table = Table(
379
        table, MetaData(), schema=schema, autoload=True, autoload_with=engine()
380
    )
381
382
    return [
383
        {
384
            "name": col.name,
385
            "description": "",
386
            "type": str(col.type).lower(),
387
            "unit": "none",
388
        }
389
        for col in table.c
390
    ]
391
392
393
def sources():
394
    shared_licenses = [license_geonutzv("© BGR, Hannover, 2021")]
395
    shared_path = "https://dx.doi.org/10.5281/zenodo.4896526"
396
    shared_title = (
397
        "Informationssystem Salz: Planungsgrundlagen, Auswahlkriterien"
398
        " und Potenzialabschätzung für die Errichtung von Salzkavernen"
399
        " zur Speicherung von Erneuerbaren Energien"
400
        " (Wasserstoff und Druckluft)"
401
        " – Doppelsalinare und flach lagernde Salzschichten."
402
        " Teilprojekt Bewertungskriterien und Potenzialabschätzung"
403
    )
404
    return {
405
        "bgr_inspee": {
406
            "title": "Salt structures in Northern Germany",
407
            "description": (
408
                'The application "Information System Salt Structures"'
409
                " provides information about the areal distribution of"
410
                " salt structures (stocks and pillows) in Northern"
411
                " Germany. With general structural describing"
412
                " information, such as depth, secondary thickness,"
413
                " types of use or state of exploration, queries can be"
414
                " conducted. Contours of the salt structures can be"
415
                " displayed at horizontal cross-sections at four"
416
                " different depths up to a maximum depth of 2000 m"
417
                " below NN. A data sheet with information and further"
418
                " reading is provided for every single salt structure."
419
                " Taking into account the fact that this work was"
420
                " undertaken at a scale for providing an overview and"
421
                " not for investigation of single structures, the scale"
422
                " of display is limited to a minimum of 1:300.000."
423
                " This web application is the product of a BMWi-funded"
424
                ' research project "InSpEE" running from the year 2012'
425
                ' to 2015. The acronym stands for "Information system'
426
                " salt structures: planning basis, selection criteria"
427
                " and estimation of the potential for the construction"
428
                " of salt caverns for the storage of renewable energies"
429
                ' (hydrogen and compressed air)".'
430
            ),
431
            "path": (
432
                "https://produktcenter.bgr.de/terraCatalog/DetailResult.do"
433
                "?fileIdentifier=338136ea-261a-4569-a2bf-92999d09bad2"
434
            ),
435
            "licenses": [license_geonutzv("© BGR, Hannover, 2015")],
436
        },
437
        "bgr_inspeeds": {
438
            "title": "Flat layered salts in Germany",
439
            "description": (
440
                "Which salt formations are suitable for storing"
441
                " hydrogen or compressed air?"
442
                " In the InSpEE-DS research project, scientists"
443
                " developed requirements and criteria for the"
444
                " assessment of suitable sites even if their"
445
                " exploration is still at an early stage and there is"
446
                " little knowledge of the salinaries structures."
447
                " Scientists at DEEP.KBB GmbH in Hanover, worked"
448
                " together with their project partners at the Federal"
449
                " Institute for Geosciences and Natural Resources and"
450
                " the Leibniz University Hanover, Institute for"
451
                " Geotechnics Hanover, to develop the planning basis"
452
                " for the site selection and for the construction of"
453
                " storage caverns in flat layered salt and multiple or"
454
                " double saliniferous formations."
455
                " Such caverns could store renewable energy in the form"
456
                " of hydrogen or compressed air."
457
                " While the previous project InSpEE was limited to salt"
458
                " formations of great thickness in Northern Germany,"
459
                " salt horizons of different ages have now been"
460
                " examined all over Germany. To estimate the potential,"
461
                " depth contour maps of the top and the base as well as"
462
                " thickness maps of the respective stratigraphic units"
463
                " and reference profiles were developed. Information on"
464
                " compressed air and hydrogen storage potential were"
465
                " given for the identified areas and for the individual"
466
                " federal states. The web service"
467
                ' "Information system for flat layered salt"'
468
                " gives access to this data. The scale of display is"
469
                " limited to a minimum of 1:300.000. This geographic"
470
                " information is product of a BMWi-funded research"
471
                ' project "InSpEE-DS" running from the year 2015 to'
472
                " 2019. The acronym stands for"
473
                ' "Information system salt: planning basis, selection'
474
                " criteria and estimation of the potential for the"
475
                " construction of salt caverns for the storage of"
476
                " renewable energies (hydrogen and compressed air)"
477
                ' - double saline and flat salt layers".'
478
            ),
479
            "path": (
480
                "https://produktcenter.bgr.de/terraCatalog/DetailResult.do"
481
                "?fileIdentifier=630430b8-4025-4d6f-9a62-025b53bc8b3d"
482
            ),
483
            "licenses": shared_licenses,
484
        },
485
        "bgr_inspeeds_data_bundle": {
486
            "title": shared_title,
487
            "description": (
488
                "Shapefiles corresponding to the data provided in"
489
                " figure 7-1 (Donadei, S., et al., 2020, p. 7-5)."
490
                " The energy storage potential data are provided per"
491
                " federal state in table 7-1"
492
                " (Donadei, S., et al., 2020, p. 7-4)."
493
                " Note: Please include all bgr data sources when using"
494
                " the data."
495
            ),
496
            "path": shared_path,
497
            "licenses": shared_licenses,
498
        },
499
        "bgr_inspeeds_report": {
500
            "title": shared_title,
501
            "description": (
502
                "The report includes availability of saltstructures for"
503
                " energy storage and energy storage potential"
504
                " accumulated per federal state in Germany."
505
            ),
506
            "path": (
507
                "https://www.bgr.bund.de/DE/Themen"
508
                "/Nutzung_tieferer_Untergrund_CO2Speicherung/Downloads"
509
                "/InSpeeDS_TP_Bewertungskriterien.pdf"
510
                "?__blob=publicationFile&v=3"
511
            ),
512
            "licenses": shared_licenses,
513
        },
514
        "demandregio": {
515
            "title": "DemandRegio",
516
            "description": (
517
                "Harmonisierung und Entwicklung von Verfahren zur"
518
                " regionalen und zeitlichen Auflösung von"
519
                " Energienachfragen"
520
            ),
521
            "path": "https://doi.org/10.34805/ffe-119-20",
522
            "licenses": [license_ccby("© FZJ, TUB, FfE")],
523
        },
524
        "egon-data": {
525
            "title": "eGon-data",
526
            "description": (
527
                "Workflow to download, process and generate data sets"
528
                " suitable for the further research conducted in the"
529
                " project eGon (https://ego-n.org/)"
530
            ),
531
            "path": "https://github.com/openego/eGon-data",
532
            "licenses": [license_agpl(settings.EGON_ATTRIBUTION)],
533
        },
534
        "egon-data_bundle": {
535
            "title": "Data bundle for egon-data",
536
            "description": (
537
                "Zenodo repository to provide several different input"
538
                " data sets for eGon-data"
539
            ),
540
            "path": "https://zenodo.org/record/10226009",
541
            "licenses": [license_ccby("© eGon development team")],
542
        },
543
        "Einspeiseatlas": {
544
            "title": "Einspeiseatlas",
545
            "description": (
546
                "Im Einspeiseatlas finden sie sich die Informationen zu"
547
                " realisierten und geplanten Biomethanaufbereitungsanlagen"
548
                " - mit und ohne Einspeisung ins Gasnetz -"
549
                " in Deutschland und weltweit."
550
            ),
551
            "path": "https://www.biogaspartner.de/einspeiseatlas/",
552
            "licenses": [
553
                license_ccby("Deutsche Energie-Agentur (dena, 2021)")
554
            ],
555
        },
556
        "era5": {
557
            "title": "ERA5 global reanalysis",
558
            "description": (
559
                "ERA5 is the fifth generation ECMWF reanalysis for the"
560
                " global climate and weather for the past 4 to 7"
561
                " decades. Currently data is available from 1950, split"
562
                " into Climate Data Store entries for 1950-1978"
563
                " (preliminary back extension) and from 1979 onwards"
564
                " (final release plus timely updates, this page)."
565
                " ERA5 replaces the ERA-Interim reanalysis."
566
                " See the online ERA5 documentation ("
567
                "https://confluence.ecmwf.int/display/CKB"
568
                "/ERA5%3A+data+documentation"
569
                "#ERA5:datadocumentation-Dataupdatefrequency)"
570
                " for more information."
571
            ),
572
            "path": (
573
                "https://confluence.ecmwf.int/display/CKB"
574
                "/ERA5%3A+data+documentation"
575
                "#ERA5:datadocumentation-Dataupdatefrequency"
576
            ),
577
            "licenses": [
578
                {
579
                    "name": "Licence to use Copernicus Products",
580
                    "title": "Licence to use Copernicus Products",
581
                    "path": (
582
                        "https://cds.climate.copernicus.eu/api/v2/terms"
583
                        "/static/licence-to-use-copernicus-products.pdf"
584
                    ),
585
                    "instruction": (
586
                        "This Licence is free of charge, worldwide,"
587
                        " non-exclusive, royalty free and perpetual."
588
                        " Access to Copernicus Products is given for"
589
                        " any purpose in so far as it is lawful,"
590
                        " whereas use may include, but is not limited"
591
                        " to: reproduction; distribution; communication"
592
                        " to the public; adaptation, modification and"
593
                        " combination with other data and information;"
594
                        " or any combination of the foregoing"
595
                    ),
596
                    "attribution": (
597
                        "Copernicus Climate Change Service (C3S)"
598
                        " Climate Data Store"
599
                    ),
600
                },
601
            ],
602
        },
603
        "dsm-heitkoetter": {
604
            "title": (
605
                "Assessment of the regionalised demand response"
606
                " potential in Germany using an open source tool and"
607
                " dataset"
608
            ),
609
            "description": (
610
                "With the expansion of renewable energies in Germany,"
611
                " imminent grid congestion events occur more often. One"
612
                " approach for avoiding curtailment of renewable"
613
                " energies is to cover excess feed-in by demand"
614
                " response."
615
                " As curtailment is often a local phenomenon, in this"
616
                " work we determine the regional demand response"
617
                " potential for the 401 German administrative districts"
618
                " with a temporal resolution of 15 min, including"
619
                " technical, socio-technical and economic restrictions."
620
            ),
621
            "path": "https://doi.org/10.1016/j.adapen.2020.100001",
622
            "licenses": [
623
                license_ccby(
624
                    "© 2020 German Aerospace Center (DLR),"
625
                    " Institute of Networked Energy Systems."
626
                )
627
            ],
628
        },
629
        "hotmaps_industrial_sites": {
630
            "titel": "industrial_sites_Industrial_Database",
631
            "description": (
632
                "Georeferenced industrial sites of energy-intensive"
633
                " industry sectors in EU28"
634
            ),
635
            "path": (
636
                "https://gitlab.com/hotmaps/industrial_sites"
637
                "/industrial_sites_Industrial_Database"
638
            ),
639
            "licenses": [
640
                license_ccby("© 2016-2018: Pia Manz, Tobias Fleiter")
641
            ],
642
        },
643
        "hotmaps_scen_buildings": {
644
            "titel": "scen_current_building_demand",
645
            "description": (
646
                "Energy demand scenarios in buidlings until the year 2050"
647
                " - current policy scenario"
648
            ),
649
            "path": "https://gitlab.com/hotmaps/scen_current_building_demand",
650
            "licenses": [
651
                license_ccby(
652
                    "© 2016-2018: Michael Hartner"
653
                    ", Lukas Kranzl"
654
                    ", Sebastian Forthuber"
655
                    ", Sara Fritz"
656
                    ", Andreas Müller"
657
                )
658
            ],
659
        },
660
        "mastr": {
661
            "title": "open-MaStR power unit registry",
662
            "description": (
663
                "Raw data download Marktstammdatenregister (MaStR) data"
664
                " using the webservice. All data from the"
665
                " Marktstammdatenregister is included. There are"
666
                " duplicates included. For further information read in"
667
                " the documentation of the original data source:"
668
                " https://www.marktstammdatenregister.de/MaStRHilfe"
669
                "/subpages/statistik.html"
670
            ),
671
            "path": "https://zenodo.org/record/10480930",
672
            "licenses": [
673
                licenses_datenlizenz_deutschland(
674
                    "© 2021 Bundesnetzagentur für Elektrizität, Gas,"
675
                    " Telekommunikation, Post und Eisenbahnen"
676
                )
677
            ],
678
        },
679
        "nep2021": {
680
            "title": (
681
                "Netzentwicklungsplan Strom 2035, Version 2021, erster"
682
                " Entwurf"
683
            ),
684
            "description": (
685
                "Die vier deutschen Übertragungsnetzbetreiber zeigen"
686
                " mit diesem ersten Entwurf des Netzentwicklungsplans"
687
                " 2035, Version 2021, den benötigten Netzausbau für die"
688
                " nächsten Jahre auf. Der NEP-Bericht beschreibt keine"
689
                " konkreten Trassenverläufe von Übertragungsleitungen,"
690
                " sondern er dokumentiert den notwendigen"
691
                " Übertragungsbedarf zwischen Netzknoten."
692
                " Das heißt, es werden Anfangs- und Endpunkte von"
693
                " zukünftigen Leitungsverbindungen definiert sowie"
694
                " konkrete Empfehlungen für den Aus- und Neubau der"
695
                " Übertragungsnetze an Land und auf See in Deutschland"
696
                " gemäß den Detailanforderungen im § 12 EnWG gegeben."
697
            ),
698
            "path": "https://zenodo.org/record/5743452#.YbCoz7so8go",
699
            "licenses": [license_ccby("© Übertragungsnetzbetreiber")],
700
        },
701
        "openffe_gas": {
702
            "title": (
703
                "Load Curves of the Industry Sector"
704
                " – eXtremOS solidEU Scenario (Europe NUTS-3)"
705
            ),
706
            "description": (
707
                "Load Curves of the Industry Sector for the eXtremOS"
708
                " solidEU Scenario Scenario at NUTS-3-Level."
709
                " More information at https://extremos.ffe.de/."
710
            ),
711
            "path": (
712
                "http://opendata.ffe.de/dataset"
713
                "/load-curves-of-the-industry-sector-extremos-solideu"
714
                "-scenario-europe-nuts-3/"
715
            ),
716
            "licenses": [license_ccby("© FfE, eXtremOS Project")],
717
        },
718
        "openstreetmap": {
719
            "title": "OpenStreetMap Data Extracts (Geofabrik)",
720
            "description": (
721
                "Full data extract of OpenStreetMap data for defined"
722
                ' spatial extent at "referenceDate"'
723
            ),
724
            "path": (
725
                "https://download.geofabrik.de/europe/germany-210101.osm.pbf"
726
            ),
727
            "licenses": [license_odbl("© OpenStreetMap contributors")],
728
        },
729
        "peta": {
730
            "title": "Pan-European Thermal Atlas, Peta version 5.0.1",
731
            "description": (
732
                "Modelled Heat Demand distribution (in GJ per hectare"
733
                " grid cell) for residential and service heat demands"
734
                " for space heating and hot water for the year 2015"
735
                " using HRE4 data and the combined top-down bottom-up"
736
                " approach of HRE4. National sector-specific heat"
737
                " demand data, derived by the FORECAST model in HRE4"
738
                " for residential (delivered energy, for space heating"
739
                " and hot water) and service-sector (delivered energy,"
740
                " for space heating, hot water and process heat)"
741
                " buildings for the year 2015, were distributed using"
742
                " modelled, spatial statistics based floor areas in"
743
                " 100x100m grids and a population grid. For further"
744
                " information please see the documentation available on"
745
                " the Heat Roadmap Europe website, in particular D2.3"
746
                " report: Methodologies and assumptions used in the"
747
                " mapping."
748
            ),
749
            "path": "https://s-eenergies-open-data-euf.hub.arcgis.com/search",
750
            "licenses": [
751
                license_ccby(
752
                    "© Europa-Universität Flensburg"
753
                    ", Halmstad University and Aalborg University"
754
                )
755
            ],
756
        },
757
        "pipeline_classification": {
758
            "title": (
759
                "Technical pipeline characteristics for high pressure"
760
                " pipelines"
761
            ),
762
            "description": (
763
                "Parameters for the classification of gas pipelines,"
764
                " the whole documentation could is available at:"
765
                " https://www.econstor.eu/bitstream/10419/173388/1"
766
                "/1011162628.pdf"
767
            ),
768
            "path": "https://zenodo.org/record/5743452",
769
            "licenses": [license_ccby("© DIW Berlin, 2017")],
770
        },
771
        "schmidt": {
772
            "title": (
773
                "Supplementary material to the masters thesis:"
774
                " NUTS-3 Regionalization of Industrial Load Shifting"
775
                " Potential in Germany using a Time-Resolved Model"
776
            ),
777
            "description": (
778
                "Supplementary material to the named masters thesis,"
779
                " containing data on industrial processes for the"
780
                " estimation of NUTS-3 load shifting potential of"
781
                " suitable electrically powered industrial processes"
782
                " (cement milling, mechanical pulping, paper"
783
                " production, air separation)."
784
            ),
785
            "path": "https://zenodo.org/record/3613767",
786
            "licenses": [license_ccby("© 2019 Danielle Schmidt")],
787
        },
788
        "SciGRID_gas": {
789
            "title": "SciGRID_gas IGGIELGN",
790
            "description": (
791
                "The SciGRID_gas dataset represents the European gas"
792
                " transport network (pressure levels of 20 bars and"
793
                " higher) including the geo-referenced transport"
794
                " pipelines, compressor stations, LNG terminals,"
795
                " storage, production sites, gas power plants, border"
796
                " points, and demand time series."
797
            ),
798
            "path": shared_path,
799
            "licenses": [
800
                license_ccby(
801
                    "Jan Diettrich; Adam Pluta; Wided Medjroubi (DLR-VE)"
802
                ),
803
            ],
804
        },
805
        "seenergies": {
806
            "title": "D5 1 Industry Dataset With Demand Data",
807
            "description": (
808
                "Georeferenced EU28 industrial sites with quantified"
809
                " annual excess heat volumes and demand data within"
810
                " main sectors: Chemical industry, Iron and steel,"
811
                " Non-ferrous metals, Non-metallic minerals, Paper and"
812
                " printing, and Refineries."
813
            ),
814
            "path": (
815
                "https://s-eenergies-open-data-euf.hub.arcgis.com"
816
                "/datasets/5e36c0af918040ed936b4e4c101f611d_0/about"
817
            ),
818
            "licenses": [license_ccby("© Europa-Universität Flensburg")],
819
        },
820
        "technology-data": {
821
            "titel": "Energy System Technology Data v0.3.0",
822
            "description": (
823
                "This script compiles assumptions on energy system"
824
                " technologies (such as costs, efficiencies, lifetimes,"
825
                " etc.) for chosen years (e.g. [2020, 2030, 2050]) from"
826
                " a variety of sources into CSV files to be read by"
827
                " energy system modelling software. The merged outputs"
828
                " have standardized cost years, technology names, units"
829
                " and source information."
830
            ),
831
            "path": "https://github.com/PyPSA/technology-data/tree/v0.3.0",
832
            "licenses": [
833
                license_agpl(
834
                    "© Marta Victoria (Aarhus University)"
835
                    ", Kun Zhu (Aarhus University)"
836
                    ", Elisabeth Zeyen (TUB)"
837
                    ", Tom Brown (TUB)"
838
                )
839
            ],
840
        },
841
        "tyndp": {
842
            "description": (
843
                "ENTSOs’ TYNDP 2020 Scenario Report describes possible"
844
                " European energy futures up to 2050. Scenarios are not"
845
                " forecasts; they set out a range of possible futures"
846
                " used by the ENTSOs to test future electricity and gas"
847
                " infrastructure needs and projects. The scenarios are"
848
                " ambitious as they deliver a low carbon energy system"
849
                " for Europe by 2050. The ENTSOs have developed"
850
                " credible scenarios that are guided by technically"
851
                " sound pathways, while reflecting country by country"
852
                " specifics, so that a pan-European low carbon future"
853
                " is achieved."
854
            ),
855
            "path": "https://tyndp.entsoe.eu/maps-data",
856
            "licenses": [license_ccby("© ENTSO-E and ENTSOG")],
857
        },
858
        "vg250": {
859
            "title": "Verwaltungsgebiete 1:250 000 (Ebenen)",
860
            "description": (
861
                "Der Datenbestand umfasst sämtliche Verwaltungseinheiten"
862
                " der hierarchischen Verwaltungsebenen vom Staat bis zu"
863
                " den Gemeinden mit ihren Grenzen, statistischen"
864
                " Schlüsselzahlen, Namen der Verwaltungseinheit sowie"
865
                " die spezifische Bezeichnung der Verwaltungsebene des"
866
                " jeweiligen Landes."
867
            ),
868
            "path": (
869
                "https://daten.gdz.bkg.bund.de/produkte/vg"
870
                "/vg250_ebenen_0101/2020"
871
                "/vg250_01-01.geo84.shape.ebenen.zip"
872
            ),
873
            "licenses": [
874
                licenses_datenlizenz_deutschland(
875
                    "© Bundesamt für Kartographie und Geodäsie"
876
                    " 2020 (Daten verändert)"
877
                )
878
            ],
879
        },
880
        "zensus": {
881
            "title": (
882
                "Statistisches Bundesamt (Destatis)"
883
                " - Ergebnisse des Zensus 2011 zum Download"
884
            ),
885
            "description": (
886
                "Als Download bieten wir Ihnen auf dieser Seite"
887
                " zusätzlich zur Zensusdatenbank CSV- und teilweise"
888
                " Excel-Tabellen mit umfassenden Personen-, Haushalts-"
889
                " und Familien- sowie Gebäude- und Wohnungs­merkmaln."
890
                " Die Ergebnisse liegen auf Bundes-, Länder-, Kreis-"
891
                " und Gemeinde­ebene vor. Außerdem sind einzele"
892
                " Ergebnisse für Gitterzellen verfügbar."
893
            ),
894
            "path": (
895
                "https://www.zensus2011.de/DE/Home/Aktuelles"
896
                "/DemografischeGrunddaten.html"
897
            ),
898
            "licenses": [
899
                licenses_datenlizenz_deutschland(
900
                    "© Statistische Ämter des Bundes und der Länder 2014"
901
                )
902
            ],
903
        },
904
    }
905
906
907
def contributors(authorlist):
908
    contributors_dict = {
909
        "am": {
910
            "title": "Aadit Malla",
911
            "email": "https://github.com/aadit879",
912
        },
913
        "an": {
914
            "title": "Amélia Nadal",
915
            "email": "https://github.com/AmeliaNadal",
916
        },
917
        "cb": {
918
            "title": "Clara Büttner",
919
            "email": "https://github.com/ClaraBuettner",
920
        },
921
        "ce": {
922
            "title": "Carlos Epia",
923
            "email": "https://github.com/CarlosEpia",
924
        },
925
        "fw": {
926
            "title": "Francesco Witte",
927
            "email": "https://github.com/fwitte",
928
        },
929
        "gp": {
930
            "title": "Guido Pleßmann",
931
            "email": "https://github.com/gplssm",
932
        },
933
        "ic": {
934
            "title": "Ilka Cußmann",
935
            "email": "https://github.com/IlkaCu",
936
        },
937
        "ja": {
938
            "title": "Jonathan Amme",
939
            "email": "https://github.com/nesnoj",
940
        },
941
        "je": {
942
            "title": "Jane Doe",
943
            "email": "https://github.com/JaneDoe",
944
        },
945
        "ke": {
946
            "title": "Katharina Esterl",
947
            "email": "https://github.com/KathiEsterl",
948
        },
949
        "kh": {
950
            "title": "Kilian Helfenbein",
951
            "email": "https://github.com/khelfen",
952
        },
953
        "sg": {
954
            "title": "Stephan Günther",
955
            "email": "https://github.com/gnn",
956
        },
957
        "um": {
958
            "title": "Ulf Müller",
959
            "email": "https://github.com/ulfmueller",
960
        },
961
    }
962
    return [
963
        {key: value for key, value in contributors_dict[author].items()}
964
        for author in authorlist
965
    ]
966
967
968
def upload_json_metadata():
969
    """Upload json metadata into db from zenodo"""
970
971
    for path in importlib_resources.files(__name__).glob("*.json"):
972
        split = path.name.split(".")
973
        if len(split) != 3:
974
            continue
975
        schema = split[0]
976
        table = split[1]
977
978
        with open(path, "r") as infile:
979
            obj = parse_metadata(infile.read())
980
981
        # TODO @jh-RLI: Deactivate license check for now
982
        validate_metadata(obj, check_license=False)
983
        metadata = f"'{obj}'"
984
        db.submit_comment(metadata, schema, table)
985
        logger.info(f"Metadata comment for {schema}.{table} stored.")
986
987
988
class Json_Metadata(Dataset):
989
    def __init__(self, dependencies):
990
        super().__init__(
991
            name="JsonMetadata",
992
            version="0.0.0",
993
            dependencies=dependencies,
994
            tasks={upload_json_metadata},
995
        )
996