Skip to content

Input data

Christian Neuwirth edited this page Feb 17, 2017 · 68 revisions

3. Structure of input data

Before SymSyn simulations can be performed, input data needs to be prepared. The required structure of input data depends on the purpose of the model. SimSyn provides different data link types to implement variant types of simulations.

A data link is a link of a Vensim model element to a database table column. At the moment subscripting data links (SDL), time-series data links (TSL) as well as time-dependent subscripting links and combinations of SDL and TSL are supported.

3.1 Subscripting data links (SDL)

SDL enable creating multiple instances of a Vensim model. This may be used for spatial simulations or to run and compare thousands of alternative model parametrizations (e.g. sensitivity analyses, scenario runs etc).

A SDL is used to link a Vensim constant to a database table column and run one independent simulation for every row value in this column. Multiple SDLs may be defined to link more than one constant to every independent simulation run (Fig. 1; A).

Fig. 1 Fig. 1. Left) Database table with two subscripting data links (SDL); Right) Database table with two time series links (TSL)

3.2 Time-series data links (TSL)

A TSL is used to assign database table columns as time series to Vensim variables (Fig. 1; B). Multiple TSL of a single or of multiple database tables may be assigned to a VENSIM model.

3.3 Time-dependent subscripting links

As an additional functionality, SDL may optionally be equipped with a simulation timestamp (see also section 6). For instance, a first SDL may be assigned to the initial simulation time 0 of a VENSIM variable element and a second SDL may be assigned to a final time step 100 of the same VENSIM variable. SimSyn linearly interpolates between the first and the second SDL values in the course of its integration.

3.4 Combinations of SDL and TSL

In some instances combinations of SDL and TSL are required. In cases where SDL and TSL are assigned to a VENSM model, the time series are duplicated and assigned to every single run of the SDL. SDL and TSL may refer to the same or different database tables.

For this type of data-linked simulation, larger computational overhead is to be expected (see also section 10).

4. Data upload

4.1 Create an empty database

  • Open pgAdmin III
  • Right-click the ‘Databases folder’ in the ‘Object browser’ window.
  • Select ‘new database…’ and assign a name to the new database.
  • Switch to ‘definition’ tab and select ‘postgres’ as a template.

4.2 Upload Excel spreadsheet data to a database

  • Make sure that point (‘.’) is set as decimal digit in Excel.
  • Copy data columns (data only, no column name) from Excel table to an Editor textfile (.txt).
  • Create an empty table and define the required columns in PostgreSQL by running the following line in the SQL query window of pgAdmin III.
CREATE TABLE 'table name' ('column name1' double precision, 'column name2' double precision,…);
  • Once the empty table is created right-click the new table in the ‘Object browser’ window and select ‘Import’. Browse for the textfile and import.
  • Finish the data upload by adding a primary key to the table. Use the following line.
ALTER TABLE 'table name' ADD COLUMN gid BIGSERIAL PRIMARY KEY;

Note: Please stick to the name 'gid' as primary key. Moreover, readable data types are constrained to integer and double precision type.

In order to convert existing PostgreSQL tables to integer or double precision, use the following SQL statement.

ALTER TABLE 'table name' ALTER COLUMN 'column name' TYPE 'new data type' USING 'column name'::'new data type';

4.3 Upload Shapefiles to a database

Before geospatial data can be loaded to a PostgreSQL database folder, PostGIS needs to be enabled in each individual database you want to use it in. In order to enable PostGIS open the database folder and run the following SQL statement.

CREATE EXTENSION postgis;

Once PostGIS is enabled shp2pgsql command line functions can be used for uploading data (see cheatsheet). The following example (Fig. 2) demonstrates the upload of a shapefile named ‘hyde_alcc_ssm’ to a table named ‘hyde_alcc’ in database ‘Hyde’. Note: Run Windows Command Prompt as administrator!

Fig. 2 Fig. 2. Shapefile upload using Windows Command Prompt and shp2pgsql

PostGIS differentiates between Polygon and Multipolygon, Shapefile does not. Capital Letter –S is used to force upload as single polygon Instead of Multipolygon. The EPSG number 4326 stands for the world geodetic reference system WGS84.

Note: Readable data types are constrained to integer and double precision type (see also section 4.2). Moreover, do not alter the geometry column name. Otherwise SimSyn will report an error to the log-file (‘SimSynEXE/SimSyn.exe.log’).

Clone this wiki locally