def GetFits(self):
     bands = dict([('J0837','F606W'),('J0901','F606W'),('J0913','F555W'),('J1125','F606W'),('J1144','F606W'),('J1218','F606W'),('J1248','F555W'),('J1323','F555W'),('J1347','F606W'),('J1446','F606W'),('J1605','F555W'),('J1606','F606W'),('J1619','F606W'),('J2228','F606W')])
     #  not working yet - this will need us to have all the images somewhere, and all the xc,yc offsets!
     # get nnls values! Ideally, these should be already saved
     print "why didn't you save these before?!?"
     yc,xc = iT.coords(self.img1.shape)
     OVRS=1
     yo,xo=iT.overSample(self.img1.shape,OVRS)
     colours = [bands[self.name], 'F814W']
     models = []
     fits = []
     for i in range(len(self.imgs)):
         if i == 0:
             dx,dy = 0,0
         else:
             dx = self.Ddic['xoffset']
             dy = self.Ddic['yoffset']
         xp,yp = xc+dx+self.Dx,yc+dy+self.Dx
         xop,yop = xo+dy+self.Dy,yo+dy+self.Dy
         image = self.imgs[i]
         sigma = self.sigs[i]
         psf = self.PSFs[i]
         imin,sigin,xin,yin = image.flatten(), sigma.flatten(),xp.flatten(),yp.flatten()
         n = 0
         model = np.empty(((len(self.gals) + len(self.srcs)+1),imin.size))
         for gal in self.gals:
             gal.setPars()
             tmp = xc*0.
             tmp = gal.pixeval(xp,yp,1./OVRS,csub=11) # evaulate on the oversampled grid. OVRS = number of new pixels per old pixel.
             tmp = iT.resamp(tmp,OVRS,True) # convert it back to original size
             tmp = convolve.convolve(tmp,psf,False)[0]
             model[n] = tmp.ravel()
             n +=1
         for lens in self.lenses:
             lens.setPars()
             x0,y0 = pylens.lens_images(self.lenses,self.srcs,[xp,yp],1./OVRS,getPix=True)
         for src in self.srcs:
             src.setPars()
             tmp = xc*0.
             tmp = src.pixeval(x0,y0,1./OVRS,csub=11)
             tmp = iT.resamp(tmp,OVRS,True)
             tmp = convolve.convolve(tmp,psf,False)[0]
             model[n] = tmp.ravel()
             n +=1
         model[n] = np.ones(model[n].shape)
         n +=1
         rhs = (imin/sigin) # data
         op = (model/sigin).T # model matrix
         fit, chi = optimize.nnls(op,rhs)
         components = (model.T*fit).T.reshape((n,image.shape[0],image.shape[1]))
         model = components.sum(0)
         models.append(model)
         #SotPleparately(image,model,sigma,colours[i])
         #NotPlicely(image,model,sigma)
         comps = False
         if comps == True:
             CotSomponents(components,colours[i])
         fits.append(fit)
         self.fits = fits
Beispiel #2
0
 def addImg(self,name,img,sig,psf=None,scale=1.):
     self.imgs.append(img)
     self.sigs.append(sig)
     if psf is not None:
         PSF = psf/psf.sum()
         self.psfImgs.append(PSF)
         PSF = convolve.convolve(img,PSF)[1]
         self.psfs.append(PSF)
     else:
         self.psfs.append(None)
         self.psfImgs.append(None)
     yc,xc = iT.overSample(img.shape,1.)
     self.xc.append(xc*scale)
     self.yc.append(yc*scale)
     if len(self.imgs)>1:
         self.offsets.append(pymc.Uniform('xoff_%s'%name,-5.*scale,5.*scale,value=0.))
         self.offsets.append(pymc.Uniform('yoff_%s'%name,-5.*scale,5.*scale,value=0.))
         self.cov += [0.1,0.1]
Beispiel #3
0
def trimandmaskPSFMatrix(PSF, imshape, mask, size=None):
    import indexTricks as iT
    if size != None:
        prad = size + 0.0001
        pc = (PSF.shape[0] - 1) / 2
        PSF = PSF[pc - prad:pc + prad, pc - prad:pc + prad]
        pc = (PSF.shape[0] - 1) / 2
        l, m = iT.overSample(PSF.shape, 1)
        l -= pc
        m -= pc
        l = l.flatten()
        m = m.flatten()
        f = ((l**2 + m**2) < prad**2)
        f = f.reshape(PSF.shape)
        pmask = numpy.zeros(PSF.shape)
        pmask[f] = 1
        pmask = pmask.reshape(PSF.shape)
        PSF[pmask != 1] = 0
    psf = PSF / PSF.sum()
    psf /= psf.sum()
    Pfull = getPSFMatrix(psf, imshape)
    Pmasked = maskPSFMatrix(Pfull, mask)
    return Pmasked, Pfull
    pl.imshow((image-im)/sigma,origin='lower',interpolation='nearest',extent=ext,vmin=-5,vmax=5,cmap='afmhot',aspect='auto')
    pl.title('signal-to-noise residuals')
    pl.colorbar()

