Skip to content

Commit

Permalink
Merge pull request #442 from lsst/tickets/DM-38400
Browse files Browse the repository at this point in the history
DM-38400: Always try to use ALTAZ from headers regardless of observation type
  • Loading branch information
timj committed Mar 28, 2023
2 parents be6179a + d49d9ba commit e34cd63
Show file tree
Hide file tree
Showing 3 changed files with 296 additions and 17 deletions.
36 changes: 19 additions & 17 deletions python/lsst/obs/lsst/translators/lsst.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,21 +628,25 @@ def to_physical_filter(self):

@cache_translation
def to_tracking_radec(self):
if not self.is_on_sky():
return None

# RA/DEC are *derived* headers and for the case where the DATE-BEG
# is 1970 they are garbage and should not be used.
if self._header["DATE-OBS"] == self._header["DATE"]:
# A fixed up date -- use AZEL as source of truth
altaz = self.to_altaz_begin()
radec = astropy.coordinates.SkyCoord(altaz.transform_to(astropy.coordinates.ICRS()),
obstime=altaz.obstime,
location=altaz.location)
else:
radecsys = ("RADESYS",)
radecpairs = (("RASTART", "DECSTART"), ("RA", "DEC"))
radec = tracking_from_degree_headers(self, radecsys, radecpairs)
try:
if self._header["DATE-OBS"] == self._header["DATE"]:
# A fixed up date -- use AZEL as source of truth
altaz = self.to_altaz_begin()
radec = astropy.coordinates.SkyCoord(altaz.transform_to(astropy.coordinates.ICRS()),
obstime=altaz.obstime,
location=altaz.location)
else:
radecsys = ("RADESYS",)
radecpairs = (("RASTART", "DECSTART"), ("RA", "DEC"))
radec = tracking_from_degree_headers(self, radecsys, radecpairs)
except Exception:
# If this observation was not formally on sky then we are allowed
# to return None.
if self.is_on_sky():
raise
radec = None

return radec

Expand All @@ -651,10 +655,8 @@ def to_altaz_begin(self):
if not self._is_on_mountain():
return None

# ALTAZ always relevant unless bias or dark
if self.to_observation_type() in ("bias", "dark"):
return None

# Always attempt to find the alt/az values regardless of observation
# type.
return altaz_from_degree_headers(self, (("ELSTART", "AZSTART"),),
self.to_datetime_begin(), is_zd=False)

