Example #1
0
                    plt.subplot(1,2,1)
                    plt.imshow(true_mod, **ima)
                    plt.subplot(1,2,2)
                    plt.imshow(tim.data, **ima)
                    plt.title('S/N %f, r_e %f' % (sn, re))
                    ps.savefig()
                
                ## run one_blob code?  Or shortcut?
                src = PointSource(RaDecPos(0., 0.),
                                  NanoMaggies(**{band: flux}))

                nblob,iblob,Isrcs = 0, 1, np.array([0])
                brickwcs = wcs
                bx0, by0, blobw, blobh = 0, 0, sz, sz
                blobmask = np.ones((sz,sz), bool)
                timargs = [(tim.data, tim.getInvError(), tim.wcs, tim.wcs.wcs,
                            tim.getPhotoCal(), tim.getSky(), tim.psf,
                            'tim', 0, sz, 0, sz, band, sig1,
                            tim.modelMinval, None)]
                srcs = [src]
                bands = band
                plots,psx = False, None
                simul_opt, use_ceres, hastycho = False, False, False
                
                X = (nblob, iblob, Isrcs, brickwcs, bx0, by0, blobw, blobh,
                     blobmask, timargs, srcs, bands, plots, psx, simul_opt,
                     use_ceres, hastycho)
                R = one_blob(X)
                #print('Got:', R)

                print('Sources:', R.sources)
Example #2
0
                    plt.subplot(1,2,1)
                    plt.imshow(true_mod, **ima)
                    plt.subplot(1,2,2)
                    plt.imshow(tim.data, **ima)
                    plt.title('S/N %f, r_e %f' % (sn, re))
                    ps.savefig()
                
                ## run one_blob code?  Or shortcut?
                src = PointSource(RaDecPos(0., 0.),
                                  NanoMaggies(**{band: flux}))

                nblob,iblob,Isrcs = 0, 1, np.array([0])
                brickwcs = wcs
                bx0, by0, blobw, blobh = 0, 0, sz, sz
                blobmask = np.ones((sz,sz), bool)
                timargs = [(tim.data, tim.getInvError(), tim.wcs, tim.wcs.wcs,
                            tim.getPhotoCal(), tim.getSky(), tim.psf,
                            'tim', 0, sz, 0, sz, band, sig1,
                            tim.modelMinval, None)]
                srcs = [src]
                bands = band
                plots,psx = False, None
                simul_opt, use_ceres, hastycho = False, False, False
                
                X = (nblob, iblob, Isrcs, brickwcs, bx0, by0, blobw, blobh,
                     blobmask, timargs, srcs, bands, plots, psx, simul_opt,
                     use_ceres, hastycho)
                R = one_blob(X)
                #print('Got:', R)

                print('Sources:', R.sources)
Example #3
0
    # lvl = logging.DEBUG
    # logging.basicConfig(level=lvl, format='%(message)s', stream=sys.stdout)

    # Optimize the model.
    for step in range(50):
        print('Tractor params:')
        tractor.printThawedParams()
        dlnp,X,alpha = tractor.optimize(damp=1.)
        print('dlnp', dlnp)
        print('galaxy:', moggal)
        #print('Mog', moggal.mog.getParams())
        if dlnp == 0:
            break

        # Plot the model as we're optimizing...
        mod = tractor.getModelImage(0)
        chi = (tim.getImage() - mod) * tim.getInvError()
        plt.clf()
        plt.subplot(1,2,1)
        plt.imshow(mod, interpolation='nearest', origin='lower')
        plt.title('Model')
        plt.subplot(1,2,2)
        mx = np.abs(chi).max()
        plt.imshow(chi, interpolation='nearest', origin='lower',
                   vmin=-mx, vmax=mx)
        plt.colorbar()
        plt.title('Chi residuals')
        plt.suptitle('MoG model after optimization step %i' % step)
        plt.savefig('mod-o%02i.png' % step)