astropy/specutils — pull request #22 by wkerzendorf (2013-04-03 17:46:16+00:00)
Title: Spec WCS

Hey guys,
I finally did my spec wcs implementation. This also solved the problem that @kbarbary and @keflavich had with the missing dispersion_unit (a I think we should switch all `disp` to `dispersion` as that was discussed and agreed upon - next PR).

Here's a little taster of what it can do:

```python
from astropy.table import Table
from astropy import units as u
from specutils import Spectrum1D
from specutils.wcs import Spectrum1DLinearWCS

wavelength = np.arange(6000, 7000, 0.1)
flux = np.random.random(10000)
uncertainty = np.sqrt(flux)

mydata = Table(dict(disp=wavelength, flux=flux, uncertainty=uncertainty))
mydata['disp'].units = u.angstrom
mydata['flux'].units = u.Unit('W/(m^2 angstrom^2)')
#initializing from_table
myspec = Spectrum1D.from_table(mydata, uncertainty_column='uncertainty')

print myspec.disp
[ 6000. 6000.1 6000.2 ..., 6999.7 6999.8 6999.9]

print myspec.flux
[ 0.70864274 0.54175854 0.69471822 ..., 0.13276595 0.58555977
0.88461505]

print myspec.dispersion_unit
Angstrom
print myspec.flux_unit
W / (Angstrom2 m2)

#initializing with a linear wcs
linear_wcs = Spectrum1DLinearWCS(dispersion0=6000, dispersion_delta=0.1, dispersion_pixel0=0, unit=u.angstrom)
myspec2 = Spectrum1D(data=flux, wcs=linear_wcs, unit=u.Unit('W / (Angstrom2 m2)'))

print myspec2.disp
[ 6000. 6000.1 6000.2 ..., 6999.7 6999.8 6999.9]

print myspec2.wcs.pixel2dispersion([0, 9999])
[ 6000. 7000.]

print myspec2.wcs.dispersion2pixel([6000, 6999.9])
[ 0. 9999.]

```

What do you guys think?