Template:Dataset Calculator: Difference between revisions

From XMS Wiki
Jump to navigationJump to search
 
(29 intermediate revisions by the same user not shown)
Line 1: Line 1:
__NOINDEX__
__NOINDEX__
__NOTC__
__NOTOC__
===Dataset Calculator===
===Dataset Calculator===
The ''Dataset Calculator'' tool will perform calculations on one or more dataset data and activity. The tool will produce a new dataset with the resulting values and activity of those datasets according to the provided mathematical expression
The ''Dataset Calculator'' tool will perform calculations on one or more dataset data and activity. The tool will produce a new dataset with the resulting values and activity of those datasets according to the provided mathematical expression.
 
It should be noted that datasets at different locations (point vs. cell) cannot be used in the same expression.


====Input Parameters====
====Input Parameters====
*''Grid Source Selection'' – The source grid of any datasets to work with.
*''Grid source selection'' – Select the geometry on which the dataset calculation will be performed. The geometry can be a 2D mesh, scatter set, grid or UGrid. The cells or points in the geometry define the locations where data from the dataset exists and the locations for the calculations specified in the tool.
*''Data Location Selection'' – The allowed location of data in datasets: either on points or cells of the source grid.
*''Data location selection'' – Determines the location of the calculations in the geometry. 2D meshes and scatter sets only support point datasets. UGrids supports both point and cell datasets. Cartesian grids can be of one type or the other.
*''Table'' –
**"Cells" – Calculations will be performed on the cell values of the geometry.
**''Dataset'' – The selected dataset
**"Points" – Calculations with be performed on the point values of the geometry.
*''Dataset table'' – Can be populated with the datasets from the select ''Grid source selection''. This table allows selecting which datasets are to be used and specify a variable name for each that will appear in the expression. The default variable names follow the pattern of d1, d2, etc., but user specified names can be specified as well. Not all datasets selected in the table need to be used in the expression.
**''Dataset'' – The selected dataset.
**''Variable Name'' – The name to be used to refer to the chosen dataset within the provided expression.  
**''Variable Name'' – The name to be used to refer to the chosen dataset within the provided expression.  
**''Time Step'' – The chosen timestep from which to use data from this dataset. Or select all timesteps to use all values within this dataset.
**''Time Step'' – The chosen time step from which to use data from this dataset. Or select all time steps to use all values within this dataset.
*''Mathematical Expression'' – The expression to be evaluated with the chosen datasets
*''Mathematical expression'' – The equation or expression that will be evaluated at each location in the dataset. Parentheses can be used in the expression as in mathematical notation.


====Output Parameters====
====Output Parameters====
Line 17: Line 21:
The output will be a new dataset on the chosen grid with values and activity according to the expression and chosen datasets.
The output will be a new dataset on the chosen grid with values and activity according to the expression and chosen datasets.


====Current Location in toolbox====
====Current Location in Toolbox====
Datasets/ Dataset Calculator
Datasets/ Dataset Calculator
 
