Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

scrollbar

UserSimple

Input

It is possible to define embedded variables in this transformation. In the expression both embedded variables and variables defined at the start of the transformations configuration file can be used. If an embedded variable and a variable defined at the start of the transformations configuration file have the same variableId, then the embedded variable will be used.

...

In the example below Location_A is part of the locationSet Test_Locations:

Code Block
xml
xml

<variable>
	<variableId>X1</variableId>
	<timeSeriesSet>
		<moduleInstanceId>UserSimpleTemplateVariable</moduleInstanceId>
		<valueType>scalar</valueType>
		<parameterId>Q.meting</parameterId>
		<locationSetId>Test_Locations</locationSetId>
		<timeSeriesType>external historical</timeSeriesType>
		<timeStep unit="day"/>
		<relativeViewPeriod unit="day" start="0" end="364"/>
		<readWriteMode>editing visible to all future task runs</readWriteMode>
	</timeSeriesSet>
</variable>
<variable>
	<variableId>Y1</variableId>
	<timeSeriesSet>
		<moduleInstanceId>UserSimpleTemplateVariable</moduleInstanceId>
		<valueType>scalar</valueType>
		<parameterId>Q.afgeleid</parameterId>
		<locationId>Location_A</locationId>
		<timeSeriesType>external historical</timeSeriesType>
		<timeStep unit="day"/>
		<relativeViewPeriod unit="day" start="0" end="364"/>
		<readWriteMode>add originals</readWriteMode>
	</timeSeriesSet>
</variable>
<transformation id="user simple test">
	<user>
		<simple>
			<inputVariableDefinition>
				<variableId>meting</variableId>
				<locationId>Location_A</locationId>
				<templateVariableId>X1</templateVariableId>
			</inputVariableDefinition>
			<expression>meting*1.08</expression>
			<outputVariable>
				<variableId>Y1</variableId>
			</outputVariable>
		</simple>
	</user>
</transformation>

...

In the example below 'X1' is a reference to a variable and 'a' and 'b' are references to a coefficient.

Code Block
xml
xml

<variable>
	<variableId>X1</variableId>
	<timeSeriesSet>
		<moduleInstanceId>UserSimpleTest2</moduleInstanceId>
		<valueType>scalar</valueType>
		<parameterId>Q.m</parameterId>
		<locationId>H-2001</locationId>
		<timeSeriesType>external historical</timeSeriesType>
		<timeStep unit="day"/>
		<relativeViewPeriod unit="day" start="0" end="364"/>
		<readWriteMode>editing visible to all future task runs</readWriteMode>
	</timeSeriesSet>
</variable>
<variable>
	<variableId>Y1</variableId>
	<timeSeriesSet>
		<moduleInstanceId>UserSimpleTest2</moduleInstanceId>
		<valueType>scalar</valueType>
		<parameterId>Q.tra</parameterId>
		<locationId>H-2001</locationId>
		<timeSeriesType>external historical</timeSeriesType>
		<timeStep unit="day"/>
		<relativeViewPeriod unit="day" start="0" end="364"/>
		<readWriteMode>add originals</readWriteMode>
	</timeSeriesSet>
</variable>
<transformation id="user simple test 2">
	<user>
		<simple>
			<expression>(a + b)*X1 - 3</expression>
			<coefficientSet>
				<coefficient id="a" value="1.34"/>
				<coefficient id="b" value="2.5"/>
			</coefficientSet>
			<outputVariable>
				<variableId>Y1</variableId>
			</outputVariable>
		</simple>
	</user>
</transformation>

The example below uses an if statement. Here 'X' is a reference to a variable and 'a' is a reference to a coefficient.

Code Block
xml
xml

<variable>
	<variableId>X</variableId>
	<timeSeriesSet>
		<moduleInstanceId>UserSimpleWithIfElseStatementTest</moduleInstanceId>
		<valueType>scalar</valueType>
		<parameterId>Q.m</parameterId>
		<locationId>H-2001</locationId>
		<timeSeriesType>external historical</timeSeriesType>
		<timeStep unit="day"/>
		<relativeViewPeriod unit="day" start="0" end="9"/>
		<readWriteMode>editing visible to all future task runs</readWriteMode>
	</timeSeriesSet>
