Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/85.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add ePSF functionality.
23 changes: 15 additions & 8 deletions phrosty/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class PipelineImage:

"""Holds a snappl.image.Image, with some other stuff the pipeline needs."""

def __init__( self, imagepath, pointing, sca ):
def __init__( self, imagepath, pointing, sca, pipeline ):
"""Create a PipelineImage

Parameters:
Expand Down Expand Up @@ -68,6 +68,7 @@ def __init__( self, imagepath, pointing, sca ):
"We hope this will change soon." )

self.pointing = pointing
self.band = pipeline.band

# Intermediate files
if self.keep_intermediate:
Expand Down Expand Up @@ -113,8 +114,11 @@ def run_sky_subtract( self, mp=True ):
imname = imname[:-3]
if imname[-5:] != '.fits':
imname = f'{imname}.fits'
if mp:
SNLogger.multiprocessing_replace()
# Hey Rob--the below is broken. The pipeline runs with mp if I use the
# example science image file from examples/perlmutter, but not if I use
# my own file. If I run with one process, my own file runs.
# if mp:
# SNLogger.multiprocessing_replace()
SNLogger.debug( f"run_sky_subtract on {imname}" )

self.skysub_path = self.save_dir / f"skysub_{imname}"
Expand Down Expand Up @@ -148,12 +152,14 @@ def get_psf( self, ra, dec ):
# the psf... and it's different for each type of
# PSF. We need to fix that... somehow....

wcs = self.image.get_wcs()
x, y = wcs.world_to_pixel( ra, dec )

if self.psfobj is None:
psftype = self.config.value( 'photometry.phrosty.psf.type' )
self.psfobj = PSF.get_psf_object( psftype, pointing=self.pointing, sca=self.image.sca )
self.psfobj = PSF.get_psf_object( psftype, band=self.band, pointing=self.pointing, sca=self.image.sca,
x=x, y=y )

wcs = self.image.get_wcs()
x, y = wcs.world_to_pixel( ra, dec )
stamp = self.psfobj.get_stamp( x, y )
if self.keep_intermediate:
outfile = self.save_dir / f"psf_{self.image.name}.fits"
Expand Down Expand Up @@ -208,9 +214,9 @@ def __init__( self, object_id, ra, dec, band, science_images, template_images, n
self.ra = ra
self.dec = dec
self.band = band
self.science_images = ( [ PipelineImage( self.image_base_dir / ppsmb[0], ppsmb[1], ppsmb[2] )
self.science_images = ( [ PipelineImage( self.image_base_dir / ppsmb[0], ppsmb[1], ppsmb[2], self )
for ppsmb in science_images if ppsmb[4] == self.band ] )
self.template_images = ( [ PipelineImage( self.image_base_dir / ppsmb[0], ppsmb[1], ppsmb[2] )
self.template_images = ( [ PipelineImage( self.image_base_dir / ppsmb[0], ppsmb[1], ppsmb[2], self )
for ppsmb in template_images if ppsmb[4] == self.band ] )
self.nprocs = nprocs
self.nwrite = nwrite
Expand Down Expand Up @@ -295,6 +301,7 @@ def align_and_pre_convolve(self, templ_image, sci_image ):
hdr_sci, hdr_templ,
sci_image.skyrms, templ_image.skyrms,
data_sci, data_templ,
cp.zeros((4088, 4088)), cp.zeros((4088, 4088)), # Replace with variance
sci_detmask, templ_detmask,
sci_psf, templ_psf
)
Expand Down