# Path: tkp/utility/coordinates.py
# CORE_LAT = 52.9088
# CORE_LON = -6.8689
# ITRF_X = 3826577.066110000
# ITRF_Y = 461022.947639000
# ITRF_Z = 5064892.786
# SECONDS_IN_HOUR = 60**2
# SECONDS_IN_DAY = 24 * SECONDS_IN_HOUR
#     FK4 = "B1950 (FK4)"
#     FK5 = "J2000 (FK5)"
#     ORIGIN = 1
#     WCS_ATTRS = ("crpix", "cdelt", "crval", "ctype", "cunit", "crota")
# def julian_date(time=None, modified=False):
# def mjd2datetime(mjd):
# def mjd2lst(mjd, position=None):
# def mjds2lst(mjds, position=None):
# def jd2lst(jd, position=None):
# def julian2unix(timestamp):
# def unix2julian(timestamp):
# def sec2deg(seconds):
# def sec2days(seconds):
# def sec2hms(seconds):
# def altaz(mjds, ra, dec, lat=CORE_LAT):
# def ratohms(radegs):
# def dectodms(decdegs):
# def propagate_sign(val1, val2, val3):
# def hmstora(rah, ram, ras):
# def dmstodec(decd, decm, decs):
# def angsep(ra1, dec1, ra2, dec2):
# def alphasep(ra1, ra2, dec1, dec2):
# def deltasep(dec1, dec2):
# def alpha(l, m, alpha0, delta0):
# def alpha_inflate(theta, decl):
# def delta(l, m, delta0):
# def l(ra, dec, cra, incr):
# def m(ra, dec, cra, cdec, incr):
# def lm_to_radec(ra0, dec0, l, m):
# def radec_to_lmn(ra0, dec0, ra, dec):
# def eq_to_gal(ra, dec):
# def gal_to_eq(lon_l, lat_b):
# def eq_to_cart(ra, dec):
# def coordsystem(name):
# def convert_coordsystem(ra, dec, insys, outsys):
#     def __init__(self):
#     def __setattr__(self, attrname, value):
#     def __getattr__(self, attrname):
#     def p2s(self, pixpos):
#     def s2p(self, spatialpos):
# class CoordSystem(object):
# class WCS(object):


import logging
import math
import numpy
    import ndimage
from UserDict import DictMixin
    from scipy import ndimage
from tkp.sourcefinder.deconv import deconv
from ..utility import coordinates
from ..utility.uncertain import Uncertain
from .gaussian import gaussian
from . import fitting
from . import utils
        self.end_smaj_x = (self.x.value - numpy.sin(self.theta.value) *
                      self.smaj.value)
        self.start_smaj_x = (self.x.value + numpy.sin(self.theta.value) *
                      self.smaj.value)
        self.end_smaj_y = (self.y.value + numpy.cos(self.theta.value) *
                      self.smaj.value)
        self.start_smaj_y = (self.y.value - numpy.cos(self.theta.value) *
                      self.smaj.value)
        self.end_smin_x = (self.x.value + numpy.cos(self.theta.value) *
                      self.smin.value)
        self.start_smin_x = (self.x.value - numpy.cos(self.theta.value) *
                      self.smin.value)
        self.end_smin_y = (self.y.value + numpy.sin(self.theta.value) *
                      self.smin.value)
        self.start_smin_y = (self.y.value - numpy.sin(self.theta.value) *
                      self.smin.value)

        # Fix negative ra values going into the database as this messes
        # up the source association step.
        self.ra.value = self.ra.value % 360.

        def pixel_to_spatial(x, y):
            try:
                return self.imagedata.wcs.p2s([x, y])
            except RuntimeError:
                logger.debug("pixel_to_spatial failed at %f, %f" % (x, y))
                return numpy.nan, numpy.nan
        end_smaj_ra, end_smaj_dec = pixel_to_spatial(self.end_smaj_x, self.end_smaj_y)
        end_smin_ra, end_smin_dec = pixel_to_spatial(self.end_smin_x, self.end_smin_y)


