Next Previous Up Contents
Next: Referencing Column Values
Up: Top
Previous: Parameter Suffixes

## 10 Algebraic Expression Syntax

Many of the STILTS commands allow you to use algebraic expressions based on table columns when doing things like making row selections, defining new columns, selecting values to plot or match, and so on. In these cases you are defining an expression which has a value in each row as a function of the values in the existing columns in that row. This is a powerful feature which permits you to manipulate and select table data in very flexible ways. The syntax for entering these expressions is explained in this section.

What you write are actually expressions in the Java language, which are compiled into Java bytecode before evaluation. However, this does not mean that you need to be a Java programmer to write them. The syntax is pretty similar to C, but even if you've never programmed in C most simple things, and many complicated ones, are quite intutitive.

The following explanation gives some guidance and examples for writing these expressions. Unfortunately a complete tutorial on writing Java expressions is beyond the scope of this document, but it should provide enough information for even a novice to write useful expressions.

The expressions that you can write are basically any function of all the column values which apply to a given row; the function result can then be used where STILTS needs a per-row value, for instance to define a new column. If the built-in operators and functions are not sufficient, or it's unwieldy to express your function in one line of code, it is possible to add new functions by writing your own classes - see Section 10.9.3.

Note that since these algebraic expressions often contain spaces, you may need to enclose them in single or double quotes so that they don't get confused with other parts of the command string.

Note: if Java is running in an environment with certain security restrictions (a security manager which does not permit creation of custom class loaders) then algebraic expressions won't work at all. It's not particularly likely that security restrictions will be in place if you are running from the command line though.

- 10.1 Referencing Column Values
- 10.2 Referencing Parameter Values
- 10.3 Special Tokens
- 10.4 Null Values
- 10.5 Operators
- 10.6 Strings and Quoting
- 10.7 Functions

- 10.7.1 Arithmetic
- 10.7.2 Arrays
- 10.7.3 Bits
- 10.7.4 Conversions
- 10.7.5 CoordsDegrees
- 10.7.6 CoordsRadians
- 10.7.7 Coverage
- 10.7.8 Distances
- 10.7.9 Fluxes
- 10.7.10 Formats
- 10.7.11 Gaia
- 10.7.12 Json
- 10.7.13 KCorrections
- 10.7.14 Lists
- 10.7.15 Maths
- 10.7.16 Randoms
- 10.7.17 Shapes
- 10.7.18 Sky
- 10.7.19 Strings
- 10.7.20 Tilings
- 10.7.21 Times
- 10.7.22 TrigDegrees
- 10.7.23 URLs
- 10.7.24 VO

- 10.8 Examples
- 10.9 Advanced Topics

- 10.9.1 Expression evaluation
- 10.9.2 Instance Methods
- 10.9.3 Adding User-Defined Functions

Next Previous Up Contents
Next: Referencing Column Values
Up: Top
Previous: Parameter Suffixes

STILTS - Starlink Tables Infrastructure Library Tool Set
Starlink User Note256
STILTS web page: http://www.starlink.ac.uk/stilts/
Author email: m.b.taylor@bristol.ac.uk
Mailing list: topcat-user@jiscmail.ac.uk