def test_skymodel_solve_fixed(self):
        self.actualSetup(ntimes=1, doiso=True, fixed=True)
        calskymodel, residual_vis = calskymodel_solve(self.vis,
                                                      self.skymodels,
                                                      niter=30,
                                                      gain=0.25)

        # Check that the components are unchanged
        calskymodel_skycomponents = list()
        for sm in [csm[0] for csm in calskymodel]:
            for comp in sm.components:
                calskymodel_skycomponents.append(comp)

        recovered_components = find_skycomponent_matches(
            calskymodel_skycomponents, self.components, 1e-5)
        for p in recovered_components:
            assert numpy.abs(calskymodel_skycomponents[p[0]].flux[0, 0] -
                             self.components[p[1]].flux[0, 0]) < 1e-15
            assert calskymodel_skycomponents[p[0]].direction.separation(
                self.components[p[1]].direction).rad < 1e-15

        residual_vis = convert_blockvisibility_to_visibility(residual_vis)
        residual_vis, _, _ = weight_visibility(residual_vis, self.beam)
        dirty, sumwt = invert_function(residual_vis, self.beam, context='2d')
        export_image_to_fits(
            dirty, "%s/test_skymodel-final-iso-residual.fits" % self.dir)

        qa = qa_image(dirty)
        assert qa.data['rms'] < 3.4e-3, qa
    def test_skymodel_solve_noiso(self):
        self.actualSetup(ntimes=1, doiso=False)
        calskymodel, residual_vis = calskymodel_solve(self.vis,
                                                      self.skymodels,
                                                      niter=30,
                                                      gain=0.25)

        residual_vis = convert_blockvisibility_to_visibility(residual_vis)
        residual_vis, _, _ = weight_visibility(residual_vis, self.beam)
        dirty, sumwt = invert_function(residual_vis, self.beam, context='2d')
        export_image_to_fits(
            dirty, "%s/test_skymodel-final-noiso-residual.fits" % self.dir)

        qa = qa_image(dirty)
        assert qa.data['rms'] < 3.8e-3, qa