Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW FEATURE] Third-party catalogue for tile objects #650

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from
Prev Previous commit
Next Next commit
sextractor_runner restored to develop
  • Loading branch information
martinkilbinger committed May 17, 2023
commit d327cc4f0540332928c4d80cb94d90b0c89fc2bf
69 changes: 69 additions & 0 deletions example/cfis/default_cat.param
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
NUMBER #Running object number
EXT_NUMBER #FITS extension number

FLUX_AUTO #Flux within a Kron-like elliptical aperture [count]
FLUXERR_AUTO #RMS error for AUTO flux [count]
MAG_AUTO #Kron-like elliptical aperture magnitude [mag]
MAGERR_AUTO #RMS error for AUTO magnitude [mag]
FLUX_WIN #Gaussian-weighted flux [count]
FLUXERR_WIN #RMS error for WIN flux [count]
MAG_WIN #Gaussian-weighted magnitude [mag]
MAGERR_WIN #RMS error for MAG_WIN [mag]
FLUX_APER(1)
FLUXERR_APER(1)

FLUX_RADIUS #Fraction-of-light radii [pixel]

SNR_WIN #Gaussian-weighted SNR

BACKGROUND #Background at centroid position [count]
THRESHOLD #Detection threshold above background [count]

X_IMAGE #Object position along x [pixel]
Y_IMAGE #Object position along y [pixel]

X_WORLD #Barycenter position along world x axis [deg]
Y_WORLD #Barycenter position along world y axis [deg]

X2_IMAGE #Variance along x [pixel**2]
Y2_IMAGE #Variance along y [pixel**2]
XY_IMAGE #Covariance between x and y [pixel**2]
ERRX2_IMAGE #Variance of position along x [pixel**2]
ERRY2_IMAGE #Variance of position along y [pixel**2]
ERRXY_IMAGE #Covariance of position between x and y [pixel**2]

XWIN_IMAGE #Windowed position estimate along x [pixel]
YWIN_IMAGE #Windowed position estimate along y [pixel]

XWIN_WORLD #Windowed position along world x axis [deg]
YWIN_WORLD #Windowed position along world y axis [deg]

X2WIN_IMAGE #Windowed variance along x [pixel**2]
Y2WIN_IMAGE #Windowed variance along y [pixel**2]
XYWIN_IMAGE #Windowed covariance between x and y [pixel**2]
ERRX2WIN_IMAGE #Variance of windowed pos along x [pixel**2]
ERRY2WIN_IMAGE #Variance of windowed pos along y [pixel**2]
ERRXYWIN_IMAGE #Covariance of windowed pos between x and y [pixel**2]

MU_THRESHOLD #Analysis threshold above background [mag * arcsec**(-2)]
MU_MAX #Peak surface brightness above background [mag * arcsec**(-2)]

FLAGS #Extraction flags
FLAGS_WIN #Flags for WINdowed parameters

#!!! REQUIRE FLAG_IMAGE !!!
IMAFLAGS_ISO #FLAG-image flags OR'ed over the iso. profile !!! REQUIRE FLAG_IMAGE !!!

FWHM_IMAGE #FWHM assuming a gaussian core [pixel]
FWHM_WORLD #FWHM assuming a gaussian core [deg]
ELONGATION #A_IMAGE/B_IMAGE
ELLIPTICITY #1 - B_IMAGE/A_IMAGE

VIGNET(51,51) #Pixel data around detection [count]

#VECTOR_ASSOC #ASSOCiated parameter vector
NUMBER_ASSOC #Number of ASSOCiated IDs