</variable>
<variable>
	<variableId>Y</variableId>
	<timeSeriesSet>
		<moduleInstanceId>UserSimpleWithIfElseStatementTest</moduleInstanceId>
		<valueType>scalar</valueType>
		<parameterId>Q.tra</parameterId>
		<locationId>H-2001</locationId>
		<timeSeriesType>external historical</timeSeriesType>
		<timeStep unit="day"/>
		<relativeViewPeriod unit="day" start="0" end="9"/>
		<readWriteMode>add originals</readWriteMode>
	</timeSeriesSet>
</variable>
<transformation id="user simple with if else statement test">
	<user>
		<simple>
			<!-- if X > 3, then the expression part if(X &gt; 3, 10.5, -2) is replaced with 10.5 -->
			<!-- if X <= 3, then the expression part if(X &gt; 3, 10.5, -2) is replaced with -2 -->
			<expression>if(X &gt; 3, 10.5, -2) + 5*a</expression>
			<coefficientSet>
				<coefficient id="a" value="1.5"/>
			</coefficientSet>
			<outputVariable>
				<variableId>Y</variableId>
			</outputVariable>
		</simple>
	</user>
</transformation>

The example below uses coefficientSetFunctions (available since build 30246, i.e. since stable build 2011.01). Here 'X' is a reference to a variable and 'a', 'b' and 'c' are references to coefficients. Here the coefficients are defined in coefficientSetFunctions, where  (coef_a),  (coef_b) and  (coef_c) refer to location number attributes that are defined in the locationSets configuration file.

Code Block
xml
xml

<variable>
	<variableId>X</variableId>
	<timeSeriesSet>
		<moduleInstanceId>UserSimpleWithCoefficientSetFunctionsTest</moduleInstanceId>
		<valueType>scalar</valueType>
		<parameterId>Q.m</parameterId>
		<locationId>locationWithAttributes4</locationId>
		<timeSeriesType>external historical</timeSeriesType>
		<timeStep unit="day"/>
		<relativeViewPeriod unit="day" start="0" end="9"/>
		<readWriteMode>editing visible to all future task runs</readWriteMode>
	</timeSeriesSet>
</variable>
<variable>
	<variableId>Y</variableId>
	<timeSeriesSet>
		<moduleInstanceId>UserSimpleWithCoefficientSetFunctionsTest</moduleInstanceId>
		<valueType>scalar</valueType>
		<parameterId>Q.tra</parameterId>
		<locationId>locationWithAttributes4</locationId>
		<timeSeriesType>external historical</timeSeriesType>
		<timeStep unit="day"/>
		<relativeViewPeriod unit="day" start="0" end="9"/>
		<readWriteMode>add originals</readWriteMode>
	</timeSeriesSet>
</variable>
<transformation id="user simple with coefficient set functions test">
	<user>
		<simple>
			<expression>a*(X^2) + b*X + c</expression>
			<coefficientSetFunctions>
				<coefficient id="a" value="@coef_a@"/>
				<coefficient id="b" value="@coef_b@"/>
				<coefficient id="c" value="@coef_c@"/>
			</coefficientSetFunctions>
			<outputVariable>
				<variableId>Y</variableId>
			</outputVariable>
		</simple>
	</user>
</transformation>

 

The example below enables the use of string comparison in a coefficient, which may be usefull in combination with modifiable attributes. If you have for example your modifier attribute OPTION_TYPE that can be "hard" or "soft" you make a coefficient that as a boolean checks which type you are using. The numerical value of the boolean coefficient can then be used in the expression. The below example will be resolved as:

  • if OPTION_TYPE = "hard" then COEF_OPTION = 1
  • if OPTION_TYPE <> "hard" then COEF_OPTION = 0

if OPTION_TYPE = NULL (undefined) then the string is interpreted as an empty string "", so the COEF_OPTION will still be 0 (and not NaN)

Code Block
languagexml
titleboolean coefficient
<variable>
	<variableId>X</variableId>
    ....
</variable>
<variable>
	<variableId>Y</variableId>
    ....
</variable>
<transformation id="user simple with boolean coefficient test">
	<user>
		<simple>
            <expression>IF(COEF_OPTION == 1, X, Y)</expression>
            <coefficientSetFunctions>
               <coefficient id="COEF_OPTION" value="@OPTION_TYPE@==&quot;hard&quot;"/>
            <coefficientSetFunctions>
    	    <outputVariable>
		        <variableId>Y</variableId>
		    </outputVariable>
		</simple>
	</user>
</transformation>

 

You can use an attribute of a related location by using this format: @<relationID>:<attribute>@.