示例#1
0
def create_unittest_components(model,
                               flux,
                               applypb=False,
                               telescope='LOW',
                               npixel=None,
                               scale=1.0,
                               single=False,
                               symmetric=False,
                               angular_scale=1.0):
    # Fill the visibility with exactly computed point sources.

    if npixel is None:
        _, _, _, npixel = model.data.shape
    spacing_pixels = int(scale * npixel) // 4
    log.info('Spacing in pixels = %s' % spacing_pixels)

    if not symmetric:
        centers = [(0.2 * angular_scale, 1.1 * angular_scale)]
    else:
        centers = list()

    if not single:
        centers.append([0.0, 0.0])

        for x in numpy.linspace(-1.2 * angular_scale, 1.2 * angular_scale, 7):
            if abs(x) > 1e-15:
                centers.append([x, x])
                centers.append([x, -x])
    model_pol = model.polarisation_frame
    # Make the list of components
    rpix = model.wcs.wcs.crpix
    components = []
    for center in centers:
        ix, iy = center
        # The phase center in 0-relative coordinates is n // 2 so we centre the grid of
        # components on ny // 2, nx // 2. The wcs must be defined consistently.
        p = int(round(rpix[0] + ix * spacing_pixels * numpy.sign(model.wcs.wcs.cdelt[0]))), \
            int(round(rpix[1] + iy * spacing_pixels * numpy.sign(model.wcs.wcs.cdelt[1])))
        sc = pixel_to_skycoord(p[0], p[1], model.wcs, origin=1)
        log.info("Component at (%f, %f) [0-rel] %s" % (p[0], p[1], str(sc)))

        # Channel images
        comp = create_skycomponent(direction=sc,
                                   flux=flux,
                                   frequency=model.frequency,
                                   polarisation_frame=model_pol)
        components.append(comp)

    if applypb:
        beam = create_pb(model, telescope=telescope, use_local=False)
        components = apply_beam_to_skycomponent(components, beam)

    return components
示例#2
0
 def test_create_primary_beams_RADEC(self):
     self.createVis()
     for telescope in ['VLA', 'ASKAP', 'MID', 'LOW']:
         model = create_image_from_visibility(self.vis,
                                              cellsize=self.cellsize,
                                              npixel=self.npixel,
                                              override_cellsize=False)
         beam = create_pb(model, telescope=telescope, use_local=False)
         assert numpy.max(beam.data) > 0.0
         if self.persist:
             export_image_to_fits(
                 beam, "%s/test_primary_beam_RADEC_%s.fits" %
                 (self.dir, telescope))
示例#3
0
    def test_apply_primary_beam_imageplane(self):
        self.createVis()
        telescope = 'MID'
        lflux = numpy.array([[100.0, 1.0, -10.0, +60.0]])
        cflux = numpy.array([[100.0, 60.0, -10.0, +1.0]])
        apply_pb = True
        for flux, vpol in ((lflux, PolarisationFrame("linear")),
                           (cflux, PolarisationFrame("circular"))):
            # print("Testing {0}".format(vpol.type))
            # print("Original flux = {}".format(flux))
            bvis = create_blockvisibility(
                self.config,
                self.times,
                self.frequency,
                channel_bandwidth=self.channel_bandwidth,
                phasecentre=self.phasecentre,
                weight=1.0,
                polarisation_frame=vpol,
                zerow=True)

            component_centre = SkyCoord(ra=+15.5 * u.deg,
                                        dec=-35.0 * u.deg,
                                        frame='icrs',
                                        equinox='J2000')
            component = create_skycomponent(
                direction=component_centre,
                flux=flux,
                frequency=self.frequency,
                polarisation_frame=PolarisationFrame("stokesIQUV"))
            model = create_image_from_visibility(
                bvis,
                cellsize=self.cellsize,
                npixel=self.npixel,
                override_cellsize=False,
                polarisation_frame=PolarisationFrame("stokesIQUV"))
            pb = create_pb(model, telescope=telescope, use_local=False)
            if apply_pb:
                pbcomp = apply_beam_to_skycomponent(component, pb)
                # print("After application of primary beam {}".format(str(pbcomp.flux)))
            else:
                pbcomp = copy_skycomponent(component)
            bvis = dft_skycomponent_visibility(bvis, pbcomp)
            iquv_image = idft_visibility_skycomponent(bvis, component)[0]