<!--
====Restrictions/Rules====
===Restrictions/Rules===
The values will be the result of the expression being performed on each set of values of the datasets at each time step.
{{Dataset Calculator Table}}
Datasets with point and cell values cannot be mixed in the dataset calculator.
{{Dataset Calculator Table Examples}}-->
*If no dataset being used in a calculation has activity, the resulting dataset will also not have activity. (See example #1 in the table below)
===Example Expressions===                 
*In calculations with multiple datasets with one timestep selected, the resulting time step will be 0.0. (See example #4)
====Traditional Mathematical Symbols====
*If there is a combination of different selections for time steps and there is at least one dataset with “all time steps” selected, the resulting dataset’s time steps will be that dataset’s time steps. (see example #5)
Includes:  +, -, *, /. (addition, subtraction, multiplication, division)
**In any such calculations, the calculator will use the single corresponding values array from any datasets with a single time step selected for every corresponding set of values in any datasets with “all time steps” selected. time step in the multiple time step selections.
=====Example 1 &ndash; mathematical operation:=====
*All datasets where “all time steps” has been selected must have the same time steps. (See example #9)
{|-
*If there is a combination of activity on cells and points between the datasets being used in a calculation, before performing calculations for activity, the calculator will find the point activity from the given cell activity and use that in the activity calculations. (See example #26)
|''Dataset table'':                              
An SMS sample file with the examples in the table can be downloaded [https://www.xmswiki.com/images/f/fb/DatasetCalculatorExamples.sms.zip here].
|
{| class="wikitable"
variable name "D" representing the water depth dataset<br>
variable name "Z" representing the ground elevation dataset
|-
|-
!Test #
|''Mathematical  expression:''
!Dataset 1 value location
|          D + Z
!Dataset 1 activity
!Dataset 1 time steps
!Dataset 2 value location
!Dataset 2 activity
!Dataset 2 time steps
!Result location
!Result activity
!Result time steps
|-
|-
|1
|   ''Output dataset name:''     
|cells
|           WSE  (new dataset representing the water surface elevation)
|no activity
|}
|1 time step
====Trigonometric Operations====
|cells
Includes: sin, cos, tan, arcsin, arccos, arctan, arctan2, sinh, cosh, tanh, arcsinh, arccosh, arctanh
|no activity
=====Example 2 &ndash; trig function:=====
|1 time step
{|-
|cells
|no activity
|1 time step
|-
|-
|2
| ''Dataset table:''                             
|cells
|variable name "AMP" representing the amplitude dataset<br>
|no activity
variable name "PHASE" representing the phase dataset
|1 time step
|cells
|no activity
|all time steps
|cells
|no activity
|all time steps
|-
|-
|3
|     ''Mathematical  expression:''       
|cells
|   AMP  * sin( PHASE)
|no activity
|all time steps
|cells
|no activity
|all time steps
|cells
|no activity
|all time steps
|-
|-
|4
|     ''Output dataset name:''               
|cells
|   WSE  (new dataset representing the water surface elevation)
|cells activity
|}
|1 time step
 
|cells
====Mathematical Functions====
|cells activity
Includes: log, log10, exp, sqrt, abs
|1 time step
=====Example 3 &ndash; square root:=====
|cells
{|-
|cells activity
|1 time step
|-
|-
|5
| ''Dataset table:''                             
|cells
|variable name "V" representing the velocity magnitude dataset<br>
|cells activity
variable name "D" representing the water depth dataset
|1 time step
|cells
|cells activity
|all time steps
|cells
|cells activity
|all time steps
|-
|-
|6
| ''Mathematical  expression: ''         
|cells
| V/sqrt(32.2 * D)
|cells activity
|all time steps
|cells
|no activity
|1 time step
|cells
|cells activity
|all time steps
|-
|-
|7
| ''Output dataset name:''       
|cells
|         FR (new dataset representing the Froude number at the computation location)
|cells activity
|}
|all time steps
=====Example 4 &ndash; exponent:=====
|cells
{|-
|no activity
|all time steps
|cells
|cells activity
|all time steps
|-
|-
|8
| '' Dataset table:''                             
|cells
| variable name "Vx" representing the velocity in the X direction dataset
|cells activity
variable name "Vy" representing the velocity in the Y direction dataset
|1 time step
|cells
|no activity
|1 time step
|cells
|cells activity
|1 time step
|-
|-
|9
| Mathematical  expression:       
|cells
|   sqrt(exp(Vx, 2) + exp(Vy, 2))
|cells activity
|all time steps
|cells
|cells activity
|all time steps
|cells
|cells activity
|all time steps
|-
|-
|10
| ''Output dataset name:''     
|cells
| Vmag (new dataset representing the velocity magnitude at the computation location)
|cells activity
|}
|1 time step
 
|cells
====Conditional Statements====
|no activity
Where(bool, number1, number2)
|all time steps
===== Example 5 &ndash; Min, max or conditional:=====
|cells
{|-
|cells activity
|all time steps
|-
|-
|11
| ''Dataset table:''                 
|points
| variable name "WSE1" representing the first water surface dataset<br>
|points activity
variable name "WSE2" representing the second water surface dataset
|1 time step
|points
|points activity
|1 time step
|points
|points activity
|1 time step
|-
|-
|12
| ''Mathematical  expression: ''   
|points
|       where(WSE1 > WSE2, WSE1, WSE2)
|points activity
|1 time step
|points
|points activity
|all time steps
|points
|points activity
|all time steps
|-
|-
|13
| ''Output dataset name: ''       
|points
|   MaxWSE (new dataset representing the maximum water surface)
|cells activity
|}
|all time steps
=====  Example 6 - truncation (nested conditional):=====
|points
{|-
|no activity
|all time steps
|points
|cells activity
|all time steps
|-
|-
|14
| ''Dataset table:'' 
|points
| variable name "SIZE" representing the nodal spacing (size) dataset
|cells activity
|all time steps
|points
|points activity
|1 time step
|points
|points activity
|all time steps
|-
|-
|15
| ''Mathematical  expression:'' 
|points
|   where(SIZE < 20, 20, where(size > 50, 50, SIZE)
|cells activity
|all time steps
|points
|points activity
|all time steps
|points
|points activity
|all time steps
|-
|-
|16
| Output dataset name:       
|points
| TRUNCSIZE (new dataset representing a truncated size dataset)
|points activity
|}
|all time steps
 
|points
===Dataset Activity===
|points activity
One of the complicating factors that can make working with datasets confusing is the fact that individual locations can be inactive (no value) for a given dataset, or a timestep in a given dataset. This activity can be specified in multiple ways including:
|all time steps
* no activity specification: in this case, all locations are assumed to have a valid value.
|points
* cell activity mask - in this case there is an additional boolean value for each cell in the dataset indicating whether this cell has a valid value. Note: this can apply to both point and cell based datasets.
|points activity
* point activity mask - in this case there is an additional boolean value for each point in the dataset indicating whether this point has a valid value.
|all time steps
* null value specified at the location - in this case the dataset has a specific value (i.e. -999, -999999, etc) which indicates that this location has no valid value exists at this location. It is a special type of an activity mask.
 
When a dataset operation is performed on multiple datasets, the resulting dataset has activity specified for each location in the dataset. The type of activity depends on the activity classifications for the arguments/parameters in the expression. The following table describes the resulting activity for the new dataset.
* If no dataset being used in a calculation has activity, the resulting dataset will also not have activity.
* In calculations with multiple datasets with one timestep selected, the resulting time step will be 0.0.
* If there is a combination of activity on cells and points between the datasets being used in a calculation, before performing calculations for activity, the calculator will find the point activity from the given cell activity and use that in the activity calculations. See example #2 in the table below.
 
====Activity Examples:====
{|- border="1"
|-
|-
|17
!
|points
!
|no activity
!Dataset 1
|1 time step
!Dataset 2
|points
!Result
|no activity
|1 time step
|points
|no activity
|1 time step
|-
|-
|18
!Example
|points
!Value location
|cells activity
!Activity
|1 time step
!Activity
|points
!Activity
|no activity
|1 time step
|points
|cells activity
|1 time step
|-
|-
|19
|1
|points
|cells
|cells activity
|none specified
|1 time step
|none specified
|points
|none specified
|cells activity
|1 time step
|points
|cells activity
|1 time step
|-
|-
|20
|2
|points
|cells
|cells activity
|cell activity
|1 time step
|cell activity
|points
|cell activity
|cells activity
|all time steps
|points
|cells activity
|all time steps
|-
|-
|21
|3
|points
|cells
|no activity  
|cell activity
|1 time step
|none specified
|points
|cell activity
|no activity
|1 time step
|points
|no activity
|1 time step
|-
|-
|22
|4
|points
|points
|no activity
|none specified
|1 time step
|none specified
|points
|none specified
|points activity
|all time steps
|points
|points activity
|all time steps
|-
|-
|23
|5
|points
|points
|cells activity
|point activity
|1 time step
|point activity
|points
|point activity
|no activity
|all time steps
|points
|cells activity
|all time steps
|-
|-
|24
|6
|points
|points
|no activity  
|cell activity
|1 time step
|none specified
|points
|cell activity
|points activity
|1 time step
|points
|points activity
|1 time step
|-
|-
|25
|7
|points
|points
|no activity  
|cell activity
|all time steps
|cell activity
|points
|cell activity
|no activity
|all time steps
|points
|no activity
|all time steps
|-
|-
|26
|8
|points
|points
|cells activity
|point activity
|1 time step
|none specified
|points
|point activity
|points activity
|1 time step
|points
|points activity
|1 time step
|-
|-
|27
|9
|points
|points
|cells activity
|cell activity
|1 time step
|point activity
|points
|point activity
|points activity
|}
|all time steps
 
|points
===Transient Datasets===
|points activity
Transient datasets are compound datasets made of  datasets for multiple values of time. These are referred to as time steps. When adding a transient dataset to an expression the use can choose a single time step from that dataset, or set a flag to evaluate the expression for "all times". In this case, the expression is evaluated separately for each time step in the dataset.
|all time steps
*If multiple transient datasets are included in a single expression using the "all time steps" option, they must have matching (identical) time steps.
|-
*If single time step datasets are included in an expression that uses one or more "all time steps" arguments, the specified single time step is used in the evaluation of the expression for each time step in the "all time steps" arguments.
|28
 
|points
===Related Tools===
|no activity
* [[Compare Datasets Tool|Compare Datasets]]
|all time steps
* [[Filter Dataset Tool|Filter Dataset]]
|points
* [[Map Activity Tool|Map Activity]]
|points activity
 
|1 time step
<small>
|points
*This tool makes use of the NumExpr (numerical expressions) library from NumPy. Documentation for this package can be found at [https://numexpr.readthedocs.io/en/latest/user_guide.html https://numexpr.readthedocs.io/en/latest/user_guide.html].</small>
|points activity
<noinclude>[[Category:Toolbox Datasets]]</noinclude>
|all time steps
|-
|29
|points
|no activity
|all time steps
|points
|points activity
|all time steps
|points
|points activity
|all time steps
|-
|30
|points
|cells activity
|all time steps
|points
|no activity
|1 time step
|points
|cells activity
|all time steps
|-
|31
|points
|cells activity
|all time steps
|points
|cells activity
|all time steps
|points
|cells activity
|all time steps
|}<noinclude>[[Category:Toolbox Datasets]]</noinclude>

Latest revision as of 14:39, 10 July 2024


Dataset Calculator

The Dataset Calculator tool will perform calculations on one or more dataset data and activity. The tool will produce a new dataset with the resulting values and activity of those datasets according to the provided mathematical expression.

It should be noted that datasets at different locations (point vs. cell) cannot be used in the same expression.

Input Parameters

  • Grid source selection – Select the geometry on which the dataset calculation will be performed. The geometry can be a 2D mesh, scatter set, grid or UGrid. The cells or points in the geometry define the locations where data from the dataset exists and the locations for the calculations specified in the tool.
  • Data location selection – Determines the location of the calculations in the geometry. 2D meshes and scatter sets only support point datasets. UGrids supports both point and cell datasets. Cartesian grids can be of one type or the other.
    • "Cells" – Calculations will be performed on the cell values of the geometry.
    • "Points" – Calculations with be performed on the point values of the geometry.
  • Dataset table – Can be populated with the datasets from the select Grid source selection. This table allows selecting which datasets are to be used and specify a variable name for each that will appear in the expression. The default variable names follow the pattern of d1, d2, etc., but user specified names can be specified as well. Not all datasets selected in the table need to be used in the expression.
    • Dataset – The selected dataset.
    • Variable Name – The name to be used to refer to the chosen dataset within the provided expression.
    • Time Step – The chosen time step from which to use data from this dataset. Or select all time steps to use all values within this dataset.
  • Mathematical expression – The equation or expression that will be evaluated at each location in the dataset. Parentheses can be used in the expression as in mathematical notation.

Output Parameters

  • Output Dataset Name – the name of the new dataset to fill with the resulting values from the expression.

The output will be a new dataset on the chosen grid with values and activity according to the expression and chosen datasets.

Current Location in Toolbox

Datasets/ Dataset Calculator

Example Expressions

Traditional Mathematical Symbols

Includes: +, -, *, /. (addition, subtraction, multiplication, division)

Example 1 – mathematical operation:
Dataset table:

variable name "D" representing the water depth dataset
variable name "Z" representing the ground elevation dataset

Mathematical expression: D + Z
Output dataset name: WSE (new dataset representing the water surface elevation)

Trigonometric Operations

Includes: sin, cos, tan, arcsin, arccos, arctan, arctan2, sinh, cosh, tanh, arcsinh, arccosh, arctanh

Example 2 – trig function:
Dataset table: variable name "AMP" representing the amplitude dataset

variable name "PHASE" representing the phase dataset

Mathematical expression: AMP * sin( PHASE)
Output dataset name: WSE (new dataset representing the water surface elevation)

Mathematical Functions

Includes: log, log10, exp, sqrt, abs

Example 3 – square root:
Dataset table: variable name "V" representing the velocity magnitude dataset

variable name "D" representing the water depth dataset

Mathematical expression: V/sqrt(32.2 * D)
Output dataset name: FR (new dataset representing the Froude number at the computation location)
Example 4 – exponent:
Dataset table: variable name "Vx" representing the velocity in the X direction dataset

variable name "Vy" representing the velocity in the Y direction dataset

Mathematical expression: sqrt(exp(Vx, 2) + exp(Vy, 2))
Output dataset name: Vmag (new dataset representing the velocity magnitude at the computation location)

Conditional Statements

Where(bool, number1, number2)

Example 5 – Min, max or conditional:
Dataset table: variable name "WSE1" representing the first water surface dataset

variable name "WSE2" representing the second water surface dataset

Mathematical expression: where(WSE1 > WSE2, WSE1, WSE2)
Output dataset name: MaxWSE (new dataset representing the maximum water surface)
Example 6 - truncation (nested conditional):
Dataset table: variable name "SIZE" representing the nodal spacing (size) dataset
Mathematical expression: where(SIZE < 20, 20, where(size > 50, 50, SIZE)
Output dataset name: TRUNCSIZE (new dataset representing a truncated size dataset)

Dataset Activity

One of the complicating factors that can make working with datasets confusing is the fact that individual locations can be inactive (no value) for a given dataset, or a timestep in a given dataset. This activity can be specified in multiple ways including:

  • no activity specification: in this case, all locations are assumed to have a valid value.
  • cell activity mask - in this case there is an additional boolean value for each cell in the dataset indicating whether this cell has a valid value. Note: this can apply to both point and cell based datasets.
  • point activity mask - in this case there is an additional boolean value for each point in the dataset indicating whether this point has a valid value.
  • null value specified at the location - in this case the dataset has a specific value (i.e. -999, -999999, etc) which indicates that this location has no valid value exists at this location. It is a special type of an activity mask.

When a dataset operation is performed on multiple datasets, the resulting dataset has activity specified for each location in the dataset. The type of activity depends on the activity classifications for the arguments/parameters in the expression. The following table describes the resulting activity for the new dataset.

  • If no dataset being used in a calculation has activity, the resulting dataset will also not have activity.
  • In calculations with multiple datasets with one timestep selected, the resulting time step will be 0.0.
  • If there is a combination of activity on cells and points between the datasets being used in a calculation, before performing calculations for activity, the calculator will find the point activity from the given cell activity and use that in the activity calculations. See example #2 in the table below.

Activity Examples:

Dataset 1 Dataset 2 Result
Example Value location Activity Activity Activity
1 cells none specified none specified none specified
2 cells cell activity cell activity cell activity
3 cells cell activity none specified cell activity
4 points none specified none specified none specified
5 points point activity point activity point activity
6 points cell activity none specified cell activity
7 points cell activity cell activity cell activity
8 points point activity none specified point activity
9 points cell activity point activity point activity

Transient Datasets

Transient datasets are compound datasets made of datasets for multiple values of time. These are referred to as time steps. When adding a transient dataset to an expression the use can choose a single time step from that dataset, or set a flag to evaluate the expression for "all times". In this case, the expression is evaluated separately for each time step in the dataset.

  • If multiple transient datasets are included in a single expression using the "all time steps" option, they must have matching (identical) time steps.
  • If single time step datasets are included in an expression that uses one or more "all time steps" arguments, the specified single time step is used in the evaluation of the expression for each time step in the "all time steps" arguments.

Related Tools