Skip to content

Commit 4edacdd

Browse files
committed
lots of comments
1 parent 7ceca2f commit 4edacdd

File tree

3 files changed

+63
-3
lines changed

3 files changed

+63
-3
lines changed

phrosty/pipeline.py

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def _read_csv( self, csvfile ):
243243
if not re.search( r"^\s*path\s+pointing\s+sca\s+mjd\s+band\s*$", hdrline ):
244244
raise ValueError( f"First line of list file {csvfile} didn't match what was expected." )
245245
for line in ifp:
246-
path, pointing, sca, mjd, band = line.split()
246+
path, pointing, sca, _mjd, band = line.split()
247247
if band == self.band:
248248
# This should yell at us if the pointing or sca doesn't match what is read from the path
249249
imlist.append( self.imgcol.get_image( path=path, pointing=pointing, sca=sca, band=band ) )
@@ -649,6 +649,11 @@ def __call__( self, through_step=None ):
649649
steps = steps[:stepdex+1]
650650

651651
if 'sky_subtract' in steps:
652+
# After this step is done, all images (both science and template)
653+
# will have the following fields set:
654+
# .skysub_img : sub-subtracted image
655+
# .detmask_img : deteciton mask image
656+
# .skyrms : float, median of sky image calculated by SExtractor
652657
SNLogger.info( "Running sky subtraction" )
653658
with nvtx.annotate( "skysub", color=0xff8888 ):
654659
self.sky_sub_all_images()
@@ -657,6 +662,9 @@ def __call__( self, through_step=None ):
657662
SNLogger.info( f"After sky_subtract, memory usage = {tracemalloc.get_traced_memory()[1]/(1024**2):.2f} MB" )
658663

659664
if 'get_psfs' in steps:
665+
# After this step, all images (both science and template) will
666+
# have the .psf_data field set with the image-resolution PSF stamp data
667+
# (from a PSF.get_stamp() call.)
660668
SNLogger.info( "Getting PSFs" )
661669
with nvtx.annotate( "getpsfs", color=0xff8888 ):
662670
self.get_psfs()
@@ -679,16 +687,63 @@ def log_fits_write_error( savepath, x ):
679687
sfftifier = None
680688

681689
if 'align_and_preconvolve' in steps:
690+
# After this step, sfftifier will be a SpaceSFFT_CupyFlow
691+
# object with the following fields filled. All cupy arrays
692+
# are float64 (even the DMASK!), and all of them are Transposed
693+
# from what's stored in the PipelineImage object
694+
# hdr_target : FITS header of science image
695+
# hdr_object : FITS header of template image
696+
# target_skyrms : float, median of sky for science image
697+
# object_skyrms : float, median of sky for template image
698+
# PixA_target_GPU : science image data on GPU
699+
# PixA_Ctarget_GPU : cross-convolved [with what?] science image on GPU
700+
# PixA_object_GPU : template image data on GPU
701+
# PixA_resamp_object_GPU : warped template image data on GPU
702+
# PixA_Cresampl_object_GPU : cross-convolved template image on GPU
703+
# BlankMask_GPU : boolean array, True where PixA_resampl_object_GPU is 0.
704+
# PixA_targetVar_GPU : noise CHECK THIS image for science image, on GPU
705+
# PixA_objectVar_GPU : noise CHECK THIS image for template image, on GPU
706+
# PiXA_resampl_objectVar_GPU : warped template variance data on GPU
707+
# PixA_target_DMASK_GPU : detmask for science image, on GPU
708+
# PixA_object_DMASK_GPU : detmask for template image, on GPU
709+
# PixA_resampl_object_DMASK_GPU : warped dmask for template image, on GPU
710+
# PSF_target_GPU : PSF stamp for science image
711+
# PSF_object_GPU : PSF stamp for template image
712+
# PSF_resampl_object_GPU : PSF stamp for template image rotated & resampled, on GPU
713+
# sci_is_target : True
714+
# GKerHW : 9 (int half-width of matching kernel, full width is 2*GKerHW+1)
715+
# KerPolyOrder : config value of photometry.phrosty.kerpolyorder
716+
# BGPolyOrder : 0
717+
# ConstPhotRatio : True
718+
# CUDA_DEVICE_4SUBTRACT : '0'
719+
# GAIN : 1.0
720+
# RANDOM_SEED : 10086
682721
SNLogger.info( "...align_and_preconvolve" )
683722
with nvtx.annotate( "align_and_pre_convolve", color=0x8888ff ):
684723
sfftifier = self.align_and_pre_convolve( templ_image, sci_image )
685724

