iiasa / ixmp

The ix modeling platform for integrated and cross-cutting scenario analysis
https://docs.messageix.org/ixmp
Apache License 2.0
38 stars 112 forks source link

Scenario.timeseries() doesn't filter results with 'year' field #440

Closed Jihoon closed 1 year ago

Jihoon commented 2 years ago

According to the documentation, Scenario.timeseries() is supposed to filter results with various fields (or indices), but applying the year field gives an error and doesn't work as intended.

Code sample or context


import ixmp
import message_ix

mp_ENE = ixmp.Platform("ixmp_dev")
sc = message_ix.Scenario(mp_ENE, model= "xxx", scenario="yyy")

# This works fine, and the result includes values for 1990 onwards.
ts_chn=sc.timeseries(region="R12_CHN")

# Both below give an error.
ts_chn=sc.timeseries(region="R12_CHN", year=1990)
ts_chn=sc.timeseries(region="R12_CHN", year="1990")

Expected result

To give a data frame with the filtered result

Problem description

  File "C:\ProgramData\Anaconda3\envs\local_mix\lib\site-packages\ixmp\core\timeseries.py", line 372, in timeseries
    df = pd.DataFrame(

  File "C:\ProgramData\Anaconda3\envs\local_mix\lib\site-packages\pandas\core\frame.py", line 710, in __init__
    data = list(data)

  File "C:\ProgramData\Anaconda3\envs\local_mix\lib\site-packages\ixmp\backend\jdbc.py", line 734, in get_data
    for row in self.jindex[ts].getTimeseries(r, v, u, None, y):

java.lang.ClassCastException: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number

Versions


ixmp:        3.4.0
message_ix:  3.4.1.dev23+g5526f43
     5526f43 (HEAD -> main, origin/main, origin/HEAD) Address failing copying of GAMS files (#568)
message_ix_models: 2022.3.3
message_data: 2020.6.21.dev1594+g1e32fcc1b.d20220316
     5a48ece18 (HEAD -> project/NGFS_phase3) Fix price reporting years

click:       8.0.4
dask:        2022.02.1
genno:       installed
graphviz:    0.19.1
jpype:       1.3.0
… JVM path:  C:\Program Files\Java\jdk1.8.0_202\jre\bin\server\jvm.dll
openpyxl:    3.0.9
pandas:      1.4.1
pint:        0.17
xarray:      2022.3.0
yaml:        6.0

iam_units:   installed
jupyter:     installed
matplotlib:  3.5.1
plotnine:    0.8.0
pyam:        1.3.1

GAMS:        26.1.0

python:      3.9.10 | packaged by conda-forge | (main, Feb  1 2022, 21:21:54) [MSC v.1929 64 bit (AMD64)]
python-bits: 64
OS:          Windows
OS-release:  10
machine:     AMD64
processor:   Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
byteorder:   little
LC_ALL:      None
LANG:        en
LOCALE:      ('English_United States', '1252')

khaeru commented 1 year ago

I just ran into this again during NAVIGATE, so will pick it up.