image = py.open('/data/ljo31/Lens/J1125/Kp_J1125_nirc2_n.fits')[0].data.copy()[650:905,640:915]
sigma = np.ones(image.shape) 

result = np.load('/data/ljo31/Lens/LensModels/J1125_212_nonconcentric')
lp= result[0]
a2=0
a1,a3 = numpy.unravel_index(lp[:,0].argmax(),lp[:,0].shape)
trace = result[1]
dic = result[2]

OVRS = 1
yc,xc = iT.overSample(image.shape,OVRS)
yo,xo = iT.overSample(image.shape,1)
xc,xo,yc,yo = xc+80,xo+80,yc+90,yo+90
mask = np.zeros(image.shape)
tck = RectBivariateSpline(yo[:,0],xo[0],mask)
mask2 = tck.ev(xc,yc)
mask2[mask2<0.5] = 0
mask2[mask2>0.5] = 1
mask2 = mask2==0
mask = mask==0

pars = []
cov = []
### four PSF components
pars.append(pymc.Uniform('xoffset',-40.,40.,value=5))
pars.append(pymc.Uniform('yoffset',-40.,40.,value=5))
guiFile = '/data/ljo31/Lens/J1605/BM2'
guiFile = '/data/ljo31/Lens/J1605/terminal_bestfit_iterated'
#guiFile = '/data/ljo31/Lens/J1605/terminal_bestfit_iterated_2'
#guiFile = '/data/ljo31/Lens/J1605/terminal_bestfit_iterated_3'
guiFile = '/data/ljo31/Lens/J1605/terminal_iterated_4'
#guiFile = '/data/ljo31/Lens/J1605/SingleSource'


print 'schon aus Terminal'

imgs = [img1,img2]
sigs = [sig1,sig2]
psfs = [psf1,psf2]

PSFs = []
yc,xc = iT.overSample(img1.shape,1.)
yc,xc = yc-15.,xc-15.
for i in range(len(imgs)):
    psf = psfs[i]
    image = imgs[i]
    psf /= psf.sum()
    psf = convolve.convolve(image,psf)[1]
    PSFs.append(psf)


OVRS = 1

G,L,S,offsets,_ = numpy.load(guiFile)

pars = []
cov = []
image = py.open('/data/ljo31/Lens/J1144/J1144_Kp_narrow_cutout.fits')[0].data.copy()
sigma = np.ones(image.shape)
guiFile = '/data/ljo31/Lens/J1144/FINAL_1src_30'
G,L,S,offsets,shear = numpy.load(guiFile)
print guiFile

result = np.load('/data/ljo31/Lens/J1144/KeckPSF_7')
lp= result[0]
a2=0
a1,a3 = numpy.unravel_index(lp[:,0].argmax(),lp[:,0].shape)
trace = result[1]
dic = result[2]

