Code Duplication    Length = 89-97 lines in 2 locations

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

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

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

@@ 694-790 (lines=97) @@
691
        )
692
693
694
def add_metadata():
695
    """Add metdata to supply.egon_era5_renewable_feedin
696
697
    Returns
698
    -------
699
    None.
700
701
    """
702
703
    # Import column names and datatypes
704
    fields = [
705
        {
706
            "description": "Weather cell index",
707
            "name": "w_id",
708
            "type": "integer",
709
            "unit": "none",
710
        },
711
        {
712
            "description": "Weather year",
713
            "name": "weather_year",
714
            "type": "integer",
715
            "unit": "none",
716
        },
717
        {
718
            "description": "Energy carrier",
719
            "name": "carrier",
720
            "type": "string",
721
            "unit": "none",
722
        },
723
        {
724
            "description": "Weather-dependent feedin timeseries",
725
            "name": "feedin",
726
            "type": "array",
727
            "unit": "p.u.",
728
        },
729
    ]
730
731
    meta = {
732
        "name": "supply.egon_era5_renewable_feedin",
733
        "title": "eGon feedin timeseries for RES",
734
        "id": "WILL_BE_SET_AT_PUBLICATION",
735
        "description": "Weather-dependent feedin timeseries for RES",
736
        "language": ["EN"],
737
        "publicationDate": datetime.date.today().isoformat(),
738
        "context": context(),
739
        "spatial": {
740
            "location": None,
741
            "extent": "Germany",
742
            "resolution": None,
743
        },
744
        "sources": [
745
            sources()["era5"],
746
            sources()["vg250"],
747
            sources()["egon-data"],
748
        ],
749
        "licenses": [
750
            license_ccby(
751
                "© Bundesamt für Kartographie und Geodäsie 2020 (Daten verändert); "
752
                "© Copernicus Climate Change Service (C3S) Climate Data Store "
753
                "© 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",
754
            )
755
        ],
756
        "contributors": [
757
            {
758
                "title": "Clara Büttner",
759
                "email": "http://github.com/ClaraBuettner",
760
                "date": time.strftime("%Y-%m-%d"),
761
                "object": None,
762
                "comment": "Imported data",
763
            },
764
        ],
765
        "resources": [
766
            {
767
                "profile": "tabular-data-resource",
768
                "name": "supply.egon_scenario_capacities",
769
                "path": None,
770
                "format": "PostgreSQL",
771
                "encoding": "UTF-8",
772
                "schema": {
773
                    "fields": fields,
774
                    "primaryKey": ["index"],
775
                    "foreignKeys": [],
776
                },
777
                "dialect": {"delimiter": None, "decimalSeparator": "."},
778
            }
779
        ],
780
        "metaMetadata": meta_metadata(),
781
    }
782
783
    # Create json dump
784
    meta_json = "'" + json.dumps(meta) + "'"
785
786
    # Add metadata as a comment to the table
787
    db.submit_comment(
788
        meta_json,
789
        EgonRenewableFeedIn.__table__.schema,
790
        EgonRenewableFeedIn.__table__.name,
791
    )
792