Skip to content

Commit

Permalink
Added iris.sg.SpectrographObservation.timedelta field which stores …
Browse files Browse the repository at this point in the history
…the exposure time of each frame.
  • Loading branch information
byrdie committed Nov 5, 2024
1 parent c1fc2f0 commit b62f60e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion iris/sg/_spectrograph.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ class SpectrographObservation(
ax[1].set_ylim(wavelength_min, wavelength_max)
"""

timedelta: u.Quantity | na.AbstractScalar = 0 * u.s
"""
The exposure time for each frame in the observation.
"""

wavelength_center: None | u.Quantity | na.AbstractScalar = None
"""
TThe rest wavelength of the dominant spectral line in the observation.
Expand Down Expand Up @@ -270,8 +275,13 @@ def from_fits(

hdul = astropy.io.fits.open(file)
hdu = hdul[index_window]
hdu_aux = hdul[~1]

wcs = astropy.wcs.WCS(hdu).wcs
detector_type = hdul[0].header[f"TDET{index_window}"]

key_timedelta = "EXPTIMEF" if "FUV" in detector_type else "EXPTIMEN"
timedelta = hdu_aux.data[..., hdu_aux.header[key_timedelta]] << u.s
self.timedelta[index] = na.ScalarArray(timedelta, axis_detector_x)

self.outputs[index] = na.ScalarArray(
ndarray=hdu.data << u.DN,
Expand All @@ -281,6 +291,8 @@ def from_fits(
time = astropy.time.Time(hdul[0].header["DATE_OBS"]).jd
self.inputs.time[index] = time

wcs = astropy.wcs.WCS(hdu).wcs

crval = self.inputs.crval
crval.wavelength[index] = wcs.crval[~iw] << u.m
crval.position.x[index] = wcs.crval[~ix] << u.deg
Expand Down Expand Up @@ -405,11 +417,15 @@ def empty(
shape = na.broadcast_shapes(shape_base, shape_wcs)
outputs = na.ScalarArray.empty(shape) << u.DN

shape_timedelta = shape_base | {axis_wavelength: shape_wcs[axis_wavelength]}
timedelta = na.ScalarArray.empty(shape_timedelta) * u.s

wavelength_center = na.ScalarArray.empty(shape_base) << u.AA

return cls(
inputs=inputs,
outputs=outputs,
timedelta=timedelta,
wavelength_center=wavelength_center,
axis_time=axis_time,
axis_wavelength=axis_wavelength,
Expand Down

0 comments on commit b62f60e

Please sign in to comment.