User Tools

Site Tools


howtos:toolcoding:general_view_writing

This is an old revision of the document!


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

Example Files

views.samm -

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

Fields:

  • creview - identifies the view as a Create view
  • import - indicates that variables are to be imported from external files
  • testInOut.s - name of the model base
  • import.v - file containing the names of the variables to be imported
  • import.t - Tool commands to import the external data according to the format of each variable
creview import	testInOut.s	import.v	import.t	"importing first scenario"

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 (not sure why, since the variables are named?). 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 munu, 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

howtos/toolcoding/general_view_writing.1263248556.txt.gz · Last modified: 2010/01/11 22:22 by craig.gaston