Skip to content

Commit

Permalink
implemented -solar option
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Mommert committed Nov 24, 2017
1 parent b95b7b1 commit ec8517a
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 24 deletions.
7 changes: 7 additions & 0 deletions _pp_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ def setup_diagnostics():
# photometric calibration
minstars = 0.5

# solar color margin
# solar color filtering allows for color indices
# [color-_pp_conf.solcol -- color+_pp_conf.solcol]
solcol = 0.2


# photometry flavor ['APER', 'ISOCOR', 'AUTO']
photmode = 'APER'
## don't change this unless you understand what you are doing

13 changes: 5 additions & 8 deletions catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -943,8 +943,7 @@ def transform_filters (self, targetfilter):
### SDSS to BVRI
### transformations based on Chonis & Gaskell 2008, AJ, 135
if (('SDSS' in self.catalogname) and
(targetfilter in {'B', 'V', 'R', 'I'}) and
(self.magsystem == 'AB')):
(targetfilter in {'B', 'V', 'R', 'I'})):

logging.info(('trying to transform %d SDSS sources to ' \
+ '%s') % (self.shape[0], targetfilter))
Expand Down Expand Up @@ -1193,9 +1192,8 @@ def transform_filters (self, targetfilter):
return self.shape[0]

# PANSTARRS to BVRI
elif (self.catalogname == 'PANSTARRS' and
targetfilter in ['B', 'V', 'R', 'I'] and
self.magsystem == 'AB'):
elif ('PANSTARRS' in self.catalogname and
targetfilter in ['B', 'V', 'R', 'I']):

logging.info(('trying to transform %d PANSTARRS sources to ' \
+ '%s') % (self.shape[0], targetfilter))
Expand Down Expand Up @@ -1243,9 +1241,8 @@ def transform_filters (self, targetfilter):
return self.shape[0]

# PANSTARRS to Sloan griz
elif (self.catalogname == 'PANSTARRS' and
targetfilter in ['g', 'r', 'i', 'z'] and
self.magsystem == 'AB'):
elif ('PANSTARRS' in self.catalogname and
targetfilter in ['g', 'r', 'i', 'z']):

logging.info(('trying to transform %d PANSTARRS sources to ' \
+ '%s') % (self.shape[0], targetfilter))
Expand Down
4 changes: 4 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Changelog

Major changes to the pipeline since 2016-10-01 (see `Mommert 2017`_) are documented here.

* 2017-11-24: implementation of `-solar` option in ``pp_run`` and
``pp_calibrate`` to obtain photometric calibration only from stars
with Sun-like colors

* 2017-10-20: implementation of ``pp_stackedphotometry``, providing
automated image stacking and subsequent photometry

Expand Down
18 changes: 14 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], images)
.. function:: pp_run ([-prefix string], [-target string], [-filter string], [-fixed_aprad float], [-solar], images)

serves as a wrapper for all the individual pipeline processes

Expand All @@ -23,8 +23,9 @@ below. All functions presented here can be called from the terminal.
level at which sources are rejected in
the image registration process; see
: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)
: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 Expand Up @@ -229,7 +230,7 @@ the logical order:
the measured FWHMs.


.. function:: pp_calibrate ([-minstars int/float], [-catalog string], [-filter string], [-maxflag integer], [-instrumental], images)
.. function:: pp_calibrate ([-minstars int/float], [-catalog string], [-filter string], [-maxflag integer], [-instrumental], [-solar], images)

photometric calibration of each input frame in one specific filter

Expand Down Expand Up @@ -262,6 +263,15 @@ the logical order:
calibration process is skipped entirely and
instrumental magnitudes are written to the
photometry database for each image
:param -solar: only use stars with solar-like colors; use this
feature for photometry of Solar System
bodies. Solar-like stars are selected based on their
`g-i` and `r-i` colors, hence, this feature is
currently only available for photometric calibration
using the PANSTARRS, APASS, and SDSS catalogs. The
threshold of solar-like colors is defined by the
`_pp_conf.solcol` parameter; the default is the
actual color index +- 0.2 mag.
:param images: images to run `pp_calibrate` on


Expand Down
60 changes: 51 additions & 9 deletions pp_calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def create_photometrycatalog(ra_deg, dec_deg, rad_deg, filtername,
preferred_catalogs,
min_sources=_pp_conf.min_sources_photometric_catalog,
max_sources=1e4, mag_accuracy=0.1,
display=False):
solar=False, display=False):
"""create a photometric catalog of the field of view"""