# Path: tkp/utility/coordinates.py
# CORE_LAT = 52.9088
# CORE_LON = -6.8689
# ITRF_X = 3826577.066110000
# ITRF_Y = 461022.947639000
# ITRF_Z = 5064892.786
# SECONDS_IN_HOUR = 60**2
# SECONDS_IN_DAY = 24 * SECONDS_IN_HOUR
#     FK4 = "B1950 (FK4)"
#     FK5 = "J2000 (FK5)"
#     ORIGIN = 1
#     WCS_ATTRS = ("crpix", "cdelt", "crval", "ctype", "cunit", "crota")
# def julian_date(time=None, modified=False):
# def mjd2datetime(mjd):
# def mjd2lst(mjd, position=None):
# def mjds2lst(mjds, position=None):
# def jd2lst(jd, position=None):
# def julian2unix(timestamp):
# def unix2julian(timestamp):
# def sec2deg(seconds):
# def sec2days(seconds):
# def sec2hms(seconds):
# def altaz(mjds, ra, dec, lat=CORE_LAT):
# def ratohms(radegs):
# def dectodms(decdegs):
# def propagate_sign(val1, val2, val3):
# def hmstora(rah, ram, ras):
# def dmstodec(decd, decm, decs):
# def angsep(ra1, dec1, ra2, dec2):
# def alphasep(ra1, ra2, dec1, dec2):
# def deltasep(dec1, dec2):
# def alpha(l, m, alpha0, delta0):
# def alpha_inflate(theta, decl):
# def delta(l, m, delta0):
# def l(ra, dec, cra, incr):
# def m(ra, dec, cra, cdec, incr):
# def lm_to_radec(ra0, dec0, l, m):
# def radec_to_lmn(ra0, dec0, ra, dec):
# def eq_to_gal(ra, dec):
# def gal_to_eq(lon_l, lat_b):
# def eq_to_cart(ra, dec):
# def coordsystem(name):
# def convert_coordsystem(ra, dec, insys, outsys):
#     def __init__(self):
#     def __setattr__(self, attrname, value):
#     def __getattr__(self, attrname):
#     def p2s(self, pixpos):
#     def s2p(self, spatialpos):
# class CoordSystem(object):
# class WCS(object):


# Path: tkp/sourcefinder/extract.py
import logging
import math
import numpy
    import ndimage
from UserDict import DictMixin
    from scipy import ndimage
from tkp.sourcefinder.deconv import deconv
from ..utility import coordinates
from ..utility.uncertain import Uncertain
from .gaussian import gaussian
from . import fitting
from . import utils

        self.end_smaj_x = (self.x.value - numpy.sin(self.theta.value) *
                      self.smaj.value)
        self.start_smaj_x = (self.x.value + numpy.sin(self.theta.value) *
                      self.smaj.value)
        self.end_smaj_y = (self.y.value + numpy.cos(self.theta.value) *
                      self.smaj.value)
        self.start_smaj_y = (self.y.value - numpy.cos(self.theta.value) *
                      self.smaj.value)
        self.end_smin_x = (self.x.value + numpy.cos(self.theta.value) *
                      self.smin.value)
        self.start_smin_x = (self.x.value - numpy.cos(self.theta.value) *
                      self.smin.value)
        self.end_smin_y = (self.y.value + numpy.sin(self.theta.value) *
                      self.smin.value)
        self.start_smin_y = (self.y.value - numpy.sin(self.theta.value) *
                      self.smin.value)

        # Fix negative ra values going into the database as this messes
        # up the source association step.
        self.ra.value = self.ra.value % 360.

        def pixel_to_spatial(x, y):
            try:
                return self.imagedata.wcs.p2s([x, y])
            except RuntimeError:
                logger.debug("pixel_to_spatial failed at %f, %f" % (x, y))
                return numpy.nan, numpy.nan
        end_smaj_ra, end_smaj_dec = pixel_to_spatial(self.end_smaj_x, self.end_smaj_y)
        end_smin_ra, end_smin_dec = pixel_to_spatial(self.end_smin_x, self.end_smin_y)


        smaj_asec = coordinates.angsep(self.ra.value, self.dec.value,