How to use the tractor.sdss.CompositeGalaxy function in tractor

To help you get started, we’ve selected a few tractor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dstndstn / tractor / projects / sdss-atlas / nasasloan.py View on Github external
plotInvvar('itune1-%d-' % (i+1)+prefix,tractor)
    
    CGPos = EG.getPosition()
    CGShape = EG.getShape()
    EGBright = EG.getBrightness()
    print(EGBright)
    CGg = EGBright[0]*1.25
    CGi = EGBright[1]*1.25
    CGr = EGBright[2]*1.25
    CGu = EGBright[3]*1.25
    CGz = EGBright[4]*1.25
    CGBright = ba.Mags(r=CGr,g=CGg,u=CGu,z=CGz,i=CGi)
    print(EGBright)
    print(CGBright)

    CG = st.CompositeGalaxy(CGPos,CGBright,CGShape,CGBright,CGShape)
    tractor.removeSource(EG)
    tractor.addSource(CG)

    for i in range(itune2):
        if (i % 5 == 0):
            tractor.optimizeCatalogLoop(nsteps=1,srcs=[CG],sky=True)
        else:
            tractor.optimizeCatalogLoop(nsteps=1,srcs=[CG],sky=False)
        tractor.changeInvvar(9.)
        tractor.clearCache()
        saveAll('itune2-%d-' % (i+1)+prefix,tractor,zr,flipBands,debug=True)
        plotInvvar('itune2-%d-' % (i+1)+prefix,tractor)

    for i in range(ntune):
        tractor.optimizeCatalogLoop(nsteps=1,sky=True)
        saveAll('ntune-%d-' % (i+1)+prefix,tractor,zr,flipBands,debug=True)
github dstndstn / tractor / ngc2595.py View on Github external
CGPos = EG.getPosition()
    CGShape1 = EG.getShape().copy()
    CGShape2 = EG.getShape().copy()
    EGBright = EG.getBrightness()
    CGr = EGBright[0] + 0.75
    CGg = EGBright[1] + 0.75
    CGu = EGBright[2] + 0.75
    CGz = EGBright[3] + 0.75
    CGi = EGBright[4] + 0.75
    CGBright1 = ba.Mags(r=CGr,g=CGg,u=CGu,z=CGz,i=CGi)
    CGBright2 = ba.Mags(r=CGr,g=CGg,u=CGu,z=CGz,i=CGi)
    print EGBright
    print CGBright1

    CG = st.CompositeGalaxy(CGPos,CGBright1,CGShape1,CGBright2,CGShape2)
    tractor.removeSource(EG)
    tractor.addSource(CG)

    for i in range(itune2):
        tractor.optimizeCatalogLoop(nsteps=1,srcs=[CG],sky=True)
        tractor.changeInvvar(IRLS_scale)
        saveAll('itune2-%d-' % (i+1)+prefix,tractor,zr,flipBands,debug=True)

    for i in range(ntune):
        tractor.optimizeCatalogLoop(nsteps=1,sky=True)
        tractor.changeInvvar(IRLS_scale)
        saveAll('ntune-%d-' % (i+1)+prefix,tractor,zr,flipBands,debug=True)
    plotInvvar('final-'+prefix,tractor)
    makeflipbook(prefix,len(tractor.getImages()),itune1,itune2,ntune)
github dstndstn / tractor / projects / sdss-atlas / newCG.py View on Github external
CGPos = EG.getPosition()
    CGShape1 = EG.getShape().copy()
    CGShape2 = EG.getShape().copy()
    EGBright = EG.getBrightness()

    CGu = EGBright[0] + 0.75
    CGg = EGBright[1] + 0.75
    CGr = EGBright[2] + 0.75
    CGi = EGBright[3] + 0.75
    CGz = EGBright[4] + 0.75
    CGBright1 = ba.Mags(r=CGr,g=CGg,u=CGu,z=CGz,i=CGi,order=['u','g','r','i','z'])
    CGBright2 = ba.Mags(r=CGr,g=CGg,u=CGu,z=CGz,i=CGi,order=['u','g','r','i','z'])
    print(EGBright)
    print(CGBright1)

    CG = st.CompositeGalaxy(CGPos,CGBright1,CGShape1,CGBright2,CGShape2)
    
    tractor.removeSource(EG)
    tractor.addSource(CG)

    tractor.catalog.freezeAllBut(CG)
    print(resource.getpagesize())
    print(resource.getrusage(resource.RUSAGE_SELF)[2])


    for i in range(itune2):
        tractor.optimize()
        tractor.changeInvvar(IRLS_scale)
        saveAll('itune2-%d-' % (i+1)+prefix,tractor,**sa)
        tractor.clearCache()
        sg.get_galaxy_cache().clear()
        print(resource.getpagesize())
github dstndstn / tractor / ngc2683.py View on Github external
#    saveBands('initial-'+prefix, tractor,zr,flipBands,debug=True)
    plotInvvar('initial-'+prefix,tractor)

    xtr,ytr = wcs.positionToPixel(RaDecPos(ra,dec))
    
    print xtr,ytr
    bright = None
    lowbright = 1000

    xt = 300. 
    yt = 700.
    r = 200.
    for src in sources:
        xs,ys = wcs.positionToPixel(src.getPosition(), src)
        if (xs-xt)**2+(ys-yt)**2 <= r**2:
            if isinstance(src,st.CompositeGalaxy):
                brightE = src.brightnessExp
                brightD = src.brightnessDev
                sumbright = sum([brightE.getMag(bandname)+brightD.getMag(bandname) for bandname in bands])
                if sumbright < lowbright:
                    print("GREATER")
                    lowBrightE = brightE
                    lowBrightD = brightD
                    lowShapeE = src.shapeExp
                    lowShapeD = src.shapeDev
            print "Removed:", src
            print xs,ys
            tractor.removeSource(src)

