Commit e5a99a1c authored by BO ZHANG's avatar BO ZHANG 🏀
Browse files

add prepare_fits_files_for_ingestion()

parent 36ed8333
Pipeline #10961 failed with stage
in 0 seconds
......@@ -9,6 +9,8 @@ Modified-History:
"""
import io
import os.path
from astropy.io.fits import *
from astropy.io import fits as astropy_fits
from csst_fs.s3_config import load_s3_options
......@@ -71,3 +73,18 @@ class HDUList(astropy_fits.HDUList):
self.writeto(memory_buffer)
fits_bytes = memory_buffer.getvalue()
return fits_bytes
def prepare_fits_files_for_ingestion(files: list[str]) -> list[dict]:
"""Prepare FITS files for ingestion."""
ingestion_files = []
for file in files:
with open(file) as hl:
fits_bytes = hl.to_bytes()
ingestion_files.append(
{
"file_name": os.path.basename(file),
"file_content": fits_bytes,
}
)
return ingestion_files
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment