Operations: Absolute value for columns

From ILWIS
Jump to: navigation, search
Main Page Arrow.png Operations
Absolute value for columns
Absolute value for columns

The operation absolute value for columns can be used to remove negative values from a column and replace them with their non-negative values. The output results of the operation for each column cell (x) is the absolute value or modulus |x| of a real number x which is the non-negative value of x; meaning |x| or |-x| is x). A few examples:

  • The absolute value of 7 is 7 (|7| = 7)
  • The absolute value of -7 is 7 (|-7| = 7)
  • The absolute value of 0 is 0 (|0| = 0)

The absolute value for columns operation can be applied to a column of a table via ILWIS-Python editor or via ILWIS main window, Toolbar and the Operatins tab. The required Python syntax is:


name of the output column = ilwis.Engine.do(name of the operation, input table name, input column name)


Example bellow, shows the Python syntax for deriving absolute values of column cells; where the input table name is mytable, the input column is mycolumn, abs is the internal name for this operation and absmycolumn is the name of the output column. Note that the input table includes the input column.


absmycolumn = ilwis.Engine.do('abs',“file:///C:/my director/mycolumn", "file:///C:/my director/mytable.tbt")


In general, the URL used in the Python syntax can be replaced with variable name generated by Python. For example: a table and a column can be opened in Python Editor as variables:


ta = ilwis.Table("file:///C:/my director/mytable.tbt")
cl = ta.column("mycolumn")


Once the variables are created via ILWIS-Python editor, then it can be used directly without quotation mark and the URL as the following:


absmycolumn = ilwis.Engine.do('abs', tb, cl)

Figure 1, Absolute value for columns operation form



To start the Absolute value for columns operation from ILWIS main window:

Mar.jpg
  • Click the Operation tab on toolbar tabs
  • From the opened operation list select Absolute value for columns

Once the Absolute value for columns operation is selected from the list, an operation form will be opened in which users can set parameters required for the operation including input(s), output(s), memory location and data format (Figure 1).
To successfully execute this operation, you need to complete the form with proper inputs data. The inputs data must be dragged from the catalog and dropped in their corresponding fields in the form or directly typed in.

Absolute value for the columns

Input table: Enter a table using drag and drop or manually type in the name of the table.
Input column name: Select a column from the dropdown list to be used in this operation. Note, once a table selected for the input, name of the value domain columns in the table will be available as a list.
Output column name: Type a name for the output column.
Output format: Select one of the three available format from the list to save the output column. The default format is Keep original meaning the output column will be added to the input table as a new column. Select the option Memory; to temporally save the output in the internal catalog. In this case, the output is a table containing all the columns of the original table plus the new output column. It has ILWIS 4 format and uses the name of the output column. The added output column, thus, will be assigned a name which by default has the prefix "column_" and its index number, e.g., column_21.This file will be removed when you exit the program unless it is saved manually via save as operation. If you select ilwis 3 table file format, then the output will be saved in the active catalog.
Execute: Click the Execute button to run this operation.