Пример #1
0
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
Пример #2
0
def makequads1(starlist, n=7, s=0, d=50.0, verbose=True):
    """
	First trivial quad maker.
	Makes combis of the n brightest stars.
	
	:param n: number of stars to consider (brightest ones).
	:type n: int
	:param s: how many of the brightest stars should I skip ?
		This feature is useful to avoid building quads with nearly saturated stars that are not
		available in other exposures.
	:type s: int
	:param d: minimal distance between stars
	:type d: float
	
	"""
    quadlist = []
    sortedstars = star.sortstarlistbyflux(starlist)

    for fourstars in itertools.combinations(sortedstars[s:s + n], 4):
        if mindist(fourstars) > d:
            quadlist.append(Quad(fourstars))

    if verbose:
        print "Made %4i quads from %4i stars (combi n=%i s=%i d=%.1f)" % (
            len(quadlist), len(starlist), n, s, d)

    return quadlist
Пример #3
0
def makequads1(starlist, n=7, s=0, d=50.0, verbose=True):
    """
    First trivial quad maker.
    Makes combis of the n brightest stars.

    :param n: number of stars to consider (brightest ones).
    :type n: int
    :param s: how many of the brightest stars should I skip ?
            This feature is useful to avoid building quads with nearly saturated stars that are not
            available in other exposures.
    :type s: int
    :param d: minimal distance between stars
    :type d: float

    """
    quadlist = []
    sortedstars = star.sortstarlistbyflux(starlist)

    for fourstars in itertools.combinations(sortedstars[s:s + n], 4):
        if mindist(fourstars) > d:
            quadlist.append(Quad(fourstars))

    if verbose:
        print("Made %4i quads from %4i stars (combi n=%i s=%i d=%.1f)" % (len(quadlist), len(starlist), n, s, d))

    return quadlist
Пример #4
0
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
Пример #5
0
	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 !")
Пример #6
0
    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 !")
Пример #7
0
    print "Removing link..."
    os.remove(linkpath)
os.symlink(refimgpath, linkpath)

print "I made an alias to this reference image here :"
print linkpath
print "Saturation level (in e-) of ref image : %.2f" % (
    refimage["saturlevel"] * refimage["gain"])

print "Now I will need some alignment stars (write them into configdir/alistars.cat)."
proquest(askquestions)

# Load the reference sextractor catalog
refsexcat = os.path.join(alidir, refimage['imgname'] + ".cat")
refautostars = star.readsexcat(refsexcat, maxflag=16, posflux=True)
refautostars = star.sortstarlistbyflux(refautostars)
refscalingfactor = refimage['scalingfactor']

# read and identify the manual reference catalog
refmanstars = star.readmancat(
    alistarscat)  # So these are the "manual" star coordinates
id = star.listidentify(
    refmanstars,
    refautostars,
    tolerance=identtolerance,
    onlysingle=True,
    verbose=True)  # We find the corresponding precise sextractor coordinates

if len(id["nomatchnames"]) != 0:
    print "Warning : the following stars could not be identified in the sextractor catalog :"
    print "\n".join(id["nomatchnames"])
Пример #8
0
		skyimage.rebin(3)
		skyimage.makepilimage(scale = "lin", negative = False)
		skyimage.upsample(2)
		skyimage.writetitle("Sky", colour=(255, 0, 0))

		skysubimage = f2n.fromfits(skysubimagepath)
		skysubimage.setzscale("auto", "auto")
		skysubimage.rebin(3)
		skysubimage.makepilimage(scale = "log", negative = False)
		skysubimage.upsample(2)
		skysubimage.writetitle("Skysubtracted image")

		# We read the 20 strongest stars from sextractor :
		sexcatpath = os.path.join(alidir, image['imgname'] + ".cat")
		sexcat = star.readsexcat(sexcatpath)
		sexcat = star.sortstarlistbyflux(sexcat)
		sexcatasdicts = [{"name":s.name, "x":s.x, "y":s.y} for s in sexcat[:20]]

		skysubimage.drawstarlist(sexcatasdicts, r = 30, colour = (255, 255, 255))
		skyimage.drawstarlist(sexcatasdicts, r = 30, colour = (255, 0, 0))

		skysubinfo = [
		"%s" % image["imgname"],
		"%s UTC" % image['datet'],
		image['telescopename'] + " - " + image['setname'],
		"Seeing : %4.2f [arcsec]" % image['seeing'],
		"Ellipticity : %4.2f" % image['ell'],
		"Airmass : %4.2f" % image['airmass'],
		"Sky level : %.1f" % image['skylevel'],
		"Sky stddev : %.1f" % image['prealistddev'],
		]