Passed
Pull Request — dev (#568)
by
unknown
02:26
created

data.metadata.sources()   B

Complexity

Conditions 1

Size

Total Lines 514
Code Lines 195

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 195
dl 0
loc 514
rs 7
c 0
b 0
f 0
cc 1
nop 0

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