def generate_energies(self, t_exp, fov, prng=None, quiet=False): """ Generate photon energies from this convolved background spectrum given an exposure time and field of view. Parameters ---------- t_exp : float, (value, unit) tuple, or :class:`~astropy.units.Quantity` The exposure time in seconds. fov : float, (value, unit) tuple, or :class:`~astropy.units.Quantity` The width of the field of view on a side in arcminutes. prng : :class:`~numpy.random.RandomState` object, integer, or None A pseudo-random number generator. Typically will only be specified if you have a reason to generate the same set of random numbers, such as for a test. Default is None, which sets the seed based on the system time. quiet : boolean, optional If True, log messages will not be displayed when creating energies. Useful if you have to loop over a lot of spectra. Default: False """ t_exp = parse_value(t_exp, "s") fov = parse_value(fov, "arcmin") prng = parse_prng(prng) rate = fov*fov*self.total_flux.value energy = _generate_energies(self, t_exp, rate, prng, quiet=quiet) earea = self.arf.interpolate_area(energy).value flux = np.sum(energy)*erg_per_keV/t_exp/earea.sum() energies = Energies(energy, flux) return energies
def generate_energies(self, t_exp, area, fov, prng=None, quiet=False): """ Generate photon energies from this background spectrum given an exposure time, effective area, and field of view. Parameters ---------- t_exp : float, (value, unit) tuple, or :class:`~astropy.units.Quantity` The exposure time in seconds. area : float, (value, unit) tuple, or :class:`~astropy.units.Quantity` The effective area in cm**2. If one is creating events for a SIMPUT file, a constant should be used and it must be large enough so that a sufficiently large sample is drawn for the ARF. fov : float, (value, unit) tuple, or :class:`~astropy.units.Quantity` The width of the field of view on a side in arcminutes. prng : :class:`~numpy.random.RandomState` object, integer, or None A pseudo-random number generator. Typically will only be specified if you have a reason to generate the same set of random numbers, such as for a test. Default is None, which sets the seed based on the system time. quiet : boolean, optional If True, log messages will not be displayed when creating energies. Useful if you have to loop over a lot of spectra. Default: False """ t_exp = parse_value(t_exp, "s") fov = parse_value(fov, "arcmin") area = parse_value(area, "cm**2") prng = parse_prng(prng) rate = area*fov*fov*self.total_flux.value energy = _generate_energies(self, t_exp, rate, prng, quiet=quiet) flux = np.sum(energy)*erg_per_keV/t_exp/area energies = Energies(energy, flux) return energies