#SPREAD_MODEL
#SPREADERR_MODEL
#FWHMPSF_IMAGE
141 changes: 58 additions & 83 deletions shapepipe/modules/sextractor_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,93 +36,68 @@ def sextractor_runner(
else:
exec_path = 'sex'

if exec_path != 'None':

# Get SExtractor config options
dot_sex = config.getexpanded(module_config_sec, 'DOT_SEX_FILE')
dot_param = config.getexpanded(module_config_sec, 'DOT_PARAM_FILE')
dot_conv = config.getexpanded(module_config_sec, 'DOT_CONV_FILE')
weight_file = config.getboolean(module_config_sec, 'WEIGHT_IMAGE')
flag_file = config.getboolean(module_config_sec, 'FLAG_IMAGE')
psf_file = config.getboolean(module_config_sec, 'PSF_FILE')
detection_image = config.getboolean(module_config_sec, 'DETECTION_IMAGE')
detection_weight = config.getboolean(module_config_sec, 'DETECTION_WEIGHT')

zp_from_header = config.getboolean(module_config_sec, 'ZP_FROM_HEADER')
if zp_from_header:
zp_key = config.get(module_config_sec, 'ZP_KEY')
else:
zp_key = None

bkg_from_header = config.getboolean(module_config_sec, 'BKG_FROM_HEADER')
if bkg_from_header:
bkg_key = config.get(module_config_sec, 'BKG_KEY')
else:
bkg_key = None

if config.has_option(module_config_sec, 'CHECKIMAGE'):
check_image = config.getlist(module_config_sec, 'CHECKIMAGE')
else:
check_image = ['']

if config.has_option(module_config_sec, 'PREFIX'):
prefix = config.get(module_config_sec, 'PREFIX')
else:
prefix = None

# Create sextractor caller class instance
ss_inst = ss.SExtractorCaller(
input_file_list,
run_dirs['output'],
file_number_string,
dot_sex,
dot_param,
dot_conv,
weight_file,
flag_file,
psf_file,
detection_image,
detection_weight,
zp_from_header,
bkg_from_header,
zero_point_key=zp_key,
background_key=bkg_key,
check_image=check_image,
output_prefix=prefix,
)

# Generate sextractor command line
command_line = ss_inst.make_command_line(exec_path)
w_log.info(f'Calling command: {command_line}')

# Execute command line
stderr, stdout = execute(command_line)

# Parse SExtractor errors
stdout, stderr = ss_inst.parse_errors(stderr, stdout)
# Get SExtractor config options
dot_sex = config.getexpanded(module_config_sec, 'DOT_SEX_FILE')
dot_param = config.getexpanded(module_config_sec, 'DOT_PARAM_FILE')
dot_conv = config.getexpanded(module_config_sec, 'DOT_CONV_FILE')
weight_file = config.getboolean(module_config_sec, 'WEIGHT_IMAGE')
flag_file = config.getboolean(module_config_sec, 'FLAG_IMAGE')
psf_file = config.getboolean(module_config_sec, 'PSF_FILE')
detection_image = config.getboolean(module_config_sec, 'DETECTION_IMAGE')
detection_weight = config.getboolean(module_config_sec, 'DETECTION_WEIGHT')

zp_from_header = config.getboolean(module_config_sec, 'ZP_FROM_HEADER')
if zp_from_header:
zp_key = config.get(module_config_sec, 'ZP_KEY')
else:
zp_key = None

bkg_from_header = config.getboolean(module_config_sec, 'BKG_FROM_HEADER')
if bkg_from_header:
bkg_key = config.get(module_config_sec, 'BKG_KEY')
else:
bkg_key = None

# Read input catalogue
if config.has_option(module_config_sec, 'CHECKIMAGE'):
check_image = config.getlist(module_config_sec, 'CHECKIMAGE')
else:
check_image = ['']
ss_inst = ss.SExtractorCaller(
input_file_list,
run_dirs['output'],
file_number_string,
None,
None,
None,
True,
False,
False,
False,
False,
False,
False,
check_image=check_image,
)
data = ss_inst.read_from_ascii()
ss_inst.write_to_fits(data)

if config.has_option(module_config_sec, 'PREFIX'):
prefix = config.get(module_config_sec, 'PREFIX')
else:
prefix = None

# Create sextractor caller class instance
ss_inst = ss.SExtractorCaller(
input_file_list,
run_dirs['output'],
file_number_string,
dot_sex,
dot_param,
dot_conv,
weight_file,
flag_file,
psf_file,
detection_image,
detection_weight,
zp_from_header,
bkg_from_header,
zero_point_key=zp_key,
background_key=bkg_key,
check_image=check_image,
output_prefix=prefix,
)

# Generate sextractor command line
command_line = ss_inst.make_command_line(exec_path)
w_log.info(f'Calling command: {command_line}')

# Execute command line
stderr, stdout = execute(command_line)

# Parse SExtractor errors
stdout, stderr = ss_inst.parse_errors(stderr, stdout)

# Run sextractor post processing
if config.getboolean(module_config_sec, 'MAKE_POST_PROCESS'):
Expand Down