Skip to content

Commit

Permalink
Pass logger to Timer
Browse files Browse the repository at this point in the history
  • Loading branch information
ndrory committed Sep 10, 2024
1 parent f4700e7 commit 59d3569
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions python/lvmdrp/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1560,10 +1560,10 @@ def reduce_2d(mjd, calibrations, expnums=None, exptime=None, cameras=CAMERAS,
if skip_done and os.path.isfile(dframe_path):
log.info(f"skipping {dframe_path}, file already exist")
else:
with Timer('Preproc '+pframe_path):
with Timer(name='Preproc '+pframe_path, logger=log.info):
preproc_raw_frame(in_image=frame_path, out_image=pframe_path,
in_mask=mpixmask_path, replace_with_nan=replace_with_nan, assume_imagetyp=assume_imagetyp)
with Timer('Detrend '+dframe_path):
with Timer(name='Detrend '+dframe_path, logger=log.info):
detrend_frame(in_image=pframe_path, out_image=dframe_path,
in_bias=mbias_path,
in_pixelflat=mpixflat_path,
Expand Down Expand Up @@ -1638,7 +1638,7 @@ def science_reduction(expnum: int, use_longterm_cals: bool = False,
if skip_2d:
log.info("skipping 2D reduction")
else:
with Timer('Reduce2d'):
with Timer(name='Reduce2d', logger=log.info):
reduce_2d(mjd=sci_mjd, calibrations=calibs, expnums=[sci_expnum], reject_cr=reject_cr, skip_done=False)

# run reduction loop for each science camera exposure
Expand Down Expand Up @@ -1674,18 +1674,18 @@ def science_reduction(expnum: int, use_longterm_cals: bool = False,
mmodel_path = calibs["model"][sci_camera]

# add astrometry to frame
with Timer('Astrometry '+dsci_path):
with Timer(name='Astrometry '+dsci_path, logger=log.info):
add_astrometry(in_image=dsci_path, out_image=dsci_path, in_agcsci_image=agcsci_path, in_agcskye_image=agcskye_path, in_agcskyw_image=agcskyw_path)

# subtract straylight
with Timer('Straylight '+lsci_path):
with Timer(name='Straylight '+lsci_path, logger=log.info):
subtract_straylight(in_image=dsci_path, out_image=lsci_path, out_stray=lstr_path,
in_cent_trace=mtrace_path, select_nrows=(5,5), use_weights=True,
aperture=15, smoothing=400, median_box=101, gaussian_sigma=20.0,
parallel=parallel_run)

# extract 1d spectra
with Timer('Extract '+xsci_path):
with Timer(name='Extract '+xsci_path, logger=log.info):
extract_spectra(in_image=lsci_path, out_rss=xsci_path, in_trace=mtrace_path, in_fwhm=mwidth_path,
in_model=mmodel_path, method=extraction_method, parallel=parallel_run)

Expand Down Expand Up @@ -1715,39 +1715,39 @@ def science_reduction(expnum: int, use_longterm_cals: bool = False,
kind='h', camera=channel, imagetype=sci_imagetyp, expnum=expnum)

# stack spectrographs
with Timer('Stack Spectrographs '+xsci_path):
with Timer(name='Stack Spectrographs '+xsci_path, logger=log.info):
stack_spectrographs(in_rsss=xsci_paths, out_rss=xsci_path)
if not os.path.exists(xsci_path):
log.error(f'No stacked file found: {xsci_path}. Skipping remaining pipeline.')
continue

# wavelength calibrate
with Timer('Wavelengths '+wsci_path):
with Timer(name='Wavelengths '+wsci_path, logger=log.info):
create_pixel_table(in_rss=xsci_path, out_rss=wsci_path, in_waves=mwave_paths, in_lsfs=mlsf_paths)

# apply fiberflat correction
with Timer('Fiberflat '+frame_path):
with Timer(name='Fiberflat '+frame_path, logger=log.info):
apply_fiberflat(in_rss=wsci_path, out_frame=frame_path, in_flat=mflat_path)

# correct thermal shift in wavelength direction
with Timer('Thermal Shifts '+frame_path):
with Timer(name='Thermal Shifts '+frame_path, logger=log.info):
shift_wave_skylines(in_frame=frame_path, out_frame=frame_path)

# interpolate sky fibers
with Timer('Interpolate Sky '+ssci_path):
with Timer(name='Interpolate Sky '+ssci_path, logger=log.info):
interpolate_sky(in_frame=frame_path, out_rss=ssci_path)

# combine sky telescopes
with Timer('Combine Sky '+ssci_path):
with Timer(name='Combine Sky '+ssci_path, logger=log.info):
combine_skies(in_rss=ssci_path, out_rss=ssci_path, sky_weights=sky_weights)

# resample wavelength into uniform grid along fiber IDs for science and sky fibers
with Timer('Resample '+hsci_path):
with Timer(name='Resample '+hsci_path, logger=log.info):
resample_wavelength(in_rss=ssci_path, out_rss=hsci_path, wave_range=SPEC_CHANNELS[channel], wave_disp=0.5, convert_to_density=True)

# use resampled frames for flux calibration in each camera, using standard stars observed in the spec telescope
# and field stars found in the sci ifu
with Timer('Fluxcal '+hsci_path):
with Timer(name='Fluxcal '+hsci_path, logger=log.info):
fluxcal_standard_stars(hsci_path, GAIA_CACHE_DIR=MASTERS_DIR+'/gaia_cache')
fluxcal_sci_ifu_stars(hsci_path, GAIA_CACHE_DIR=MASTERS_DIR+'/gaia_cache')

Expand All @@ -1761,15 +1761,15 @@ def science_reduction(expnum: int, use_longterm_cals: bool = False,
log.error('No fframe files found. Cannot join spectrograph channels. Exiting pipeline.')
return

with Timer('Join Channels '+cframe_path):
with Timer(name='Join Channels '+cframe_path, logger=log.info):
join_spec_channels(in_fframes=fframe_paths, out_cframe=cframe_path, use_weights=True)

# sky subtraction
with Timer('QSky '+sframe_path):
with Timer(name='QSky '+sframe_path, logger=log.info):
quick_sky_subtraction(in_cframe=cframe_path, out_sframe=sframe_path, skip_subtraction=skip_sky_subtraction)

# update the drpall summary file
with Timer('DRPAll '+sframe_path):
with Timer(name='DRPAll '+sframe_path, logger=log.info):
log.info('Updating the drpall summary file')
update_summary_file(sframe_path, tileid=sci_tileid, mjd=sci_mjd, expnum=sci_expnum, master_mjd=cals_mjd)

Expand Down

0 comments on commit 59d3569

Please sign in to comment.