Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def getDevProfile():
return DevGalaxy.profile
## Using DECaLS shapes
if sources is None:
sources = []
for obj in comp_galaxy:
pos_x, pos_y = obj['x'], obj['y']
sources.append(
CompositeGalaxy(
PixPos(pos_x, pos_y), Flux(0.4 * obj['flux']),
EllipseE(obj['shapeexp_r'], obj['shapeexp_e1'],
obj['shapeexp_e2']), Flux(0.6 * obj['flux']),
EllipseE(obj['shapedev_r'], obj['shapedev_e1'],
obj['shapedev_e2'])))
for obj in dev_galaxy:
pos_x, pos_y = obj['x'], obj['y']
sources.append(
DevGalaxy(
PixPos(pos_x, pos_y), Flux(obj['flux']),
EllipseE(obj['shapedev_r'], obj['shapedev_e1'],
-obj['shapedev_e2'])))
for obj in exp_galaxy:
pos_x, pos_y = obj['x'], obj['y']
sources.append(
ExpGalaxy(
PixPos(pos_x, pos_y), Flux(obj['flux']),
EllipseE(obj['shapeexp_r'], obj['shapeexp_e1'],
-obj['shapeexp_e2'])))
for obj in rex_galaxy:
#if obj['point_source'] > 0.0:
# sources.append(PointSource(PixPos(w.wcs_world2pix([[obj['ra'], obj['dec']]],1)[0]),
# Flux(obj['flux'])))
pos_x, pos_y = obj['x'], obj['y']
sources.append(
print('Reverted')
lnp3 = tractor.getLogProb()
print('lnp3', lnp3)
assert(lnp3 == lnp0)
elif stype == 'complexify':
for j,src in enumerate(tractor.getCatalog()):
cat = tractor.getCatalog()
ii = cat.index(src)
p0 = cat.getParams()
print('Try complexifying source', src)
#if isinstance(src, PointSource):
newsrc = None
if (isinstance(src, stgal.ExpGalaxy) or
isinstance(src, stgal.DevGalaxy)):
# HACK
faintmag = 21
faint = Mags(**dict([(b,faintmag) for b in bands]))
print('Faint mag:', faint)
args = [src.pos]
if isinstance(src, stgal.ExpGalaxy):
args.extend([src.brightness, src.shape])
args.extend([faint, src.shape])
else:
args.extend([faint, src.shape])
args.extend([src.brightness, src.shape])
newsrc = stgal.CompositeGalaxy(*args)
if newsrc is None:
continue
lnp0 = tractor.getLogProb()
def getParamDerivatives(self, img, modelMask=None):
e = ExpGalaxy(self.pos, self.brightness, self.shapeExp)
d = DevGalaxy(self.pos, self.brightness, self.shapeDev)
e.dname = 'fcomp.exp'
d.dname = 'fcomp.dev'
if self.isParamFrozen('pos'):
e.freezeParam('pos')
d.freezeParam('pos')
if self.isParamFrozen('shapeExp'):
e.freezeParam('shape')
if self.isParamFrozen('shapeDev'):
d.freezeParam('shape')
if hasattr(self, 'halfsize'):
e.halfsize = self.halfsize
d.halfsize = self.halfsize
dexp = e.getParamDerivatives(img, modelMask=modelMask)
def getParamDerivatives(self, img, modelMask=None):
e = ExpGalaxy(self.pos, self.brightnessExp, self.shapeExp)
d = DevGalaxy(self.pos, self.brightnessDev, self.shapeDev)
if hasattr(self, 'halfsize'):
e.halfsize = d.halfsize = self.halfsize
e.dname = 'comp.exp'
d.dname = 'comp.dev'
if self.isParamFrozen('pos'):
e.freezeParam('pos')
d.freezeParam('pos')
if self.isParamFrozen('brightnessExp'):
e.freezeParam('brightness')
if self.isParamFrozen('shapeExp'):
e.freezeParam('shape')
if self.isParamFrozen('brightnessDev'):
d.freezeParam('brightness')
if self.isParamFrozen('shapeDev'):
d.freezeParam('shape')
for i, t in enumerate(T):
pos = RaDecPos(t.ra, t.dec)
flux = NanoMaggies(**{wanyband: 1.})
if all_ptsrcs:
cat.append(PointSource(pos, flux))
continue
tt = t.type.strip()
if tt in ['PTSRC', 'STAR', 'S']:
cat.append(PointSource(pos, flux))
elif tt in ['EXP', 'E']:
shape = EllipseE(*t.shapeexp)
cat.append(ExpGalaxy(pos, flux, shape))
elif tt in ['DEV', 'D']:
shape = EllipseE(*t.shapedev)
cat.append(DevGalaxy(pos, flux, shape))
elif tt in ['COMP', 'C']:
eshape = EllipseE(*t.shapeexp)
dshape = EllipseE(*t.shapedev)
cat.append(FixedCompositeGalaxy(pos, flux, t.fracdev,
eshape, dshape))
else:
print('Did not understand row', i, 'of input catalog:')
t.about()
assert(False)
W = unwise_forcedphot(cat, tiles, roiradecbox=roiradecbox,
bands=opt.bands, unwise_dir=opt.unwise_dir,
use_ceres=opt.ceres, ceres_block=opt.ceresblock,
save_fits=opt.save_fits, ps=ps)
W.writeto(outfn)
if sources is None:
sources = []
for obj in comp_galaxy:
pos_x, pos_y = obj['x'], obj['y']
sources.append(
CompositeGalaxy(
PixPos(pos_x, pos_y), Flux(0.4 * obj['flux']),
GalaxyShape(obj['a_arcsec'] * 0.8, 0.9,
90.0 + obj['theta'] * 180.0 / np.pi),
Flux(0.6 * obj['flux']),
GalaxyShape(obj['a_arcsec'], obj['b_arcsec'] / obj['a_arcsec'],
90.0 + obj['theta'] * 180.0 / np.pi)))
for obj in dev_galaxy:
pos_x, pos_y = obj['x'], obj['y']
sources.append(
DevGalaxy(
PixPos(pos_x, pos_y), Flux(obj['flux']),
GalaxyShape(obj['a_arcsec'], (obj['b_arcsec'] / obj['a_arcsec']),
(90.0 + obj['theta'] * 180.0 / np.pi))))
for obj in exp_galaxy:
pos_x, pos_y = obj['x'], obj['y']
sources.append(
ExpGalaxy(
PixPos(pos_x, pos_y), Flux(obj['flux']),
GalaxyShape(obj['a_arcsec'], (obj['b_arcsec'] / obj['a_arcsec']),
(90.0 + obj['theta'] * 180.0 / np.pi))))
for obj in rex_galaxy:
pos_x, pos_y = obj['x'], obj['y']
sources.append(
ExpGalaxy(
PixPos(pos_x, pos_y), Flux(obj['flux']),
GalaxyShape(obj['a_arcsec'], (obj['b_arcsec'] / obj['a_arcsec']),
def _getUnitFluxPatchSize(self, img, px=0., py=0., minval=0.):
if hasattr(self, 'halfsize'):
return self.halfsize
pixscale = img.wcs.pixscale_at(px, py)
f = self.fracDev.clipped()
r = 1.
if f < 1.:
s = self.shapeExp
rexp = ExpGalaxy.nre * s.re
r = max(r, rexp)
if f > 0.:
s = self.shapeDev
rdev = max(r, DevGalaxy.nre * s.re)
r = max(r, rdev)
halfsize = r / pixscale
halfsize += img.psf.getRadius()
return halfsize
def getLensedImages(self, mypos, quasar):
pass
class Quasar(ParamList):
pass
class MagFudge(ParamList):
pass
pos = RaDecPos(234.5, 17.9)
bright = Mags(r=17.4, g=18.9, order=['g','r'])
# re [arcsec], ab ratio, phi [deg]
shape = GalaxyShape(2., 0.5, 48.)
light = DevGalaxy(pos, bright, shape)
mass = LensingMass(1e14, 0.1)
quasar = Quasar()
fudge = MagFudge(0., 0., 0., 0.)
lq = LensedQuasar(light, mass, quasar, fudge)
print('LensedQuasar params:')
for nm,val in zip(lq.getParamNames(), lq.getParams()):
print(' ', nm, '=', val)