Skip to content

Commit 511d0db

Browse files
authored
Merge pull request #337 from lsst-dm/tickets/DM-51822
DM-51822: PP-dev upload_from_repo test with LSSTCam
2 parents 4c81960 + 2088c7e commit 511d0db

File tree

8 files changed

+121
-178
lines changed

8 files changed

+121
-178
lines changed

etc/export_comCamSim.yaml

Lines changed: 0 additions & 17 deletions
This file was deleted.

etc/tester/LATISS.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ query:
33
collections: LATISS/raw/all
44
# Observations before 2024-04-09 are not compatible with calibs in dev repo
55
where: "exposure.science_program in ('AUXTEL_PHOTO_IMAGING', 'BLOCK-306') and exposure.day_obs in (20240409..20241001)"
6-
repo: embargo_old
6+
repo: main

etc/tester/LSSTCam-all.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
instrument: LSSTCam
2+
query:
3+
collections: LSSTCam/raw/all
4+
where: "exposure.science_program='BLOCK-365'"
5+
repo: main

etc/tester/LSSTCam-clean.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
instrument: LSSTCam
2+
query:
3+
collections: u/hchiang2/tagged/DM-51822/dayobs20250525
4+
where: "exposure.science_program='BLOCK-365'"
5+
repo: main

etc/tester/LSSTComCamSim.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.

python/tester/upload.py

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838

3939
from shared.raw import (
4040
LSST_REGEXP,
41-
IMSIM_REGEXP,
4241
OTHER_REGEXP,
4342
get_raw_path,
4443
_LSST_CAMERA_LIST,
@@ -51,7 +50,6 @@
5150
get_last_group,
5251
increment_group,
5352
make_exposure_id,
54-
make_imsim_time_headers,
5553
replace_header_key,
5654
send_next_visit,
5755
)
@@ -69,7 +67,7 @@
6967
_log.setLevel(logging.INFO)
7068

7169

72-
def process_group(kafka_url, visit_infos, uploader, start_time):
70+
def process_group(kafka_url, visit_infos, uploader):
7371
"""Simulate the observation of a single on-sky pointing.
7472
7573
Parameters
@@ -83,8 +81,6 @@ def process_group(kafka_url, visit_infos, uploader, start_time):
8381
uploader : callable [`shared.visit.FannedOutVisit`, int]
8482
A callable that takes an exposure spec and a snap ID, and uploads the
8583
visit's data.
86-
start_time : `float`
87-
The Unix time (TAI) of the exposure start.
8884
"""
8985
# Assume group/snaps is shared among all visit_infos
9086
for info in visit_infos:
@@ -110,7 +106,7 @@ def process_group(kafka_url, visit_infos, uploader, start_time):
110106
for info in visit_infos:
111107
_log.info(f"Uploading group: {info.groupId} snap: {snap} filters: {info.filters} "
112108
f"detector: {info.detector}")
113-
uploader(info, snap, start_time)
109+
uploader(info, snap)
114110
_log.info(f"Uploaded group: {info.groupId} snap: {snap} filters: {info.filters} "
115111
f"detector: {info.detector}")
116112

@@ -284,10 +280,7 @@ def get_samples_lsst(bucket, instrument):
284280
for blob in blobs:
285281
# Assume that the unobserved bucket uses the same filename scheme as
286282
# the observed bucket.
287-
if instrument == "LSSTCam-imSim":
288-
m = re.match(IMSIM_REGEXP, blob.key)
289-
else:
290-
m = re.match(LSST_REGEXP, blob.key)
283+
m = re.match(LSST_REGEXP, blob.key)
291284
if not m or m["extension"] == ".json":
292285
continue
293286

@@ -302,10 +295,7 @@ def get_samples_lsst(bucket, instrument):
302295

303296
sal_index = INSTRUMENTS[instrument].sal_index
304297
# Use special sal_index to indicate a subset of detectors
305-
if instrument == "LSSTCam-imSim":
306-
# For imSim data, the OBSID header has the exposure ID.
307-
sal_index = int(md["OBSID"])
308-
elif instrument == "LSSTCam":
298+
if instrument == "LSSTCam":
309299
_, _, day_obs, seq_num = md["OBSID"].split("_")
310300
exposure_num = LsstBaseTranslator.compute_exposure_id(int(day_obs), int(seq_num))
311301
sal_index = exposure_num
@@ -382,18 +372,11 @@ def upload_from_raws(kafka_url, instrument, raw_pool, src_bucket, dest_bucket, n
382372
# Copy all the visit-blob dictionaries under each snap_id,
383373
# replacing the (immutable) FannedOutVisit objects to point to group
384374
# instead of true_group.
385-
# Update next_visit timestamp for LSSTCam-imSim only.
386-
now = astropy.time.Time.now().unix_tai
387-
start_time = now + 2*(EXPOSURE_INTERVAL + SLEW_INTERVAL)
388375
for snap_id, old_visits in raw_pool[true_group].items():
389376
snap_dict[snap_id] = {
390377
dataclasses.replace(
391378
true_visit,
392379
groupId=group,
393-
**({
394-
"startTime": start_time,
395-
"private_sndStamp": now
396-
} if instrument == "LSSTCam-imSim" else {})
397380
): blob
398381
for true_visit, blob in old_visits.items()}
399382
# Gather all the FannedOutVisit objects found in snap_dict, merging
@@ -402,14 +385,11 @@ def upload_from_raws(kafka_url, instrument, raw_pool, src_bucket, dest_bucket, n
402385

403386
# TODO: may be cleaner to use a functor object than to depend on
404387
# closures for the buckets and data.
405-
def upload_from_pool(visit, snap_id, start_time):
388+
def upload_from_pool(visit, snap_id):
406389
src_blob = snap_dict[snap_id][visit]
407390
exposure_num, headers = \
408391
make_exposure_id(visit.instrument, visit.groupId, snap_id)
409-
# Only LSSTCam-imSim uses the given timestamp for the exposure start.
410-
# Other instruments keep the original exposure timespan.
411-
if instrument == "LSSTCam-imSim":
412-
headers.update(make_imsim_time_headers(EXPOSURE_INTERVAL, start_time))
392+
# The original exposure timespan is kept.
413393
filename = get_raw_path(visit.instrument, visit.detector, visit.groupId, snap_id,
414394
exposure_num, visit.filters)
415395

@@ -433,7 +413,7 @@ def upload_from_pool(visit, snap_id, start_time):
433413
dest_bucket.upload_fileobj(buffer, filename)
434414
_log.debug(f"{filename} is uploaded to {dest_bucket}")
435415

436-
process_group(kafka_url, visit_infos, upload_from_pool, start_time)
416+
process_group(kafka_url, visit_infos, upload_from_pool)
437417

438418

439419
if __name__ == "__main__":

0 commit comments

Comments
 (0)