Beispiel #1
0
 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
Beispiel #2
0
 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)
Beispiel #3
0
 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)
Beispiel #4
0
 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)
Beispiel #5
0
 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)