for catalogname in preferred_catalogs:
Expand All @@ -74,14 +74,51 @@ def create_photometrycatalog(ra_deg, dec_deg, rad_deg, filtername,
print(n_sources, 'sources downloaded from', catalogname)
if n_sources < min_sources:
continue

if 'URAT' in catalogname:
print(catalogname + ' should only be used as an astrometric '
'catalog; please use APASS9 instead')
logging.error(catalogname + ' should only be used as an '
'astrometric catalog; please use APASS9 instead')
return None

# reject non-solar colors, if requested by user
if solar:
sol_gr = 0.44 # g-r
sol_ri = 0.11 # r-i
n_rejected = 0
n_raw = cat.shape[0]
if ('SDSS' in cat.catalogname or
'APASS' in cat.catalogname):
n_rejected += cat.reject_sources_with(
(cat['gmag']-cat['rmag']) < sol_gr-_pp_conf.solcol)
n_rejected += cat.reject_sources_with(
(cat['gmag']-cat['rmag']) > sol_gr+_pp_conf.solcol)
n_rejected += cat.reject_sources_with(
(cat['rmag']-cat['imag']) < sol_ri-_pp_conf.solcol)
n_rejected += cat.reject_sources_with(
(cat['rmag']-cat['imag']) > sol_ri+_pp_conf.solcol)
elif 'PANSTARRS' in cat.catalogname:
cat.transform_filters('g') # derive Sloan griz
n_rejected += cat.reject_sources_with(
(cat['_gmag']-cat['_rmag']) <sol_gr-_pp_conf.solcol)
n_rejected += cat.reject_sources_with(
(cat['_gmag']-cat['_rmag']) >sol_gr+_pp_conf.solcol)
n_rejected += cat.reject_sources_with(
(cat['_rmag']-cat['_imag']) <sol_ri-_pp_conf.solcol)
n_rejected += cat.reject_sources_with(
(cat['_rmag']-cat['_imag']) >sol_ri+_pp_conf.solcol)
else:
if display:
print('Warning: solar colors not supported for catalog',
cat.catalogname)
logging.warning(('Warning: solar colors not supported ' +
'for catalog'), cat.catalogname)
if display:
print('%d/%d sources left with solar-like colors' %
(n_raw-n_rejected, n_raw))
logging.info('%d/%d sources left with solar-like colors' %
(n_raw-n_rejected, n_raw))

# transform catalog to requested filtername, if necessesary
if ( n_sources > 0 and
Expand Down Expand Up @@ -131,7 +168,7 @@ def create_photometrycatalog(ra_deg, dec_deg, rad_deg, filtername,
logging.info('less than %d sources (%d), try other catalog' %
(min_sources, n_sources))
continue

# end up here if none of the catalogs has n_sources > min_sources
if display:
print('ERROR: not enough sources in reference catalog %s (%d)' % \
Expand Down Expand Up @@ -346,7 +383,8 @@ def derive_zeropoints(ref_cat, catalogs, filtername, minstars_external,

def calibrate(filenames, minstars, manfilter, manualcatalog,
obsparam, maxflag=3,
magzp=None, display=False, diagnostics=False):
magzp=None, solar=False,
display=False, diagnostics=False):
"""
wrapper for photometric calibration
"""
Expand Down Expand Up @@ -420,10 +458,9 @@ def calibrate(filenames, minstars, manfilter, manualcatalog,
if filtername is not None and magzp is None:
ref_cat = create_photometrycatalog(ra_deg, dec_deg, rad_deg,
filtername, preferred_catalogs,
max_sources=2e4, display=display)
else:
ref_cat = None

max_sources=2e4, solar=solar,
display=display)

if ref_cat == None:
if magzp == None:
print('Skip calibration - report instrumental magnitudes')
Expand Down Expand Up @@ -542,6 +579,9 @@ def calibrate(filenames, minstars, manfilter, manualcatalog,
parser.add_argument('-magzp', help=('provide external magnitude zeropoint' +
' and uncertainty'),
nargs=2)
parser.add_argument('-solar',
help='restrict to solar-color stars',
action="store_true", default=False)
parser.add_argument('images', help='images to process', nargs='+')
args = parser.parse_args()
minstars = float(args.minstars)
Expand All @@ -550,6 +590,7 @@ def calibrate(filenames, minstars, manfilter, manualcatalog,
manualcatalog = args.cat
instrumental = args.instrumental
man_magzp = args.magzp
solar = args.solar
filenames = args.images

# manfilter: None: instrumental magnitudes, False: no manfilter provided
Expand Down Expand Up @@ -580,7 +621,8 @@ def calibrate(filenames, minstars, manfilter, manualcatalog,

calibration = calibrate(filenames, minstars, manfilter,
manualcatalog, obsparam, maxflag=maxflag,
magzp=man_magzp, display=True, diagnostics=True)
magzp=man_magzp, solar=solar,
display=True, diagnostics=True)



Expand Down
11 changes: 8 additions & 3 deletions pp_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@


def run_the_pipeline(filenames, man_targetname, man_filtername,
fixed_aprad, source_tolerance):
fixed_aprad, source_tolerance, solar):
"""
wrapper to run the photometry pipeline
"""
Expand Down Expand Up @@ -280,7 +280,8 @@ def run_the_pipeline(filenames, man_targetname, man_filtername,
print('\n----- run photometric calibration\n')

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

# if calibration == None:
Expand Down Expand Up @@ -354,6 +355,9 @@ def run_the_pipeline(filenames, man_targetname, man_filtername,
help='tolerance on source properties for registration',
choices=['none', 'low', 'medium', 'high'],
default='high')
parser.add_argument('-solar',
help='restrict to solar-color stars',
action="store_true", default=False)
parser.add_argument('images', help='images to process or \'all\'',
nargs='+')

Expand All @@ -363,6 +367,7 @@ def run_the_pipeline(filenames, man_targetname, man_filtername,
man_filtername = args.filter
fixed_aprad = float(args.fixed_aprad)
source_tolerance = args.source_tolerance
solar = args.solar
filenames = args.images


Expand Down Expand Up @@ -407,7 +412,7 @@ def run_the_pipeline(filenames, man_targetname, man_filtername,
else:
# call run_the_pipeline only on filenames
run_the_pipeline(filenames, man_targetname, man_filtername,
fixed_aprad, source_tolerance)
fixed_aprad, source_tolerance, solar)
pass


Expand Down

0 comments on commit ec8517a

Please sign in to comment.