LBCgo.lbcproc¶
Functions¶
Check if required external tools are available. |
|
|
Remove overscan and trim LBC object images. |
|
Create a master bias frame from a collection of zero frames. |
|
Apply a master bias frame to multi-extension FITS object data. |
|
Create a master sky flat field for a single filter. |
|
Apply master flat fields to multi-extension FITS object data. |
|
|
|
Organise flat-fielded files into per-target and per-filter subdirectories. |
|
Split multi-extension flat-fielded files into single-chip FITS files. |
|
|
|
Process a directory of LBC (Large Binocular Camera) data through the complete reduction pipeline. |
Module Contents¶
- LBCgo.lbcproc.check_external_dependencies()¶
Check if required external tools are available.
- LBCgo.lbcproc.go_overscan(image_collection, lbc_chips=True, objects_only=True, image_directory='./', raw_directory='./raw/', verbose=True, return_files=True)¶
Remove overscan and trim LBC object images.
Fits a 4th-order polynomial to each chip’s overscan strip (
BIASSEC), subtracts it, then trims to the science region (TRIMSEC). Also removes LBC header keywords that confuse downstream astrometric tools (BIASSEC,TRIMSEC,DATASEC,ROTANGLE,PARANGLE, and all duplicate keywords ending inA).By default only processes frames with
IMAGETYP=object; calibration frames are handled internally bymake_bias()andmake_flatfield().- Parameters:
image_collection (ccdproc.ImageFileCollection) – Collection of raw LBC FITS files.
lbc_chips (bool or list of int, optional) – Chips to process. If True, processes all 4 chips. Default: True
objects_only (bool, optional) – If True, restrict to
IMAGETYP=objectframes. Default: Trueimage_directory (str, optional) – Output directory for overscan-corrected files. Default: ‘./’
raw_directory (str, optional) – Directory containing raw input files. Default: ‘./raw/’
verbose (bool, optional) – Print progress messages. Default: True
return_files (bool, optional) – Return a list of output filenames. Default: True
- Returns:
Paths to overscan-corrected, trimmed FITS files (
*_over.fits), or None ifreturn_files=False.- Return type:
list of str or None
- LBCgo.lbcproc.make_bias(image_collection, bias_filename=None, lbc_chips=True, image_directory='./', raw_directory='./raw/', verbose=True)¶
Create a master bias frame from a collection of zero frames.
Overscan-subtracts and trims each bias frame, then median-combines with 3-sigma clipping. The result is written as a multi-extension FITS file (one extension per chip). The number of combined frames is recorded in each chip header as
NCOMBINE.- Parameters:
image_collection (ccdproc.ImageFileCollection) – Collection containing raw bias frames (
IMAGETYP=zero).bias_filename (str or None, optional) – Output filename for the master bias. Default:
'zero.fits'lbc_chips (bool or list of int, optional) – Chips to process. If True, processes all 4 chips. Default: True
image_directory (str, optional) – Output directory for the master bias. Default: ‘./’
raw_directory (str, optional) – Directory containing raw bias frames. Default: ‘./raw/’
verbose (bool, optional) – Print progress messages. Default: True
- LBCgo.lbcproc.go_bias(image_collection, bias_file=None, image_directory='./', input_directory='./', bias_directory='./', lbc_chips=True, verbose=True, return_files=False)¶
Apply a master bias frame to multi-extension FITS object data.
- Parameters:
image_collection (ccdproc.ImageFileCollection or list of str) – Collection or list of filenames for the overscan-corrected object frames.
bias_file (str or None, optional) – Filename of the master bias. Default:
'zero.fits'image_directory (str, optional) – Output directory for bias-subtracted files. Default: ‘./’
input_directory (str, optional) – Directory containing the input object frames. Default: ‘./’
bias_directory (str, optional) – Directory containing the master bias file. Default: ‘./’
lbc_chips (bool or list of int, optional) – Chips to process. If True, processes all 4 chips. Default: True
verbose (bool, optional) – Print progress messages. Default: True
return_files (bool, optional) – Return a list of output filenames. Default: False
- Returns:
Paths to bias-subtracted FITS files (
*_zero.fits), or None ifreturn_files=False.- Return type:
list of str or None
- LBCgo.lbcproc.make_flatfield(image_collection, filter_name=None, lbc_chips=True, image_directory='./', raw_directory='./raw/', cosmiccorrect=False, verbose=True)¶
Create a master sky flat field for a single filter.
Overscan-subtracts and trims each sky flat (
IMAGETYP=flat,OBJECT=SkyFlat), rejects frames with mean counts above 55,000 ADU as saturated, normalises the remaining frames to a common level, and median-combines with 3-sigma clipping. The number of combined frames is stored asNCOMBINEin the primary header.- Parameters:
image_collection (ccdproc.ImageFileCollection) – Collection containing raw sky flat frames.
filter_name (str or None, optional) – Filter to process. If None, uses the first filter found in the collection summary. Default: None
lbc_chips (bool or list of int, optional) – Chips to process. If True, processes all 4 chips. Default: True
image_directory (str, optional) – Output directory for the master flat. Default: ‘./’
raw_directory (str, optional) – Directory containing raw flat frames. Default: ‘./raw/’
cosmiccorrect (bool, optional) – Apply cosmic-ray cleaning to individual flats before combining. Default: False
verbose (bool, optional) – Print progress messages. Default: True
- Returns:
Writes
flat.<filter_name>.fitstoimage_directory. Returns None if no usable flat frames are found.- Return type:
None
- LBCgo.lbcproc.go_flatfield(image_collection, flat_file=None, filter_names=None, image_directory='./', input_directory='./', flat_directory='./', lbc_chips=True, cosmiccorrect=True, verbose=True, return_files=False)¶
Apply master flat fields to multi-extension FITS object data.
Loops over filters, reads the corresponding master flat, and divides each object frame by it. Pre-flat-fielded files are moved to a
data/subdirectory. Output files carry the_flat.fitssuffix.- Parameters:
image_collection (ccdproc.ImageFileCollection) – Collection of bias-corrected (or overscan-only) object frames.
flat_file (str or None, optional) – Override flat filename. If None, expects
flat.<filter>.fitsinflat_directory. Default: Nonefilter_names (list of str or None, optional) – Filters to process. If None, all filters in the collection are used. Default: None
image_directory (str, optional) – Output directory for flat-fielded files. Default: ‘./’
input_directory (str, optional) – Directory containing input object frames. Default: ‘./’
flat_directory (str, optional) – Directory containing master flat files. Default: ‘./’
lbc_chips (bool or list of int, optional) – Chips to process. If True, processes all 4 chips. Default: True
cosmiccorrect (bool, optional) – Apply cosmic-ray cleaning before flat fielding. Default: True
verbose (bool, optional) – Print progress messages. Default: True
return_files (bool, optional) – Return a list of output filenames. Default: False
- Returns:
Paths to flat-fielded FITS files (
*_flat.fits), or None ifreturn_files=False.- Return type:
list of str or None
- LBCgo.lbcproc.go_cleancosmic(ccd, mbox=15, rbox=15, gbox=11, sigclip=5, cleantype='medmask', cosmic_method='lacosmic')¶
- LBCgo.lbcproc.make_targetdirectories(image_collection, image_directory='./', object_names=None, verbose=True)¶
Organise flat-fielded files into per-target and per-filter subdirectories.
Creates
<image_directory><object>/and<image_directory><object>/<filter>/subdirectories and moves files into them. Spaces in object names are stripped (NGC 891→NGC891). Existing directories are silently reused.- Parameters:
image_collection (ccdproc.ImageFileCollection) – Collection of flat-fielded object frames to organise.
image_directory (str, optional) – Root output directory under which target subdirectories are created. Default: ‘./’
object_names (list of str or None, optional) – Restrict processing to these object names. If None, all unique
OBJECTvalues in the collection are used. Default: Noneverbose (bool, optional) – Print progress messages. Default: True
- Returns:
object_directories (list of str) – Paths to the per-target directories that were created or reused.
filter_directories (list of str) – Paths to the per-filter subdirectories within each target directory.
- LBCgo.lbcproc.go_extractchips(filter_directories, lbc_chips=True, verbose=True, return_files=False)¶
Split multi-extension flat-fielded files into single-chip FITS files.
For each
*_flat.fitsfile found in the supplied filter directories, writes one output file per chip named<base>_<chip>.fits, each containing a single image extension. The original multi-extension file is moved to adata/subdirectory. Output files are the direct inputs to the astrometric registration step.- Parameters:
filter_directories (str or list of str) – Directory path(s) containing
*_flat.fitsmulti-extension files.lbc_chips (bool or list of int, optional) – Chips to extract. If True, extracts all 4 chips. Default: True
verbose (bool, optional) – Print progress messages. Default: True
return_files (bool, optional) – Return a list of output filenames. Default: False
- Returns:
Paths to per-chip FITS files (e.g.
*_1.fits…*_4.fits), or None ifreturn_files=False.- Return type:
list of str or None
- LBCgo.lbcproc.go_scrub()¶
- LBCgo.lbcproc.lbcgo(raw_directory='./raw/', image_directory='./', lbc_chips=True, lbcr=True, lbcb=True, filter_names=None, bias_proc=False, do_astrometry=True, astrometric_catalog='GAIA-DR3', scamp_iterations=3, verbose=True, clean=True)¶
Process a directory of LBC (Large Binocular Camera) data through the complete reduction pipeline.
This function performs comprehensive data reduction for LBT LBC observations, including overscan subtraction, flat fielding, cosmic ray removal, chip extraction, astrometric calibration, and final image combination. The pipeline processes multi-extension FITS files from both LBC-Blue and LBC-Red cameras.
Detailed Processing Steps: 1. Collect and filter raw image files by camera and filter 2. Create master bias frames (optional) 3. Create master flat field frames per filter 4. Remove overscan regions and trim images 5. Apply bias correction (optional) 6. Apply flat field correction 7. Organize data by target and filter into subdirectories 8. Extract individual CCD chips for astrometric processing 9. Perform astrometric calibration using SExtractor/SCAMP (optional) 10. Co-add registered images using SWARP (optional)
- Parameters:
raw_directory (str, optional) – Path to directory containing raw LBC FITS files. Files should follow the naming convention ‘lbc[br].YYYYMMDD.NNNNNN.fits’. Default: ‘./raw/’
image_directory (str, optional) – Output directory for processed images and intermediate files. Default: ‘./’
lbc_chips (bool or list, optional) – CCD chips to process. If True, processes all 4 chips [1,2,3,4]. Can specify subset as list (e.g., [1,3]). Default: True
lbcr (bool, optional) – Process LBC-Red camera data. Default: True
lbcb (bool, optional) – Process LBC-Blue camera data. Default: True
filter_names (list or None, optional) – List of filter names to process (e.g., [‘g-SLOAN’, ‘r-SLOAN’]). If None, processes all filters found in data. Default: None
bias_proc (bool, optional) – Apply bias frame correction. Requires bias frames in raw data. Default: False
do_astrometry (bool, optional) – Perform astrometric calibration and image registration using SExtractor, SCAMP, and SWARP. Requires external tools to be installed. Default: True
astrometric_catalog (str, optional) – Astrometric reference catalog to use for SCAMP calibration. Common options include ‘GAIA-DR3’, ‘SDSS-R12’, ‘2MASS’, etc. Default: ‘GAIA-DR3’
scamp_iterations (int, optional) – Number of SCAMP iterations for astrometric solution refinement. Minimum of 2 iterations recommended. Default: 3
verbose (bool, optional) – Print detailed processing information and progress. Default: True
clean (bool, optional) – Clean up intermediate files after processing. If True, removes intermediate files and diagnostic outputs. If False, preserves catalog files in ‘cat/’ directory for inspection. Default: True
- Returns:
Function performs file operations and creates output images in specified directories. Final products include flat-fielded individual chip images and (if do_astrometry=True) astrometrically-calibrated combined images.
- Return type:
None
Notes
Raw files are expected to be multi-extension FITS with 4 CCD extensions
SkyFlatTest images are automatically excluded from processing
External dependencies (SExtractor, SCAMP, SWARP) are required if do_astrometry=True
For nights with V-band observations from both cameras, run separately with lbcr=False then lbcb=False to avoid inappropriate co-addition
Processing creates subdirectories organized by target name and filter
Intermediate files are moved to a ‘data/’ subdirectory during processing
Examples
Basic processing with astrometry: >>> lbcgo()
Process only g-band data from LBC-Blue: >>> lbcgo(lbcb=True, lbcr=False, filter_names=[‘g-SLOAN’])
Process without astrometric calibration: >>> lbcgo(do_astrometry=False)
Custom directories and bias correction: >>> lbcgo(raw_directory=’/data/lbc/raw/’, … image_directory=’/data/lbc/reduced/’, … bias_proc=True)