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 !")
if os.path.exists(linkpath) or os.path.islink(linkpath): 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 :"
images = db.select(imgdb, ['gogogo', 'treatme'], [True, True], returnType='dict', sortFields=['setname','mjd']) #images = db.select(imgdb, ['gogogo', 'treatme'], [True, True], returnType='dict', sortFields=['date']) #images = db.select(imgdb, ['gogogo', 'treatme'], [True, True], returnType='dict', sortFields=['seeing']) #images = db.select(imgdb, ['gogogo', 'treatme'], [True, True], returnType='dict', sortFields=['mjd']) #images = db.select(imgdb, ['gogogo', 'ell'], [True, ">0.65"], returnType='dict', sortFields=['mjd']) #images = db.select(imgdb, ['recno'], ['*'], returnType='dict', sortFields=['mjd']) print "I will treat", len(images), "images." proquest(askquestions) # We get the ref image to draw the ali stars, as for 1a_checkalistars.py etc : refimage = db.select(imgdb, ['imgname'], [refimgname], returnType='dict') refimage = refimage[0] refsexcat = os.path.join(alidir, refimage['imgname'] + ".cat") refautostars = star.readsexcat(refsexcat) refautostars = star.sortstarlistbyflux(refautostars) refmanstars = star.readmancat(alistarscat) # So these are the "manual" star coordinates id = star.listidentify(refmanstars, refautostars, tolerance = identtolerance) # We find the corresponding precise sextractor coordinates preciserefmanstars = star.sortstarlistbyflux(id["match"]) preciserefmanstarsasdicts = [{"name":star.name, "x":star.x, "y":star.y} for star in preciserefmanstars] starttime = datetime.now() for i, image in enumerate(images): print "- " * 40 print i+1, "/", len(images), ":", image['imgname']
proquest(askquestions) # As we will tweak the database, backup backupfile(imgdb, dbbudir, 'photomdb') db.addFields(imgdb, ["%s:%s" % (f["name"], f["type"]) for f in dbfieldstoadd]) for i, image in enumerate(images): print "- " * 30 print i + 1, "/", nbrofimages, ":", image['imgname'] # We read the sextractor catalog : sexcatpath = os.path.join(alidir, image['imgname'] + ".alicat") sexstars = star.readsexcat( sexcatpath, maxflag=0, posflux=False, propfields=[f["sexname"] for f in sexphotomfields]) # We identify these sextractor stars with the handwritten selection id = star.listidentify(photomstars, sexstars, tolerance=identtolerance, onlysingle=True, verbose=True) # This is already printed by listidentify #if len(id["nomatchnames"]) > 0: # print "No match for " + ", ".join([n for n in id["nomatchnames"]]) #if len(id["notsurenames"]) > 0: # print "Not sure for " + ", ".join([n for n in id["notsurenames"]])
skyimage.setzscale("ex", "ex") 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'],
proquest(askquestions) db.addFields(imgdb, [ 'nbrcoeffstars:int', 'maxcoeffstars:int', 'medcoeff:float', 'sigcoeff:float', 'spancoeff:float' ]) # we read the handwritten star catalog normstars = star.readmancat(normstarscat) for s in normstars: print s.name print "Checking reference image ..." refsexcat = os.path.join(alidir, refimgname + ".alicat") refcatstars = star.readsexcat(refsexcat, propfields=[ "FLUX_APER", "FLUX_APER1", "FLUX_APER2", "FLUX_APER3", "FLUX_APER4" ]) id = star.listidentify(normstars, refcatstars, tolerance=identtolerance) refidentstars = id["match"] # now refidentstars contains the same stars as normstars, but with sex fluxes. ''' print "="*25 print refcatstars[0].props print refcatstars[0].flux import sys sys.exit() '''