Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Direct data read fails when data dimension is not the first subscript #113

Closed
ToddFincannon opened this issue Sep 16, 2021 · 1 comment · Fixed by #114 or #190
Closed

Direct data read fails when data dimension is not the first subscript #113

ToddFincannon opened this issue Sep 16, 2021 · 1 comment · Fixed by #114 or #190
Assignees
Labels
Milestone

Comments

@ToddFincannon
Copy link
Collaborator

Direct data variables read from an Excel or CSV file may have a dimension on the LHS. In this case, the data is a 2D matrix with time on one axis and the dimension indices on the other axis. We handled this before, but assumed that there would be just one subscript on the LHS, and took the first one as the dimension to apply the data table to. But if there is more than one subscript, this can fail if the subscript is not the first one. For instance, in this model:

DimA: A1, A2 ~~|
DimB: B1, B2 ~~|
i[A1, DimB] = GET DIRECT DATA('e_data.csv', ',', 'A', 'B2') ~~|
j[A1, DimB] = i[A1, DimB] ~~|

FINAL TIME = 2050 ~~|
INITIAL TIME = 1990 ~~|
TIME STEP = 1 ~~|
SAVEPER = TIME STEP ~~|

the dimension for the table data is the second subscript, and the wrong column is read from the table.

@ToddFincannon ToddFincannon added this to the 0.6.0 milestone Sep 16, 2021
@ToddFincannon ToddFincannon self-assigned this Sep 16, 2021
@ToddFincannon
Copy link
Collaborator Author

Instead of assuming that the first subscript is the one to use for the data, consult the separationDims property in the variable, and then find the subscript that uses that dimension. It will be an index that was previously separated on the dimension. Use the numeric index value to offset to the correct row or column in the table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment