#!/usr/bin/env python # coding: utf-8 # # ## DOLPHOT_LC # # Dolphot-LC is an automated Hubble Space Telescope (HST) data pipeline based on the popular Dolphot analysis package. This package allows for the creation of lightcurves and difference images from HST data. # # This Jupyter Notebook allows the user to run their own fits images through the pipeline and generate results. Requires a coadded template image and science images that are already aligned to template. # **Before running this notebook, ensure the following steps are done.** # # Follow the dolphot_lc installation steps listed here - https://dolphot-lc.readthedocs.io/en/latest/install.html # # Activate your python=3.7, dolphot astroconda environment. # # conda activate /env name/ # # To use install this conda environment in Jupyter Notebook, run the command: # # python -m ipykernel install --user --name=/env name/ # # Now change the kernel version of this notebook to your conda environment. # In[ ]: import dolphot_lc as dlc import time import os start = time.time() sexpath = 'source-extractor' # **List working directories and add your fits files to the correct locations.** # # Use the example folder as the base directory. Within this directory create the folders "Images", "image_backup", and "ref". Within image_backup folder create the folders "ims", "ref", and "template". Within Images folder create the folders "ims" and "template". # # Place fits image files in /example/Images/, /example/Images/ims/, and /example/image_backup/ims/. # # Make sure your coadded image is named "coadd_CLASH_sci.fits". Place this file in /example/ref/, and /example/image_backup/ref/. # # Make sure your coadded image is named "coadd_tweak_F110W_sci.fits". Place this file in /example/Images/, /example/Images/template, and /example/image_backup/template/. # # *Note that the same file is used as the template and registration image.* # In[ ]: imroot = os.getcwd() # example folder / base directory orig_im_loc = f'{imroot}/image_backup/ims' # image orig_temp_loc = f'{imroot}/image_backup/template' # template im_loc = f'{imroot}/Images' # path to working directory ref_image = f'{imroot}/ref/coadd_CLASH_sci.fits' # registration image dolphot_path = '/Users/rwhite/dolphot_lc/example/dolphot2.0/bin' # **List the RA and DEC coordinates of the object in sexigesimal and degree units:** # In[ ]: sn_ra_me, sn_dec_me = '13:47:31.8180', '-11:45:51.914' objCoords = {'S1': [206.8833, -11.7644], 'S2': [206.8833, -11.7644], 'S3': [206.8833, -11.7644], 'S4': [206.8833, -11.7644], 'SX': [206.8833, -11.7644] } # **Input dolphot parameters:** # # *For help with this step, identify the HST instrument used to aquire your images and visit DOLPHOT user's guide for recommended settings. http://americano.dolphinsim.com/dolphot/dolphotWFC3.pdf* # In[ ]: dolphot_params = { 'UseWCS': 1, 'raper': 5, 'rchi': 1.5, 'rsky0': 8, 'rsky1': 3, 'rpsf': 15, 'WFC3IRpsfType': 1, # wide field camera 3 IR } # **Run dolphot process,** nothing to change here. # In[ ]: a = dlc.prep_directory(orig_im_loc, orig_temp_loc, im_loc, ref_image, dolphot_path, imroot, sn_ra_me, sn_dec_me, sexpath, dolphot_params) dlc.prep_files_for_dolphot('/dolphot_prepped', r_in=15, r_out=35, step=4, sig_low=2.25, sig_high=2.00, dlc_param=a) #Processes images through masking/spliting/calcsky programs in Dolphot dlc.dolphot_simultaneous(a) #Creates Dolphot parameter file & runs on processed images dlc.blot_back(r_in=15, #Inner radius of sky annulus r_out=35, #Outer radius of sky annulus step=4, #How often is the sky value is sampled in pixels sig_low=2.25, #Low sigma under which samples will be rejected sig_high=2.00, #High sigma above which samples will be rejected dlc_param=a) #Parameter object from prep_directory function #Blots coadded template image to distorted science images & creates difference image # In[ ]: dlc.dolphot_force(apermag=False, force_same_mag=True, psfphot=1, objCoords=objCoords, dlc_param=a) #Runs Dolphot on difference images end = time.time() a = (end - start)/60 m = 0 while a > 1: a = a - 1 m = m + 1 print(f'Time: {m}:{str(int(60*a)).zfill(2)}') # Aftering running DOLPHOT forced photometry, the results are placed in the /example/diffs/ folder to be analyzed. # # Analyze the Results # # Refer to the analyze_data.py file in order to garner results. Add the following code to this file. # # Declare the type of object to be analyzed and pixel coordinates of the object. # # objs = [['SN', 567.9625526342381, 176.49369319498047]] # # Finally, run: # # imroot = os.getcwd() # example folder / base directory # imdir_prepped = f'{imroot}/diffs/' # a = dolphot_output( imdir_prepped + 'singlestar') # for objname,x,y in objs: # a.info_single_object(x, y, objname, 'orig', settings=False, verbose=False)