import numpy
import esutil as eu
import biggles
run='wlse0003'
exposure='decam--24--37-i-7'
ccd = 62
dir='$DESDATA/wlbnl/%s/%s' % (run,exposure)
starfile = '%s/%s_%s_%s_stars.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 findstars output: ',starfile
fsdata = eu.io.read(starfile,ext=1)
# make a size-mag diagram
plt = biggles.FramedPlot()
# all points
points = biggles.Points( fsdata['mag'], fsdata['sigma0'] )
points.label = 'all'
# those we used for PSF stars
w, = numpy.where( fsdata['star_flag'] == 1)
psf_points = biggles.Points( fsdata['mag'][w], fsdata['sigma0'][w],color='red' )
psf_points.label = 'PSF stars'
k = biggles.PlotKey( .1, .9, [points,psf_points] )
plt.add(points, psf_points, k)
plt.xlabel = 'i-mag'
plt.ylabel = r'$\sigma_0$'
plt.xrange = 8,18.5
plt.yrange = 0,3
# to view interactively
plt.show()
# write to encapsulated postscript
plt.write_eps('sizemag.eps')
# or png. Note you usually get better results writing the postscript and then
# converting it to png
plt.write_img(600,600,'sizemag.png')
Here is the post script output: sizemag.eps
Here is the .eps file converted to png:
And this is the result of the write_img(), which is less nice. There may be options
to improve this however.