686725
if 'subtract' in steps:
726+
# After this step is done, two more fields in sfftifier are set:
727+
# Solution_GPU : --something--??
728+
# PixA_DIFF_GPU : difference image ??
729+
# Get Lei to write docs on PureCupy_Customized_Packet.PCCP so
730+
# we can figure out what these are
687731
SNLogger.info( "...subtract" )
688732
with nvtx.annotate( "subtraction", color=0x44ccff ):
689733
sfftifier.sfft_subtraction()
690734

691735
if 'find_decorrelation' in steps:
736+
# This step does ...
737+
# After it's done, the following fields of sfftifier are set:
738+
# Solution : CPU copy of Solution_GPU
739+
# FKDECO_GPU : result of PureCupy_Decorrelation_Calculator.PCDC
740+
# Get Lei to write documentation on P:ureCupy_DeCorrelation_Calculator
741+
# so we can figure out what this is, but I THINK it's a
742+
# kernel that is used to convolve with things to "decorrelate".
743+
# (From what?)
744+
# In addition the two local varaibles diff_var and diff_var_path are set.
745+
# diff_var : variance in difference image (I THINK), on GPU
746+
# diff_var_path : where we want to write diff_var in self.dia_out_dir
692747
SNLogger.info( "...find_decorrelation" )
693748
with nvtx.annotate( "find_decor", color=0xcc44ff ):
694749
sfftifier.find_decorrelation()
@@ -700,6 +755,11 @@ def log_fits_write_error( savepath, x ):
700755
diff_var_path = self.dia_out_dir / f"diff_var_{mess}"
701756

702757
if 'apply_decorrelation' in steps:
758+
# After this step is done, the following FITS files will be written in self.dia_out_dir:
759+
# decorr_diff_* : difference image convolved with FKDECO_GPU
760+
# diff_var_* : variance of difference image convolved with FKDECO_GPU
761+
# decorr_zpt_path_* : preconvolved science image (PixA_Ctarget_GPU) convolved with FKDECO_GPU
762+
# decor_psf_path_* : PSF stamp for science image, convolved with FKDECO_GPU
703763
mess = f"{sci_image.image.name}-{templ_image.image.name}"
704764
decorr_psf_path = self.dia_out_dir / f"decorr_psf_{mess}"
705765
decorr_zptimg_path = self.dia_out_dir / f"decorr_zptimg_{mess}"

phrosty/tests/test_imagesubtraction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_sky_subtract( dia_out_dir ):
2626
fits.writeto( in_path, imdata, header=hdr )
2727
img = FITSImageOnDisk( path=in_path )
2828

29-
subim, detmask, skymedrms = phrosty.imagesubtraction.sky_subtract( img, temp_dir=dia_out_dir )
29+
subim, _detmask, skymedrms = phrosty.imagesubtraction.sky_subtract( img, temp_dir=dia_out_dir )
3030
assert skymedrms == pytest.approx( 10., abs=0.2 )
3131
assert subim.data.mean() == pytest.approx( 0., abs=5 * 10. / 512. ) # 3σ
3232
assert subim.data.std() == pytest.approx( 10., rel=0.05 )

phrosty/tests/test_pipeline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def test_pipeline_run_simple_gauss1( config ):
2525
imgcol = ImageCollection.get_collection( 'manual_fits', subset='threefile',
2626
base_path='/photometry_test_data/simple_gaussian_test/sig2.0' )
2727
tmplim = [ imgcol.get_image(path=f'test_{t:7.1f}') for t in [ 60000., 60005. ] ]
28-
sciim = [ imgcol.get_image(path=f'test_{t:7.1f}') for t in range( 60000, 60065, 5 ) ]
28+
sciim = [ imgcol.get_image(path=f'test_{t:7.1f}') for t in range( 60010, 60065, 5 ) ]
2929

3030
# We have to muck about with the config, because the default config loaded for tests is
3131
# set up for ou2024. We're going to do naughty things we're not supposed to do,

0 commit comments

Comments
 (0)