示例#4
0
def create_simulation_components(context,
                                 phasecentre,
                                 frequency,
                                 pbtype,
                                 offset_dir,
                                 flux_limit,
                                 pbradius,
                                 pb_npixel,
                                 pb_cellsize,
                                 show=False):
    """ Construct components for simulation
    
    :param context:
    :param phasecentre:
    :param frequency:
    :param pbtype:
    :param offset_dir:
    :param flux_limit:
    :param pbradius:
    :param pb_npixel:
    :param pb_cellsize:
    :return:
    """

    HWHM_deg, null_az_deg, null_el_deg = find_pb_width_null(pbtype, frequency)

    dec = phasecentre.dec.deg
    ra = phasecentre.ra.deg

    if context == 'singlesource':
        log.info("create_simulation_components: Constructing single component")
        offset = [HWHM_deg * offset_dir[0], HWHM_deg * offset_dir[1]]
        log.info(
            "create_simulation_components: Offset from pointing centre = %.3f, %.3f deg"
            % (offset[0], offset[1]))

        # The point source is offset to approximately the halfpower point
        offset_direction = SkyCoord(
            ra=(ra + offset[0] / numpy.cos(numpy.pi * dec / 180.0)) *
            units.deg,
            dec=(dec + offset[1]) * units.deg,
            frame='icrs',
            equinox='J2000')

        original_components = [
            Skycomponent(flux=[[1.0]],
                         direction=offset_direction,
                         frequency=frequency,
                         polarisation_frame=PolarisationFrame('stokesI'))
        ]

    elif context == 'null':
        log.info(
            "create_simulation_components: Constructing single component at the null"
        )

        offset = [null_az_deg * offset_dir[0], null_el_deg * offset_dir[1]]
        HWHM = HWHM_deg * numpy.pi / 180.0

        log.info(
            "create_simulation_components: Offset from pointing centre = %.3f, %.3f deg"
            % (offset[0], offset[1]))

        # The point source is offset to approximately the null point
        offset_direction = SkyCoord(
            ra=(ra + offset[0] / numpy.cos(numpy.pi * dec / 180.0)) *
            units.deg,
            dec=(dec + offset[1]) * units.deg,
            frame='icrs',
            equinox='J2000')

        original_components = [
            Skycomponent(flux=[[1.0]],
                         direction=offset_direction,
                         frequency=frequency,
                         polarisation_frame=PolarisationFrame('stokesI'))
        ]

    else:
        offset = [0.0, 0.0]
        # Make a skymodel from S3
        max_flux = 0.0
        total_flux = 0.0
        log.info("create_simulation_components: Constructing s3sky components")
        from rascil.processing_components.simulation import create_test_skycomponents_from_s3

        original_components = create_test_skycomponents_from_s3(
            flux_limit=flux_limit / 100.0,
            phasecentre=phasecentre,
            polarisation_frame=PolarisationFrame("stokesI"),
            frequency=numpy.array(frequency),
            radius=pbradius)
        log.info(
            "create_simulation_components: %d components before application of primary beam"
            % (len(original_components)))

        pbmodel = create_image(npixel=pb_npixel,
                               cellsize=pb_cellsize,
                               phasecentre=phasecentre,
                               frequency=frequency,
                               polarisation_frame=PolarisationFrame("stokesI"))
        pb = create_pb(pbmodel,
                       "MID_GAUSS",
                       pointingcentre=phasecentre,
                       use_local=False)
        pb_feko = create_pb(pbmodel,
                            pbtype,
                            pointingcentre=phasecentre,
                            use_local=True)
        pb.data = pb_feko.data[:, 0, ...][:, numpy.newaxis, ...]
        pb_applied_components = [
            copy_skycomponent(c) for c in original_components
        ]
        pb_applied_components = apply_beam_to_skycomponent(
            pb_applied_components, pb)
        filtered_components = []
        for icomp, comp in enumerate(pb_applied_components):
            if comp.flux[0, 0] > flux_limit:
                total_flux += comp.flux[0, 0]
                if abs(comp.flux[0, 0]) > max_flux:
                    max_flux = abs(comp.flux[0, 0])
                filtered_components.append(original_components[icomp])
        log.info(
            "create_simulation_components: %d components > %.3f Jy after application of primary beam"
            % (len(filtered_components), flux_limit))
        log.info(
            "create_simulation_components: Strongest components is %g (Jy)" %
            max_flux)
        log.info(
            "create_simulation_components: Total flux in components is %g (Jy)"
            % total_flux)
        original_components = [
            copy_skycomponent(c) for c in filtered_components
        ]
        if show:
            plt.clf()
            show_image(pb, components=original_components)
            plt.show(block=False)

        log.info("create_simulation_components: Created %d components" %
                 len(original_components))
        # Primary beam points to the phasecentre
        offset_direction = SkyCoord(ra=ra * units.deg,
                                    dec=dec * units.deg,
                                    frame='icrs',
                                    equinox='J2000')

    return original_components, offset_direction
