Fake Source Injection with lcogtsnpipe

1) sourceingest.py


sourceingest.py takes images from photlco that have ' e91' in the filename and have a zeropoint, and create a new image with a fake source and a new filename labeled with 'e93' instead of 'e91'. The header of this new image will be the same as the e91, but with a new key, FAKEMAG, which will contain the magnitude of the source that was placed into the image. sourceingest.py will both ingest the image into photlcoraw and photlco. However, it will not reduce the photometry of this data, so that is still necessary to do with lscloop.py

Query Arguments:


-e, --epoch YYYYMMDD-YYYYMMDD
     This argument is necessary, and will specify the dayobs of the images or image you want. You can input both a range of dates, or just one date.
-n, --name OBJNAME
    This argument, while not necessary for the script to run, is very useful when specifying images. You will be able to choose the object name of the image or images you want to inject a fake source into. A typical objname would be SEATiDE001.
-f. --filename FILENAME
    This argument isn't very useful due to the use of the objname option. However, you can specify a specific filename to be used for the source injection and ingestion. Notice, all files to be used for this will need to have e91 in their name.

Fake Source Creation Arguments:
-m, --magnitude MAG 
    This argument has two options. The first would be to manually specify the magnitude of the source that you want to inject. The second would be to not use this argument, and have the program 50/50 having a source and not having one. If the option to have a source is chosen, the header key FAKEMAG will be blank. If the chance falls on having a source, the program will randomly choose a float between 14-20 and have that be the magnitude. This magnitude will be shown in FAKEMAG.
-F, --force
    This argument is a boolean. Upon executing the program with this option, the boolean will be set to true, and will force the program to perform the injection on all images. Without this option, the program will compare the FAKE MAG header key of a preexisiting images of the same name with the input magnitude to see if anytime can be saved.

Movement Arguments:
--RAS degrees
    This argument is not necessary and will be used to move the fake source to the specified right ascension. Using this or --DECS will change the filename to *e93.moved.fits. This is useful for creating a source over background noise. You can then use --RAS in the psfmag stage of lscloop to find the photometry.
--DECS degrees
   This argument is not necessary and will be used to move the fake source to the specified right ascension. Using this or --RAS will change the filename to *e93.moved.fits. This is useful for creating a source over background noise. You can then use --DECS in the psfmag stage of lscloop to find the photometry.




2) magcomparison

    This is a new table that I have created to store the data created from sourcesub.py.
CREATE TABLE magcomparison( id bigint(20) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
targetid bigint(20) NOT NULL, instrument text DEFAULT NULL, filepath text DEFAULT NULL,
filename varchar(100) DEFAULT NULL, temppath text DEFAULT NULL, tempname varchar(100) DEFAULT NULL,
tempdate text DEFAULT NULL, dayobs text DEFAULT NULL, objname text DEFAULT NULL,
inmag double DEFAULT 9999, diffmag double DEFAULT 9999, outlier boolean DEFAULT false);

3) sourcesub.py

   sourcesub.py first look query for images to put sources into. It will then loop through all images available and then search for any templates that have already been made for that image's specific SEATiDE object. If no object has been found, it will try to make a new template. If there are no images available to make into templates, it will skip the image. It will then create a fake source in the image and create the target image. The psf of the target image will be created and cosmic ray rejection will be run. The program will then subtract the target and the template images and do photometry on the subtracted image. The magnitude of the subtracted source will be stored in a column called diffmag in magcomparison, and the input magnitude will be stored in a column called inmag.

Query Arguments:

-e, -epoch  YYYYMMDD-YYYYMMDD
    This argument specifies the range of dates, date, or all dates(by not choosing one) of the images you want to use to create e93s.
-n, --name OBJNAME
    This argument specifies the object name of the images you want to make into e93s
--tempdate YYYYMMDD
    This argument allows you to specify a specific date for the template. Without the argument, the earliest template will be chosen.
--temptel TEMPTEL
    This argument allows you to specify the instrument of the template images. The default is fl.

Image Outcome Manipulation Arguments:

-m, --magnitude MAGLIST
    Enter any number of magnitudes to be used to create fake sources for the e93s. If option not chosen, items in np.arange(14, 20, 0.5) will be used for magnitudes.
-F, --force
    By default, the program will avoid processing on images where a row already exists for a specific filename and input magnitude. Selecting this argument will force the program to run on all specified images and magnitudes.
-o, --optimal
    By default, the program will run hotpants image subtraction. Selecting this argument will change the subtraction to use David's difference imaging program OptimalSub.py

PSF Editing Arguments:

    I suggest using these options after data has already been put into magcomparison, and should mostly be used to redo data if it is an outlier.
-r, --redo
    When selected, this will redo all the photometry on the target e91 images where the diffmag in magcomparison is defined as an outlier or is 9999.
-s, --show
When selected, this will show psf fitting in the psf stage of photometry. This will show on both template and target images. Make sure to have the same fwhm for the target e91 and e93.
-f, --fwhm
    This fwhm will be used to create the psf for the e93 image before subtraction. However, it will also be used on the e91 target image if --redo is selected. If --show is selected, make sure that the fwhm is the same for both, for the best results.
--tempfwhm
    This argument is used to specify the fwhm for the template images. If a template does exist, the psf stage will only be run once. If a template doesn't already exist, the psf stage will be run, then template stage, then the psf stage on the template image. If --show is selected, make sure that the tempfwhm is the same for both psf stages.