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

data.metadata.meta_metadata()   A

Complexity

Conditions 1

Size

Total Lines 16
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

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