Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added iris.sg.SpectrographObservation.timedelta field which stores the exposure time for each frame of the observation. #20

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_detector_x: shape_wcs[axis_detector_x]}
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
Loading