def bilinear_interp(self, v, skydir=None): b = self.band sd = skydir or SkyDir(Hep3Vector(v[0], v[1], v[2])) healpix_index = b.index(sd) d = b.dir(healpix_index) b.findNeighbors(healpix_index, self.iv) idx = np.asarray([x for x in iv] + [healpix_index]) dirs = [b.dir(idx) for idx in self.iv] + [d] diffs = np.asarray([sd.difference(di) for di in dirs]) # use co-ordinate system that puts pixels closest to equator use_gal = abs(d.b()) < abs(d.dec()) if use_gal: lons = np.asarray([d.b() for d in dirs]) lats = np.asarray([d.l() for d in dirs]) sdlon = sd.b() sdlat = sd.l() else: lons = np.asarray([d.ra() for d in dirs]) lats = np.asarray([d.dec() for d in dirs]) sdlon = sd.ra() sdlat = sd.dec() s = np.argsort(diffs) lons = lons[s][:4] lats = lats[s][:4] vals = np.asarray([self(0, skydir=dirs[x]) for x in s[:4]]) return (np.abs(lons - sdlon) * np.abs(lats - sdlat) * vals).sum()
def __call__(self, v): sd = SkyDir(Hep3Vector(v[0], v[1], v[2])) v1 = self.tscalc(sd, repeat_diffuse=False, bright_source_mask=None) if self.bright_source_mask is not None: return self.tscalc(sd, repeat_diffuse=True, bright_source_mask=self.bright_source_mask) return v1
def __call__(self, v, skydir=None): sd = skydir or SkyDir(Hep3Vector(v[0], v[1], v[2])) if self.band1.index(sd) != self.index: return np.nan id = self.band2.index(sd) if id != self.previous_index: self.previous_value = self.img[np.searchsorted(self.inds, id)] self.previous_index = id return self.previous_value
def __call__(self, v, skydir=None): sd = skydir or SkyDir(Hep3Vector(v[0], v[1], v[2])) rval = 0 for band in self.bands: PythonUtilities.arclength(band.rvals, band.wsdl, sd) mask = band.rvals < band.max_rad rval += (band.psf(band.rvals[mask], density=True) * band.pix_counts[mask]).sum() return rval
def __call__(self, v): skydir = SkyDir(Hep3Vector(v[0], v[1], v[2])) i = self.indexfun(skydir) try: t = self.hpdict[i] self.hit += 1 return self.scale(t) except KeyError: #else: self.miss += 1 return np.nan
def call2(self, v, skydir=None): sd = skydir or SkyDir(Hep3Vector(v[0], v[1], v[2])) rval = 0 for band in self.bands: if band.photons == 0: continue band.rvals = np.empty(len(band.wsdl), dtype=float) PythonUtilities.arclength(band.rvals, band.wsdl, sd) mask = band.rvals < band.r99 rval += (band.psf(band.rvals[mask], density=True) * band.pix_counts[mask]).sum() return rval
def __call__(self, v, skydir=None): """ copied from roi_tsmap.HealpixKDEMap """ sd = skydir or SkyDir(Hep3Vector(v[0], v[1], v[2])) rval = 0 for i, band in enumerate(self.bands): if not band.has_pixels: continue rvals = np.empty(len(band.wsdl), dtype=float) PythonUtilities.arclength(rvals, band.wsdl, sd) mask = rvals < self.r95[i] rval += (band.psf(rvals[mask]) * band.pix_counts[mask]).sum() return rval
def draw_ecliptic(self, ax): """ draw the ecliptic path onto the axis ax """ ecl_glon = [] ecl_singlat = [] zaxis = SkyDir(270, 90 - 23.439281) xaxis = SkyDir() yaxis = zaxis.cross(xaxis) for phi in np.arange(0, 2 * np.pi, 0.05): t = np.sin(phi) * xaxis + np.cos(phi) * yaxis sd = SkyDir(Hep3Vector(*t)) tglon = sd.l() if tglon > 180: tglon -= 360 ecl_glon.append(tglon) ecl_singlat.append(np.sin(np.radians(sd.b()))) ia = np.argsort(ecl_glon) ax.plot(np.array(ecl_glon)[ia], np.array(ecl_singlat)[ia], '-', color='gray')
def __call__(self, skydir): """ This funciton is analogous to the BandCALDBPsf.__call__ function except that it always returns the density (probability per unit area). Also, it is different in that it takes in a skydir or WSDL instead of a radial distance. """ if isinstance(skydir, BaseWeightedSkyDirList): difference = np.empty(len(skydir), dtype=float) PythonUtilities.arclength( difference, skydir, self.extended_source.spatial_model.center) return self.val(difference) elif type(skydir) == np.ndarray: return self.val(skydir) elif type(skydir) == list and len(skydir) == 3: skydir = SkyDir(Hep3Vector(skydir[0], skydir[1], skydir[2])) elif type(skydir) == SkyDir: return float( self.val( skydir.difference( self.extended_source.spatial_model.center))) else: raise Exception("Unknown input to AnalyticConvolution.__call__()")
def skyplotfun(v): skydir = SkyDir(Hep3Vector(v[0], v[1], v[2])) return self(skydir)
def skyfun(self, v): skydir = SkyDir(Hep3Vector(v[0], v[1], v[2])) return self.v[self.subband.index(skydir)]
def __call__(self, v): skydir = SkyDir(Hep3Vector(v[0], v[1], v[2])) t = self.v[self.subband.index(skydir)] #if self.scale=='sqrt': return np.sqrt(max(t,0)) #elif self.scale=='log': return np.log10(max(t, 1e-1)) return self.scale(t)
def __call__(self,v): skydir = SkyDir(Hep3Vector(v[0],v[1],v[2])) t =self.v[self.band.index(skydir)] return self.scale(t)
def __call__(self, v): sd = SkyDir(Hep3Vector(v[0], v[1], v[2])) return self.psf(DEG2RAD * (90. - sd.b()))[0]
def __call__(self, v): sd = SkyDir(Hep3Vector(v[0], v[1], v[2])) return self.tscalc(sd, **self.kwargs)
def skyplotfun(v): skydir = SkyDir(Hep3Vector(v[0],v[1],v[2])) index = band.index(skydir) return crec[index]
def __call__(self, v): skydir = SkyDir(Hep3Vector(v[0], v[1], v[2])) return self.tsfun(skydir)
def __call__(self, v, skydir=None): sd = skydir or SkyDir(Hep3Vector(v[0], v[1], v[2]))
def __call__(self, v, skydir=None): sd = skydir or SkyDir(Hep3Vector(v[0], v[1], v[2])) healpix_index = self.band.index(sd) return self.vals[healpix_index]
def __call__(self, v, skydir=None): sd = skydir or SkyDir(Hep3Vector(v[0], v[1], v[2])) id = self.band1.index(sd) tsmap = self.tsmaps[id] if not tsmap: return np.nan return tsmap.multipix_call(sd)
def __call__(self,v): return self.TSmap(SkyDir(Hep3Vector(v[0],v[1],v[2])))