def __call__(self, RA, Dec, energy): self.ncalls += 1 RA0 = self.parameters['RA0'].value Dec0 = self.parameters['Dec0'].value radius = self.parameters['radius'].getValue(energy) return np.power(180 / np.pi, 2) * 1. / (np.pi * radius ** 2) * (angsep(RA, Dec, RA0, Dec0) < radius)
def matchsorted(ra, dec, ra1, dec1, tol): """ Find closest ra,dec within tol to a target in an ra-sorted list of ra,dec. Arguments: ra - Right Ascension decimal degrees (numpy sorted in ascending order) dec - Declination decimal degrees (numpy array) ra1 - RA to match (scalar, decimal degrees) ra1 - Dec to match (scalar, decimal degrees) tol - Matching tolerance in decimal degrees. Returns: ibest - index of the best match within tol; -1 if no match within tol sep - separation (defaults to tol if no match within tol) """ i1 = searchsorted(ra, ra1 - tol) - 1 i2 = searchsorted(ra, ra1 + tol) + 1 if i1 < 0: i1 = 0 sep = angsep.angsep(ra[i1:i2], dec[i1:i2], ra1, dec1) # print "tolerance ",tol indices = argsort(sep) # print sep if sep[indices[0]] > tol: return -1, tol ibest = indices[0] + i1 return ibest, sep[indices[0]]
def __call__(self,RA,Dec,energy): self.ncalls += 1 RA0 = self.parameters['RA0'].value Dec0 = self.parameters['Dec0'].value sigma = self.parameters['sigma'].getValue(energy) return np.maximum( np.power(180/np.pi,2)*1./(2 * np.pi * sigma**2) * np.exp(-0.5 * np.power(angsep(RA,Dec,RA0,Dec0),2)/sigma**2), 1e-30)