Beispiel #1
0
    def get_v4_output(self, slvr_cfg, **kwargs):
        # Get visibilities from the v4 solver
        gpu_slvr_cfg = slvr_cfg.copy()
        gpu_slvr_cfg.update(**kwargs)
        gpu_slvr_cfg[Options.VERSION] = Options.VERSION_FOUR

        with FitsBeam(base_beam_file) as fb:
            beam_shape = fb.shape
            gpu_slvr_cfg[Options.E_BEAM_WIDTH] = beam_shape[0]
            gpu_slvr_cfg[Options.E_BEAM_HEIGHT] = beam_shape[1]
            gpu_slvr_cfg[Options.E_BEAM_DEPTH] = beam_shape[2]

            from montblanc.impl.rime.v4.cpu.CPUSolver import CPUSolver

            with montblanc.rime_solver(gpu_slvr_cfg) as slvr:

                cpu_slvr_cfg = slvr.config().copy()
                cpu_slvr_cfg[Options.DATA_SOURCE] = Options.DATA_SOURCE_EMPTY
                cpu_slvr = CPUSolver(cpu_slvr_cfg)

                # Create and transfer lm to the solver
                lm = np.empty(shape=slvr.lm.shape, dtype=slvr.lm.dtype)
                l, m = lm[:,0], lm[:,1]
                l[:] = _L
                m[:] = _M
                slvr.transfer_lm(lm)

                # Create and transfer stoke and alpha to the solver
                stokes = np.empty(shape=slvr.stokes.shape, dtype=slvr.stokes.dtype)
                alpha = np.empty(shape=slvr.alpha.shape, dtype=slvr.alpha.dtype)
                I, Q, U, V = stokes[:,:,0], stokes[:,:,1], stokes[:,:,2], stokes[:,:,3]
                I[:] = _I
                Q[:] = _Q
                U[:] = _U
                V[:] = _V
                alpha[:] = _ALPHA
                slvr.transfer_stokes(stokes)
                slvr.transfer_alpha(alpha)

                fb.reconfigure_frequency_axes(slvr.retrieve_frequency())

                # Create the beam from FITS file
                ebeam = np.zeros(shape=slvr.E_beam.shape, dtype=slvr.E_beam.dtype)
                ebeam.real[:] = fb.real()
                ebeam.imag[:] = fb.imag()
                slvr.transfer_E_beam(ebeam)

                # Configure the beam extents
                ll, lm, lf, ul, um, uf = fb.beam_extents

                slvr.set_beam_ll(ll)
                slvr.set_beam_lm(lm)
                slvr.set_beam_lfreq(lf)
                slvr.set_beam_ul(ul)
                slvr.set_beam_um(um)
                slvr.set_beam_ufreq(uf)

                # Set the reference frequency
                ref_freq = np.full(slvr.ref_frequency.shape, _REF_FREQ, dtype=slvr.ref_frequency.dtype)
                slvr.transfer_ref_frequency(ref_freq)

                from montblanc.solvers import copy_solver

                copy_solver(slvr, cpu_slvr)
                cpu_slvr.compute_E_beam()

                slvr.solve()

                return slvr.X2, slvr.retrieve_model_vis()