OVRS = 1
PVRS=2
yc,xc = iT.overSample(image.shape,OVRS)
yo,xo = iT.overSample(image.shape,1)
xc,xo,yc,yo=xc*0.2,xo*0.2,yc*0.2,yo*0.2
xc,xo = xc+12 , xo+12 
yc,yo = yc+20 , yo+20 
mask = np.zeros(image.shape)
tck = RectBivariateSpline(yo[:,0],xo[0],mask)
mask2 = tck.ev(xc,yc)
mask2[mask2<0.5] = 0
mask2[mask2>0.5] = 1
mask2 = mask2==0
mask = mask==0
xpsf,ypsf = iT.coords((340,340))-170
xpsf,ypsf = iT.overSample((340,340),PVRS) # oversampling
xpsf,ypsf=xpsf-170.,ypsf-170.
dx,dy,sig1,q1,pa1,amp1,sig2,q2,pa2 = trace[a1,a2,a3]
Beispiel #7
0
def optimize(data, niter, oname=None, first=True):
    import pymc, pyfits, numpy
    import indexTricks as iT

    priors = data['PRIORS']
    models = data['MODELS']
    pars = data['PARAMS']

    image = {}
    for key in data['IMG'].keys():
        image[key] = data['IMG'][key].copy()
    ZP = data['ZP']
    filters = [filt for filt in data['FILTERS']]

    sigmas = data['SIGMA']
    if 'GAIN' in data.keys():
        gain = data['GAIN']
        doSigma = True
    else:
        doSigma = False

    if 'OVRS' in data.keys():
        OVRS = data['OVRS']
    else:
        OVRS = 1

    MASK = data['MASK'].copy()
    mask = MASK == 0
    mask_r = mask.ravel()

    key2index = {}
    i = 0
    for key in filters:
        key2index[key] = i
        i += 1

    model2index = {}
    i = 0
    for key in filters:
        for model in models[key]:
            model2index[model.name] = i
            i += 1

    imshape = MASK.shape
    yc, xc = iT.overSample(imshape, OVRS)

    if doSigma == True:
        nu = {}
        eta = {}
        background = {}
        counts = {}
        sigmask = {}
        for key in filters:
            nu[key] = pymc.Uniform('nu_%s' % key,
                                   -6,
                                   6,
                                   value=log10(gain[key]))
            eta[key] = pymc.Uniform('eta_%s' % key, -4, 5, value=1.)
            background[key] = sigmas[key]
            sigmask[key] = image[key] > 1.5 * sigmas[key]**0.5
            counts[key] = image[key][sigmask[key]].copy()
            pars.append(nu[key])
            pars.append(eta[key])

        def getSigma(n=nu, e=eta, b=background, c=counts, m=mask):
            sigma = b.copy()
            sigma[m] += ((10**n) * c)**e
            return numpy.sqrt(sigma).ravel()

        sigmas = []
        for key in filters:
            parents = {
                'n': nu[key],
                'e': eta[key],
                'b': background[key],
                'c': counts[key],
                'm': sigmask[key]
            }
            sigmas.append(
                pymc.Deterministic(eval=getSigma,
                                   name='sigma_%s' % key,
                                   parents=parents,
                                   doc='',
                                   trace=False,
                                   verbose=False))
    else:
        for key in filters:
            sigmas[key] = sigmas[key].ravel()

    for key in filters:
        image[key] = image[key].ravel()

    @pymc.deterministic(trace=False)
    def logpAndMags(p=pars):
        lp = 0.
        mags = []
        for key in filters:
            indx = key2index[key]
            if doSigma == True:
                sigma = sigmas[indx].value
            else:
                sigma = sigmas[key]
            simage = (image[key] / sigma)[mask_r]
            lp += linearmodelSB(p,
                                simage,
                                sigma[mask_r],
                                mask,
                                models[key],
                                xc,
                                yc,
                                OVRS=OVRS)
            mags += [model.Mag(ZP[key]) for model in models[key]]
        return lp, mags

    @pymc.deterministic
    def lp(lpAM=logpAndMags):
        return lpAM[0]

    @pymc.deterministic
    def Mags(lpAM=logpAndMags):
        return lpAM[1]

    @pymc.observed
    def logpCost(value=0., logP=lp):
        return logP

    costs = [logpCost]
    if priors is not None:

        @pymc.observed
        def colorPrior(value=0., M=Mags):
            lp = 0.
            for p in priors:
                color = M[model2index[p[0]]] - M[model2index[p[1]]]
                lp += p[2](color)
            return lp

        costs.append(colorPrior)

    def resid(p):
        model = numpy.empty(0)
        for key in filters:
            indx = key2index[key]
            if doSigma == True:
                sigma = sigmas[indx].value
            else:
                sigma = sigmas[key]
            simage = (image[key] / sigma)[mask_r]
            model = numpy.append(
                model,
                linearmodelSB(p,
                              simage,
                              sigma[mask_r],
                              mask,
                              models[key],
                              xc,
                              yc,
                              levMar=True,
                              OVRS=OVRS))
        return model

    print "Optimizing", niter
    from SampleOpt import AMAOpt as Opt, levMar as levMar
    default = numpy.empty(0)
    for key in filters:
        indx = key2index[key]
        if doSigma == True:
            sigma = sigmas[indx].value
        else:
            sigma = sigmas[key]
        simage = (image[key] / sigma)[mask_r]
        default = numpy.append(default, simage)
