radio-tools/pvextractor — pull request #6 by astrofrog (2014-04-08 20:15:38+00:00)
Title: Refactor geometry

Example code to use this so far:

```
from astropy.io import fits

from pvextractor.geometry import sample_curve, extract_line_slice, extract_thick_slice

data = fits.open('m33_bigspatial_db.fits')[0].data[0]
print data.shape

# Generate sampled curve
d, x, y = sample_curve([1600., 2800.], [3200, 3900], spacing=1.0)

x_mid = (x[1:] + x[:-1]) * 0.5
y_mid = (y[1:] + y[:-1]) * 0.5

slice = extract_line_slice(data, x_mid, y_mid)

fits.writeto('slice.fits', slice, clobber=True)

slice = extract_line_slice(data, x_mid, y_mid, interpolation='nearest')

fits.writeto('slice_near.fits', slice, clobber=True)

thick_slice = extract_thick_slice(data, x, y, width=5)

fits.writeto('slice_thick.fits', thick_slice, clobber=True)
```