From ea3aada73792b2e56394b5d9f5fc57e2511dee39 Mon Sep 17 00:00:00 2001
From: Eric Koch <koch.eric.w@gmail.com>
Date: Thu, 15 Aug 2024 15:05:02 -0400
Subject: [PATCH] Add extension names for the stamp fits files

---
 fil_finder/filament.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/fil_finder/filament.py b/fil_finder/filament.py
index 057a5eb..2dd358e 100644
--- a/fil_finder/filament.py
+++ b/fil_finder/filament.py
@@ -1535,6 +1535,7 @@ def save_fits(self, savename, image, pad_size=20 * u.pix, header=None,
             input_image = input_image.value.copy()
 
         hdu = fits.PrimaryHDU(input_image, header)
+        hdu.name = 'IMAGE'
 
         skel_hdr = header.copy()
         skel_hdr['BUNIT'] = ("", "bool")
@@ -1542,13 +1543,18 @@ def save_fits(self, savename, image, pad_size=20 * u.pix, header=None,
             time.strftime("%c")
 
         skel_hdu = fits.ImageHDU(skels.astype(int), skel_hdr)
+        skel_hdu.name = 'SKELETON'
 
         skel_lp_hdu = fits.ImageHDU(skels_lp.astype(int), skel_hdr)
+        skel_lp_hdu.name = 'SKELETON_LONGPATH'
 
         model_hdu = fits.ImageHDU(model, header)
+        model_hdu.name = 'MODEL'
 
-        hdulist = fits.HDUList([hdu, skel_hdu, skel_lp_hdu, model_hdu])
-        hdulist.append(fits.table_to_hdu(tab))
+        tab_hdu = fits.table_to_hdu(tab)
+        tab_hdu.name = 'PIXEXTENTS'
+
+        hdulist = fits.HDUList([hdu, skel_hdu, skel_lp_hdu, model_hdu, tab_hdu])
 
         hdulist.writeto(savename, **kwargs)