#    levMar(pars,resid,default)

    cov = None
    if 'COV' in data.keys():
        cov = data['COV']

    O = Opt(pars, costs, [lp, Mags], cov=cov)
    O.set_minprop(len(pars) * 2)
    O.sample(niter / 10)

    O = Opt(pars, costs, [lp, Mags], cov=cov)
    O.set_minprop(len(pars) * 2)
    O.cov = O.cov / 4.
    O.sample(niter / 4)

    O = Opt(pars, costs, [lp, Mags], cov=cov)
    O.set_minprop(len(pars) * 2)
    O.cov = O.cov / 10.
    O.sample(niter / 4)

    O = Opt(pars, costs, [lp, Mags], cov=cov)
    O.set_minprop(len(pars) * 2)
    O.cov = O.cov / 10.
    O.sample(niter)
    logp, trace, result = O.result()
    mags = numpy.array(result['Mags'])

    for key in model2index.keys():
        result[key] = mags[:, model2index[key]].copy()
    del result['Mags']

    output = {}
    for key in filters:
        indx = key2index[key]
        if doSigma == True:
            sigma = sigmas[indx].value
        else:
            sigma = sigmas[key]
        simage = (image[key] / sigma)[mask_r]
        m = linearmodelSB([p.value for p in pars],
                          simage,
                          sigma[mask_r],
                          mask,
                          models[key],
                          xc,
                          yc,
                          noResid=True,
                          OVRS=OVRS)
        output[key] = m
    return output, (logp, trace, result)
sigName = '/data/ljo31/Lens/J1606/dump/SDSSJ1606+2235_F606W_noise_cutout_2.fits'
sigName = '/data/ljo31/Lens/J1606/SDSSJ1606+2235_F606W_noisemap.fits'
psfName = '/data/ljo31/Lens/J1606/SDSSJ1606+2235_F606W_psf.fits'

#img2Name = '/data/ljo31/Lens/SDSSJ1606+2235_F814W_sci_cutout.fits'
#sig2Name = '/data/ljo31/Lens/SDSSJ1606+2235_F814W_noise3_cutout.fits'
#psf2Name = '/data/ljo31/Lens/SDSSJ1606+2235_F814W_psf.fits'

guiFile = '/data/ljo31/Lens/J1606/fits/ModelFit20_uniform'


image = pyfits.open(imgName)[0].data.copy()
sigma = pyfits.open(sigName)[0].data.copy()
psf = pyfits.open(psfName)[0].data.copy()

yc,xc = iT.overSample(image.shape,1.)
psf /= psf.sum()
psf = convolve.convolve(image,psf)[1]

OVRS = 1

G,L,S,_,_ = numpy.load(guiFile)

pars = []
srcs = []
cov = []
for name in S.keys():
    s = S[name]
    p = {}
    for key in 'x','y','q','pa','re','n':
        if s[key]['type']=='constant':
psf1 = psf1[15:-15,15:-15]
psf1 /= psf1.sum()

img2 = pyfits.open('/data/ljo31/Lens/J1347/SDSSJ1347-0101_F814W_sci_cutout.fits')[0].data.copy()
sig2 = pyfits.open('/data/ljo31/Lens/J1347/SDSSJ1347-0101_F814W_noisemap.fits')[0].data.copy()
psf2 = pyfits.open('/data/ljo31/Lens/J1347/SDSSJ1347-0101_F814W_psf_#2.fits')[0].data.copy()
psf2 = psf2[15:-15,15:-16]
psf2 /= psf2.sum()

imgs = [img1,img2]
sigs = [sig1,sig2]
psfs = [psf1,psf2]

PSFs = []
OVRS = 4
yc,xc = iT.overSample(img1.shape,OVRS)
yc,xc = yc,xc
for i in range(len(imgs)):
    psf = psfs[i]
    image = imgs[i]
    psf /= psf.sum()
    psf = convolve.convolve(image,psf)[1]
    PSFs.append(psf)

lp = 0.
for i in range(len(imgs)):
        if i == 0:
            x0,y0 = 0,0
        else:
            x0 = dx
            y0 = dy
guiFile = '/data/ljo31/Lens/J1347/1_src3'
'''
result = np.load('/data/ljo31/Lens/J1347/emcee_FINAL_uncertainties_TWO')
lp= result[0]
a1,a2 = numpy.unravel_index(lp.argmax(),lp.shape)
trace = result[1]
dx,dy,x1,y1,q1,pa1,re1,n1,q2,pa2,re2,n2,x3,y3,q3,pa3,re3,n3,x4,y4,q4,pa4,b,eta,shear,shearpa = trace[a1,a2,:]
'''
imgs = [img1,img2,img3]
sigs = [sig1,sig2,sig3]
psfs = [psf1,psf2,psf3]

