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

DM-43175: Fix translation problem with negative exposure time and no DATE-END #514

Merged
merged 4 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions python/lsst/obs/lsst/translators/latiss.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ def fix_header(cls, header, instrument, obsid, filename=None):
modified = True

if date < TARGET_STARTS_SPECCOLON:
if "OBJECT" in header:
header["OBJECT"] = header['OBJECT'].replace('spec:', '')
if (obj := header.get("OBJECT", None)) is not None:
header["OBJECT"] = obj.replace('spec:', '')
modified = True

if "RADESYS" in header:
Expand Down
11 changes: 9 additions & 2 deletions python/lsst/obs/lsst/translators/lsst.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ def to_location(self):
try:
# Try standard FITS headers
return super().to_location()
except KeyError:
except (KeyError, TypeError):
return self._DEFAULT_LOCATION

@cache_translation
Expand All @@ -537,7 +537,14 @@ def to_datetime_end(self):
if self.is_key_ok("DATE-END"):
return super().to_datetime_end()

return self.to_datetime_begin() + self.to_exposure_time()
exposure_time = self.to_exposure_time()
if exposure_time.value < 0.0:
# Some translators deliberately return -1.0s if the exposure
# time can not be determined. In that scenario set end time
# to the same value as the start time.
return self.to_datetime_begin()

return self.to_datetime_begin() + exposure_time

