Skip to content

Commit

Permalink
ZTFMOSAIC implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
mommermi committed Nov 6, 2019
1 parent 6e7077c commit b7ad371
Show file tree
Hide file tree
Showing 8 changed files with 509 additions and 47 deletions.
7 changes: 3 additions & 4 deletions doc/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Functions
The individual pipeline functions are introduced and explained
below. All functions presented here can be called from the terminal.

.. function:: pp_run ([-prefix string], [-target string], [-filter string], [-fixed_aprad float], [-solar], images)
.. function:: pp_run ([-prefix string], [-target string], [-filter string], [-fixed_aprad float], [-solar], [-rerun_registration], [-asteroids], [-keep_wcs], images)

serves as a wrapper for all the individual pipeline processes

Expand Down Expand Up @@ -35,9 +35,8 @@ below. All functions presented here can be called from the terminal.
all frames registered successfull during
the first try.
:param -asteroids: (optional) make use of ``-asteroids`` option of
:func:`pp_distill`
:param -filter: (optional) make use of ``-filter`` option of
:func:`pp_distill`, default: ``pos``
:func:`pp_distill`
:param -keep_wcs: (optional) skip registration and keep wcs information
:param images: images on which the pipeline is supposed to run,
wildcard symbols (``'*'``, ``'?'``) can be used; or,
by using ``all``, PP runs on all FITS files in
Expand Down
6 changes: 6 additions & 0 deletions doc/supported.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ observatories/instruments:
+--------------------------+--------------------+----------------+
| WIYN 0.9m | Half Degree Imager | WIYN09HDI |
+--------------------------+--------------------+----------------+
| ZTF | Mosaic (***) | ZTFMOSAIC |
+--------------------------+--------------------+----------------+
| Generic Telescope | any | GENERIC |
+--------------------------+--------------------+----------------+

Expand All @@ -117,6 +119,10 @@ keywords ``PARAM0``, ``PARAM61``, ``PARAM62``, and ``PARAM63`` prior
to running PP, e.g., using the ``delhead`` command provided by
`WCSTools`_.

(***): wcs provided with telescope data is usually excellent; in this case
I suggest skipping registration and to use ``pp_run`` with the
``-keep_wcs`` option.
It is recommended to stitch images from cameras with multiple amplifiers
together using the correct orientations.

