Next Previous Up Contents
Next: Adding User-Defined Functions
Up: Algebraic Expression Syntax
Previous: Instance Methods

### 7.8 Examples

Here are some general examples. They could be used to define synthetic columns or (where numeric) to define values for one of the axes in a plot.

Average

          (first + second) * 0.5

Square root

          sqrt(variance)

Angle conversion

          radiansToDegrees(DEC_radians)
          degreesToRadians(RA_degrees)

Conversion from string to number

          parseInt($12)
          parseDouble(ident)

Conversion from number to string

          toString(index)

Conversion between numeric types

           toShort(obs_type)
           toDouble(range)

  or

          (short) obs_type
          (double) range

Conversion from sexagesimal to radians

          hmsToRadians(RA1950)
          dmsToRadians(decDeg,decMin,decSec)

Conversion from radians to sexagesimal

          radiansToDms($3)
          radiansToHms(RA,2)

Outlier clipping

          min(1000, max(value, 0))

Converting a magic value to null

          jmag == 9999 ? NULL : jmag

Converting a null value to a magic one

          NULL_jmag ? 9999 : jmag

Taking the third scalar element from an array-valued column

          psfCounts[2]

and here are some examples of boolean expressions that could be used to define row subsets (or to create boolean synthetic columns):

Within a numeric range

          RA > 100 && RA < 120 && Dec > 75 && Dec < 85

Within a circle

          $2*$2 + $3*$3 < 1
          skyDistance(ra0,dec0,degreesToRadians(RA),degreesToRadians(DEC))<15*ARC_MINUTE

First 100 rows

          index <= 100

Every tenth row

          index % 10 == 0

String equality/matching

          equals(SECTOR, "ZZ9 Plural Z Alpha")
          equalsIgnoreCase(SECTOR, "zz9 plural z alpha")
          startsWith(SECTOR, "ZZ")
          contains(ph_qual, "U")

String regular expression matching

          matches(SECTOR, "[XYZ] Alpha")

Combining subsets

          (_1 && _2) && ! _3

Test for non-blank value

          ! NULL_ellipticity

Next Previous Up Contents
Next: Adding User-Defined Functions
Up: Algebraic Expression Syntax
Previous: Instance Methods

TOPCAT - Tool for OPerations on Catalogues And Tables
Starlink User Note253
TOPCAT web page: http://www.starlink.ac.uk/topcat/
Author email: m.b.taylor@bristol.ac.uk
Mailing list: topcat-user@bristol.ac.uk