Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Array Data Tables

Array data tables provide array values indexed by rows or columns. This is useful for certain types of parameters, such as monthly or daily profiles, which require an array of values. The following example shows how to define an array data table in CSV format with a single row index.

Note: Currently, Pywr supports up to 4 keys for array data tables. This means you can have up to 4 row or column indices.

month,1,2,3,4,5,6,7,8,9,10,11,12
profile1,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5
profile2,0.6,0.7,0.75,0.8,0.75,0.7,0.7,0.6,0.6,0.6,0.6,0.6
profile3,0.7,0.8,0.9,0.9,0.9,0.8,0.8,0.75,0.7,0.7,0.65,0.65

To use this table in your model use "type": "Array" in the table definition in your JSON, as shown below.

      {
        "name": "array-row",
        "type": "Array",
        "format": "CSV",
        "lookup": {
          "type": "Row",
          "rows": 1
        },
        "url": "tbl-array-row.csv"
      },

The same data can be formatted with a column index instead of a row index, as shown below.

month,profile1,profile2,profile3
1,0.5,0.6,0.7
2,0.5,0.7,0.8
3,0.5,0.75,0.9
4,0.5,0.8,0.9
5,0.5,0.75,0.9
6,0.5,0.7,0.8
7,0.5,0.7,0.8
8,0.5,0.6,0.75
9,0.5,0.6,0.7
10,0.5,0.6,0.7
11,0.5,0.6,0.65
12,0.5,0.6,0.65

And the corresponding table definition in JSON:

      {
        "name": "array-col",
        "type": "Array",
        "format": "CSV",
        "lookup": {
          "type": "Col",
          "cols": 1
        },
        "url": "tbl-array-col.csv"
      }