Beispiel #1
0
 def lightcurve(self, location_a, location_b, range_c=None):
     """Given a pixel index return a lightcurve."""
     return LightCurve(
         DataFrame(
             {
                 "{0},{1}".format(location_a, location_b):
                 self.data[:, location_a, location_b]
             },
             index=self.date))
Beispiel #2
0
    def slice_to_lightcurve(self, wavelength, y_coord=None, x_coord=None):
        """
        For a time-lambda-y cube, returns a lightcurve with curves at the
        specified wavelength and given y-coordinate. If no y is given, all of
        them will be used (meaning the lightcurve object could contain more
        than one timecurve.)
        Parameters
        ----------
        wavelength: int or astropy quantity
            The wavelength to take the y-coordinates from
        y_coord: int or astropy quantity, optional
            The y-coordinate to take the lightcurve from.
        x_coord: int or astropy quantity, optional
            In the case of hypercubes, specify an extra celestial coordinate.
        """
        if self.axes_wcs.wcs.ctype[0] not in ['TIME', 'UTC']:
            raise cu.CubeError(1,
                               'Cannot create a lightcurve with no time axis')
        if self.axes_wcs.wcs.ctype[1] != 'WAVE':
            raise cu.CubeError(2, 'A spectral axis is needed in a lightcurve')
        if self.data.ndim == 3:
            data = self._choose_wavelength_slice(wavelength)
            if y_coord is not None:
                data = data[:, cu.pixelize(y_coord, self.axes_wcs, 1)]
        else:
            if y_coord is None and x_coord is None:
                raise cu.CubeError(4, "At least one coordinate must be given")
            if y_coord is None:
                y_coord = slice(None, None, None)
            else:
                y_coord = cu.pixelize(y_coord, self.axes_wcs, 2)
            if x_coord is None:
                x_coord = slice(None, None, None)
            else:
                x_coord = cu.pixelize(x_coord, self.axes_wcs, 3)
            item = (slice(None, None, None), wavelength, y_coord, x_coord)
            data = self.data[item]

        return LightCurve(data=data, meta=self.meta)