/usr/lib/python/astrometry/util/lsstutils.py is in astrometry.net 0.46-0ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | from lsst.afw.detection import SourceSet, Source
from astrometry.util.fits import *
sourceset_fields = ['FlagForDetection', "XAstrom", "XAstromErr", "YAstrom", "YAstromErr",
"PsfFlux", "ApFlux", "Ixx", "IxxErr", "Iyy",
"IyyErr", "Ixy", "IxyErr"]
# eg, from astrometry.util.fits : fits_table() or text_table()
def sourceset_from_table(t):
N = len(t)
ss = SourceSet()
for i in range(N):
s = Source()
ss.push_back(s)
for f in sourceset_fields:
vals = t.getcolumn(f.lower())
for s,v in zip(ss,vals):
fname = "set" + f
func = getattr(s, fname)
if func is None:
raise Exception('Function not found in Source object: ' + fname + ', object %s' % str(s))
func(v)
return ss
def sourceset_to_dict(ss):
d = dict()
for f in sourceset_fields:
vals = []
for s in ss:
func = getattr(s, "get" + f)
vals.append(func())
d[f] = vals
return d
def sourceset_to_table(ss):
sd = sourceset_to_dict(ss)
td = tabledata()
for k,v in sd.items():
td.set(k, array(v))
return td
def sourceset_from_dict(d):
x = d[sourceset_fields[0]]
N = len(x)
ss = SourceSet()
for i in range(N):
s = Source()
ss.push_back(s)
for f in sourceset_fields:
vals = d[f]
for s,v in zip(ss,vals):
func = getattr(s, "set" + f)
func(v)
return ss
|