Skip to content

Commit

Permalink
fixed skycenter declination bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mommermi committed Dec 7, 2017
1 parent cb6fecd commit d5c559c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,21 @@ def get_binning(header, obsparam):

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

ra, dec = old_div((max_ra+min_ra),2.), old_div((max_dec+min_dec),2.)
rad = numpy.sqrt((old_div((max_ra-min_ra),2.))**2 +
(old_div((max_dec-min_dec),2.))**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 d5c559c

Please sign in to comment.