nleethochawalit / GLACiAR2-master

Creative Commons Attribution Share Alike 4.0 International
6 stars 0 forks source link

GLACiAR2

Overview

GLACiAR2 is an open-source python3 tool for injection-recovery simulations that determine completeness in galaxy surveys. It's an updated version of GLACiAR developped by Carrasco et al. 2018 (https://arxiv.org/abs/1805.08985, https://github.com/danielacarrasco/GLACiAR).

Requirements

Python and SExtractor are required to run the program. We also recommend DS9 to visualise the images.

We suggest users to download Anaconda https://www.anaconda.com/download/ which includes all the softwares needed to run GLACiAR.

GLACiAR2 uses a module that may not be included in most python installations, which is pysysp. User may need to edit the source code of pysysp so that it is compatible with python3.

Running GLACiAR

  1. Download the source code from GitHub
  2. Modify or create a parameter file (e.g. parameters.yaml).
  3. Create a directory that contains the images for all different fields and bands required. In this directory, a subfolder Results will be created by GLACiAR2. All the files created will be saved here.
  4. Make sure that the throughput tables for all bands and the PSF images are in the Files folder.
  5. Modify the SExtractor file parameters.sex in the folder SExtractor_files if needed.
  6. Modify 'dropouts.py' if needed.
  7. Run python completeness.py -s source-extractor parameters.yaml. The -s option is for inputting the command that runs SExtractor (default = 'source-extractor').

Parameters

Modify or create a yaml parameter file (e.g. 'parameters.yaml').

Parameters files

Files

Files required to run GLACiAR2.

Modules

The code is made of several modules, with the main mudule completeness.py. Their descriptions are as follow.

How it works

This process is repeated a given number of iterations for each magnitude bin, redshift bin, and number of fields.

GLACiAR2 first runs SExtractor on the original science image in dual mode and creates the original catalogue. It then creates artificial galaxies stamps according to the user specified magnitude bins, redshift bins, radii, UV slope, and light profiles. In each iteration, the number of injected galaxies and the sampled magnitudes can be specified to follow either a uniform, a Schechter, a linear or an exponential probability distribution. All galaxies in an iteration will have the same magnitude, spectrum, radii, and redshift but different light profiles. These artificial sources and then added to the science image of each band at random positions. It then runs SExtractor again on the new images.

The programme then compares the new catalogue to the original catalouge by checking a grid centered in the input position of the galaxies. The recovering status of the injected galaxies are as follows:

If required by the user, the programme can run a dropout selection criteria (dropout.py).

Outputs

The code produces a set of files, images and tables. All are located in the specified path_to_results folder but some of them will be deleted on the fly to save memory space. We outline them below.

The new images are the original images with the simulated galaxies added. Each iteration in the simulation produces one image per filter. They are saved and then deleted immediately after SExtractor runs on them. Location = Results/images/sersic_sources*.fits

These are the files generated by SExtractor, which are the catalouges in fits format and the segmentation maps:

  1. The catalouges for the original images are in the SciImages folder.
  2. The catalogues for the images with artificial images are in the Results/Catalogs/ folder. We only include the artificial sources that are detected. Other sources are deleted to save the memory space. For running SExtractor, we recommend using the provided default3.param file that detailed the catalog contents. The included fields are the following.
    • NUMBER Running object number
    • FLUX_ISO Isophotal flux [count]
    • FLUXERR_ISO RMS error for isophotal flux [count]
    • MAG_ISO Isophotal magnitude [mag]
    • MAGERR_ISO RMS error for isophotal magnitude [mag]
    • FLUX_APER Flux vector within fixed circular aperture(s) [count]
    • FLUXERR_APER RMS error vector for aperture flux(es) [count]
    • MAG_APER Fixed aperture magnitude vector [mag]
    • MAGERR_APER RMS error vector for fixed aperture mag. [mag]
    • FLUX_AUTO Flux within a Kron-like elliptical aperture [count]
    • FLUXERR_AUTO RMS error for AUTO flux [count]
    • MAG_AUTO Kron-like elliptical aperture magnitude [mag]
    • MAGERR_AUTO RMS error for AUTO magnitude [mag]
    • KRON_RADIUS Kron apertures in units of A or B
    • BACKGROUND Background at centroid position [count]
    • X_IMAGE Object position along x [pixel]
    • Y_IMAGE Object position along y [pixel]
    • ALPHA_J2000 Right ascension of barycenter (J2000) [deg]
    • DELTA_J2000 Declination of barycenter (J2000) [deg]
    • A_IMAGE Profile RMS along major axis [pixel]
    • B_IMAGE Profile RMS along minor axis [pixel]
    • THETA_IMAGE Position angle (CCW/x) [deg]
    • FWHM_IMAGE FWHM assuming a gaussian core [pixel]
    • FWHM_WORLD FWHM assuming a gaussian core [deg]
    • FLAGS Extraction flags
    • CLASS_STAR S/G classifier output
    • FLUX_RADIUS Fraction-of-light radii [pixel]
  3. The segmentation maps (fits images) indicating the source boundaries and thier indices in the catalouges. Unless indicated otherwise, they will be deleted after each iteration. To keep these maps, run GLACiAR2 with an option -m False e.g. python completeness.py -m False parameters.yaml.

GLACiAR2 outputs three main tables. Their description is the following.

The first table {LF name}_RecoveredStats_cat{field name}.cat contains the summary statistics on the counts and fractions of the recovered sources and the dropouts (if specified). For each magnitude and redshift bin, tt shows the number of injected sources, and the number of recovered sources at each status. It also show the recoverd fraction and the dropout fraction (i.e. the completeness as a function of intrinsic magnitude).

Below are the columns in this table.

  1. z: Input redshift of the simulated galaxy.
  2. m: Central value of the magnitude bin.
  3. N_Obj: Number of objects injected in the corresponding redshift and magnitude bin in all the iterations.
  4. St=xx: Number of artificial sources recovered with status xx (7 columns).
  5. N_Dropouts: Number of recovered sources with status >= 0 that passed the dropout selection criteria.
  6. N_Recovered: Number of recovered sources with status >= 0.
  7. Dropout_frac: Fraction of artificial sources that passed the selection criteria: N_Drop/N_Obj.
  8. Rec: Fraction of not recovered artificial sources : N_Rec/N_Obj.

The second type of tables, {LF name}_RecoveredStats_cat{field name}_nout.cat and {LF name}_RecoveredStats_cat{field name}_dout.cat, are the output matrices produced by the code. The *_nout.cat shows the number of galaxies with injected magnitude M whose recovered with status >=0 and apparent magnitude m in the detection band -- N(M,m)-- at each redshift. The *_dout.cat shows similar matrix but for the galaxies that also pass the selection criteria. For ease of use, we also provide the two tables in a Python-specific binary format (pickle file) as GLACiAR_output_{field name}.pickle.

To easily check or visualize the output, the code also produces one ds9 region file for each iteration in /Results/SegmentationMaps. The region file indicates locations of the injected sources, their SExtractor ID, recovered magnitude, and status.

**Note on pysysp package*** The current version pip install pysysp is for python2. To make the code runs with python3, a few lines in the installed pysysp need to be changed.

  1. In pysysp.py, change "import pyfits" to "import astropy.io.fits as pyfits"
  2. In pysysp.py, change "import extinction as extlaws" to "from . import extinction as extlaws"
  3. In init.py, chage "from pysysp import StarSpectrum, BandPass, showfilters, listlaws" to "from .pysysp import StarSpectrum, BandPass, showfilters, listlaws"