示例#5
0
        print("%d components before application of primary beam" %
              (len(original_components)))

        pbmodel = rsexecute.execute(create_image_from_visibility)(
            vis_list0,
            npixel=pb_npixel,
            cellsize=pb_cellsize,
            override_cellsize=False,
            phasecentre=phasecentre,
            frequency=frequency,
            nchan=nfreqwin,
            polarisation_frame=PolarisationFrame("stokesI"))
        pbmodel = rsexecute.compute(pbmodel, sync=True)
        # Use MID_GAUSS to filter the components since MID_GRASP is in local coordinates
        pb = create_pb(pbmodel,
                       "MID_GAUSS",
                       pointingcentre=phasecentre,
                       use_local=False)
        pb_applied_components = [
            copy_skycomponent(c) for c in original_components
        ]
        pb_applied_components = apply_beam_to_skycomponent(
            pb_applied_components, pb)
        filtered_components = []
        for icomp, comp in enumerate(pb_applied_components):
            if comp.flux[0, 0] > flux_limit:
                total_flux += comp.flux[0, 0]
                if abs(comp.flux[0, 0]) > max_flux:
                    max_flux = abs(comp.flux[0, 0])
                filtered_components.append(original_components[icomp])
        print("%d components > %.3f Jy after application of primary beam" %
              (len(filtered_components), flux_limit))
