Skip to content

Commit

Permalink
changed dlab to datalab
Browse files Browse the repository at this point in the history
  • Loading branch information
LTDakin committed Oct 11, 2024
1 parent bd4ff43 commit 7d0416a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions datalab/datalab_session/data_operations/fits_output_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class FITSOutputHandler():
The FITS file is then saved to the cache and the large and small jpgs are created.
Attributes:
dlab_id (str): The cache key for the FITS file.
datalab_id (str): The cache key for the FITS file.
primary_hdu (fits.PrimaryHDU): The primary HDU for the FITS file.
image_hdu (fits.ImageHDU): The image HDU for the FITS file.
data (np.array): The data for the image HDU.
Expand All @@ -28,13 +28,13 @@ def __init__(self, cache_key: str, data: np.array, comment: str=None) -> None:
data (np.array): The data that will create the image HDU.
comment (str): Optionally add a comment to add to the FITS file.
"""
self.dlab_id = cache_key
self.datalab_id = cache_key
self.primary_hdu = fits.PrimaryHDU(header=fits.Header([('KEY', cache_key)]))
self.image_hdu = fits.ImageHDU(data=data, name='SCI')
if comment: self.set_comment(comment)

def __str__(self) -> str:
return f"Key: {self.dlab_id}\nData:\n{self.data}"
return f"Key: {self.datalab_id}\nData:\n{self.data}"

def set_comment(self, comment: str):
"""Add a comment to the FITS file."""
Expand All @@ -52,11 +52,11 @@ def create_and_save_data_products(self, index: int=None, large_jpg_path: str=Non
small_jpg (str): Optionally add a path to a small jpg to save, will not create a new jpg.
"""
hdu_list = fits.HDUList([self.primary_hdu, self.image_hdu])
fits_output_path = tempfile.NamedTemporaryFile(suffix=f'{self.dlab_id}.fits').name
fits_output_path = tempfile.NamedTemporaryFile(suffix=f'{self.datalab_id}.fits').name
hdu_list.writeto(fits_output_path, overwrite=True)

# allow for operations to pregenerate the jpgs, ex. RGB stacking
if not large_jpg_path or not small_jpg_path:
large_jpg_path, small_jpg_path = create_jpgs(self.dlab_id, fits_output_path)
large_jpg_path, small_jpg_path = create_jpgs(self.datalab_id, fits_output_path)

return save_fits_and_thumbnails(self.dlab_id, fits_output_path, large_jpg_path, small_jpg_path, index)
return save_fits_and_thumbnails(self.datalab_id, fits_output_path, large_jpg_path, small_jpg_path, index)

0 comments on commit 7d0416a

Please sign in to comment.