diff --git a/models/directdata/directdata.dat b/models/directdata/directdata.dat index 41d78ef5..46fb5c44 100644 --- a/models/directdata/directdata.dat +++ b/models/directdata/directdata.dat @@ -374,6 +374,130 @@ h 2050 470 INITIAL TIME 1990 1990 +j[A1,B1] +1990 610 +1991 609.333 +1992 608.667 +1993 608 +1994 607.333 +1995 606.667 +1996 606 +1997 605.333 +1998 604.667 +1999 604 +2000 603.333 +2001 602.667 +2002 602 +2003 601.333 +2004 600.667 +2005 600 +2006 599 +2007 598 +2008 597 +2009 596 +2010 595 +2011 594 +2012 593 +2013 592 +2014 591 +2015 590 +2016 590.2 +2017 590.4 +2018 590.6 +2019 590.8 +2020 591 +2021 591.2 +2022 591.4 +2023 591.6 +2024 591.8 +2025 592 +2026 592.2 +2027 592.4 +2028 592.6 +2029 592.8 +2030 593 +2031 592.5 +2032 592 +2033 591.5 +2034 591 +2035 590.5 +2036 590 +2037 589.5 +2038 589 +2039 588.5 +2040 588 +2041 587.5 +2042 587 +2043 586.5 +2044 586 +2045 585.5 +2046 585 +2047 584.5 +2048 584 +2049 583.5 +2050 583 +j[A1,B2] +1990 210 +1991 209.333 +1992 208.667 +1993 208 +1994 207.333 +1995 206.667 +1996 206 +1997 205.333 +1998 204.667 +1999 204 +2000 203.333 +2001 202.667 +2002 202 +2003 201.333 +2004 200.667 +2005 200 +2006 199 +2007 198 +2008 197 +2009 196 +2010 195 +2011 194 +2012 193 +2013 192 +2014 191 +2015 190 +2016 189.667 +2017 189.333 +2018 189 +2019 188.667 +2020 188.333 +2021 188 +2022 187.667 +2023 187.333 +2024 187 +2025 186.667 +2026 186.333 +2027 186 +2028 185.667 +2029 185.333 +2030 185 +2031 184.75 +2032 184.5 +2033 184.25 +2034 184 +2035 183.75 +2036 183.5 +2037 183.25 +2038 183 +2039 182.75 +2040 182.5 +2041 182.25 +2042 182 +2043 181.75 +2044 181.5 +2045 181.25 +2046 181 +2047 180.75 +2048 180.5 +2049 180.25 +2050 180 SAVEPER 1990 1 1991 1 @@ -490,3 +614,15 @@ g 2040 17 2045 35 2050 47 +i[A1,B1] +1990 610 +2005 600 +2015 590 +2030 593 +2050 583 +i[A1,B2] +1990 210 +2005 200 +2015 190 +2030 185 +2050 180 diff --git a/models/directdata/directdata.mdl b/models/directdata/directdata.mdl index 10afb071..25e303eb 100644 --- a/models/directdata/directdata.mdl +++ b/models/directdata/directdata.mdl @@ -1,5 +1,6 @@ {UTF-8} DimA: A1, A2 ~~| +DimB: B1, B2 ~~| a[DimA] := GET DIRECT DATA('?data', 'A Data', 'A', 'B2') ~~| b[DimA] = a[DimA] * 10 ~~~:SUPPLEMENTARY| @@ -13,6 +14,12 @@ f[DimA] = e[DimA] * 10 ~~~:SUPPLEMENTARY| g:= GET DIRECT DATA('g_data.csv', ',', 'A', 'B2') ~~| h = g * 10 ~~~:SUPPLEMENTARY| +i[A1, DimB] = GET DIRECT DATA('e_data.csv', ',', 'A', 'B2') +~ +~ multiple LHS subscripts +| +j[A1, DimB] = i[A1, DimB] ~~~:SUPPLEMENTARY| + ******************************************************** .Control ********************************************************~ @@ -27,32 +34,24 @@ TIME STEP = 1 ~~| \\\---/// Sketch information - do not modify anything except names V300 Do not put anything below this section - it will be ignored *View 1 -$192-192-192,0,Times New Roman|12||0-0-0|0-0-0|0-0-255|-1--1--1|-1--1--1|0,0,100,0 +$192-192-192,0,Times New Roman|12||0-0-0|0-0-0|0-0-255|-1--1--1|-1--1--1|96,96,100,0 ///---\\\ :L<%^E!@ -1:directdata.vdf -9:directdata -30:?data=data.xlsx -15:0,0,0,0,0,0 -19:100,0 -27:0, -34:0, +1:directdata.vdfx 4:Time 5:FINAL TIME -35:Date -36:YYYY-MM-DD -37:2000 -38:1 -39:1 -40:2 -41:0 -42:0 +6:A1 +6:B1 +9:directdata +19:100,0 24:1990 25:2050 26:2050 57:1 54:0 55:0 +82:0 +86:0 59:0 56:0 58:0 @@ -68,4 +67,30 @@ $192-192-192,0,Times New Roman|12||0-0-0|0-0-0|0-0-255|-1--1--1|-1--1--1|0,0,100 43:directdata 47:directdata 48: -6:A1 +30:?data=data.xlsx +15:0,0,0,0,0,0 +27:0, +34:0, +42:0 +72:0 +73:0 +35:Date +36:YYYY-MM-DD +37:2000 +38:1 +39:1 +40:2 +41:0 +95:0 +96:0 +97:0 +77:0 +78:0 +93:0 +94:0 +92:0 +91:0 +90:0 +87:0 +75: +43:directdata diff --git a/src/EquationGen.js b/src/EquationGen.js index 7acb2d39..79447243 100644 --- a/src/EquationGen.js +++ b/src/EquationGen.js @@ -388,11 +388,19 @@ export default class EquationGen extends ModelReader { // If the data was found, convert it to a lookup. if (getCellValue) { let indexNum = 0 - if (!R.isEmpty(this.var.subscripts)) { + if (!R.isEmpty(this.var.separationDims)) { // Generate a lookup for a separated index in the variable's dimension. - // TODO allow the index to be in either position of a 2D subscript - let ind = sub(this.var.subscripts[0]) - indexNum = ind.value + if (this.var.separationDims.length > 1) { + console.error(`WARNING: direct data variable ${this.var.varName} separated on more than one dimension`) + } + let dimName = this.var.separationDims[0] + for (let subscript of this.var.subscripts) { + if (sub(subscript).family === dimName) { + let ind = sub(subscript) + indexNum = ind.value + break + } + } } result.push(this.generateDirectDataLookup(getCellValue, timeRowOrCol, startCell, indexNum)) }