def makequads2(starlist, f=5.0, n=6, s=0, d=50.0, verbose=True): """ Similar, but fxf in subareas roughly f times smaller than the full frame. s allows to skip the brightest stars in each region :param f: smallness of the subareas :type f: float :param n: number of stars to consider in each subarea :type n: int :param d: minimal distance between stars :type d: float :param s: number of brightest stars to skip in each subarea :type s: int """ quadlist = [] sortedstars = star.sortstarlistbyflux(starlist) (xmin, xmax, ymin, ymax) = star.area(sortedstars) r = 2.0 * max(xmax - xmin, ymax - ymin) / f for xc in np.linspace(xmin, xmax, f+2)[1:-1]: for yc in np.linspace(ymin, ymax, f+2)[1:-1]: cstar = star.Star(x=xc, y=yc) das = cstar.distanceandsort(sortedstars) #closest = [s["star"] for s in das[0:4]] brightestwithinr = star.sortstarlistbyflux([element["star"] for element in das if element["dist"] <= r])[s:s+n] for fourstars in itertools.combinations(brightestwithinr, 4): if mindist(fourstars) > d: quadlist.append(Quad(fourstars)) if verbose: print "Made %4i quads from %4i stars (combi sub f=%.1f n=%i s=%i d=%.1f)" % (len(quadlist), len(starlist), f, n, s, d) return quadlist
def makestarlist(self, skipsaturated=False, n=200, verbose=True): if self.cat: if skipsaturated: maxflag = 3 else: maxflag = 7 self.starlist = star.sortstarlistbyflux(star.readsexcat(self.cat, hdu=self.hdu, maxflag=maxflag, verbose=verbose))[:n] (xmin, xmax, ymin, ymax) = star.area(self.starlist, border=0.01) self.xlim = (xmin, xmax) self.ylim = (ymin, ymax) # Given this starlists, what is a good minimal distance for stars in quads ? self.mindist = min(min(xmax - xmin, ymax - ymin) / 10.0, 30.0) else: raise RuntimeError("No cat : call makecat first !")
def makestarlist(self, skipsaturated=False, n=200, verbose=True): if self.cat: if skipsaturated: maxflag = 3 else: maxflag = 7 self.starlist = star.sortstarlistbyflux( star.readsexcat(self.cat, hdu=self.hdu, maxflag=maxflag, verbose=verbose))[:n] (xmin, xmax, ymin, ymax) = star.area(self.starlist, border=0.01) self.xlim = (xmin, xmax) self.ylim = (ymin, ymax) # Given this starlists, what is a good minimal distance for stars in quads ? self.mindist = min(min(xmax - xmin, ymax - ymin) / 10.0, 30.0) else: raise RuntimeError("No cat : call makecat first !")
def makequads2(starlist, f=5.0, n=6, s=0, d=50.0, verbose=True): """ Similar, but fxf in subareas roughly f times smaller than the full frame. s allows to skip the brightest stars in each region :param f: smallness of the subareas :type f: float :param n: number of stars to consider in each subarea :type n: int :param d: minimal distance between stars :type d: float :param s: number of brightest stars to skip in each subarea :type s: int """ quadlist = [] sortedstars = star.sortstarlistbyflux(starlist) (xmin, xmax, ymin, ymax) = star.area(sortedstars) r = 2.0 * max(xmax - xmin, ymax - ymin) / f for xc in np.linspace(xmin, xmax, f + 2)[1:-1]: for yc in np.linspace(ymin, ymax, f + 2)[1:-1]: cstar = star.Star(x=xc, y=yc) das = cstar.distanceandsort(sortedstars) #closest = [s["star"] for s in das[0:4]] brightestwithinr = star.sortstarlistbyflux([ element["star"] for element in das if element["dist"] <= r ])[s:s + n] for fourstars in itertools.combinations(brightestwithinr, 4): if mindist(fourstars) > d: quadlist.append(Quad(fourstars)) if verbose: print "Made %4i quads from %4i stars (combi sub f=%.1f n=%i s=%i d=%.1f)" % ( len(quadlist), len(starlist), f, n, s, d) return quadlist