def info(self): """Print some basic info. """ ss = "\nSummary PSFKing info\n" ss += "---------------------\n" ss += array_stats_str(self.offset_axis.center, "offset") ss += array_stats_str(self.energy_axis_true.center, "energy") ss += array_stats_str(self.gamma, "gamma") ss += array_stats_str(self.sigma, "sigma") # TODO: should quote containment values also return ss
def info( self, fraction=[0.68, 0.95], energy_true=[[1.0], [10.0]] * u.TeV, offset=0 * u.deg, ): """ Print PSF summary info. The containment radius for given fraction, energies and thetas is computed and printed on the command line. Parameters ---------- fraction : list Containment fraction to compute containment radius for. energy_true : `~astropy.units.u.Quantity` Energies to compute containment radius for. offset : `~astropy.units.u.Quantity` Offset to compute containment radius for. Returns ------- ss : string Formatted string containing the summary info. """ info = "\nSummary PSF info\n" info += "----------------\n" info += array_stats_str(self.axes["offset"].center.to("deg"), "Theta") info += array_stats_str(self.axes["energy_true"].edges[1:], "Energy hi") info += array_stats_str(self.axes["energy_true"].edges[:-1], "Energy lo") containment_radius = self.containment_radius(energy_true=energy_true, offset=offset, fraction=fraction) energy_true, offset, fraction = np.broadcast_arrays(energy_true, offset, fraction, subok=True) for idx in np.ndindex(containment_radius.shape): info += f"{100 * fraction[idx]:.2f} containment radius " info += f"at offset = {offset[idx]} " info += f"and energy_true = {energy_true[idx]:4.1f}: " info += f"{containment_radius[idx]:.3f}\n" return info
def __str__(self): ss = "EnergyDependentTablePSF\n" ss += "-----------------------\n" ss += "\nAxis info:\n" ss += " " + array_stats_str(self.rad.to("deg"), "rad") ss += " " + array_stats_str(self.energy, "energy") ss += "\nContainment info:\n" # Print some example containment radii fractions = [0.68, 0.95] energies = u.Quantity([10, 100], "GeV") for fraction in fractions: rads = self.containment_radius(energy=energies, fraction=fraction) for energy, rad in zip(energies, rads): ss += " " + "{}% containment radius at {:3.0f}: {:.2f}\n".format( 100 * fraction, energy, rad) return ss
def info( self, fractions=[0.68, 0.95], energies=Quantity([1.0, 10.0], "TeV"), thetas=Quantity([0.0], "deg"), ): """ Print PSF summary info. The containment radius for given fraction, energies and thetas is computed and printed on the command line. Parameters ---------- fractions : list Containment fraction to compute containment radius for. energies : `~astropy.units.Quantity` Energies to compute containment radius for. thetas : `~astropy.units.Quantity` Thetas to compute containment radius for. Returns ------- ss : string Formatted string containing the summary info. """ ss = "\nSummary PSF info\n" ss += "----------------\n" # Summarise data members ss += array_stats_str(self.theta.to("deg"), "Theta") ss += array_stats_str(self.energy_hi, "Energy hi") ss += array_stats_str(self.energy_lo, "Energy lo") ss += "Safe energy threshold lo: {:6.3f}\n".format( self.energy_thresh_lo) ss += "Safe energy threshold hi: {:6.3f}\n".format( self.energy_thresh_hi) for fraction in fractions: containment = self.containment_radius(energies, thetas, fraction) for i, energy in enumerate(energies): for j, theta in enumerate(thetas): radius = containment[j, i] ss += ("{:2.0f}% containment radius at theta = {} and " "E = {:4.1f}: {:5.8f}\n" "".format(100 * fraction, theta, energy, radius)) return ss
def info(self): """Print basic info.""" ss = array_stats_str(self.rad_axis.center, "offset") ss += f"integral = {self.containment(self.rad_axis.edges[-1])}\n" for containment in [68, 80, 95]: radius = self.containment_radius(0.01 * containment) ss += f"containment radius {radius.deg} deg for {containment}%\n" return ss
def info(self): """Print basic info.""" ss = array_stats_str(self.rad.deg, "offset") ss += "integral = {}\n".format(self.integral()) for containment in [68, 80, 95]: radius = self.containment_radius(0.01 * containment) ss += "containment radius {} deg for {}%\n".format( radius.deg, containment) return ss
def info(self): """Print some basic info. """ ss = "\nSummary PSF3D info\n" ss += "---------------------\n" ss += array_stats_str(self.energy_lo, "energy_lo") ss += array_stats_str(self.energy_hi, "energy_hi") ss += array_stats_str(self.offset, "offset") ss += array_stats_str(self.rad_lo, "rad_lo") ss += array_stats_str(self.rad_hi, "rad_hi") ss += array_stats_str(self.psf_value, "psf_value") # TODO: should quote containment values also return ss
def test_array_stats_str(): actual = array_stats_str(np.pi, "pi") assert actual == "pi : size = 1, min = 3.142, max = 3.142\n" actual = array_stats_str([np.pi, 42]) assert actual == "size = 2, min = 3.142, max = 42.000\n"