Skip to content

Commit

Permalink
added LOWELL42SITE
Browse files Browse the repository at this point in the history
  • Loading branch information
mommermi committed Mar 26, 2018
1 parent 399a60b commit 7bc965c
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 41 deletions.
2 changes: 1 addition & 1 deletion _pp_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
except ImportError:
print('Module numpy not found. Please install with: pip install numpy')
sys.exit()

# import pipeline-specific modules
from toolbox import *

Expand Down
2 changes: 2 additions & 0 deletions doc/supported.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ observatories/instruments:
+--------------------------+--------------------+----------------+
| Lowell 42" | NASA42 | LOWELL42 |
+--------------------------+--------------------+----------------+
| Lowell 42" | SITE | LOWELL42SITE |
+--------------------------+--------------------+----------------+
| Magellan | IMACS | MAGIMACS |
+--------------------------+--------------------+----------------+
| Observatoire Haute- | CCD | OHP120 |
Expand Down
41 changes: 19 additions & 22 deletions pp_prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,19 @@
import os
import re
import sys
import shutil
import logging
import subprocess
import argparse
import shlex
import time
try:
import callhorizons
except ImportError:
print('Module callhorizons not found. Please install with: pip install '
'callhorizons')
sys.exit()
#try:
# import callhorizons
#except ImportError:
# print('Module callhorizons not found. Please install with: pip install '
# 'callhorizons')
# sys.exit()
from astropy.io import fits

# pipeline-specific modules
import _pp_conf
from catalog import *
import pp_extract
import diagnostics as diag
import toolbox

Expand Down Expand Up @@ -101,7 +96,7 @@ def prepare(filenames, obsparam, header_update, keep_wcs=False,
'extract individual extensions and run them '
'individually.')
sys.exit()

# keywords that have to be implanted into each image
implants = {}

