def test_returns_correct_units_with_without_area_argument( self, area, expected_units): flux = np.ones(11) * u.Unit("ph s-1 m-2 um-1") wave = np.linspace(1, 2, 11) * u.um spec = SourceSpectrum(Empirical1D, points=wave, lookup_table=flux) counts = source_utils.photons_in_range([spec], 1 * u.um, 2 * u.um, area=area) assert counts.unit == expected_units
def test_returns_correct_half_flux_with_bandpass(self): flux = np.ones(11) * u.Unit("ph s-1 m-2 um-1") wave = np.linspace(0.5, 2.5, 11) * u.um spec = SourceSpectrum(Empirical1D, points=wave, lookup_table=flux) bandpass = SpectralElement(Empirical1D, points=np.linspace(1, 2, 13) * u.um, lookup_table=0.5 * np.ones(13)) counts = source_utils.photons_in_range([spec], 1 * u.um, 2 * u.um, bandpass=bandpass) assert counts.value == approx(0.5)
def test_with_bandpass_and_area_returns_correct_value( self, flux, area, expected): flux = flux * u.Unit("ph s-1 m-2 um-1") spec = SourceSpectrum(Empirical1D, points=np.linspace(0.5, 2.5, 11) * u.um, lookup_table=flux) bandpass = SpectralElement(Empirical1D, points=np.linspace(1, 2, 13) * u.um, lookup_table=0.5 * np.ones(13)) counts = source_utils.photons_in_range([spec], 1 * u.um, 2 * u.um, bandpass=bandpass, area=area) assert counts.value == approx(expected)
def test_returns_ones_for_unity_spectrum(self): flux = np.ones(11) * u.Unit("ph s-1 m-2 um-1") wave = np.linspace(1, 2, 11) * u.um spec = SourceSpectrum(Empirical1D, points=wave, lookup_table=flux) counts = source_utils.photons_in_range([spec], 1 * u.um, 2 * u.um) assert counts.value == approx(1)
def test_returns_correct_number_of_photons_for_one_spectrum( self, ii, n_ph, input_spectra): spec = input_spectra[ii] counts = source_utils.photons_in_range([spec], 1, 2) assert np.isclose(counts.value, n_ph, rtol=2e-3)