import numpy
from numpy import sqrt
import esutil as eu
from esutil.numpy_util import ahelp
from esutil.misc import colprint
run='wlse0003'
exposure='decam--24--37-i-7'
ccd = 62
dir='$DESDATA/wlbnl/%s/%s' % (run,exposure)
psffile = '%s/%s_%s_%s_psf.fits' % (dir,run,exposure,ccd)
# eu.io.read will expand the $DESDATA environment variable. Note, it also
# returns a plain ndarray, for which you access fields dictionary style
# data['fieldname']. If you prefer record style data.fieldname send
# view=numpy.recarray, but note that field names can get clobbered by array
# attributes!
print 'Reading PSF stars output: ',psffile
psfdata = eu.io.read(psffile,ext=1)
# A quick view of what is contained in this
# data structure
print 'here is a description of the PSF data\n'
ahelp(psfdata)
# This gets e1 and e2 for all objects
print '\ngetting e1/e2\n'
e1 = psfdata['shapelets'][:, 3]
e2 = psfdata['shapelets'][:, 4]
e1 *= sqrt(2)
e2 *= sqrt(2)
# take a look at the first 20 shapes
colprint(e1,e2,format='%7.4f', names=['e1','e2'], nformat='%7s',nlines=20)
Reading PSF stars output: $DESDATA/wlbnl/wlse0003/decam--24--37-i-7/wlse0003_decam--24--37-i-7_62_psf.fits
here is a description of the PSF data
size: 198 nfields: 10 type: records
id >i4 3
x >f8 557.300945496
y >f8 28.3650280366
sky >f8 1670.40246582
noise >f8 0.0
psf_flags >i4 0
nu >f8 415.712982059
psf_order >i4 10
sigma_p >f8 0.527686686356
shapelets >f8 array[66]
getting e1/e2
e1 e2
0.0029 -0.0048
0.0110 -0.0084
0.0098 -0.0181
0.0041 -0.0037
0.0098 -0.0082
-0.0062 -0.0035
-0.0030 -0.0027
0.0013 0.0022
0.0084 -0.0177
-0.0001 -0.0070
-0.0150 0.0029
-0.0035 -0.0025
-0.0004 -0.0090
0.0043 -0.0131
-0.0001 -0.0084
-0.0032 -0.0041
-0.0053 -0.0081
-0.0061 -0.0027
-0.0142 -0.0191
-0.0008 -0.0071