Expand Down
9 changes: 8 additions & 1 deletion pp_prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ def prepare(filenames, obsparam, header_update, keep_wcs=False,
# add header keywords for Source Extractor
if 'EPOCH' not in header:
header['EPOCH'] = (2000, 'PP: required for registration')
elif int(header['EPOCH']) < 1950:
header['EPOCH'] = (2000, 'PP: required for registration')

# add header keywords for SCAMP
header['PHOTFLAG'] = ('F', 'PP: data is not photometric (SCAMP)')
Expand Down Expand Up @@ -264,11 +266,15 @@ def prepare(filenames, obsparam, header_update, keep_wcs=False,

# create observation midtime jd
if not keep_wcs or 'MIDTIMJD' not in header:
if obsparam['date_keyword'].find('|') == -1:
if ('|' not in obsparam['date_keyword'] and
'JD' not in obsparam['date_keyword']):
header['MIDTIMJD'] = \
(toolbox.dateobs_to_jd(header[obsparam['date_keyword']]) +
float(header[obsparam['exptime']])/2./86400.,
'PP: obs midtime')
elif 'JD' in obsparam['date_keyword']:
header['MIDTIMJD'] = (header[obsparam['date_keyword']],
'PP: obs midtime')
else:
datetime = (header[obsparam['date_keyword'].split('|')[0]] +
'T' + header[obsparam['date_keyword'].split('|')[1]])
Expand Down Expand Up @@ -338,6 +344,7 @@ def prepare(filenames, obsparam, header_update, keep_wcs=False,
# transform to equinox J2000, if necessary
if 'EQUINOX' in header:
equinox = float(header['EQUINOX'])
header['EQUINOX'] = equinox
if equinox != 2000.:
anyeq = SkyCoord(ra=ra_deg*u.deg, dec=dec_deg*u.deg,
frame=FK5,
Expand Down
84 changes: 45 additions & 39 deletions pp_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

def run_the_pipeline(filenames, man_targetname, man_filtername,
fixed_aprad, source_tolerance, solar,
rerun_registration, asteroids):
rerun_registration, asteroids, keep_wcs):
"""
wrapper to run the photometry pipeline
"""
Expand Down Expand Up @@ -180,48 +180,50 @@ def run_the_pipeline(filenames, man_targetname, man_filtername,
# prepare fits files for photometry pipeline
preparation = pp_prepare.prepare(filenames, obsparam,
change_header,
diagnostics=True, display=True)
diagnostics=True, display=True,
keep_wcs=keep_wcs)

# run wcs registration

# default sextractor/scamp parameters
snr, source_minarea = obsparam['source_snr'], obsparam['source_minarea']
aprad = obsparam['aprad_default']

registration_run_number = 0
while True:

print('\n----- run image registration\n')
registration = pp_register.register(filenames, telescope, snr,
source_minarea, aprad,
None, obsparam,
obsparam['source_tolerance'],
False,
display=True,
diagnostics=True)

if len(registration['badfits']) == len(filenames):
summary_message = "<FONT COLOR=\"red\">registration failed</FONT>"
elif len(registration['goodfits']) == len(filenames):
summary_message = "<FONT COLOR=\"green\">all images registered" + \
"</FONT>; "
break
else:
summary_message = "<FONT COLOR=\"orange\">registration failed for " + \
("%d/%d images</FONT>; " %
(len(registration['badfits']),
len(filenames)))
# break from loop if maximum number of iterations (2) achieved
registration_run_number += 1
if registration_run_number == 2:
break
if not keep_wcs:
# default sextractor/scamp parameters
snr, source_minarea = obsparam['source_snr'], obsparam['source_minarea']
aprad = obsparam['aprad_default']

registration_run_number = 0
while True:

print('\n----- run image registration\n')
registration = pp_register.register(filenames, telescope, snr,
source_minarea, aprad,
None, obsparam,
obsparam['source_tolerance'],
False,
display=True,
diagnostics=True)

if len(registration['badfits']) == len(filenames):
summary_message = "<FONT COLOR=\"red\">registration failed</FONT>"
elif len(registration['goodfits']) == len(filenames):
summary_message = "<FONT COLOR=\"green\">all images registered" + \
"</FONT>; "
break
else:
summary_message = "<FONT COLOR=\"orange\">registration failed for " + \
("%d/%d images</FONT>; " %
(len(registration['badfits']),
len(filenames)))
# break from loop if maximum number of iterations (2) achieved
registration_run_number += 1
if registration_run_number == 2:
break

# add information to summary website, if requested
if _pp_conf.use_diagnostics_summary:
diag.insert_into_summary(summary_message)
# add information to summary website, if requested
if _pp_conf.use_diagnostics_summary:
diag.insert_into_summary(summary_message)

# in case not all image were registered successfully
filenames = registration['goodfits']
# in case not all image were registered successfully
filenames = registration['goodfits']

# stop here if registration failed for all images
if len(filenames) == 0:
Expand Down Expand Up @@ -370,6 +372,9 @@ def run_the_pipeline(filenames, man_targetname, man_filtername,
parser.add_argument('-reject',
help='schemas for target rejection',
nargs=1, default='pos')
parser.add_argument('-keep_wcs',
help='keep wcs information and skip registration',
action="store_true", default=False)
parser.add_argument('images', help='images to process or \'all\'',
nargs='+')

Expand All @@ -383,6 +388,7 @@ def run_the_pipeline(filenames, man_targetname, man_filtername,
rerun_registration = args.rerun_registration
asteroids = args.asteroids
rejectionfilter = args.reject
keep_wcs = args.keep_wcs
filenames = sorted(args.images)

# if filenames = ['all'], walk through directories and run pipeline
Expand Down Expand Up @@ -426,5 +432,5 @@ def run_the_pipeline(filenames, man_targetname, man_filtername,
# call run_the_pipeline only on filenames
run_the_pipeline(filenames, man_targetname, man_filtername,
fixed_aprad, source_tolerance, solar,
rerun_registration, asteroids)
rerun_registration, asteroids, keep_wcs)
pass
59 changes: 56 additions & 3 deletions setup/telescopes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3909,6 +3909,57 @@
'photometry_catalogs': ['PANSTARRS', 'SDSS-R9', 'APASS9']
}

ztfmosaic_param = {
'telescope_instrument': 'ZTF/MOSAIC', # telescope/instrument name
'telescope_keyword': 'ZTFMOSAIC', # telescope/instrument keyword
'observatory_code': 'I41', # MPC observatory code
'secpix': (1.012, 1.012), # pixel size (arcsec) before binning

# image orientation preferences
'flipx': True,
'flipy': False,
'rotate': 0,

# instrument-specific FITS header keywords
'binning': ('CCDSUM#blank0', 'CCDSUM#blank1'), # binning in x/y
'extent': ('NAXIS1', 'NAXIS2'), # N_pixels in x/y
'ra': 'OBJRAD', # telescope pointing, RA
'dec': 'OBJDECD', # telescope pointin, Dec
'radec_separator': 'XXX', # RA/Dec hms separator, use 'XXX'
# if already in degrees
'date_keyword': 'OBSJD', # obs date/time
# keyword; use
# 'date|time' if
# separate
'obsmidtime_jd': 'MIDTIMJD', # obs midtime jd keyword
# (usually provided by
# pp_prepare
'object': 'OBJECT', # object name keyword
'filter': 'FILTER', # filter keyword
'filter_translations': {'ZTF_g': 'g', 'ZTF_r': 'r'},
# filtername translation dictionary
'exptime': 'EXPTIME', # exposure time keyword (s)
'airmass': 'AIRMASS', # airmass keyword

# source extractor settings
'source_minarea': 12, # default sextractor source minimum N_pixels
'source_snr': 3, # default sextractor source snr for registration
'aprad_default': 5, # default aperture radius in px
'aprad_range': [2, 10], # [minimum, maximum] aperture radius (px)
'sex-config-file': rootpath + '/setup/ztfmosaic.sex',
'mask_file': {},
# mask files as a function of x,y binning

# scamp settings
'scamp-config-file': rootpath + '/setup/ztfmosaic.scamp',
'reg_max_mag': 19,
'reg_search_radius': 0.1, # deg
'source_tolerance': 'high',

# default catalog settings
'astrometry_catalogs': ['GAIA'],
'photometry_catalogs': ['PANSTARRS', 'SDSS-R9']
}

# access functions for telescope configurations

Expand All @@ -3931,7 +3982,8 @@
'LCOSPECFS01', 'P60OPT', 'P60SEDM', 'GMOSN',
'DFOSC', 'LONEOS', 'PDO25CMF63ST8', 'PDO05F81KAF1001E',
'PDS35CMSTL1001E', 'MMTCAM', 'MAGLDSS3',
'SL40IN', 'STEWARD90SCC', 'STRUVECQUEAN']
'SL40IN', 'STEWARD90SCC', 'STRUVECQUEAN',
'ZTFMOSAIC']

# translate INSTRUME (or others, see _pp_conf.py) header keyword into
# PP telescope keyword
Expand Down Expand Up @@ -4004,7 +4056,8 @@
'LDSS3-C': 'MAGLDSS3',
'Finger Lakes Instr. ProLine Model PL23042, S/N PL0101015':
'STEWARD90SCC',
'2.1m Otto Struve': 'STRUVECQUEAN'}
'2.1m Otto Struve': 'STRUVECQUEAN',
'ZTF/MOSAIC': 'ZTFMOSAIC'}

# translate telescope keyword into parameter set defined here
telescope_parameters = {'VATT4K': vatt4k_param,
Expand Down Expand Up @@ -4065,7 +4118,7 @@
'SL40IN': sl40in_param,
'STEWARD90SCC': steward90scc_param,
'STRUVECQUEAN': struvecquean_param,
}
'ZTFMOSAIC': ztfmosaic_param}


# append mytelescopes.py, if available
Expand Down

0 comments on commit b7ad371

Please sign in to comment.