@cache_translation
def to_detector_num(self):
Expand Down
237 changes: 237 additions & 0 deletions tests/headers/latiss-AT_C_20220426_000004_R00_S00.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
SIMPLE: true
EXTEND: true
DATE: '2022-04-26T23:35:47.129'
MJD: 59695.98318436323
CCD_MANU: ITL
CCD_TYPE: 3800C
IMGTYPE: UNKNOWN
TEMP_SET: -94.15
FILENAME: null
BINX: 1
BINY: 1
CCDGAIN: 1.0
CCDNOISE: 10.0
DATE-OBS: '2022-04-26T23:36:20.879'
MJD-OBS: 59695.98357498832
DATE-TRG: '2022-04-26T23:35:47.105'
MJD-TRG: 59695.98318408569
IMAGETAG: 6e235fd6a0d1936d
CCDSLOT: S00
RAFTBAY: R00
FIRMWARE: '11384004'
PLATFORM: auxtel
CONTNUM: 189216ee
DAQVERS: R5-V0.6 2021-10-06T19:50:32Z (1800122)
DAQPART: lat
DAQFOLD: raw
OBSANNOT: ''
OBSID: AT_C_20220426_000004
CAMCODE: AT
CONTRLLR: C
DAYOBS: '20220426'
SEQNUM: 4
HEADVER: 2
INSTRUME: LATISS
TELESCOP: LSST AuxTelescope
TSTAND: null
SEQFILE: FP_ITL_2s_ir2_v25.seq
SEQCKSUM: '2552520002'
LSST_NUM: ITL-3800C-068
CCD_SERN: '20862'
REBNAME: Unknown
RAFTNAME: AuxTel-Raft
DARKTIME: 537.406
FPVERS: 1.1.2-SNAPSHOT
IHVERS: 1.0.29-SNAPSHOT
OBS-LONG: null
OBS-LAT: null
OBS-ELEV: null
OBSGEO-X: null
OBSGEO-Y: null
OBSGEO-Z: null
RA: null
DEC: null
RASTART: null
DECSTART: null
RAEND: null
DECEND: null
ROTPA: null
ROTCOORD: null
HASTART: null
ELSTART: null
AZSTART: null
AMSTART: null
HAEND: null
ELEND: null
AZEND: null
AMEND: null
TRACKSYS: null
RADESYS: null
FOCUSZ: null
OBJECT: null
SIMULATE ATMCS: null
SIMULATE ATHEXAPOD: null
SIMULATE ATPNEUMATICS: null
SIMULATE ATDOME: null
SIMULATE ATSPECTROGRAPH: null
GROUPID: null
BUNIT: null
INSTPORT: null
ATM3PORT: null
DOMEAZ: null
SHUTLOWR: null
SHUTUPPR: null
WCSAXES: null
CTYPE1: null
CTYPE2: null
CUNIT1: null
CUNIT2: null
CRVAL1: null
CRVAL2: null
CRPIX1: null
CRPIX2: null
CD1_1: null
CD1_2: null
CD2_1: null
CD2_2: null
EQUINOX: null
GRATING: null
GRATBAND: null
GRATSLOT: null
AIRTEMP: null
PRESSURE: null
HUMIDITY: null
WINDSPD: null
WINDDIR: null
SEEING: null
LINSPOS: null
TIMESYS: TAI
CURINDEX: null
MAXINDEX: null
PROGRAM: null
REASON: null
FILTBAND: null
FILTER: null
FILTPOS: null
FILTSLOT: null
SHUTTIME: null
DATE-BEG: null
DATE-END: null
MJD-BEG: null
MJD-END: null
FACILITY: Vera C. Rubin Observatory
CCDTEMP: -90.4816
XTENSION: IMAGE
BITPIX: 32
NAXIS: 2
NAXIS1: 576
NAXIS2: 2048
PCOUNT: 0
GCOUNT: 1
CHECKSUM: YdjHZZi9YbiEYZi9
CHANNEL: 1
EXTNAME: Segment10
CCDSUM: 1 1
DATASEC: '[4:512,1:2000]'
DETSEC: '[509:1,1:2000]'
DETSIZE: '[1:4072,1:4000]'
DTV1: 513
DTV2: 0
DTM1_1: -1.0
DTM2_2: 1.0
DTM1_2: 0.0
DTM2_1: 0.0
WCSNAMEA: AMPLIFIER
CTYPE1A: Seg_X
CTYPE2A: Seg_Y
PC1_1A: 0.0
PC1_2A: -1.0
PC2_1A: -1.0
PC2_2A: 0.0
CDELT1A: 1.0
CDELT2A: 1.0
CRPIX1A: 0.0
CRPIX2A: 0.0
CRVAL1A: 2001.0
CRVAL2A: 513.0
WCSNAMEC: CCD
CTYPE1C: CCD_X
CTYPE2C: CCD_Y
PC1_1C: 0.0
PC1_2C: -1.0
PC2_1C: -1.0
PC2_2C: 0.0
CDELT1C: 1.0
CDELT2C: 1.0
CRPIX1C: 0.0
CRPIX2C: 0.0
CRVAL1C: 4001.0
CRVAL2C: 513.0
WCSNAMER: RAFT
CTYPE1R: RAFT_X
CTYPE2R: RAFT_Y
PC1_1R: 0.0
PC1_2R: -1.0
PC2_1R: -1.0
PC2_2R: 0.0
CDELT1R: 1.0
CDELT2R: 1.0
CRPIX1R: 0.0
CRPIX2R: 0.0
CRVAL1R: 4126.0
CRVAL2R: 602.0
WCSNAMEF: FOCAL_PLANE
CTYPE1F: FP_X
CTYPE2F: FP_Y
PC1_1F: 0.0
PC1_2F: -1.0
PC2_1F: -1.0
PC2_2F: 0.0
CDELT1F: 1.0
CDELT2F: 1.0
CRPIX1F: 0.0
CRPIX2F: 0.0
CRVAL1F: 16826.0
CRVAL2F: 602.0
WCSNAMEE: FP_SERPAR
CTYPE1E: FP_S
CTYPE2E: FP_P
PC1_1E: -1.0
PC1_2E: 0.0
PC2_1E: 0.0
PC2_2E: -1.0
CDELT1E: 1.0
CDELT2E: 1.0
CRPIX1E: 0.0
CRPIX2E: 0.0
CRVAL1E: 602.0
CRVAL2E: 16826.0
WCSNAMEB: CCD_SERPAR
CTYPE1B: CCD_S
CTYPE2B: CCD_P
PC1_1B: -1.0
PC1_2B: 0.0
PC2_1B: 0.0
PC2_2B: -1.0
CDELT1B: 1.0
CDELT2B: 1.0
CRPIX1B: 0.0
CRPIX2B: 0.0
CRVAL1B: 513.0
CRVAL2B: 4001.0
WCSNAMEQ: RAFT_SERPAR
CTYPE1Q: RAFT_S
CTYPE2Q: RAFT_P
PC1_1Q: -1.0
PC1_2Q: 0.0
PC2_1Q: 0.0
PC2_2Q: -1.0
CDELT1Q: 1.0
CDELT2Q: 1.0
CRPIX1Q: 0.0
CRPIX2Q: 0.0
CRVAL1Q: 602.0
CRVAL2Q: 4126.0
BSCALE: 1.0
BZERO: 0.0
DATASUM: '248893210'
30 changes: 30 additions & 0 deletions tests/test_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,36 @@ def test_latiss_translator(self):
# the recorded AZ/EL/TIME.
wcs_params=dict(max_sep=7.),
)),
("latiss-AT_C_20220426_000004_R00_S00.yaml",
dict(telescope="Rubin Auxiliary Telescope",
instrument="LATISS",
boresight_rotation_coord="unknown",
dark_time=537.406*u.s,
detector_exposure_id=0x28c9000400,
detector_group="RXX",
detector_name="S00",
detector_num=0,
detector_serial="ITL-3800C-068",
exposure_id=3022042600004,
exposure_group="3022042600004",
exposure_time=-1.0*u.s,
focus_z=0.0*u.mm,
group_counter_end=4,
group_counter_start=4,
has_simulated_content=False,
object="UNKNOWN",
observation_counter=4,
observation_id="AT_C_20220426_000004",
observation_type="unknown",
observation_reason="unknown",
observing_day=20220426,
physical_filter="unknown~unknown",
pressure=None,
relative_humidity=None,
science_program="unknown",
temperature=None,
visit_id=3022042600004,
)),
("latiss-AT_O_20230321_000053.yaml",
dict(telescope="Rubin Auxiliary Telescope",
instrument="LATISS",
Expand Down
Loading