Skip to content

Commit

Permalink
added automatic calibration retry in pp_run if solar option fails
Browse files Browse the repository at this point in the history
  • Loading branch information
mommermi committed Nov 21, 2018
1 parent 0d630c0 commit 7715d63
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 35 deletions.
5 changes: 4 additions & 1 deletion doc/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ below. All functions presented here can be called from the terminal.
:func:`pp_register` for details.
:param -solar: the photometric calibration (`pp_calibrate`) is only
using stars with solar-like colors (see
`pp_calibrate` documentation for details)
`pp_calibrate` documentation for details); if the
calibration using `-solar` fails (too few matches with
reference catalog), the calibration is automatically
repeated without the `-solar` option
:param -rerun_registration: (optional) for some data, the image
registration has to be run twice; this option
will rerun the registration step, if not
Expand Down
15 changes: 10 additions & 5 deletions pp_calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ def create_photometrycatalog(ra_deg, dec_deg, rad_deg, filtername,
(n_raw-n_rejected, n_raw))
logging.info('%d/%d sources left with solar-like colors' %
(n_raw-n_rejected, n_raw))
cat.history += (', {:d} stars left with solar colors'.
format(n_raw-n_rejected))
cat.catalogname += '_solar'

# transform catalog to requested filtername, if necessesary
if (n_sources > 0 and
Expand Down Expand Up @@ -282,11 +285,13 @@ def derive_zeropoints(ref_cat, catalogs, filtername, minstars_external,
# fewer than 3 reference stars -> skip this catalog
if len(residuals) < 3:
if display:
print(('Warning: %d reference stars after source matching '
+ 'for frame %s') % (len(residuals), cat.catalogname))
logging.warning(('Warning: %d reference stars after source '
+ 'matching for frame %s') %
(len(residuals), cat.catalogname))
print(('Warning: {:d} stars left after source matching '
'for frame {:s}; report instrumental magnitudes').
format(len(residuals), cat.catalogname))
logging.warning(
('Warning: {:d} stars left after source matching '
'for frame {:s}; report instrumental magnitudes').
format(len(residuals), cat.catalogname))
clipping_steps = [[0, 0, 1e-10, [], [[], []]]]

output['zeropoints'].append({'filename': cat.catalogname,
Expand Down
59 changes: 35 additions & 24 deletions pp_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ def run_the_pipeline(filenames, man_targetname, man_filtername,
source_minarea, aprad,
None, obsparam,
obsparam['source_tolerance'],
False,
display=True,
diagnostics=True)

Expand Down Expand Up @@ -269,32 +270,42 @@ def run_the_pipeline(filenames, man_targetname, man_filtername,

print('\n----- run photometric calibration\n')

calibration = pp_calibrate.calibrate(filenames, minstars, filtername,
manualcatalog, obsparam, solar=solar,
display=True,
diagnostics=True)

# if calibration == None:
# print('Nothing to do!')
# logging.error('Nothing to do! Error in pp_calibrate')
# diag.abort('pp_calibrate')
# sys.exit(1)
while True:
calibration = pp_calibrate.calibrate(filenames, minstars,
filtername,
manualcatalog, obsparam,
solar=solar,
display=True,
diagnostics=True)

try:
zps = [frame['zp'] for frame in calibration['zeropoints']]
zp_errs = [frame['zp_sig'] for frame in calibration['zeropoints']]
try:
zps = [frame['zp'] for frame in calibration['zeropoints']]
zp_errs = [frame['zp_sig']
for frame in calibration['zeropoints']]

# rerun calibration
if solar and any(np.isnan(zps)):
logging.warning(('Photometric calibration failed for one '
'or more frames; re-try without the '
'solar option'))
print(('Warning: Photometric calibration '
'failed for one or more frames; '
're-try without the -solar option'))
solar = False
continue

if calibration['ref_cat'] is not None:
refcatname = calibration['ref_cat'].catalogname
else:
refcatname = 'instrumental magnitudes'
summary_message = "<FONT COLOR=\"green\">average zeropoint = " + \
("%5.2f+-%5.2f using %s</FONT>; " %
(np.average(zps),
np.average(zp_errs),
refcatname))
except TypeError:
summary_message = "<FONT COLOR=\"red\">no phot. calibration</FONT>; "
if calibration['ref_cat'] is not None:
refcatname = calibration['ref_cat'].catalogname
else:
refcatname = 'instrumental magnitudes'
summary_message = "<FONT COLOR=\"green\">average zeropoint = " + \
("%5.2f+-%5.2f using %s</FONT>; " %
(np.average(zps),
np.average(zp_errs),
refcatname))
except TypeError:
summary_message = "<FONT COLOR=\"red\">no phot. calibration</FONT>; "
break

# add information to summary website, if requested
if _pp_conf.use_diagnostics_summary:
Expand Down
13 changes: 8 additions & 5 deletions setup/telescopes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3427,7 +3427,7 @@
'aprad_default': 5, # default aperture radius in px
'aprad_range': [2, 10], # [minimum, maximum] aperture radius (px)
'sex-config-file': rootpath+'/setup/pdo.sex',
'mask_file': {}, # mask files as a function of x,y binning
'mask_file': {}, # mask files as a function of x,y binning

# registration settings (Scamp)
'scamp-config-file': rootpath+'/setup/pdo.scamp',
Expand Down Expand Up @@ -3514,7 +3514,8 @@

# CS3-PDS-2-14N, 35cm SCT, STL-1001E
pds35cmstl1001e_param = {
'telescope_instrument': 'CS3-PDS-2-14N 35cm SCT/STL-1001E', # telescope/instrument name
# telescope/instrument name
'telescope_instrument': 'CS3-PDS-2-14N 35cm SCT/STL-1001E',
'telescope_keyword': 'PDS35CMSTL1001E', # telescope/instrument keyword
'observatory_code': 'U82', # MPC observatory code
'secpix': (1.48, 1.48), # pixel size (arcsec) before binning
Expand Down Expand Up @@ -3549,7 +3550,7 @@
'aprad_default': 5, # default aperture radius in px
'aprad_range': [2, 10], # [minimum, maximum] aperture radius (px)
'sex-config-file': rootpath+'/setup/pds.sex',
'mask_file': {}, # mask files as a function of x,y binning
'mask_file': {}, # mask files as a function of x,y binning

# registration settings (Scamp)
'scamp-config-file': rootpath+'/setup/pds.scamp',
Expand Down Expand Up @@ -3606,6 +3607,7 @@
'E2V CCD-231 4096x4112': 'LOWELL42',
'PRISM Instrument': 'LOWELL72',
'Prism 2048x2048 CCD': 'LOWELL72',
'prism': 'LOWELL72',
'cfccd': 'CTIO09',
'Y4KCam': 'CTIO10',
'ANDICAM-CCD': 'CTIO13CCD',
Expand Down Expand Up @@ -3654,9 +3656,10 @@
'DFOSC_FASU': 'DFOSC',
'loneos': 'LONEOS',
'25cm f/6.3 SCT_SBIG ST-8': 'PDO25CMF63ST8',
'0.5m f/8.1 Ritchey-Chretien_FLI KAF1001E': 'PDO05F81KAF1001E',
'0.5m f/8.1 Ritchey-Chretien_FLI KAF1001E':
'PDO05F81KAF1001E',
'0.35-m SCT_STL-1001E': 'PDS35CMSTL1001E',
}
}

# translate telescope keyword into parameter set defined here
telescope_parameters = {'VATT4K': vatt4k_param,
Expand Down

0 comments on commit 7715d63

Please sign in to comment.