[lsst-dm-stack-users] Changes to make sub-images less clunky
Paul Price
price at astro.princeton.edu
Tue Jan 29 14:48:35 PST 2013
On Jan 29, 2013, at 5:02 PM, Robert Lupton the Good wrote:
> FYI, after the SLAC demo I felt really embarrassed by
> subIm = im.Factory(afwGeom.BoxI(afwGeom.PointI(10, 20), afwGeom.PointI(20, 30)))
> to get a subimage. I realised that this wasn't necessary, and the latest afw supports
> subIm = im[10:20, 20:30]
> or
> im[12:15, :] = -1
You can also get a numpy array from an Image by:
a = im.getArray()
and then you can do:
a[:,12:15] = -1
*** Note that numpy indices are [y,x], while Robert's new direct Python slicing of an Image uses [x,y]. The way I remember this is that numpy is operating directly on the in-memory representation (which is accessed y,x, as usual in C), while Robert's slicing makes things a bit nicer, and so is x,y as is usual in math and English.
If this confuses you, please forget I mentioned it, but I find the ability to access an Image as a numpy array is quite powerful.
P.
More information about the dm-users
mailing list