def create_simulation_components(
        context,
        phasecentre,
        frequency,
        pbtype,
        offset_dir,
        flux_limit,
        pbradius,
        pb_npixel,
        pb_cellsize,
        show=False,
        fov=10,
        polarisation_frame=PolarisationFrame("stokesI"),
        filter_by_primary_beam=True,
        flux_max=10.0):
    """ Construct components for simulation
    
    :param context: singlesource or null or s3sky
    :param phasecentre: Centre of components
    :param frequency: Frequency
    :param pbtype: Type of primary beam
    :param offset_dir: Offset in ra, dec degrees
    :param flux_limit: Lower limit flux
    :param pbradius: Radius of components in radians
    :param pb_npixel: Number of pixels in the primary beam model
    :param pb_cellsize: Cellsize in primary beam model
    :param fov: FOV in degrees (used to select catalog)
    :param flux_max: Maximum flux in model before application of primary beam
    :param filter_by_primary_beam: Filter components by primary beam
    :param polarisation_frame:
    :param show:

    :return:
    """

    HWHM_deg, null_az_deg, null_el_deg = find_pb_width_null(pbtype, frequency)

    dec = phasecentre.dec.deg
    ra = phasecentre.ra.deg

    if context == 'singlesource':
        log.info("create_simulation_components: Constructing single component")
        offset = [HWHM_deg * offset_dir[0], HWHM_deg * offset_dir[1]]
        log.info(
            "create_simulation_components: Offset from pointing centre = %.3f, %.3f deg"
            % (offset[0], offset[1]))

        # The point source is offset to approximately the halfpower point
        odirection = SkyCoord(
            ra=(ra + offset[0] / numpy.cos(numpy.pi * dec / 180.0)) *
            units.deg,
            dec=(dec + offset[1]) * units.deg,
            frame='icrs',
            equinox='J2000')

        if polarisation_frame.type == "stokesIQUV":
            original_components = [
                Skycomponent(
                    flux=[[1.0, 0.0, 0.0, 0.0]],
                    direction=odirection,
                    frequency=frequency,
                    polarisation_frame=PolarisationFrame('stokesIQUV'))
            ]
        else:
            original_components = [
                Skycomponent(flux=[[1.0]],
                             direction=odirection,
                             frequency=frequency,
                             polarisation_frame=PolarisationFrame('stokesI'))
            ]

        offset_direction = odirection

    elif context == 'doublesource':

        original_components = []

        log.info(
            "create_simulation_components: Constructing double components")

        for sign_offset in [(-1, 0), (1, 0)]:
            offset = [HWHM_deg * sign_offset[0], HWHM_deg * sign_offset[1]]

            log.info(
                "create_simulation_components: Offset from pointing centre = %.3f, %.3f deg"
                % (offset[0], offset[1]))

            odirection = SkyCoord(
                ra=(ra + offset[0] / numpy.cos(numpy.pi * dec / 180.0)) *
                units.deg,
                dec=(dec + offset[1]) * units.deg,
                frame='icrs',
                equinox='J2000')
            if polarisation_frame.type == "stokesIQUV":
                original_components.append(
                    Skycomponent(
                        flux=[[1.0, 0.0, 0.0, 0.0]],
                        direction=odirection,
                        frequency=frequency,
                        polarisation_frame=PolarisationFrame('stokesIQUV')))
            else:
                original_components.append(
                    Skycomponent(
                        flux=[[1.0]],
                        direction=odirection,
                        frequency=frequency,
                        polarisation_frame=PolarisationFrame('stokesI')))

        for o in original_components:
            print(o)

        offset_direction = odirection

    elif context == 'null':
        log.info(
            "create_simulation_components: Constructing single component at the null"
        )

        offset = [null_az_deg * offset_dir[0], null_el_deg * offset_dir[1]]
        HWHM = HWHM_deg * numpy.pi / 180.0

        log.info(
            "create_simulation_components: Offset from pointing centre = %.3f, %.3f deg"
            % (offset[0], offset[1]))

        # The point source is offset to approximately the null point
        offset_direction = SkyCoord(
            ra=(ra + offset[0] / numpy.cos(numpy.pi * dec / 180.0)) *
            units.deg,
            dec=(dec + offset[1]) * units.deg,
            frame='icrs',
            equinox='J2000')

        if polarisation_frame.type == "stokesIQUV":
            original_components = [
                Skycomponent(
                    flux=[[1.0, 0.0, 0.0, 0.0]],
                    direction=offset_direction,
                    frequency=frequency,
                    polarisation_frame=PolarisationFrame('stokesIQUV'))
            ]
        else:
            original_components = [
                Skycomponent(flux=[[1.0]],
                             direction=offset_direction,
                             frequency=frequency,
                             polarisation_frame=PolarisationFrame('stokesI'))
            ]

    else:
        offset = [0.0, 0.0]
        # Make a skymodel from S3
        max_flux = 0.0
        total_flux = 0.0
        log.info("create_simulation_components: Constructing s3sky components")
        from rascil.processing_components.simulation import create_test_skycomponents_from_s3

        all_components = create_test_skycomponents_from_s3(
            flux_limit=flux_limit / 100.0,
            phasecentre=phasecentre,
            polarisation_frame=polarisation_frame,
            frequency=numpy.array(frequency),
            radius=pbradius,
            fov=fov)
        original_components = filter_skycomponents_by_flux(all_components,
                                                           flux_max=flux_max)
        log.info(
            "create_simulation_components: %d components before application of primary beam"
            % (len(original_components)))

        if filter_by_primary_beam:
            pbmodel = create_image(
                npixel=pb_npixel,
                cellsize=pb_cellsize,
                phasecentre=phasecentre,
                frequency=frequency,
                polarisation_frame=PolarisationFrame("stokesI"))
            stokesi_components = [
                copy_skycomponent(o) for o in original_components
            ]
            for s in stokesi_components:
                s.flux = numpy.array([[s.flux[0, 0]]])
                s.polarisation_frame = PolarisationFrame("stokesI")

            pb = create_pb(pbmodel,
                           "MID_GAUSS",
                           pointingcentre=phasecentre,
                           use_local=False)
            pb_applied_components = [
                copy_skycomponent(c) for c in stokesi_components
            ]
            pb_applied_components = apply_beam_to_skycomponent(
                pb_applied_components, pb)
            filtered_components = []
            for icomp, comp in enumerate(pb_applied_components):
                if comp.flux[0, 0] > flux_limit:
                    total_flux += comp.flux[0, 0]
                    if abs(comp.flux[0, 0]) > max_flux:
                        max_flux = abs(comp.flux[0, 0])
                    filtered_components.append(original_components[icomp])
            log.info(
                "create_simulation_components: %d components > %.3f Jy after filtering with primary beam"
                % (len(filtered_components), flux_limit))
            log.info(
                "create_simulation_components: Strongest components is %g (Jy)"
                % max_flux)
            log.info(
                "create_simulation_components: Total flux in components is %g (Jy)"
                % total_flux)
            original_components = [
                copy_skycomponent(c) for c in filtered_components
            ]
            if show:
                plt.clf()
                show_image(pb, components=original_components)
                plt.show(block=False)

        log.info("create_simulation_components: Created %d components" %
                 len(original_components))
        # Primary beam points to the phasecentre
        offset_direction = SkyCoord(ra=ra * units.deg,
                                    dec=dec * units.deg,
                                    frame='icrs',
                                    equinox='J2000')

    return original_components, offset_direction
