Code Duplication    Length = 89-97 lines in 2 locations

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

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

@@ 651-747 (lines=97) @@
648
        )
649
650
651
def add_metadata():
652
    """Add metdata to supply.egon_era5_renewable_feedin
653
654
    Returns
655
    -------
656
    None.
657
658
    """
659
660
    # Import column names and datatypes
661
    fields = [
662
        {
663
            "description": "Weather cell index",
664
            "name": "w_id",
665
            "type": "integer",
666
            "unit": "none",
667
        },
668
        {
669
            "description": "Weather year",
670
            "name": "weather_year",
671
            "type": "integer",
672
            "unit": "none",
673
        },
674
        {
675
            "description": "Energy carrier",
676
            "name": "carrier",
677
            "type": "string",
678
            "unit": "none",
679
        },
680
        {
681
            "description": "Weather-dependent feedin timeseries",
682
            "name": "feedin",
683
            "type": "array",
684
            "unit": "p.u.",
685
        },
686
    ]
687
688
    meta = {
689
        "name": "supply.egon_era5_renewable_feedin",
690
        "title": "eGon feedin timeseries for RES",
691
        "id": "WILL_BE_SET_AT_PUBLICATION",
692
        "description": "Weather-dependent feedin timeseries for RES",
693
        "language": ["EN"],
694
        "publicationDate": datetime.date.today().isoformat(),
695
        "context": context(),
696
        "spatial": {
697
            "location": None,
698
            "extent": "Germany",
699
            "resolution": None,
700
        },
701
        "sources": [
702
            sources()["era5"],
703
            sources()["vg250"],
704
            sources()["egon-data"],
705
        ],
706
        "licenses": [
707
            license_ccby(
708
                "© Bundesamt für Kartographie und Geodäsie 2020 (Daten verändert); "
709
                "© Copernicus Climate Change Service (C3S) Climate Data Store "
710
                "© 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",
711
            )
712
        ],
713
        "contributors": [
714
            {
715
                "title": "Clara Büttner",
716
                "email": "http://github.com/ClaraBuettner",
717
                "date": time.strftime("%Y-%m-%d"),
718
                "object": None,
719
                "comment": "Imported data",
720
            },
721
        ],
722
        "resources": [
723
            {
724
                "profile": "tabular-data-resource",
725
                "name": "supply.egon_scenario_capacities",
726
                "path": None,
727
                "format": "PostgreSQL",
728
                "encoding": "UTF-8",
729
                "schema": {
730
                    "fields": fields,
731
                    "primaryKey": ["index"],
732
                    "foreignKeys": [],
733
                },
734
                "dialect": {"delimiter": None, "decimalSeparator": "."},
735
            }
736
        ],
737
        "metaMetadata": meta_metadata(),
738
    }
739
740
    # Create json dump
741
    meta_json = "'" + json.dumps(meta) + "'"
742
743
    # Add metadata as a comment to the table
744
    db.submit_comment(
745
        meta_json,
746
        EgonRenewableFeedIn.__table__.schema,
747
        EgonRenewableFeedIn.__table__.name,
748
    )
749