
.. contents::
   :depth: 3
..

----------------------

**How to run**
=========================

Below is explained how to use
each routine of CluSex. Every 
routine below is a command in 
the shell (bash). They are independent 
routines, but 
it is recommended to be used from 
top to bottom after clusex command has 
been executed.



Joincat 
~~~~~~~~~

Joincat is a small CluSex version. It just joins two 
existent sextractor catalogs. The aim is that a sextractor 
catalog can be merged with the output of CluSex. The aim is to 
detect those objects that were unable to be detected 
by CluSex. 

The principle is the same as CluSex: objects of the second catalog
will be added to the first one only if their center is outside the 
ellipse of the objects of the first catalog. Use it only when necessary. 


::

    usage: joincat [-h] [-s JOINSCALE] [-o OUTPUT] [-sf SATFILE] FirstCatalog SecondCatalog


JOINSCALE: the factor that multiply the major axis ratio of the ellipse in
the first catalog. Default = 1

SATFILE: the saturated ds9 region file generated by clusex (optional)

FirstCatalog: The catalog generated by Sextractor (or CluSex). All the objects
of this catalog will be added to the final catalog.

SecondCatalog: The catalog generated by Sextractor (or CluSex). Objects of this 
catalog will be added to the output only if their center is outside of any
of the ellipses of the first catalog.



MakeMask
~~~~~~~~~~

This routine creates an image containing ellipse masks for every object. 
It needs the CluSex output catalog and saturated ds9 regions (created by
CluSex as well)

::

    usage: makemask [-h] [-s SCALE] [-off OFFSET] [-o OUTMASK] [-sf SATFILE] [-n] SexCatalog Image

SexCatalog: the output CluSex (or sextractor) catalog 
Image: the Fits image
SCALE: the factor that will be multiplied to the major axis of the ellipse to increase (or
decrease) it
OFFSET: value to be added to the major axis of the ellipse. 
SATFILE: saturation ds9 region file created by CluSex. 
n: This option will not open Ds9 when the program finish. 
OUTMASK: output fits mask. 


compsky
~~~~~~~~~

This routine use two methods (gradient sky and random box) to compute
sky background for every detected object by CluSex. Output catalog
is the same as the input catalog but with the background column changed
to the new values

::

    usage: compsky [-h] [-s SCALERADIUS] [-w WIDTH] [-b BOX] [-nb NUMBOX] [-sm SCALERADMAX] [-m METHOD] [-o OUTCAT] SexCatalog Image MaskFile

SexCatalog: the output CluSex (or sextractor) catalog 
Image: the Fits image
MaskFile: the fits mask file created by makemask
METHOD: Method used to compute sky. 1 = gradient sky. 2 = random box
SCALERADIUS: factor that multiplies the radius of the catalog objects. 
              For grad sky it is the Inital radius. For rand sky is 
              the minimum radius of the box around main object. Default = 1

WIDTH: Width of the ring for the gradient method.
BOX: Size of the box for the random box method
NUMBOX: Number of boxes to use for the random box method
SCALERADMAX: factor that multiplies the radius of the 
              catalog objects. It is the maximum 
              radius of the box around main object. 
              Only for random box method.  Default = 20
OUTCAT: output catalog 

sex2ds9
~~~~~~~~~

Creates a ds9 region file from the sextractor output catalog

::
  
  usage: sex2ds9 [-h] [-s SCALE] [-off OFFSET] [-o OUTREG] SexCatalog


SexCatalog: the output CluSex (or sextractor) catalog 
SCALE: the factor that will be multiplied to the major axis of the ellipse to increase (or
decrease) it
OFFSET: value to be added to the major axis of the ellipse. 
OUTREG: output Ds9 region file


remellmask
~~~~~~~~~~~~~

This is a short routine that removes ellipse masks from
the mask. Useful when a model fitting will be applied
to the galaxy. It needs the image created by makemask 

::

    usage: remellmask [-h] [-f FILL] [-o OUTMASK] mask number



mask: Fits image of the objects
number: ellipse number to be removed (or changed check option -f)
FILL: Value number to be filled within the ellipse mask. 
      0 = object removed. Default = 0
OUTMASK: name of the new mask

makeobjimg
~~~~~~~~~~~~~

This is a short routine that makes a objects image, i.e. 
it is the same input image but the regions where there is not
any detected object have a value of 0 counts. 

::

    usage: makeobjimg [-h] [-o OUTIMAGE] image mask



image: the Fits image
mask: Fits image of the objects
OUTIMAGE: name of the new output image


makestamps
~~~~~~~~~~~~

This routine creates image stamps for every object. The 
stamps includes only the main object, everything else is removed.
Those stamps can be used to classify the galaxies either manual or
throught neural networks. 


::

      usage: makestamps [-h] [-sr STRETCH] [-so SKYOFF] [-dp DPI] [-cm CMAP] [-s SCALE]
                  [-off OFFSET] [-br BRIGHT] [-co CONTRAST] [-gc GALCLASS]
                  image catalog mask

image: the Fits image
mask: Fits image of the objects
catalog: Sextractor catalog
DPI: number of dots per inch. 
CMAP: color map used for the images.
SCALE: the factor that will be multiplied to the
      major axis of the ellipse to increase (or decrease) it
OFFSET: value to be added to the major axis of the ellipse. 
SKYOFF: value to be added to the mean of the sky background
STRETCH:  stretch factor to enlarge the stamps
BRIGHT: brightness of the image. 
CONTRAST: contrast of the image.
GALCLASS: galaxy/star sextractor classification limit. 
          Sextractor Classification 1 = Star. 0 = galaxy. 
          Sextractor Class above this value will be reject to be in 
          the stamps




