OSeMOSYS / otoole

OSeMOSYS Tools for Energy
https://otoole.readthedocs.io
MIT License
23 stars 17 forks source link

[Bug]: Cannot read TradeRoute from Excel #165

Open willu47 opened 1 year ago

willu47 commented 1 year ago

The Issue

The TradeRoute parameter has two REGION indexes, and issue discussed in #130.

Expected Behavior

The TradeRoute parameter should be converted to whatever format with the two indices intact.

Steps To Reproduce

Set up an Excel file with the TradeRoute parameter

REGION  REGION  FUEL    2015 2016 2017
a b ELC 1 1 1
a a ELC 0 0 0

and a config file config.yaml:

TradeRoute:
    indices: [REGION,REGION,FUEL,YEAR]
    type: param
    dtype: float
    default: 0

and then run otoole convert excel csv <workbook.xlsx> <folder> config.yaml

Log output

DEBUG:otoole.input:Expected indices for TradeRoute are ['REGION', 'REGION', 'FUEL', 'YEAR']
Traceback (most recent call last):
  File "/Users/wusher/miniconda3/envs/otoole38/bin/otoole", line 33, in <module>
    sys.exit(load_entry_point('otoole', 'console_scripts', 'otoole')())
  File "/Users/wusher/repository/otoole/src/otoole/cli.py", line 470, in main
    args.func(args)
  File "/Users/wusher/repository/otoole/src/otoole/cli.py", line 220, in conversion_matrix
    input_data, _ = read_strategy.read(args.from_path)
  File "/Users/wusher/repository/otoole/src/otoole/read_strategies.py", line 158, in read
    input_data = self._check_index(input_data)
  File "/Users/wusher/repository/otoole/src/otoole/input.py", line 388, in _check_index
    self._check_param_index_names(name=name, config=details, df=df)
  File "/Users/wusher/repository/otoole/src/otoole/input.py", line 435, in _check_param_index_names
    raise OtooleIndexError(
otoole.exceptions.OtooleIndexError: TradeRoute -> Indices inconsistent between config and data. Config indices are ['REGION', 'REGION', 'FUEL', 'YEAR']. Data indices are ['REGION', 'REGION.1', 'FUEL', 'YEAR'].

Operating System

MacOS

What version of otoole are you running?

v1.01

Possible Solution

Investigate using xarray as an internal data store. This allows the definition of variables over duplicate dimensions.

Anything else?

No response