Code Duplication    Length = 89-97 lines in 2 locations

src/egon/data/datasets/renewable_feedin.py 1 location

@@ 628-724 (lines=97) @@
625
        )
626
627
628
def add_metadata():
629
    """Add metdata to supply.egon_era5_renewable_feedin
630
631
    Returns
632
    -------
633
    None.
634
635
    """
636
637
    # Import column names and datatypes
638
    fields = [
639
        {
640
            "description": "Weather cell index",
641
            "name": "w_id",
642
            "type": "integer",
643
            "unit": "none",
644
        },
645
        {
646
            "description": "Weather year",
647
            "name": "weather_year",
648
            "type": "integer",
649
            "unit": "none",
650
        },
651
        {
652
            "description": "Energy carrier",
653
            "name": "carrier",
654
            "type": "string",
655
            "unit": "none",
656
        },
657
        {
658
            "description": "Weather-dependent feedin timeseries",
659
            "name": "feedin",
660
            "type": "array",
661
            "unit": "p.u.",
662
        },
663
    ]
664
665
    meta = {
666
        "name": "supply.egon_era5_renewable_feedin",
667
        "title": "eGon feedin timeseries for RES",
668
        "id": "WILL_BE_SET_AT_PUBLICATION",
669
        "description": "Weather-dependent feedin timeseries for RES",
670
        "language": ["EN"],
671
        "publicationDate": datetime.date.today().isoformat(),
672
        "context": context(),
673
        "spatial": {
674
            "location": None,
675
            "extent": "Germany",
676
            "resolution": None,
677
        },
678
        "sources": [
679
            sources()["era5"],
680
            sources()["vg250"],
681
            sources()["egon-data"],
682
        ],
683
        "licenses": [
684
            license_ccby(
685
                "© Bundesamt für Kartographie und Geodäsie 2020 (Daten verändert); "
686
                "© Copernicus Climate Change Service (C3S) Climate Data Store "
687
                "© Jonathan Amme, Clara Büttner, Ilka Cußmann, Julian Endres, Carlos Epia, Stephan Günther, Ulf Müller, Amélia Nadal, Guido Pleßmann, Francesco Witte",
688
            )
689
        ],
690
        "contributors": [
691
            {
692
                "title": "Clara Büttner",
693
                "email": "http://github.com/ClaraBuettner",
694
                "date": time.strftime("%Y-%m-%d"),
695
                "object": None,
696
                "comment": "Imported data",
697
            },
698
        ],
699
        "resources": [
700
            {
701
                "profile": "tabular-data-resource",
702
                "name": "supply.egon_scenario_capacities",
703
                "path": None,
704
                "format": "PostgreSQL",
705
                "encoding": "UTF-8",
706
                "schema": {
707
                    "fields": fields,
708
                    "primaryKey": ["index"],
709
                    "foreignKeys": [],
710
                },
711
                "dialect": {"delimiter": None, "decimalSeparator": "."},
712
            }
713
        ],
714
        "metaMetadata": meta_metadata(),
715
    }
716
717
    # Create json dump
718
    meta_json = "'" + json.dumps(meta) + "'"
719
720
    # Add metadata as a comment to the table
721
    db.submit_comment(
722
        meta_json,
723
        EgonRenewableFeedIn.__table__.schema,
724
        EgonRenewableFeedIn.__table__.name,
725
    )
726

src/egon/data/datasets/zensus_vg250.py 1 location

@@ 662-750 (lines=89) @@
659
    )
660
661
662
def add_metadata_vg250_zensus():
663
    # Import column names and datatypes
664
    fields = [
665
        {
666
            "name": "zensus_population_id",
667
            "description": "Index of zensus population cell",
668
            "type": "integer",
669
            "unit": "none",
670
        },
671
        {
672
            "name": "zensus_geom",
673
            "description": "Gemetry of zensus cell",
674
            "type": "geometry(point,3035)",
675
            "unit": "none",
676
        },
677
        {
678
            "name": "vg250_municipality_id",
679
            "description": "Index of municipality",
680
            "type": "integer",
681
            "unit": "none",
682
        },
683
        {
684
            "name": "vg250_nuts3",
685
            "description": "NUTS3 region-code",
686
            "type": "varchar",
687
            "unit": "none",
688
        },
689
    ]
690
691
    meta = {
692
        "name": "boundaries.egon_map_zensus_vg250",
693
        "title": "eGon feedin timeseries for RES",
694
        "id": "WILL_BE_SET_AT_PUBLICATION",
695
        "description": "Weather-dependent feedin timeseries for RES",
696
        "language": ["EN"],
697
        "publicationDate": datetime.date.today().isoformat(),
698
        "context": context(),
699
        "spatial": {
700
            "location": None,
701
            "extent": "Germany",
702
            "resolution": "100mx100m",
703
        },
704
        "sources": [
705
            sources()["zensus"],
706
            sources()["vg250"],
707
            sources()["egon-data"],
708
        ],
709
        "licenses": [
710
            license_ccby(
711
                "© Bundesamt für Kartographie und Geodäsie 2020 (Daten verändert); "
712
                "© Statistische Ämter des Bundes und der Länder 2014 "
713
                "© Jonathan Amme, Clara Büttner, Ilka Cußmann, Julian Endres, Carlos Epia, Stephan Günther, Ulf Müller, Amélia Nadal, Guido Pleßmann, Francesco Witte",
714
            )
715
        ],
716
        "contributors": [
717
            {
718
                "title": "Clara Büttner",
719
                "email": "http://github.com/ClaraBuettner",
720
                "date": time.strftime("%Y-%m-%d"),
721
                "object": None,
722
                "comment": "Added metadata",
723
            },
724
        ],
725
        "resources": [
726
            {
727
                "profile": "tabular-data-resource",
728
                "name": "boundaries.egon_map_zensus_vg250",
729
                "path": None,
730
                "format": "PostgreSQL",
731
                "encoding": "UTF-8",
732
                "schema": {
733
                    "fields": fields,
734
                    "primaryKey": ["index"],
735
                    "foreignKeys": [],
736
                },
737
                "dialect": {"delimiter": None, "decimalSeparator": "."},
738
            }
739
        ],
740
        "metaMetadata": meta_metadata(),
741
    }
742
743
    # Create json dump
744
    meta_json = "'" + json.dumps(meta) + "'"
745
746
    # Add metadata as a comment to the table
747
    db.submit_comment(
748
        meta_json,
749
        MapZensusVg250.__table__.schema,
750
        MapZensusVg250.__table__.name,
751
    )
752