Table of Contents

General View Writing

Here's a presentation with information about view writing using_views_with_samm.ppt

Here are some examples of import and exports: Working with data

Understanding indexing wrt history and background

This is especially useful to understand when working with create and feedback views. For more information see the product documentation under TOOL Language/TOOL Scripts/View.

When referencing an object array, you must specify the element in the array that you would like to access. This is accomplished by using array indexes. The form of an object array reference is:

 objectName[upperDims,auxDims][index] 

where:

$history$backgroundObject TypeObject Array Contents Value of$numScns
truetrueUobject[][1] = history instance2
object[][2] = background instance
truetrueFobject[][1] = history instance3
object[][2] = background instance
object[][3] = new instance to be filled
truefalseUobject[][1] = history instance1
truefalseFobject[][1] = history instance2
object[][2] = new instance to be filled
falsetrueUobject[][1] = background instance1
falsetrueFobject[][1] = background instance2
object[][2] = new instance to be filled
falsefalseUobject[][1] = no instance - Error —
falsefalseFobject[][1] = new instance to be filled1

note: $history has value false when running views in calibrator.

Example Files

views.samm -

This is a Create view, which loads the initial data for four variables in a simple input-output model.

Fields:

setpath $HOME/V4/cal/views

! Data creation views:
creview import	testInOut.c	import.v	import.t	"importing first scenario"


! Data display views:
disview	energyUseRpt myCalc energyUseRpt .v			energyUseRpt .t			"energy use report"

import.v - The names of the four variables to be imported are listed. The order of the variables must conform to the order in import.t. It is recommended to select from the Documentor the variable names to be imported and paste them here to avoid spelling errors. F indicates …?

! accounts variables
finalDemand	F
accounts/Inputs	F
accounts/Outputs	F
accounts/primary	F

! inOutModel variables

import.t - The following Tool script associates the imported data to a specific scenario defined by $index. The import command indicates the variable to be filled, the format of the external file, followed by its name.

! accounts variables
creview	 finalDemand[c][]
creview	 Inputs[c,i][]
creview	 Outputs[i,c][]
creview	 primary[i][]

! inOutModel variables


string $importDir
$importDir = $home + "/models/inOut/PrimaryData"

integer $index
$index = 1
if $history == true
	$index = $index + 1
endif
if $background == true
	$index = $index + 1
endif

! accounts variables
say ("importing accounts variables")
finalDemand[c][$index] = import (; rowTitles=off, dataFile=$importDir/finalDemand.txt)
Inputs[c,i][$index] = import (; format=coord, allCoord=on, dataFile=$importDir/Inputs.txt)
Outputs[i,c][$index] = import (; rowTitles=on, dataFile=$importDir/Outputs.txt)
primary[i][$index] = import (; rowTitles=off, dataFile=$importDir/PrimaryInputs.txt)

! inOutModel variables
say ("importing inOutModel variables")

say ("Done.")

Loading Views into SAMM

- Before a a view can be run it must be loaded into SAMM

Here are the steps for loading a view:

  1. In the Windows menu, click Views .
  2. Click Load in the View Actions window
    1. Set the correct path name to the views.samm file. This will be found in the views folder under the sim folder under the model version in your home directory.
    2. click OK

Here are the steps for re-loading a view after editing the .t or .v

  1. Delete the existing view
  2. Repeat above steps

Running a View

Here are the steps for running a view:

  1. Click run in the View Actions menu or double click the view.

Note that running a create view generates new instances of the variables. To see how instances can be combined in a scenario see:

Scenario Management - Understanding Scenarios, Variables and Instances