Table Of Contents

Previous topic

LDAC - Conversion from and to the ASCII format

Next topic

LDAC - Catalogue Matching

This Page

LDAC - Advanced Catalogue Manipulations


The concrete examples on this page use the LDAC catalogues and

A tar archive with the complete set of LDAC Tools example files is here

Filtering Objects from an LDAC Table

The command ldacfilter allows the selection of a subset of objects within an LDAC table:

user$ ldacdesc -i
****** Table #3
       Number of elements:.....100

user$ ldacfilter
> SYNTAX: ldacfilter -i Input_catalog [-o Output_catalog] -c <filter_condition>
                     [ -m maskname ] [options]

Options are:  -t <Table_name> [defaulted to OBJECTS]

user$ ldacfilter -i -o -t LDAC_OBJECTS -c "(MAG_APER(2)<26);"

user$ ldacdesc -i
****** Table #3
       Number of elements:.....49

user$ ldacfilter -i -o -t LDAC_OBJECTS \
                 -c "((MAG_AUTO<26)AND(X_IMAGE<2000))AND(Y_IMAGE<15);"


  1. The condition parsing string always needs to be protected from the shell by embedding it into double quotes! Inside the quotes, it needs to be embedded into a pair of parentheses and it needs to finish with a semicolon! (e.g. ‘-c “(MAG_AUTO<26);”‘)
  2. It is only possible to connect TWO conditions with AND or OR. If more than two conditions are necessary we need to collect them with an appropriate amount of parentheses! Hence, use ‘-c “(((A)AND(B))AND(C));”’ instead of ‘-c “((A)AND(B)AND(C));”’
  3. It is not possible to put constraints on keys with keytype string.

Calculating new Quantities

To calculate new object quantities we use the command ldaccalc:

user$ ldaccalc
> SYNTAX: ldaccalc -i Input_catalog
        [-o Output_catalog]
         -c <filter_condition>
         -n <new_column_name> <new_column_comment>
         -k  <new_column_type>


user$ ldaccalc -i -o -t LDAC_OBJECTS \
               -c "(FLUX_RADIUS*0.186);" -n FLUX_RADIUS_WORLD "Flux Radius in arcsec" -k FLOAT \
               -c "((A_IMAGE+B_IMAGE)/2);" -n A_B_MEAN "Mean of object ellipse axes" -k FLOAT

user$ ldacdesc -i -t LDAC_OBJECTS


****** Key #25
       Key name:...............FLUX_RADIUS_WORLD
       Key comment:............Flux Radius in arcsec
       Key type:...............Float
       Key dimension:..........0
****** Key #26
       Key name:...............A_B_MEAN
       Key comment:............Mean of object ellipse axes
       Key type:...............Float
       Key dimension:..........0


  1. Currently, ldaccalc does not treat correctly calculations with vector keys
  2. For the condition string of ldaccalc the same restrictions as for that of ldacfilter apply!
  3. Possible types for the new key(s) (<new_column_type>) are: SHORT, LONG, FLOAT, DOUBLE
  4. ldaccalc knows the mathematical functions +, -, *, /, abs, cos, exp, int, log, sin, sqrt

Transferring keys from one catalogue to another

Often, we transfer parts of an LDAC table to an ASCII file and process it with another program that creates new columns of data. We would like to include these new columns into the initial catalogue. The main ingredient for this and similar tasks is the ldacjoinkey command (besides ldactoasc and asctoldac). In the following example the two catalogues and were created with SExtractor in the Dual-Image mode. They contain information from two different filters of exactly the same objects. We create ONE catalogue that contains the essential information from both catalogues:

user$ ldacrenkey -i -o -t LDAC_OBJECTS \
                 -k MAG_APER MAG_APER_r MAG_ISO MAG_ISO_r # rename MAG_APER to MAG_APER_r etc.

user$ ldacrenkey -i -o -t LDAC_OBJECTS \
                 -k MAG_APER MAG_APER_i MAG_ISO MAG_ISO_i

user$ ldacjoinkey
> SYNTAX: ldacjoinkey -i Catalog [-o Output_catalog] -p Proto_Catalog
          [-t Table_name] -k Key_name [Key_name ...]

user$ ldacjoinkey -i -o -t LDAC_OBJECTS -p \
                  -k MAG_APER_i MAG_ISO_i

user$ ldactoasc -i -t LDAC_OBJECTS -k MAG_ISO_r MAG_ISO_i
#   1 MAG_ISO_r           Isophotal magnitude                        [mag]
#   2 MAG_ISO_i           Isophotal magnitude                        [mag]
27.4693 26.9716
28.3986 28.3386
29.0798 28.6733
27.3656 26.4385

Making Scatter Plots of LDAC keys

The Python script (based on the Python modules,, pyfits, matplotlib) allows us to generate scatter plots of LDAC keys:

user$ -h
usage: [-h] -i INPUT_FILE -t TABLE -k KEYS KEYS
                 [-c [CONDITION [CONDITION ...]]] [-ti TITLE]
                 [-s MARKER_STYLE] [-m MARKER_SIZE]

optional arguments:
  -h, --help            show this help message and exit
  -i INPUT_FILE, --input_file INPUT_FILE
                        input file name
  -t TABLE, --table TABLE


user$ -i -o magplot.png -t LDAC_OBJECTS \
                  -k MAG_AUTO 'MAG_APER(4)' \
                  -c MAG_AUTO 10.0 30.0 "MAG_APER(4)" 10.0 30.0 -m 10 \
                  -ti "Magnitude Comparison"

Saving plot to magplot.png
difference of AUTO and APERTURE magnitudes

Other Tools

The meaning of several other, important LDAC tools is selfexplaining or can easily be extracted from the program help message:

Tool Task
ldacaddmask mark objects lying within saoimage/ds9 region files
ldacaddtab transfer an entire LDAC table from one catalogue to another
ldacdelkey delete an LDAC key in an LDAC table
ldacdeltab delete an LDAC table
ldacrenkey rename an LDAC key within a table
ldacrentab rename an LDAC table
ldacstats obtain basic statistics on an LDAC key
ldactoskycat create an ASCII table to overlay objects in Skycat