def test_prepare_observed(): def check(spec, obj): if obj.uncertainty is not None: if (type(obj.wavelength.value) == float) | (type(obj.wavelength.value) == int): assert spec.wavelength.value == obj.wavelength.value assert spec.flux.value == obj.flux.value assert spec.uncertainty.value == obj.uncertainty.value else: for i in range(len(spec.wavelength.value)): assert spec.wavelength.value[i] == obj.wavelength.value[i] assert spec.flux.value[i] == obj.flux.value[i] assert spec.uncertainty.value[i] == obj.uncertainty.value[i] else: if (type(obj.wavelength.value) == float) | (type(obj.wavelength.value) == int): assert spec.wavelength.value == obj.wavelength.value assert spec.flux.value == obj.flux.value assert spec.uncertainty is not None else: for i in range(len(spec.wavelength.value)): assert spec.wavelength.value[i] == obj.wavelength.value[i] assert spec.flux.value[i] == obj.flux.value[i] assert spec.uncertainty is not None assert type(spec) == SKSpectrum1D w = Quantity(1000, 'Angstrom') f = Quantity(100, 'Jy') u = Quantity(3, 'Jy') obj = SKSpectrum1D(w, f, u) spec = spectral.prepare_observed(obj) check(spec, obj) w = Quantity([1000, 1500, 2000], 'Angstrom') f = Quantity([100, 150, 100], 'Jy') u = Quantity([2, 5, 1], 'Jy') obj = SKSpectrum1D(w, f, u) spec = spectral.prepare_observed(obj) check(spec, obj) w = Quantity([1000, 1500, 2000], 'Angstrom') f = Quantity([100, 150, 100], 'Jy') obj = SKSpectrum1D(w, f, None) spec = spectral.prepare_observed(obj) check(spec, obj)
def _update_observed_spectrum(self, observed): self.observed = prepare_observed(observed) self.signal_to_noise = (self.observed.flux.value / self.observed.uncertainty.value) self.flux_unit = observed.flux.unit self._rcond = (len(observed.flux.value) * np.finfo(observed.flux.dtype).eps) self._Vp = np.polynomial.polynomial.polyvander( observed.wavelength.value/observed.wavelength.mean().value - 1., self.npol) self.domain = u.Quantity([observed.wavelength.min().value, observed.wavelength.max().value]) self.window = self.domain/observed.wavelength.mean().value - 1.
def _update_observed_spectrum(self, observed): self.observed = prepare_observed(observed) self.signal_to_noise = (self.observed.flux.value / self.observed.uncertainty.value) self.flux_unit = observed.flux.unit self._rcond = (len(observed.flux.value) * np.finfo(observed.flux.dtype).eps) self._Vp = np.polynomial.polynomial.polyvander( observed.wavelength.value / observed.wavelength.mean().value - 1., self.npol) self.domain = u.Quantity( [observed.wavelength.min().value, observed.wavelength.max().value]) self.window = self.domain / observed.wavelength.mean().value - 1.
def _update_observed_spectrum(self, observed): self.observed = prepare_observed(observed)