Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
xtr,ytr = wcs.positionToPixel(RaDecPos(ra,dec))
xt = xtr
yt = ytr
r = ((remradius*60.))/.396 #radius in pixels
for src in sources:
xs,ys = wcs.positionToPixel(src.getPosition(),src)
if (xs-xt)**2+(ys-yt)**2 <= r**2:
#print "Removed:", src
#print xs,ys
tractor.removeSource(src)
#saveAll('removed-'+prefix, tractor,**sa)
newShape = sg.GalaxyShape((remradius*60.)/10.,ab,angle)
newBright = ba.Mags(r=15.0,g=15.0,u=15.0,z=15.0,i=15.0,order=['u','g','r','i','z'])
EG = st.ExpGalaxy(RaDecPos(ra,dec),newBright,newShape)
print(EG)
tractor.addSource(EG)
saveAll('added-'+prefix,tractor,**sa)
#print 'Tractor has', tractor.getParamNames()
for im in tractor.images:
im.freezeAllParams()
im.thawParam('sky')
tractor.catalog.freezeAllBut(EG)
#print 'Tractor has', tractor.getParamNames()
#print 'values', tractor.getParams()
xtr,ytr = wcs.positionToPixel(RaDecPos(ra,dec))
xt = xtr
yt = ytr
r = ((remradius*60.))/.396 #radius in pixels
for src in sources:
xs,ys = wcs.positionToPixel(src.getPosition(),src)
if (xs-xt)**2+(ys-yt)**2 <= r**2:
#print "Removed:", src
#print xs,ys
tractor.removeSource(src)
#saveAll('removed-'+prefix, tractor,**sa)
newShape = sg.GalaxyShape((remradius*60.)/10.,ab,angle)
newBright = ba.Mags(r=15.0,g=15.0,u=15.0,z=15.0,i=15.0,order=['u','g','r','i','z'])
EG = st.ExpGalaxy(RaDecPos(ra,dec),newBright,newShape)
print(EG)
tractor.addSource(EG)
saveAll('added-'+prefix,tractor,**sa)
#print 'Tractor has', tractor.getParamNames()
for im in tractor.images:
im.freezeAllParams()
im.thawParam('sky')
tractor.catalog.freezeAllBut(EG)
#print 'Tractor has', tractor.getParamNames()
#print 'values', tractor.getParams()
xtr,ytr = wcs.positionToPixel(RaDecPos(ra,dec))
xt = xtr
yt = ytr
r = ((remradius*60.))/.396 #radius in pixels
for src in sources:
xs,ys = wcs.positionToPixel(src.getPosition(),src)
if (xs-xt)**2+(ys-yt)**2 <= r**2:
#print "Removed:", src
#print xs,ys
tractor.removeSource(src)
#saveAll('removed-'+prefix, tractor,**sa)
newShape = sg.GalaxyShape((remradius*60.)/10.,1.,0.)
newBright = ba.Mags(r=15.0,g=15.0,u=15.0,z=15.0,i=15.0,order=['u','g','r','i','z'])
EG = st.ExpGalaxy(RaDecPos(ra,dec),newBright,newShape)
print EG
tractor.addSource(EG)
saveAll('added-'+prefix,tractor,**sa)
#print 'Tractor has', tractor.getParamNames()
for im in tractor.images:
im.freezeAllParams()
im.thawParam('sky')
tractor.catalog.freezeAllBut(EG)
#print 'Tractor has', tractor.getParamNames()
#print 'values', tractor.getParams()
print(xtr,ytr)
xt = xtr
yt = ytr
r = 250.
for src in sources:
xs,ys = wcs.positionToPixel(src.getPosition(),src)
if (xs-xt)**2+(ys-yt)**2 <= r**2:
print("Removed:", src)
print(xs,ys)
tractor.removeSource(src)
# saveAll('removed-'+prefix, tractor,zr,flipBands,debug=True)
newShape = sg.GalaxyShape(30.,1.,0.)
newBright = ba.Mags(r=15.0,g=15.0,u=15.0,z=15.0,i=15.0)
EG = st.ExpGalaxy(RaDecPos(ra,dec),newBright,newShape)
print(EG)
tractor.addSource(EG)
saveAll('added-'+prefix,tractor,zr,flipBands,debug=True)
plotInvvar('added-'+prefix,tractor)
for i in range(itune1):
if (i % 5 == 0):
tractor.optimizeCatalogLoop(nsteps=1,srcs=[EG],sky=True)
else:
tractor.optimizeCatalogLoop(nsteps=1,srcs=[EG],sky=False)
tractor.changeInvvar(9.)
tractor.clearCache()
saveAll('itune1-%d-' % (i+1)+prefix,tractor,zr,flipBands,debug=True)
plotInvvar('itune1-%d-' % (i+1)+prefix,tractor)
print(xtr,ytr)
xt = xtr
yt = ytr
r = ((remradius*60.))/.396 #radius in pixels
for src in sources:
xs,ys = wcs.positionToPixel(src.getPosition(),src)
if (xs-xt)**2+(ys-yt)**2 <= r**2:
#print "Removed:", src
#print xs,ys
tractor.removeSource(src)
#saveAll('removed-'+prefix, tractor,**sa)
newShape = sg.GalaxyShape((remradius*60.)/10.,1.,0.)
newBright = ba.Mags(r=15.0,g=15.0,u=15.0,z=15.0,i=15.0,order=['u','g','r','i','z'])
EG = st.ExpGalaxy(RaDecPos(ra,dec),newBright,newShape)
newShape2 = sg.GalaxyShape((remradius*60.)/10.,1.,0.)
newBright2 = ba.Mags(r=15.0,g=15.0,u=15.0,z=15.0,i=15.0,order=['u','g','r','i','z'])
EG2 = st.ExpGalaxy(RaDecPos(ra2,dec2),newBright2,newShape2)
print(EG)
print(EG2)
tractor.addSource(EG)
tractor.addSource(EG2)
saveAll('added-'+prefix,tractor,**sa)
#print 'Tractor has', tractor.getParamNames()
for im in tractor.images:
im.freezeAllParams()