Error moving to Pypsa 1.0 - createmodel with multi_investment_periods

2 views
Skip to first unread message

Tobie Nortje

unread,
Jan 29, 2026, 4:40:26 AM (4 days ago) Jan 29
to pypsa
HI,

1. I load the network from csv in to variable `network` and then
2. network.investment_periods  = [1]

when network.optimize.create_model(multi_investment_periods=True)  is called I get the following error wich worked up to 0.35.

xarray.structure.alignment.AlignmentError: cannot align objects on coordinate 'snapshot' because of conflicting indexes
first index: PandasIndex(Index([   (1, 2),    (1, 3),    (1, 4),    (1, 5),    (1, 6),    (1, 7),
          (1, 8),    (1, 9),   (1, 10),   (1, 11),
       ...
       (1, 8751), (1, 8752), (1, 8753), (1, 8754), (1, 8755), (1, 8756),
       (1, 8757), (1, 8758), (1, 8759), (1, 8760)],
      dtype='object', name='snapshot', length=8759))
second index: PandasIndex(MultiIndex([(1,    1),
            (1,    2),
            (1,    3),
            (1,    4),
            (1,    5),
            (1,    6),
            (1,    7),
            (1,    8),
            (1,    9),
            (1,   10),
            ...
            (1, 8751),
            (1, 8752),
            (1, 8753),
            (1, 8754),
            (1, 8755),
            (1, 8756),
            (1, 8757),
            (1, 8758),
            (1, 8759),
            (1, 8760)],
           name='snapshot', length=8760))
first variable: <xarray.IndexVariable 'snapshot' (snapshot: 8759)> Size: 70kB
array([(1, 2), (1, 3), (1, 4), ..., (1, 8758), (1, 8759), (1, 8760)],
      dtype=object)
second variable: <xarray.IndexVariable 'snapshot' (snapshot: 8760)> Size: 70kB
array([(1, 1), (1, 2), (1, 3), ..., (1, 8758), (1, 8759), (1, 8760)],
      dtype=object)

I have checked all the inputs and they are all the same shape as snapshots.csv

Any idea what could cause this?

regards
Tobie


Tobie Nortje

unread,
Jan 29, 2026, 4:42:49 AM (4 days ago) Jan 29
to pypsa
The full stack trace originates at  define_ramp_limit_constraints:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Users\tobie\PycharmProjects\afripow-streamlit-gui\.venv\Lib\site-packages\pypsa\optimization\optimize.py", line 572, in create_model
    define_ramp_limit_constraints(n, sns, c, attr)
  File "C:\Users\tobie\PycharmProjects\afripow-streamlit-gui\.venv\Lib\site-packages\pypsa\optimization\constraints.py", line 697, in define_ramp_limit_constraints
    ramp_limit_up_ext = ramp_limit_up.reindex(
                        ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\tobie\PycharmProjects\afripow-streamlit-gui\.venv\Lib\site-packages\xarray\core\dataarray.py", line 2218, in reindex
    return alignment.reindex(
           ^^^^^^^^^^^^^^^^^^
  File "C:\Users\tobie\PycharmProjects\afripow-streamlit-gui\.venv\Lib\site-packages\xarray\structure\alignment.py", line 984, in reindex
    aligner.align()
  File "C:\Users\tobie\PycharmProjects\afripow-streamlit-gui\.venv\Lib\site-packages\xarray\structure\alignment.py", line 559, in align
    self.align_indexes()
  File "C:\Users\tobie\PycharmProjects\afripow-streamlit-gui\.venv\Lib\site-packages\xarray\structure\alignment.py", line 432, in align_indexes
    update_dicts(key, idx, index_vars, False)
  File "C:\Users\tobie\PycharmProjects\afripow-streamlit-gui\.venv\Lib\site-packages\xarray\structure\alignment.py", line 369, in update_dicts
    raise AlignmentError(

Fabian Hofmann

unread,
Jan 29, 2026, 5:38:08 AM (4 days ago) Jan 29
to py...@googlegroups.com

Hey Tobie,

thanks for the message. For bug reports please use the Github plattform. There we can better track and discuss.

Best wishes,

Fabian Hofmann

--
You received this message because you are subscribed to the Google Groups "pypsa" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pypsa+un...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/pypsa/18392655-7e44-49be-bf93-4ef37877e750n%40googlegroups.com.
-- 
Dr. Fabian Hofmann 

Senior Energy System Modeller
Open Energy Transition
https://openenergytransition.org/

http://fabianhofmann.org/
Reply all
Reply to author
Forward
0 new messages