示例#7
0
def create_low_test_skymodel_from_gleam(npixel=512,
                                        polarisation_frame=PolarisationFrame(
                                            "stokesI"),
                                        cellsize=0.000015,
                                        frequency=numpy.array([1e8]),
                                        channel_bandwidth=numpy.array([1e6]),
                                        phasecentre=None,
                                        kind='cubic',
                                        applybeam=True,
                                        flux_limit=0.1,
                                        flux_max=numpy.inf,
                                        flux_threshold=1.0,
                                        insert_method='Nearest',
                                        telescope='LOW') -> SkyModel:
    """Create LOW test skymodel from the GLEAM survey

    Stokes I is estimated from a cubic spline fit to the measured fluxes. The polarised flux is always zero.

    See http://www.mwatelescope.org/science/gleam-survey The catalog is available from Vizier.

    VIII/100   GaLactic and Extragalactic All-sky MWA survey  (Hurley-Walker+, 2016)

    GaLactic and Extragalactic All-sky Murchison Wide Field Array (GLEAM) survey. I: A low-frequency extragalactic
    catalogue. Hurley-Walker N., et al., Mon. Not. R. Astron. Soc., 464, 1146-1167 (2017), 2017MNRAS.464.1146H

    :param telescope:
    :param npixel: Number of pixels
    :param polarisation_frame: Polarisation frame (default PolarisationFrame("stokesI"))
    :param cellsize: cellsize in radians
    :param frequency:
    :param channel_bandwidth: Channel width (Hz)
    :param phasecentre: phasecentre (SkyCoord)
    :param kind: Kind of interpolation (see scipy.interpolate.interp1d) Default: cubic
    :param applybeam: Apply the primary beam?
    :param flux_limit: Weakest component
    :param flux_max: Maximum strength component to be included in components
    :param flux_threshold: Split between components (brighter) and image (weaker)
    :param insert_method: Nearest | PSWF | Lanczos
    :return:
    :return: SkyModel

    """
    check_data_directory()

    if phasecentre is None:
        phasecentre = SkyCoord(ra=+15.0 * u.deg,
                               dec=-35.0 * u.deg,
                               frame='icrs',
                               equinox='J2000')

    radius = npixel * cellsize

    sc = create_low_test_skycomponents_from_gleam(
        flux_limit=flux_limit,
        polarisation_frame=polarisation_frame,
        frequency=frequency,
        phasecentre=phasecentre,
        kind=kind,
        radius=radius)

    sc = filter_skycomponents_by_flux(sc, flux_max=flux_max)
    if polarisation_frame is None:
        polarisation_frame = PolarisationFrame("stokesI")

    npol = polarisation_frame.npol
    nchan = len(frequency)
    shape = [nchan, npol, npixel, npixel]
    w = WCS(naxis=4)
    # The negation in the longitude is needed by definition of RA, DEC
    w.wcs.cdelt = [
        -cellsize * 180.0 / numpy.pi, cellsize * 180.0 / numpy.pi, 1.0,
        channel_bandwidth[0]
    ]
    w.wcs.crpix = [npixel // 2 + 1, npixel // 2 + 1, 1.0, 1.0]
    w.wcs.ctype = ["RA---SIN", "DEC--SIN", 'STOKES', 'FREQ']
    w.wcs.crval = [phasecentre.ra.deg, phasecentre.dec.deg, 1.0, frequency[0]]
    w.naxis = 4
    w.wcs.radesys = 'ICRS'
    w.wcs.equinox = 2000.0

    model = create_image_from_array(numpy.zeros(shape),
                                    w,
                                    polarisation_frame=polarisation_frame)

    if applybeam:
        beam = create_pb(model, telescope=telescope, use_local=False)
        sc = apply_beam_to_skycomponent(sc, beam)

    weaksc = filter_skycomponents_by_flux(sc, flux_max=flux_threshold)
    brightsc = filter_skycomponents_by_flux(sc, flux_min=flux_threshold)
    model = insert_skycomponent(model, weaksc, insert_method=insert_method)

    log.info(
        'create_low_test_skymodel_from_gleam: %d bright sources above flux threshold %.3f, %d weak sources below '
        % (len(brightsc), flux_threshold, len(weaksc)))

    return SkyModel(components=brightsc,
                    image=model,
                    mask=None,
                    gaintable=None)
示例#8
0
def create_low_test_image_from_gleam(npixel=512,
                                     polarisation_frame=PolarisationFrame(
                                         "stokesI"),
                                     cellsize=0.000015,
                                     frequency=numpy.array([1e8]),
                                     channel_bandwidth=numpy.array([1e6]),
                                     phasecentre=None,
                                     kind='cubic',
                                     applybeam=False,
                                     flux_limit=0.1,
                                     flux_max=numpy.inf,
                                     flux_min=-numpy.inf,
                                     radius=None,
                                     insert_method='Nearest') -> Image:
    """Create LOW test image from the GLEAM survey

    Stokes I is estimated from a cubic spline fit to the measured fluxes. The polarised flux is always zero.

    See http://www.mwatelescope.org/science/gleam-survey The catalog is available from Vizier.

    VIII/100   GaLactic and Extragalactic All-sky MWA survey  (Hurley-Walker+, 2016)

    GaLactic and Extragalactic All-sky Murchison Wide Field Array (GLEAM) survey. I: A low-frequency extragalactic
    catalogue. Hurley-Walker N., et al., Mon. Not. R. Astron. Soc., 464, 1146-1167 (2017), 2017MNRAS.464.1146H

    :param npixel: Number of pixels
    :param polarisation_frame: Polarisation frame (default PolarisationFrame("stokesI"))
    :param cellsize: cellsize in radians
    :param frequency:
    :param channel_bandwidth: Channel width (Hz)
    :param phasecentre: phasecentre (SkyCoord)
    :param kind: Kind of interpolation (see scipy.interpolate.interp1d) Default: linear
    :return: Image

    """
    check_data_directory()

    if phasecentre is None:
        phasecentre = SkyCoord(ra=+15.0 * u.deg,
                               dec=-35.0 * u.deg,
                               frame='icrs',
                               equinox='J2000')

    if radius is None:
        radius = npixel * cellsize / numpy.sqrt(2.0)

    sc = create_low_test_skycomponents_from_gleam(
        flux_limit=flux_limit,
        polarisation_frame=polarisation_frame,
        frequency=frequency,
        phasecentre=phasecentre,
        kind=kind,
        radius=radius)

    sc = filter_skycomponents_by_flux(sc, flux_min=flux_min, flux_max=flux_max)

    if polarisation_frame is None:
        polarisation_frame = PolarisationFrame("stokesI")

    npol = polarisation_frame.npol
    nchan = len(frequency)
    shape = [nchan, npol, npixel, npixel]
    w = WCS(naxis=4)
    # The negation in the longitude is needed by definition of RA, DEC
    w.wcs.cdelt = [
        -cellsize * 180.0 / numpy.pi, cellsize * 180.0 / numpy.pi, 1.0,
        channel_bandwidth[0]
    ]
    w.wcs.crpix = [npixel // 2 + 1, npixel // 2 + 1, 1.0, 1.0]
    w.wcs.ctype = ["RA---SIN", "DEC--SIN", 'STOKES', 'FREQ']
    w.wcs.crval = [phasecentre.ra.deg, phasecentre.dec.deg, 1.0, frequency[0]]
    w.naxis = 4
    w.wcs.radesys = 'ICRS'
    w.wcs.equinox = 2000.0

    model = create_image_from_array(numpy.zeros(shape),
                                    w,
                                    polarisation_frame=polarisation_frame)

    model = insert_skycomponent(model, sc, insert_method=insert_method)
    if applybeam:
        beam = create_pb(model, telescope='LOW', use_local=False)
        model.data[...] *= beam.data[...]

    return model