Skip to content

Commit

Permalink
Add visitInfo to exposures
Browse files Browse the repository at this point in the history
  • Loading branch information
mfisherlevine committed Mar 13, 2024
1 parent 6e30a75 commit 87ca43e
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion python/lsst/summit/utils/starTracker/starTracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@
from dataclasses import dataclass

import numpy as np
from astropy.io import fits
from PIL import Image

import lsst.afw.image as afwImage
import lsst.daf.base as dafBase
from lsst.afw.image import ExposureInfo, VisitInfo
from lsst.summit.utils.utils import dayObsIntToString

__all__ = (
Expand Down Expand Up @@ -144,7 +147,27 @@ def fitsToExp(filename):
exp : `lsst.afw.image.Exposure`
The exposure.
"""
exp = afwImage.ExposureF(filename)
with fits.open(filename) as f:
header = f[0].header
data = f[1].data

data = np.asarray(data, dtype=np.float32)
img = afwImage.ImageF(data)
maskedIm = afwImage.MaskedImageF(img)

viDict = {}
viDict["exposureTime"] = header.get("EXPTIME")

# set the midpoint of BEG and END as the DATE
begin = datetime.datetime.fromisoformat(header.get("DATE-BEG"))
end = datetime.datetime.fromisoformat(header.get("DATE-END"))
mid = begin + (end - begin) / 2
newTime = dafBase.DateTime(mid.isoformat(), dafBase.DateTime.Timescale.TAI)
viDict["date"] = newTime

vi = VisitInfo(**viDict)
expInfo = ExposureInfo(visitInfo=vi)
exp = afwImage.ExposureF(maskedIm, exposureInfo=expInfo)
return exp


Expand Down

0 comments on commit 87ca43e

Please sign in to comment.