Skip to content

Commit

Permalink
fixed up spectrum1d to work with initial specwcs
Browse files Browse the repository at this point in the history
  • Loading branch information
wkerzendorf committed Apr 3, 2013
1 parent 57be3c2 commit 4c14438
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions specutils/spectrum1d.py
Expand Up @@ -75,13 +75,14 @@ def from_array(cls, disp, flux, dispersion_unit=None, uncertainty=None, mask=Non
if disp.ndim != 1 or disp.shape != flux.shape:
raise ValueError("disp and flux need to be one-dimensional Numpy arrays with the same shape")
spec_wcs = Spectrum1DLookupWCS(disp, unit=dispersion_unit)
return cls(data=flux, wcs=disp)
return cls(data=flux, wcs=spec_wcs)

@classmethod
def from_table(cls, table, uncertainty=None, mask=None, disp_col='disp', flux_col='flux'):
flux = table[flux_col]
disp = table[disp_col]
return cls(data=flux, wcs=disp, uncertainty=uncertainty, mask=mask)
def from_table(cls, table, mask=None, dispersion_column='disp', flux_column='flux', uncertainty_column=None):
flux = table[flux_column]
disp = table[dispersion_column]

return cls.from_array(data=flux.data, wcs=disp.data, dispersion_unit=disp.units, units=flux.units)



Expand All @@ -96,7 +97,7 @@ def from_ascii(cls, filename, uncertainty=None, mask=None, dtype=np.float, comme
if raw_data.shape[1] != 2:
raise ValueError('data contained in filename must have exactly two columns')

return cls(data=raw_data[:,1], wcs=raw_data[:,0], uncertainty=uncertainty, mask=mask)
return cls.from_array(data=raw_data[:,0], wcs=raw_data[:,1], uncertainty=uncertainty, mask=mask)

@classmethod
def from_fits(cls, filename, uncertainty=None):
Expand Down Expand Up @@ -250,7 +251,7 @@ def slice_dispersion(self, start=None, stop=None):
"""

# Transform the dispersion end points to index space
start_index, stop_index = self.disp.searchsorted([start, stop])
start_index, stop_index = self.wcs.dispersion2pixel([start, stop])

return self.slice_index(start_index, stop_index)

Expand Down

0 comments on commit 4c14438

Please sign in to comment.