Skip to content

No support for XMILE models with multiple array dimensions? #473

Description

@Steve-Yang-Sys

Hello,

Recently, I tried to read a Stella model with PySD package, but it does not work at all.

After several tests, I found that PySD cannot read arrayed variables with multiple (>1) dimensions or subscripts in Stella. Additionally, it also does not support arrayed variables indexed by Number (NOT Label). The sample error message is given as below:


KeyError Traceback (most recent call last)
in
----> 1 model = pysd.read_xmile(MODEL_PATH)

~/opt/anaconda3/lib/python3.8/site-packages/pysd/pysd.py in read_xmile(xmile_file, data_files, initialize, missing_values)
85
86 # build Python file
---> 87 py_model_file = ModelBuilder(abs_model).build_model()
88
89 # load Python file

~/opt/anaconda3/lib/python3.8/site-packages/pysd/builders/python/python_model_builder.py in init(self, abstract_model)
39 self.dict = abstract_model.dict.copy()
40 # load sections
---> 41 self.sections = [
42 SectionBuilder(section)
43 for section in abstract_model.sections

~/opt/anaconda3/lib/python3.8/site-packages/pysd/builders/python/python_model_builder.py in (.0)
40 # load sections
41 self.sections = [
---> 42 SectionBuilder(section)
43 for section in abstract_model.sections
44 ]

~/opt/anaconda3/lib/python3.8/site-packages/pysd/builders/python/python_model_builder.py in init(self, abstract_section)
87 abstract_section.subscripts, self.root)
88 # Load the elements in the section
---> 89 self.elements = [
90 ElementBuilder(element, self)
91 for element in abstract_section.elements

~/opt/anaconda3/lib/python3.8/site-packages/pysd/builders/python/python_model_builder.py in (.0)
88 # Load the elements in the section
89 self.elements = [
---> 90 ElementBuilder(element, self)
91 for element in abstract_section.elements
92 ]

~/opt/anaconda3/lib/python3.8/site-packages/pysd/builders/python/python_model_builder.py in init(self, abstract_element, section)
548 self.section = section
549 # Get the subscripts of the element after merging all the components
--> 550 self.subscripts = section.subscripts.make_merge_list(
551 [component.subscripts[0] for component in self.components])
552 # Get the subscript dictionary of the element

~/opt/anaconda3/lib/python3.8/site-packages/pysd/builders/python/subscripts.py in make_merge_list(self, subs_list, element)
296 """
297 coords_set = [set() for i in range(len(subs_list[0]))]
--> 298 coords_list = [
299 self.make_coord_dict(subs)
300 for subs in subs_list

~/opt/anaconda3/lib/python3.8/site-packages/pysd/builders/python/subscripts.py in (.0)
297 coords_set = [set() for i in range(len(subs_list[0]))]
298 coords_list = [
--> 299 self.make_coord_dict(subs)
300 for subs in subs_list
301 ]

~/opt/anaconda3/lib/python3.8/site-packages/pysd/builders/python/subscripts.py in make_coord_dict(self, subs)
257 coordinates[sub] = self.subscripts[sub[:-1]]
258 else:
--> 259 coordinates[sub] = self.subscripts[sub]
260 return coordinates
261

KeyError: '1'


Normally, we try to translate large and complex SD models into Python environment for deeper analysis, but this support limitation really hinders the impact of PySD package. Hopefully, this issue is something under your kind consideration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions