Skip to content

PRIME Photometry Pipeline ‐ Photometry Instruction and Basic Usage

Oriohno edited this page Mar 4, 2024 · 1 revision

PRIME Photometry Pipeline - Photometry Instruction and Basic Usage

Before using Photometry.py

Before using this script, make sure you already possess a co-added final image, likely created through usage of master.py. Currently, master.py and photometry.py are separate, requiring 1 command to process into a final image and another command to run photometry. I could (and plan to) combine them into 1 big script that does everything in 1 go. However, while combining the basic functionality of photometry.py with master.py would be relatively easy, due to the many current (and future) optional arguments for photometry.py I don't want to have a very cluttered single command that would be prone to misinputting, leading to many minutes of lost time. So, for now, they're separate until I update them.

Using Photometry.py

Same start point as master.py, make sure you've cd'd into /photomitrus. Running the help command:

python ./photometry/photometry.py -h

will present helpful text on what each argument is, though the amount of them can be daunting. The formatting is as follows:

photometry.py [-h] [-exp_query] [-plots] [-grb] [-dir DIR] [-name NAME] [-filter FILTER] [-survey SURVEY] [-crop CROP] [-RA RA] [-DEC DEC] [-thresh THRESH]

Let us again start with the required positional arguments:

Required Arguments

  • -dir is a string that denotes the parent directory where the co-added final image is stored.

  • -name is a string that denotes the filename of the co-added final image. Note, this is not the full path, but just the filename. If you utilized stack.py to create the image, the format of the name should be (see stack.py's documentation for more info):

    coadd.Open-#.12345678-12345678.C#.fits

  • -filter is a single character string which denotes the filter of the co-added final image. This should be clear from the filename of the image. For instance, 'Open-J' is J band, so we would put 'J' for this argument.

  • -survey is a string which denotes which survey photometry.py will be using for calibration. Currently, there are 2 surveys supported: 2MASS and the VISTA Hemisphere Survey (VHS). VHS is a deeper survey and generally a better pick for photometry, but it is limited in area to targets in the southern hemisphere, so keep this in mind or you may get an error. 2MASS is all-sky, so it should be fine anywhere. To utilize 2MASS, put '2MASS', to utilize VISTA, put 'VHS'.

  • -crop in an integer which denotes how far in pixels from the edge of the stacked image the script should crop out sources. This is used to combat bad edge artifacts resulting in many false positive sources. The default is 300 pixels.

Optional Arguments

The previous were all required arguments, now we will discuss the optional arguments.

  • -exp_query is an optional flag that will make photometry.py export an .ecsv file of the survey query results. This file will contain that survey's information about any sources that were found, excluding the cropped edges. This can be useful when comparing PRIME's calculated magnitudes to 2MASS or VHS, beyond the scope of what the script already does.

  • -plots is an optional flag that will currently generate 2 plots. The first is a magnitude comparison plot. It plots the calculated PRIME mags and survey mags of crossmatched sources against eachother. This can be a good, quick, visual representation of how well the photometry is doing. For a more in depth look, the 2nd plot is a residuals plot. A linear fit is run on the crossmatched mag data and then residuals are calculated and plotted. The residual plot contains useful information, such as lines representing σ values, fitted slope & intercept values and error, along with R2 and RSS values.

  • -grb is an optional flag to be used when you're trying to find a specific source. With this flag, you input the RA and Dec of the GRB you wish to find, along with a search threshold diameter. photometry.py will search for a sextracted source within that area. If it finds one, it will print information about the source to the command line, along with generating an .ecsv file with the same information. This info includes the source's RA & Dec, calculated magnitude & error, 50% flux radius, and SNR. Below are the optional arguments that must be inputted when using this flag.

    • -RA: GRB RA
    • -DEC: GRB Dec
    • -thresh: Search diameter in arcsec, default = 4"

Now that all of that is out of the way, here is a sample command using all the arguments:

python ./photometry/photometry.py -plots -grb -dir /../../J_Band/stack/ -name coadd.Open-J.00654321-00123456.C1.fits -filter J -survey 2MASS -crop 400 -RA 221.248375 -DEC -60.697972 -thresh 2.0

How Photometry.py Works

  • To begin, photometry.py reads the WCS of the co-added final image, in order to find the RA and Dec at the center of the image, along with the width and height of the image in arcmin. (Though, due to the empty edges of the stacked images having no direct coordinate data, these width and height values can be inaccurate and rough, so currently we rely on the edge cropping of sources later on).
  • After getting the size and center of the image in sky coordinates, it then uses astroquery to remotely run a box query the chosen catalog for crossmatching and calibration.
  • Sextractor is then run on the co-added image in order to initially extract sources. Once this catalog is generated, PSFex is run on the catalog to create a PSF model for sources in the catalog. Then, this PSF model is run back through sextractor, performing model-fitting on sources and calculating PSF-fit magnitudes.
  • Once this final sextractor catalog is generated, both it and the previous survey query catalogue have sources on the edges cropped. The two catalogues are then crossmatched, with a crossmatch being defined as sources in both catalogues that are within 1" of eachother. photometry.py prints the amount of crossmatches to the command line.
    • If you included -exp_query, it is at this point that the survey query catalogue is saved.
  • Each crossmatched source then has their sextractor calculated mags subtracted from the catalog source mags. These offsets are used to calculate the zero point. This is done by calculating the median and standard deviation of the offset data, excluding sources > 3σ from the median.
  • For each source, the zero point is then added to the sextractor mags to generate the final filter mag. The error in this mag is calculated by combining the sextractor mag error and offset data stdev in quadrature. These mags are then written to columns and added as an addition to the sextractor columns, before being written to a new .ecsv file. (The VIGNET column is removed from the sextractor catalogue before this writing)
    • After this point, your photometry is done! If you've included -grb, then after this file is written, it is read back in and an attempt at a crossmatch is made using your inputted RA, Dec, and thresh. If it finds a source within these parameters, it will give source information and write it to an .ecsv file. If not, then it'll let you know.
    • If you included -plots, then it will also read in the final sextractor .ecsv and the cropped survey query in order to generate the mag comparison and residual plots.