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

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