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

data.metadata.contributors()   B

Complexity

Conditions 1

Size

Total Lines 58
Code Lines 44

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 44
dl 0
loc 58
rs 8.824
c 0
b 0
f 0
cc 1
nop 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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