PSFs = []
OVRS = 3
yc,xc = iT.overSample(img1.shape,OVRS)
yo,xo = iT.overSample(img1.shape,1)
yck,xck = iT.overSample(img3.shape,1)
yck,xck=yck*0.6,xck*0.6
xck,yck=xck,yck

mask=np.ones(img1.shape)
tck = RectBivariateSpline(yo[:,0],xo[0],mask)
mask2 = tck.ev(yc,xc)
mask2[mask2<0.5] = 0
mask2[mask2>0.5] = 1
print mask2.shape, mask.shape
mask2 = mask2==1
mask = mask==1

for i in range(len(imgs)):
Beispiel #11
0
    def GetPDFs(self,kpc=False):
        self.muPDF = []
        self.murestPDF = []
        self.RePDF = []
        self.magrestPDF = []
        self.LumPDF = []
        self.magPDF = []
        self.fitPDF = []
        self.bbandPDF = []
        OVRS=self.OVRS
        yo,xo = iT.coords(self.img1.shape)
        yc,xc=iT.overSample(self.img1.shape,OVRS)
        colours = [bands[self.name], 'F814W']
        for b1 in range(0,len(self.dictionaries),100):
            srcs,gals,lenses = [],[],[]
            for number in range(1,1+self.srcno):
                name = 'Source '+str(number)
                p = {}
                for key in 'q','re','n','pa':
                    p[key] = self.dictionaries[b1][name+' '+key]
                for key in 'x','y': # subtract lens potition - to be added back on later in each likelihood iteration!
                    p[key] = self.dictionaries[b1][name+' '+key]+self.dictionaries[b1]['Lens 1 '+key]
                srcs.append(SBBModels.Sersic(name,p))
            for number in range(1,1+self.galno):
                name = 'Galaxy '+str(number)
                p = {}
                for key in 'x','y','q','re','n','pa':
                    p[key] = self.dictionaries[b1][name+' '+key]
                gals.append(SBBModels.Sersic(name,p))
            p = {}
            for key in 'x','y','q','pa','b','eta':
                p[key] = self.dictionaries[b1]['Lens 1 '+key]
            lenses.append(MassModels.PowerLaw('Lens 1',p))
            p = {}
            p['x'] = lenses[0].pars['x']
            p['y'] = lenses[0].pars['y']
            p['b'] = self.dictionaries[b1]['extShear']
            p['pa'] = self.dictionaries[b1]['extShear PA']
            lenses.append(MassModels.ExtShear('shear',p))
            # fits
            fits = []
            for i in range(len(self.imgs)):
                if i == 0:
                    dx,dy = 0,0
                else:
                    dx = self.dictionaries[b1]['xoffset']
                    dy = self.dictionaries[b1]['yoffset']
                xp,yp = xc+dx+self.Dx,yc+dy+self.Dy
                xop,yop = xo+dy+self.Dx,yo+dy+self.Dy
                image = self.imgs[i]
                sigma = self.sigs[i]
                psf = self.PSFs[i]
                imin,sigin,xin,yin = image.flatten(), sigma.flatten(),xp.flatten(),yp.flatten()
                n = 0
                model = np.empty(((len(gals) + len(srcs)+1),imin.size))
                for gal in gals:
                    gal.setPars()
                    tmp = xc*0.
                    tmp = gal.pixeval(xp,yp,1./OVRS,csub=11) # evaulate on the oversampled grid. OVRS = number of new pixels per old pixel.
                    tmp = iT.resamp(tmp,OVRS,True) # convert it back to original size
                    tmp = convolve.convolve(tmp,psf,False)[0]
                    model[n] = tmp.ravel()
                    n +=1
                for lens in lenses:
                    lens.setPars()
                    x0,y0 = pylens.lens_images(lenses,srcs,[xp,yp],1./OVRS,getPix=True)
                for src in srcs:
                    src.setPars()
                    tmp = xc*0.
                    if 'boxiness' in self.dic.keys():
                        if src.name == 'Source 2':
                            #print 'this source has a boxy/disky component with c = ', '%.2f'%self.Ddic['boxiness'], '. I hope this is J1606!'
                            tmp = src.boxypixeval(x0,y0,1./OVRS,csub=11,c=self.Ddic['boxiness'])
                        else:
                            tmp = src.pixeval(x0,y0,1./OVRS,csub=11)
                    else:
                        tmp = src.pixeval(x0,y0,1./OVRS,csub=11)
                    tmp = iT.resamp(tmp,OVRS,True)
                    tmp = convolve.convolve(tmp,psf,False)[0]
                    model[n] = tmp.ravel()
                    if self.name == 'J0837':
                        #print "making J0837's dust lane..."
                        if src.name == 'Source 2':
                            model[n] *= -1
                    n +=1
                model[n] = np.ones(model[n].shape)
                n +=1
                rhs = (imin/sigin) # data
                op = (model/sigin).T # model matrix
                fit, chi = optimize.nnls(op,rhs)
                fits.append(fit)
            # source plane (observed) magnitudes
            if len(self.srcs)==1 or self.name == 'J0837':
                mag_v = srcs[0].getMag(fits[0][-2],self.ZPs[0])
                mag_i = srcs[0].getMag(fits[1][-2],self.ZPs[1])
            elif len(self.srcs)==2 and self.name != 'J0837':
                mv1,mv2 = srcs[0].getMag(fits[0][-3],self.ZPs[0]), srcs[1].getMag(fits[0][-2],self.ZPs[0])
                mi1,mi2 = srcs[0].getMag(fits[1][-3],self.ZPs[1]),srcs[1].getMag(fits[1][-2],self.ZPs[1]) 
                Fv = 10**(0.4*(self.ZPs[0]-mv1)) + 10**(0.4*(self.ZPs[0]-mv2))
                Fi = 10**(0.4*(self.ZPs[0]-mi1)) + 10**(0.4*(self.ZPs[0]-mi2))
                mag_v, mag_i = -2.5*np.log10(Fv) + self.ZPs[0], -2.5*np.log10(Fi) + self.ZPs[1]
            else:
                print 'how many sources do you want from me?'
            # intrinsic magnitudes
            if bands[self.name] == 'F555W':
                vband = MassB2
                bband = MassB2toB
            elif bands[self.name] == 'F606W':
                vband = MassB1
                bband = MassB1toB
            iband, kband = MassR, MassK
            Lv,mag_v_rest = vband(mag_v, self.z)
            Li,mag_i_rest = iband(mag_i, self.z)
            Lb,mag_b_rest = bband(mag_v,self.z)
            # sizes
            if self.srcno == 1 or self.name == 'J0837':
                Re_v, Re_i = srcs[0].pars['re']*0.05, srcs[0].pars['re']*0.05
            elif self.srcno == 2 and self.name != 'J0837':
                Xgrid = np.logspace(-4,5,1501)
                Ygrid = np.logspace(-4,5,1501)
                bandRes = []
                for i in range(len(self.imgs)):
                    source = fits[i][-3]*srcs[0].eval(Xgrid) + fits[i][-2]*srcs[1].eval(Xgrid)
                    R = Xgrid.copy()
                    light = source*2.*np.pi*R
                    mod = splrep(R,light,t=np.logspace(-3.8,4.8,1301))
                    intlight = np.zeros(len(R))
                    for i in range(len(R)):
                        intlight[i] = splint(0,R[i],mod)
                    model = splrep(intlight[:-300],R[:-300])
                    if len(model[1][np.where(np.isnan(model[1])==True)]>0):
                        #print 'here'
                        model = splrep(intlight[:-600],R[:-600])
                    reff = splev(0.5*intlight[-1],model)
                    bandRes.append(reff*0.05)
                Re_v,Re_i = bandRes
            # surface brightnesses
            mu_v_rest = mag_v_rest +  2.5*np.log10(2.*np.pi*Re_v**2.)
            mu_i_rest = mag_i_rest + 2.5*np.log10(2.*np.pi*Re_i**2.)
            mu_b_rest = mag_b_rest + 2.5*np.log10(2.*np.pi*Re_v**2.)
            mu_v = mag_v +  2.5*np.log10(2.*np.pi*Re_v**2.)
            mu_i = mag_i + 2.5*np.log10(2.*np.pi*Re_i**2.)
            self.muPDF.append([mu_v,mu_i])
            self.murestPDF.append([mu_v_rest,mu_i_rest,mu_b_rest])
	    if kpc:
		self.RePDF.append([Re_v*self.scale,Re_i*self.scale])
	    else:
		self.RePDF.append([Re_v,Re_i])
            self.magrestPDF.append([mag_v_rest,mag_i_rest,mag_b_rest])
            self.LumPDF.append([Lv,Li,Lb])
            self.magPDF.append([mag_v,mag_i])
            self.fitPDF.append(fits)