30
30
31
31
import numpy as np
32
32
import pandas as pd
33
+ import time
33
34
34
35
from lsst .daf .base import DateTime
35
36
import lsst .dax .apdb as daxApdb
@@ -210,6 +211,7 @@ def run(self, visit, detector,
210
211
idGeneratorForced : `lsst.meas.base,IdGenerator`, optional
211
212
ID generator for forced sources at existing diaObject locations.
212
213
"""
214
+ t_sim0 = time .time ()
213
215
idGen = idGenerator .make_table_id_factory ()
214
216
idGenFakes = idGeneratorFakes .make_table_id_factory ()
215
217
idGenForced = idGeneratorForced .make_table_id_factory ()
@@ -252,11 +254,16 @@ def run(self, visit, detector,
252
254
diaSourcesRaw = pd .concat ([diaSourcesReal , diaSourcesBogus ])
253
255
254
256
diaSources = convertTableToSdmSchema (self .schema , diaSourcesRaw , tableName = "DiaSource" )
257
+ t_sim1 = time .time ()
258
+ self .log .info ("Simulated source timing: %.2fs" , t_sim1 - t_sim0 )
255
259
260
+ t_load0 = time .time ()
256
261
diaObjects = self .loadDiaObjects (region .getBoundingCircle (), self .schema )
262
+ t_load1 = time .time ()
263
+ self .log .info ("diaObject load timing: %.2fs" , t_load1 - t_load0 )
257
264
258
265
if diaObjects .empty :
259
- self .log .info (f "diaObjects contain 0 diaSources (empty)" )
266
+ self .log .info ("diaObjects contain 0 diaSources (empty)" )
260
267
else :
261
268
nDiaSources = diaObjects .nDiaSources
262
269
self .log .info (f"diaObjects contain { np .min (nDiaSources )} to { np .max (nDiaSources )} diaSources" )
@@ -274,18 +281,21 @@ def run(self, visit, detector,
274
281
nSrc = len (associatedDiaSources )
275
282
dateTime = DateTime .now ().toAstropy ()
276
283
ind = 0
284
+ t_write0 = time .time ()
277
285
# Note that nObj must always be equal to or greater than nSrc
278
286
for start in range (0 , nObj , self .config .maximum_table_length ):
279
287
end = min (start + self .config .maximum_table_length , nObj )
280
288
diaObjectsChunk = mergedDiaObjects .iloc [start :end ]
281
- self .log .info (f"Writing diaObject chunk { ind } of length { len (diaObjectsChunk )} to the APDB" )
289
+ nObjChunk = len (diaObjectsChunk )
290
+ self .log .info (f"Writing diaObject chunk { ind } of length { nObjChunk } (of { nObj } ) to the APDB" )
282
291
srcEnd = min (start + self .config .maximum_table_length , nSrc )
283
292
if srcEnd <= start :
284
293
finalDiaSources = None
285
294
else :
286
295
diaSourcesChunk = associatedDiaSources .iloc [start :srcEnd ]
287
296
finalDiaSources = convertTableToSdmSchema (self .schema , diaSourcesChunk , tableName = "DiaSource" )
288
- self .log .info (f"Writing diaSource chunk { ind } of length { len (diaSourcesChunk )} to the APDB" )
297
+ nSrcChunk = len (diaSourcesChunk )
298
+ self .log .info (f"Writing diaSource chunk { ind } of length { nSrcChunk } (of { nSrc } ) to the APDB" )
289
299
diaForcedSources = self .runForcedMeasurement (diaObjectsChunk , idGenForced , visit , detector )
290
300
291
301
finalDiaObjects = convertTableToSdmSchema (self .schema , diaObjectsChunk , tableName = "DiaObject" )
@@ -295,6 +305,8 @@ def run(self, visit, detector,
295
305
f" { len (finalDiaForcedSources )} to the APDB" )
296
306
self .writeToApdb (finalDiaObjects , finalDiaSources , finalDiaForcedSources , dateTime )
297
307
ind += 1
308
+ t_write1 = time .time ()
309
+ self .log .info ("APDB write timing: %.2fs" , t_write1 - t_write0 )
298
310
marker = pexConfig .Config ()
299
311
return pipeBase .Struct (apdbTestMarker = marker )
300
312
0 commit comments