def partition_skymodel_by_flux(sc, model, flux_threshold=-numpy.inf): """Partition skymodel according to flux Bright skycomponents are put into a SkyModel as a list, and weak skycomponents are inserted into SkyModel as an image. :param sc: List of skycomponents :param model: Model image :param flux_threshold: :return: SkyModel For example:: fluxes = numpy.linspace(0, 1.0, 11) sc = [create_skycomponent(direction=phasecentre, flux=numpy.array([[f]]), frequency=frequency, polarisation_frame=PolarisationFrame('stokesI')) for f in fluxes] sm = partition_skymodel_by_flux(sc, model, flux_threshold=0.31) assert len(sm.components) == 7, len(sm.components) """ brightsc = filter_skycomponents_by_flux(sc, flux_min=flux_threshold) weaksc = filter_skycomponents_by_flux(sc, flux_max=flux_threshold) log.info( 'Converted %d components into %d bright components and one image containing %d components' % (len(sc), len(brightsc), len(weaksc))) im = copy_image(model) im = insert_skycomponent(im, weaksc) return SkyModel(components=[copy_skycomponent(comp) for comp in brightsc], image=copy_image(im), mask=None, fixed=False)
def test_partition_skycomponent_neighbours(self): all_components = create_low_test_skycomponents_from_gleam( flux_limit=0.1, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI'), radius=0.5) bright_components = create_low_test_skycomponents_from_gleam( flux_limit=1.0, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI'), radius=0.5) model = create_image(npixel=512, cellsize=0.001, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI')) beam = create_low_test_beam(model, use_local=False) all_components = apply_beam_to_skycomponent(all_components, beam) all_components = filter_skycomponents_by_flux(all_components, flux_min=0.1) bright_components = apply_beam_to_skycomponent(bright_components, beam) bright_components = filter_skycomponents_by_flux(bright_components, flux_min=2.0) comps_lists = partition_skycomponent_neighbours( all_components, bright_components) assert len(comps_lists) == len(bright_components) assert len(comps_lists[0]) > 0 assert len(comps_lists[-1]) > 0
def test_filter_flux(self): self.components = create_low_test_skycomponents_from_gleam( flux_limit=0.1, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI'), radius=0.5) newsc = filter_skycomponents_by_flux(self.components, flux_min=0.3) assert len(newsc) < len(self.components), len(self.components) newsc = filter_skycomponents_by_flux(self.components, flux_min=5.0) assert len(newsc) == 138, len(newsc) newsc = filter_skycomponents_by_flux(self.components, flux_max=8.0) assert len(newsc) == 11744, len(newsc)
def test_create_gaintable_from_screen(self): screen = import_image_from_fits( rascil_path('data/models/test_mpc_screen.fits')) beam = create_test_image(cellsize=0.0015, phasecentre=self.vis.phasecentre, frequency=self.frequency) beam = create_low_test_beam(beam, use_local=False) gleam_components = create_low_test_skycomponents_from_gleam( flux_limit=1.0, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI'), radius=0.2) pb_gleam_components = apply_beam_to_skycomponent( gleam_components, beam) actual_components = filter_skycomponents_by_flux(pb_gleam_components, flux_min=1.0) gaintables = create_gaintable_from_screen(self.vis, actual_components, screen) assert len(gaintables) == len(actual_components), len(gaintables) assert gaintables[0].gain.shape == (3, 94, 3, 1, 1), gaintables[0].gain.shape
def test_create_gaintable_from_pointingtable(self): s3_components = create_test_skycomponents_from_s3( flux_limit=0.3, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI'), radius=1.5 * numpy.pi / 180.0) s3_components = filter_skycomponents_by_flux(s3_components, 0.0, 10.0) pt = create_pointingtable_from_blockvisibility(self.vis) pt = simulate_pointingtable(pt, pointing_error=0.01, static_pointing_error=[0.001, 0.0001]) vp = create_vp(self.model, 'MID') gt = simulate_gaintable_from_pointingtable(self.vis, s3_components, pt, vp) if self.doplot: import matplotlib.pyplot as plt plt.clf() plt.plot(gt[0].time, numpy.real(1.0 / gt[0].gain[:, 0, 0, 0, 0]), '.') plt.plot(gt[0].time, numpy.imag(1.0 / gt[0].gain[:, 0, 0, 0, 0]), '.') plt.title('test_create_gaintable_from_pointingtable') plt.show(block=False) assert gt[0].gain.shape == (self.ntimes, self.nants, 1, 1, 1), gt[0].gain.shape
def test_expand_skymodel_by_skycomponents(self): beam = create_test_image(cellsize=0.0015, phasecentre=self.vis.phasecentre, frequency=self.frequency) beam = create_low_test_beam(beam, use_local=False) gleam_components = create_low_test_skycomponents_from_gleam( flux_limit=1.0, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI'), radius=0.2) pb_gleam_components = apply_beam_to_skycomponent( gleam_components, beam) actual_components = filter_skycomponents_by_flux(pb_gleam_components, flux_min=1.0) assert len(actual_components) == 37, len(actual_components) sm = SkyModel(image=self.model, components=actual_components) assert len(sm.components) == len(actual_components) scatter_sm = expand_skymodel_by_skycomponents(sm) assert len(scatter_sm) == len(actual_components) + 1 assert len(scatter_sm[0].components) == 1
def partition_skymodel_by_flux(sc, model, flux_threshold=-numpy.inf): """Partition skymodel according to flux :param sc: :param model: :param flux_threshold: :return: """ brightsc = filter_skycomponents_by_flux(sc, flux_min=flux_threshold) weaksc = filter_skycomponents_by_flux(sc, flux_max=flux_threshold) log.info( 'Converted %d components into %d bright components and one image containing %d components' % (len(sc), len(brightsc), len(weaksc))) im = copy_image(model) im = insert_skycomponent(im, weaksc) return SkyModel(components=[copy_skycomponent(comp) for comp in brightsc], image=copy_image(im), mask=None, fixed=False)
def test_select_neighbouring_components(self): self.components = create_low_test_skycomponents_from_gleam( flux_limit=0.1, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI'), radius=0.5) bright_components = filter_skycomponents_by_flux(self.components, flux_min=2.0) indices, d2d = select_neighbouring_components(self.components, bright_components) assert len(indices) == 11801, len(indices) assert numpy.max(indices) == (len(bright_components) - 1)
def test_grid_gaintable_to_screen(self): self.actualSetup() screen = import_image_from_fits( rascil_data_path('models/test_mpc_screen.fits')) beam = create_test_image(cellsize=0.0015, phasecentre=self.vis.phasecentre, frequency=self.frequency) beam = create_low_test_beam(beam, use_local=False) gleam_components = create_low_test_skycomponents_from_gleam( flux_limit=1.0, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI'), radius=0.2) pb_gleam_components = apply_beam_to_skycomponent( gleam_components, beam) actual_components = filter_skycomponents_by_flux(pb_gleam_components, flux_min=1.0) gaintables = create_gaintable_from_screen(self.vis, actual_components, screen) assert len(gaintables) == len(actual_components), len(gaintables) assert gaintables[0].gain.shape == (3, 94, 1, 1, 1), gaintables[0].gain.shape newscreen = create_empty_image_like(screen) newscreen, weights = grid_gaintable_to_screen(self.vis, gaintables, newscreen) assert numpy.max(numpy.abs(screen.data)) > 0.0 if self.persist: export_image_to_fits( newscreen, rascil_path('test_results/test_mpc_screen_gridded.fits')) if self.persist: export_image_to_fits( weights, rascil_path( 'test_results/test_mpc_screen_gridded_weights.fits'))
def test_expand_skymodel_voronoi(self): self.model = create_image( npixel=256, cellsize=0.001, polarisation_frame=PolarisationFrame("stokesI"), frequency=self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre) beam = create_low_test_beam(self.model, use_local=False) gleam_components = create_low_test_skycomponents_from_gleam( flux_limit=1.0, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI'), radius=0.1) pb_gleam_components = apply_beam_to_skycomponent( gleam_components, beam) actual_components = filter_skycomponents_by_flux(pb_gleam_components, flux_min=1.0) _, actual_components = remove_neighbouring_components( actual_components, 0.05) for imask, mask in enumerate( image_voronoi_iter(self.model, actual_components)): mask.data *= beam.data assert isinstance(mask, Image) assert mask.data.dtype == "float" assert numpy.sum(mask.data) > 1 # import matplotlib.pyplot as plt # from rascil.processing_components.image.operations import show_image # show_image(mask) # plt.show(block=False) assert len(actual_components) == 9, len(actual_components) sm = SkyModel(image=self.model, components=actual_components) assert len(sm.components) == len(actual_components) scatter_sm = expand_skymodel_by_skycomponents(sm) assert len(scatter_sm) == len(actual_components) + 1 assert len(scatter_sm[0].components) == 1
def test_voronoi_decomposition(self): bright_components = create_low_test_skycomponents_from_gleam( flux_limit=1.0, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI'), radius=0.5) model = create_image(npixel=512, cellsize=0.001, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI')) beam = create_low_test_beam(model, use_local=False) bright_components = apply_beam_to_skycomponent(bright_components, beam) bright_components = filter_skycomponents_by_flux(bright_components, flux_min=2.0) vor, vor_array = voronoi_decomposition(model, bright_components) assert len(bright_components) == (numpy.max(vor_array) + 1)
def test_image_voronoi_iter(self): bright_components = create_low_test_skycomponents_from_gleam( flux_limit=1.0, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI'), radius=0.5) model = create_image(npixel=512, cellsize=0.001, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI')) model.data[...] = 1.0 beam = create_low_test_beam(model, use_local=False) bright_components = apply_beam_to_skycomponent(bright_components, beam) bright_components = filter_skycomponents_by_flux(bright_components, flux_min=2.0) for im in image_voronoi_iter(model, bright_components): assert numpy.sum(im.data) > 1
def test_create_gaintable_from_screen_troposphere(self): self.actualSetup("troposphere") screen = import_image_from_fits( rascil_data_path('models/test_mpc_screen.fits')) beam = create_test_image(cellsize=0.00015, phasecentre=self.vis.phasecentre, frequency=self.frequency) beam = create_low_test_beam(beam, use_local=False) s3_components = create_test_skycomponents_from_s3( flux_limit=0.3, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI'), radius=1.5 * numpy.pi / 180.0) assert len(s3_components) > 0, "No S3 components selected" pb_s3_components = apply_beam_to_skycomponent(s3_components, beam) actual_components = filter_skycomponents_by_flux(pb_s3_components, flux_max=10.0) assert len( actual_components) > 0, "No components after applying primary beam" gaintables = create_gaintable_from_screen( self.vis, actual_components, screen, height=3e3, type_atmosphere="troposphere") assert len(gaintables) == len(actual_components), len(gaintables) assert gaintables[0].gain.shape == (3, 63, 1, 1, 1), gaintables[0].gain.shape
def test_remove_neighbouring_components(self): all_components = create_low_test_skycomponents_from_gleam( flux_limit=3.0, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI'), radius=0.5) model = create_image(npixel=512, cellsize=0.001, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI')) beam = create_low_test_beam(model, use_local=False) all_components = apply_beam_to_skycomponent(all_components, beam) all_components = filter_skycomponents_by_flux(all_components, flux_min=0.1) idx, comps = remove_neighbouring_components(all_components, 0.1) assert idx == [ 0, 1, 3, 8, 12, 13, 17, 22, 25, 26, 29, 32, 35, 38, 41, 42, 46, 47, 50, 52, 53, 56, 57, 58, 61, 63, 66, 68, 70 ], idx assert comps[0].name == 'GLEAM J215739-661155', comps[0].name
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
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)
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