Skip to content

Commit

Permalink
Update countries attributes (#57)
Browse files Browse the repository at this point in the history
* Update countries attributes

* Fix square bracket

* Fix square brackets

* Correct India and Japan

* Update copyright

* Bump nomenclature requirement version

* Add Ruff

* Add closing empty line
  • Loading branch information
dc-almeida authored Oct 3, 2024
1 parent 01e3894 commit d348544
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 47 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Ruff
on: [ push, pull_request ]
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# ADIADNE project - scenario processing workflow

Copyright (c) 2021-2024 IIASA and the ARIADNE consortium

Copyright (c) 2021 IIASA and the ARIADNE consortium
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

This repository is released under the [APACHE 2.0 license](LICENSE).
![GitHub](https://img.shields.io/github/license/iiasa/ariadne-intern-workflow)
Expand Down
2 changes: 1 addition & 1 deletion attachments/variable_mapping.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"outputs": [],
"source": [
"nomenclature.create_yaml_from_xlsx(\n",
" source=file, \n",
" source=file,\n",
" target=definition_path / \"variable\" / \"variables.yaml\",\n",
" sheet_name=\"variable_definitions\",\n",
" col=\"Variable\",\n",
Expand Down
6 changes: 2 additions & 4 deletions db-admin/db-docs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
"metadata": {},
"outputs": [],
"source": [
"import yaml\n",
"import pandas as pd\n",
"import ixmp\n",
"import pyam"
"import ixmp"
]
},
{
Expand All @@ -32,7 +30,7 @@
"metadata": {},
"outputs": [],
"source": [
"#mp = ixmp.Platform('ariadne-intern')\n",
"# mp = ixmp.Platform('ariadne-intern')\n",
"mp = ixmp.Platform(\"ariadne\")"
]
},
Expand Down
10 changes: 4 additions & 6 deletions db-admin/db-setup.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
"outputs": [],
"source": [
"import yaml\n",
"import pandas as pd\n",
"import ixmp\n",
"import pyam"
"import ixmp"
]
},
{
Expand All @@ -32,7 +30,7 @@
"metadata": {},
"outputs": [],
"source": [
"mp = ixmp.Platform('ariadne-intern')"
"mp = ixmp.Platform(\"ariadne-intern\")"
]
},
{
Expand All @@ -48,7 +46,7 @@
"metadata": {},
"outputs": [],
"source": [
"with open('../regions.yaml', 'r', encoding='utf-8') as stream:\n",
"with open(\"../regions.yaml\", \"r\", encoding=\"utf-8\") as stream:\n",
" region_dict = yaml.load(stream, Loader=yaml.FullLoader)"
]
},
Expand All @@ -61,7 +59,7 @@
"for category, items in region_dict.items():\n",
" for name, attributes in items.items():\n",
" mp.add_region(name, hierarchy=category)\n",
" for a in ['iso3', 'abbr']:\n",
" for a in [\"iso3\", \"abbr\"]:\n",
" if attributes is not None and a in attributes:\n",
" mp.add_region_synonym(attributes[a], mapped_to=name)"
]
Expand Down
62 changes: 31 additions & 31 deletions definitions/region/regions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,63 +9,63 @@

- Europäische Länder:
- Bulgarien:
iso3: BGR
countries: [ Bulgaria ]
- Dänemark:
iso3: DNK
countries: [ Denmark ]
- Deutschland:
iso3: DEU
countries: [ Germany ]
- Estland:
iso3: EST
countries: [ Estonia ]
- Finnland:
iso3: FIN
countries: [ Finland ]
- Frankreich:
iso3: FRA
countries: [ France ]
- Griechenland:
iso3: GRC
countries: [ Greece ]
- Irland:
iso3: IRL
countries: [ Ireland ]
- Italien:
iso3: ITA
countries: [ Italy ]
- Kroatien:
iso3: HRV
countries: [ Croatia ]
- Lettland:
iso3: LVA
countries: [ Latvia ]
- Litauen:
iso3: LTU
countries: [ Lithuania ]
- Luxemburg:
iso3: LUX
countries: [ Luxembourg ]
- Malta:
iso3: MLT
countries: [ Malta ]
- Niederlande:
iso3: NLD
countries: [ Netherlands ]
- Österreich:
iso3: AUT
countries: [ Austria ]
- Polen:
iso3: POL
countries: [ Poland ]
- Portugal:
iso3: PRT
countries: [ Portugal ]
- Rumänien:
iso3: ROU
countries: [ Romania ]
- Schweden:
iso3: SWE
countries: [ Sweden ]
- Slowakei:
iso3: SVK
countries: [ Slovakia ]
- Slowenien:
iso3: SVN
countries: [ Slovenia ]
- Spanien:
iso3: ESP
countries: [ Spain ]
- Tschechien:
iso3: CZE
countries: [ Czechia ]
- Ungarn:
iso3: HUN
countries: [ Hungary ]
- Zypern:
iso3: CYP
countries: [ Cyprus ]
- Vereinigtes Königreich:
iso3: GBR
countries: [ United Kingdom ]
- Norwegen:
iso3: NOR
countries: [ Norway ]
- Schweiz:
iso3: CHE
countries: [ Switzerland ]
- Europäische Regionen:
- EU_East:
definition: Polen, Tschechien, Slowakei, Estland, Lettland, Litauen
Expand Down Expand Up @@ -105,9 +105,9 @@
- China (inkl. Hongkong, Macao, Taiwan):
abbr: CHN_HKG_MAC_TWN
- Indien:
iso3: IND
countries: [ India ]
- Japan:
iso3: JPN
countries: [ Japan ]
- USA
- Regionen außerhalb Europas:
- CAN_NZL_AUS:
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
pyam-iamc>=1.0 # the pyam package is released on pypi.org under this name
nomenclature-iamc >= 0.18.1
nomenclature-iamc >= 0.19.0 # use the latest release on PyPI
8 changes: 6 additions & 2 deletions workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
# datetime must be in Central European Time (CET)
EXP_TZ = "UTC+01:00"
EXP_TIME_OFFSET = timedelta(seconds=3600)
OE_SUBANNUAL_FORMAT = lambda x: x.strftime("%m-%d %H:%M%z").replace("+0100", "+01:00")


def oe_subannual_format(x):
return x.strftime("%m-%d %H:%M%z").replace("+0100", "+01:00")


# allowed values for required meta columns, use first of list as default
REQUIRED_META_ARIADNE = {
Expand Down Expand Up @@ -98,7 +102,7 @@ def _validate(df: pyam.IamDataFrame) -> pyam.IamDataFrame:
# convert to subannual format if data provided in datetime format
if df.time_col == "time":
logger.info('Re-casting from "time" column to categorical "subannual" format')
df = df.swap_time_for_year(subannual=OE_SUBANNUAL_FORMAT)
df = df.swap_time_for_year(subannual=oe_subannual_format)

# check that any datetime-like items in "subannual" are valid datetime and UTC+01:00
if "subannual" in df.dimensions:
Expand Down

0 comments on commit d348544

Please sign in to comment.