Skip to content

Commit bf2b393

Browse files
authored
Merge pull request #124 from Roman-Supernova-PIT/121-aligned-images-get-overwritten-if-the-same-template-is-used
Fixed file names for all intermediate files so there is no overwriting.
2 parents 00c2b97 + aaa7c68 commit bf2b393

File tree

2 files changed

+12
-26
lines changed

2 files changed

+12
-26
lines changed

changes/124.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed file names for all saved intermediate files so there is no overwriting.

phrosty/pipeline.py

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -714,62 +714,47 @@ def log_fits_write_error( savepath, x ):
714714
if self.keep_intermediate:
715715
# Each key is the file prefix addition.
716716
# Each list has [descriptive filetype, image file name, data, header].
717-
# The 'convolved' images have that [:-8] in their image file name and combined
718-
# names because LNA thinks it's important that we keep track of which images
719-
# have been convolved with which. Because also then if you use the same template
720-
# image more than once, it gets overwritten.
721717

722-
# TODO: Include variance images. Include multiprocessing.
718+
# TODO: Include multiprocessing.
723719
# In the future, we may want to write these things right after they happen
724720
# instead of saving it all for the end of the SFFT stuff.
725721

726-
# HACK ALERT : we're stripping the .gz off of the end of filenames
727-
# if they have them, and making sure filenames end in .fits,
728-
# because that's what SFFT needs. This can go away if we
729-
# refactor.
730-
if sci_image.image.name[-3:] == '.gz':
731-
conv_sci_name = str( pathlib.Path( sci_image.image.name ).stem )
732-
if sci_image.image.name[-5:] != '.fits':
733-
conv_sci_name = f'{sci_image.image.name}.fits'
734-
735-
if templ_image.image.name[-3:] == '.gz':
736-
conv_templ_name = str( pathlib.Path( templ_image.image.name ).stem )
737-
if templ_image.image.name[-5:] != '.fits':
738-
conv_templ_name = f'{templ_image.image.name}.fits'
722+
sci_filepathpart = f'{sci_image.band}_{sci_image.pointing}_{sci_image.image.sca}'
723+
templ_filepathpart = f'{templ_image.band}_{templ_image.pointing}_{templ_image.image.sca}'
739724

740725
write_filepaths = {'aligned': [['img',
741-
templ_image.image.name,
726+
f'{templ_filepathpart}_-_{sci_filepathpart}.fits',
742727
cp.asnumpy(sfftifier.PixA_resamp_object_GPU.T),
743728
sfftifier.hdr_target],
744729
['var',
745-
templ_image.image.name,
730+
f'{templ_filepathpart}_-_{sci_filepathpart}.fits',
746731
cp.asnumpy(sfftifier.PixA_resamp_objectVar_GPU.T),
747732
sfftifier.hdr_target],
748733
['psf',
749-
templ_image.image.name,
734+
f'{templ_filepathpart}_-_{sci_filepathpart}.fits',
750735
cp.asnumpy(sfftifier.PSF_resamp_object_GPU.T),
751736
sfftifier.hdr_target],
752737
['detmask',
753-
sci_image.image.name,
738+
f'{sci_filepathpart}_-_{templ_filepathpart}.fits',
754739
cp.asnumpy(sfftifier.PixA_resamp_object_DMASK_GPU.T),
755740
sfftifier.hdr_target]
756741
],
757742
'convolved': [['img',
758-
f'{conv_sci_name[:-5]}_{conv_templ_name}',
743+
f'{sci_filepathpart}_-_{templ_filepathpart}.fits',
759744
cp.asnumpy(sfftifier.PixA_Ctarget_GPU.T),
760745
sfftifier.hdr_target],
761746
['img',
762-
f'{conv_templ_name[:-5]}_{conv_sci_name}',
747+
f'{templ_filepathpart}_-_{sci_filepathpart}.fits',
763748
cp.asnumpy(sfftifier.PixA_Cresamp_object_GPU.T),
764749
sfftifier.hdr_target]
765750
],
766751
'diff': [['img',
767-
f'{conv_sci_name[:-5]}_{conv_templ_name}',
752+
f'{sci_filepathpart}_-_{templ_filepathpart}.fits',
768753
cp.asnumpy(sfftifier.PixA_DIFF_GPU.T),
769754
sfftifier.hdr_target]
770755
],
771756
'decorr': [['kernel',
772-
sci_image.image.name,
757+
f'{sci_filepathpart}_-_{templ_filepathpart}.fits',
773758
cp.asnumpy(sfftifier.FKDECO_GPU.T),
774759
sfftifier.hdr_target]
775760
]

0 commit comments

Comments
 (0)