Expand Down Expand Up @@ -225,7 +220,7 @@ def prepare(filenames, obsparam, header_update, keep_wcs=False,
header['PHOTFLAG'] = ('F', 'PP: data is not photometric (SCAMP)')
header['PHOT_K'] = (0.05, 'PP: assumed extinction coefficient')


if not keep_wcs:

# remove keywords that might collide with fake wcs
Expand Down Expand Up @@ -262,7 +257,7 @@ def prepare(filenames, obsparam, header_update, keep_wcs=False,
header['CUNIT2'] = ('deg')
except KeyError:
pass

# if GENERIC telescope, add implants to header
if obsparam['telescope_keyword'] is 'GENERIC':
for key, val in list(implants.items()):
Expand All @@ -277,7 +272,7 @@ def prepare(filenames, obsparam, header_update, keep_wcs=False,
header['SECPIXY'] = (obsparam['secpix'][1]*binning[1],
'PP: y pixscale after binning')

# create observation midtime jd
# create observation midtime jd
if not keep_wcs or 'MIDTIMJD' not in header:
if obsparam['date_keyword'].find('|') == -1:
header['MIDTIMJD'] = \
Expand All @@ -297,6 +292,8 @@ def prepare(filenames, obsparam, header_update, keep_wcs=False,
'PP: tel/instr name')
header['TEL_KEYW'] = (obsparam['telescope_keyword'],
'PP: tel/instr keyword')

header[obsparam['filter']] = header[obsparam['filter']].strip()
header['FILTER'] = (header[obsparam['filter']], 'PP:copied')
header['EXPTIME'] = (header[obsparam['exptime']], 'PP: copied')
if obsparam['airmass'] in header:
Expand All @@ -315,7 +312,7 @@ def prepare(filenames, obsparam, header_update, keep_wcs=False,
header['FILTER'] = (header[obsparam['filter']], 'PP:copied')



# perform header update
for key, value in list(header_update.items()):
if key in header:
Expand All @@ -328,7 +325,7 @@ def prepare(filenames, obsparam, header_update, keep_wcs=False,
header['OBJECT'] = 'None'
elif len(header['OBJECT'].strip()) == 0:
header['OBJECT'] = 'None'

# # check if RA, Dec, airmass headers are available;
# # else: query horizons
# # to get approximate information
Expand Down Expand Up @@ -364,7 +361,7 @@ def prepare(filenames, obsparam, header_update, keep_wcs=False,

# add fake wcs information that is necessary to run SCAMP


# read out ra and dec from header
if obsparam['radec_separator'] == 'XXX':
ra_deg = float(header[obsparam['ra']])
Expand Down Expand Up @@ -395,7 +392,7 @@ def prepare(filenames, obsparam, header_update, keep_wcs=False,
ra_deg = coo.ra.deg
dec_deg = coo.dec.deg
header['EQUINOX'] = (2000.0, 'PP: normalized to ICRS')

if man_ra is not None and man_dec is not None:
ra_deg = float(man_ra)
dec_deg = float(man_dec)
Expand All @@ -410,7 +407,7 @@ def prepare(filenames, obsparam, header_update, keep_wcs=False,
except KeyError:
# JITTER keywords not in combined images
pass

# apply flips
xnorm, ynorm = 1, 1
if this_flipx:
Expand Down Expand Up @@ -460,7 +457,7 @@ def prepare(filenames, obsparam, header_update, keep_wcs=False,
'%s %s') % (obsparam['distort']['functionof'],
header[obsparam['distort']
['functionof']]))

header['CD1_1'] = (xnorm * numpy.cos(this_rotate/180.*numpy.pi) *
obsparam['secpix'][0]*binning[0]/3600.,
'PP: fake Coordinate matrix')
Expand Down Expand Up @@ -561,7 +558,7 @@ def prepare(filenames, obsparam, header_update, keep_wcs=False,
telescope = 'GENERIC'

obsparam = _pp_conf.telescope_parameters[telescope]

header_update = {}
if man_target is not None:
header_update[obsparam['object']] = man_target
Expand Down
76 changes: 73 additions & 3 deletions setup/telescopes.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,74 @@
'photometry_catalogs' : ['SDSS-R9', 'APASS9', 'PANSTARRS', '2MASS']
}

# Lowell42, SITE
lowell42site_param = {
'telescope_instrument' : 'Lowell42/SITE', # telescope/instrument name
'telescope_keyword' : 'LOWELL42SITE', # telescope/instrument keyword
'observatory_code' : '688', # MPC observatory code
'secpix' : (0.6, 0.6), # pixel size (arcsec)
# before binning
'ext_coeff' : 0.05, # typical extinction coefficient


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

# instrument-specific FITS header keywords
'binning' : ('CCDSUM#blank1', 'CCDSUM#blank2'),
# binning in x/y, '_blankN' denotes that both axes
# are listed in one keyword, sep. by blanks
'extent' : ('NAXIS1', 'NAXIS2'), # N_pixels in x/y
'ra' : 'RA', # telescope pointing, RA
'dec' : 'DEC', # telescope pointin, Dec
'radec_separator' : ':', # RA/Dec hms separator, use 'XXX'
# if already in degrees
'date_keyword' : 'DATE-OBS|UT', # 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' : 'FILTNAME', # filter keyword
'filter_translations' : {'R': 'R', 'I': 'I', 'V': 'V'},
# 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/lowell42.sex',
'mask_file' : {},
# mask files as a function of x,y binning

# registration settings (Scamp)
'scamp-config-file' : rootpath+'/setup/lowell42.scamp',
'reg_max_mag' : 19,
'reg_search_radius' : 0.5, # deg
'source_tolerance': 'high',

# swarp settings
'copy_keywords' : ('TELESCOP,INSTRUME,CCDSUM,FILTNAME,EXPTIME,'+
'OBJECT,' +
'DATE-OBS,UT,RA,DEC,PIXSCAL,AIRMASS,' +
'TEL_KEYW'),
# keywords to be copied in image
# combination using swarp
'swarp-config-file' : rootpath+'/setup/lowell42.swarp',

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


# Lowell72 (Perkins), PRISM
lowell72_param = {
Expand Down Expand Up @@ -2136,7 +2204,7 @@
#'SL74SAH',
'TNGDOLORES', 'GENERIC', 'KPNO4MOS1', 'FROST',
'MEXMAN', 'KPNO4MOS1', 'KPNOMOS3',
'KPNO4NEWF', 'UKIRTWFCAM', 'VLTFORS2']
'KPNO4NEWF', 'UKIRTWFCAM', 'VLTFORS2', 'LOWELL42SITE']

# translate INSTRUME (or others, see _pp_conf.py) header keyword into
# PP telescope keyword
Expand Down Expand Up @@ -2179,7 +2247,8 @@
'WFCAM': 'UKIRTWFCAM',
'SIRIUS': 'IRSFSIRIUS',
'Goodman Spectro': 'SOARGOODMAN',
'FORS2': 'VLTFORS2'
'FORS2': 'VLTFORS2',
'2:1 f/17 direct' : 'LOWELL42SITE'
}

# translate telescope keyword into parameter set defined here
Expand Down Expand Up @@ -2215,7 +2284,8 @@
'KPNO4NEWF': kpno4newf_param,
'UKIRTWFCAM': ukirtwfcam_param,
'IRSFSIRIUS': irsfsirius_param,
'VLTFORS2': vltfors2_param
'VLTFORS2': vltfors2_param,
'LOWELL42SITE': lowell42site_param
}


Expand Down
35 changes: 20 additions & 15 deletions toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"""
from __future__ import print_function
from __future__ import division
# Photometry Pipeline

# Photometry Pipeline
# Copyright (C) 2016 Michael Mommert, michael.mommert@nau.edu

# This program is free software: you can redistribute it and/or modify
Expand All @@ -28,7 +28,7 @@
except ImportError:
print('Module future not found. Please install with: pip install future')
sys.exit()

import math
import numpy

Expand All @@ -42,18 +42,18 @@
##### TIME AND DATE

def jd_to_gregorian(jd, is_mjd=False):
""" convert a julian date into a gregorian data """
""" convert a julian date into a gregorian data """
if is_mjd:
mjd = jd
else:
mjd = jd -2400000.5

MJD0 = 2400000.5 # 1858 November 17, 00:00:00 hours
MJD0 = 2400000.5 # 1858 November 17, 00:00:00 hours

modf = math.modf
a = int(mjd+MJD0+0.5)
b = int(old_div((a-1867216.25),36524.25))
c = a+ b - int(modf(old_div(b,4))[1]) + 1525
c = a+ b - int(modf(old_div(b,4))[1]) + 1525

d = int(old_div((c-122.1),365.25))
e = 365*d + int(modf(old_div(d,4))[1])
Expand All @@ -80,6 +80,11 @@ def dateobs_to_jd(date):
date = date.split(' ')
time = date[1].split(':')
date = date[0].split('-')

# check if date is yyyy-mm-dd or dd-mm-yyyy
if len(date[2]) == 4 and len(date[0]) < 3:
date = date[::-1]

a = (14 - float(date[1]))//12
y = float(date[0]) + 4800 - a
m = float(date[1]) + 12*a - 3
Expand All @@ -89,7 +94,7 @@ def dateobs_to_jd(date):


def jd_to_fractionalyear(jd, is_mjd=False):
""" convert a julian date into a fractional year, e.g., 2000.123456 """
""" convert a julian date into a fractional year, e.g., 2000.123456 """
if is_mjd:
jd += 2400000.5
date = jd_to_gregorian(jd)
Expand All @@ -98,7 +103,7 @@ def jd_to_fractionalyear(jd, is_mjd=False):


def fractionalyear_to_jd(date):
""" convert a fractional year into a julian date """
""" convert a fractional year into a julian date """
jd_jan1 = dateobs_to_jd('%4d-01-01T00:00:00' % math.floor(date))
return jd_jan1 + 365*(date-math.floor(date))

Expand Down Expand Up @@ -129,7 +134,7 @@ def read_scamp_output():
for item in line:
if len(item.strip()) > 0 and item.find('\n') == -1:
this_data.append(item)
### control reading
### control reading
# activate reading
if not read_this and \
raw[idx].find('<TABLE ID="Fields" name="Fields">') > -1:
Expand All @@ -138,14 +143,14 @@ def read_scamp_output():
if read_this and raw[idx].find('</TABLEDATA></DATA>') > -1:
read_this = False
idx += 1

# check if data rows have same length as header
abort = False
for i in range(len(data)):
if len(headers) != len(data[i]):
raise (RuntimeError,
('data and header lists from SCAMP output file have '
'different lengths for image %s; do the FITS files have the '
('data and header lists from SCAMP output file have '
'different lengths for image %s; do the FITS files have the '
'OBJECT keyword populated?') % data[i][headers['Catalog_Name']])
return (headers, data)

Expand Down Expand Up @@ -189,19 +194,19 @@ def skycenter(catalogs, ra_key='ra.deg', dec_key='dec.deg'):
"""derive center position and radius from catalogs"""
from astropy.coordinates import SkyCoord
from astropy import units as u

min_ra = min([numpy.min(cat[ra_key]) for cat in catalogs])
max_ra = max([numpy.max(cat[ra_key]) for cat in catalogs])
min_dec = min([numpy.min(cat[dec_key]) for cat in catalogs])
max_dec = max([numpy.max(cat[dec_key]) for cat in catalogs])

ra, dec = (max_ra+min_ra)/2, (max_dec+min_dec)/2

lower_left= SkyCoord(ra=min_ra, dec=min_dec, frame='icrs', unit='deg')
upper_right = SkyCoord(ra=max_ra, dec=max_dec, frame='icrs', unit='deg')

rad = lower_left.separation(upper_right).deg/2

return ra, dec, rad


Expand Down

0 comments on commit 7bc965c

Please sign in to comment.