#    saveBands('removed-'+prefix, tractor,zr,flipBands,debug=True)
    plotInvvar('removed-'+prefix,tractor)
github dstndstn / tractor / projects / sdss-atlas / general.py View on Github external
CGPos = EG.getPosition()
    CGShape1 = EG.getShape().copy()
    CGShape2 = EG.getShape().copy()
    EGBright = EG.getBrightness()

    CGu = EGBright[0] + 0.75
    CGg = EGBright[1] + 0.75
    CGr = EGBright[2] + 0.75
    CGi = EGBright[3] + 0.75
    CGz = EGBright[4] + 0.75
    CGBright1 = ba.Mags(r=CGr,g=CGg,u=CGu,z=CGz,i=CGi,order=['u','g','r','i','z'])
    CGBright2 = ba.Mags(r=CGr,g=CGg,u=CGu,z=CGz,i=CGi,order=['u','g','r','i','z'])
    print(EGBright)
    print(CGBright1)

    CG = st.CompositeGalaxy(CGPos,CGBright1,CGShape1,CGBright2,CGShape2)
    tractor.removeSource(EG)
    tractor.addSource(CG)

    tractor.catalog.freezeAllBut(CG)
    print(resource.getpagesize())
    print(resource.getrusage(resource.RUSAGE_SELF)[2])


    for i in range(itune2):
        tractor.optimize()
        tractor.changeInvvar(IRLS_scale)
        saveAll('itune2-%d-' % (i+1)+prefix,tractor,**sa)
        tractor.clearCache()
        sg.get_galaxy_cache().clear()
        print(resource.getpagesize())
        print(resource.getrusage(resource.RUSAGE_SELF)[2])
github dstndstn / tractor / projects / sdss-atlas / ugc5459.py View on Github external
lowShapeE = src.shapeExp
                    lowShapeD = src.shapeDev
            print("Removed:", src)
            print(xs,ys)
            tractor.removeSource(src)

    saveBands('removed-'+prefix, tractor,zr,flipBands,debug=True)

#    bright = Mags(r=15.,u=15.,g=15.,z=15.,i=15.,order=['r','u','g','z','i'])
#    shape = st.GalaxyShape(re,ab,phi)
#    shape2 = st.GalaxyShape(30.,0.3,45.)
#    print bright
#    print shape
#   print shape2

    CG = st.CompositeGalaxy(RaDecPos(ra,dec),lowBrightE,lowShapeE,lowBrightD,lowShapeD)
    print(CG)
    tractor.addSource(CG)


    saveBands('added-'+prefix,tractor,zr,flipBands,debug=True)


    for img in tractor.getImages():
        star =  [(x,y) for x in range(img.getWidth()) for y in range(img.getHeight()) if (x-starx)**2+(y-stary)**2 <= starr**2]
        for (x,y) in star:
            img.getInvError()[y][x] = 0


    saveBands('nostar-'+prefix,tractor,zr,flipBands,debug=True)
    for i in range(itune):
        tractor.optimizeCatalogLoop(nsteps=1,srcs=[CG],sky=False)
github dstndstn / tractor / projects / sdss-atlas / twogalaxies.py View on Github external
CGPos = EG.getPosition()
    CGShape1 = EG.getShape().copy()
    CGShape2 = EG.getShape().copy()
    EGBright = EG.getBrightness()

    CGu = EGBright[0] + 0.75
    CGg = EGBright[1] + 0.75
    CGr = EGBright[2] + 0.75
    CGi = EGBright[3] + 0.75
    CGz = EGBright[4] + 0.75
    CGBright1 = ba.Mags(r=CGr,g=CGg,u=CGu,z=CGz,i=CGi,order=['u','g','r','i','z'])
    CGBright2 = ba.Mags(r=CGr,g=CGg,u=CGu,z=CGz,i=CGi,order=['u','g','r','i','z'])
    print(EGBright)
    print(CGBright1)

    CG = st.CompositeGalaxy(CGPos,CGBright1,CGShape1,CGBright2,CGShape2)

    CG2Pos = EG2.getPosition()
    CG2Shape1 = EG2.getShape().copy()
    CG2Shape2 = EG2.getShape().copy()
    EG2Bright = EG2.getBrightness()

    CG2u = EG2Bright[0] + 0.75
    CG2g = EG2Bright[1] + 0.75
    CG2r = EG2Bright[2] + 0.75
    CG2i = EG2Bright[3] + 0.75
    CG2z = EG2Bright[4] + 0.75
    CG2Bright1 = ba.Mags(r=CG2r,g=CG2g,u=CG2u,z=CG2z,i=CG2i,order=['u','g','r','i','z'])
    CG2Bright2 = ba.Mags(r=CG2r,g=CG2g,u=CG2u,z=CG2z,i=CG2i,order=['u','g','r','i','z'])
    CG2 = st.CompositeGalaxy(CG2Pos,CG2Bright1,CG2Shape1,CG2Bright2,CG2Shape2)

    tractor.removeSource(EG)