Expand Down
245 changes: 245 additions & 0 deletions tests/headers/latiss-AT_O_20230321_000053.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
SIMPLE: true
EXTEND: true
CCD_MANU: ITL
CCD_TYPE: 3800C
BINX: 1
BINY: 1
CCDGAIN: 1.0
CCDNOISE: 10.0
CCDSLOT: S00
RAFTBAY: R00
FIRMWARE: '11384004'
PLATFORM: auxtel
CONTNUM: 189216ee
DAQVERS: R5-V5.0 2022-11-15T20:42:08Z (dd1d3e77)
DAQPART: lat
DAQFOLD: raw
SEQFILE: FP_ITL_2s_ir2_v26.seq
SEQNAME: FP_ITL_2s_ir2_v26.seq
SEQCKSUM: '980618532'
LSST_NUM: ITL-3800C-068
CCD_SERN: '20862'
REBNAME: Unknown
RAFTNAME: AuxTel-Raft
FPVERS: 1.1.6
IHVERS: 1.0.36
STUTTER ROWS: 0
STUTTER DELAY: 0.0
STUTTER NSHIFTS: 0
FILTPOS: null
CCDTEMP: -90.4134
COMMENT: '---- Checksums ----'
DATE: '2023-03-21T16:11:37.716'
MJD: 60024.67474208353
IMGTYPE: DARK
DATE-OBS: '2023-03-21T16:11:07.706'
MJD-OBS: 60024.67439474538
DATE-TRG: '2023-03-21T16:11:37.712'
MJD-TRG: 60024.674742036965
OBSID: AT_O_20230321_000053
DATE-BEG: '2023-03-21T16:11:07.706'
MJD-BEG: 60024.67439474538
DATE-END: '2023-03-21T16:11:37.719'
MJD-END: 60024.67474211799
GROUPID: '2023-03-21T16:11:07.633'
BUNIT: adu
TIMESYS: TAI
INSTRUME: LATISS
TELESCOP: LSST AuxTelescope
OBS-LONG: -70.749417
OBS-LAT: -30.244639
OBS-ELEV: 2663.0
OBSGEO-X: 1818938.94
OBSGEO-Y: -5208470.95
OBSGEO-Z: -3195172.08
FACILITY: Vera C. Rubin Observatory
RA: 142.50000000000003
DEC: -80.88077821957737
RASTART: 142.4991379349352
DECSTART: -80.88061139891191
RAEND: 142.49909582721642
DECEND: -80.88068841358722
ROTPA: 183.66883336421898
ROTCOORD: sky
HASTART: 13.89846977345079
ELSTART: 22.133383392229938
AZSTART: 175.34841395774586
AMSTART: 2.6203191940792587
AHAEND: null
AELEND: null
AAZEND: null
AAMEND: null
TRACKSYS: null
RADESYS: ICRS
FOCUSZ: 0.0
OBJECT: slew_icrs
INSTPORT: 2
ATM3PORT: 2
DOMEAZ: 255.43
SHUTLOWR: 0.0
SHUTUPPR: 0.0
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
TESTTYPE: DARK
CAMCODE: AT
CONTRLLR: O
DAYOBS: '20230321'
SEQNUM: 53
PROGRAM: null
REASON: null
CURINDEX: 1
MAXINDEX: 1
TSTAND: null
IMAGETAG: fa22f3510b8576a3
OBSANNOT: ''
TEMP_SET: -94.15
GRATING: empty_1
GRATBAND: EMPTY
GRATSLOT: 0
LINSPOS: 67.0
FILTBAND: EMPTY
FILTER: empty_1
FILTSLOT: 0
EXPTIME: 30.0
DARKTIME: 30.0126
SHUTTIME: 30.0
AIRTEMP: null
PRESSURE: null
HUMIDITY: null
WINDSPD: null
WINDDIR: null
SEEING: null
FILENAME: AT_O_20230321_000053_R00_S00.fits
HEADVER: 2
SIMULATE ATMCS: null
SIMULATE ATHEXAPOD: 0
SIMULATE ATPNEUMATICS: null
SIMULATE ATDOME: 0
SIMULATE ATSPECTROGRAPH: 0
XTENSION: IMAGE
BITPIX: 32
NAXIS: 2
NAXIS1: 576
NAXIS2: 2048
PCOUNT: 0
GCOUNT: 1
CHECKSUM: KGpgNGoZKGodKGoZ
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
C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
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
INHERIT: true
DATASUM: '333020674'
32 changes: 32 additions & 0 deletions tests/test_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ def test_latiss_translator(self):
science_program="unknown",
temperature=None,
visit_id=4702443654717948604,
check_altaz=True,
)),
("latiss-AT_O_20200128_000379.yaml",
dict(telescope="Rubin Auxiliary Telescope",
Expand Down Expand Up @@ -735,6 +736,37 @@ def test_latiss_translator(self):
# the recorded AZ/EL/TIME.
wcs_params=dict(max_sep=7.),
)),
("latiss-AT_O_20230321_000053.yaml",
dict(telescope="Rubin Auxiliary Telescope",
instrument="LATISS",
boresight_rotation_coord="unknown",
dark_time=30.0126*u.s,
detector_exposure_id=2023032100053,
detector_group="RXX",
detector_name="S00",
detector_num=0,
detector_serial="ITL-3800C-068",
exposure_id=2023032100053,
exposure_group="2023-03-21T16:11:07.633",
exposure_time=30.0*u.s,
focus_z=0.0*u.mm,
group_counter_end=53,
group_counter_start=53,
has_simulated_content=False,
object="slew_icrs",
observation_counter=53,
observation_id="AT_O_20230321_000053",
observation_type="dark",
observation_reason="dark",
observing_day=20230321,
physical_filter="empty~empty",
pressure=None,
relative_humidity=None,
science_program="unknown",
temperature=None,
visit_id=2593446676330000,
check_altaz=True,
))
)
self.assertObservationInfoFromYaml("latiss-future.yaml", dir=self.datadir)
for filename, expected in test_data:
Expand Down

0 comments on commit e34cd63

Please sign in to comment.