def import_image_from_fits(fitsfile: str): """ Read an Image from fits :param fitsfile: :type str: :returns: Image """ hdulist = fits.open(crocodile_path(fitsfile)) fim = Image() fim.data = hdulist[0].data fim.wcs = WCS(crocodile_path(fitsfile)) hdulist.close() log.debug("import_image_from_fits: Max, min in %s = %.6f, %.6f" % (fitsfile, fim.data.max(), fim.data.min())) return fim
def setUp(self): self.m31image = replicate_image( import_image_from_fits(crocodile_path("data/models/M31.MOD"))) self.cellsize = 180.0 * 0.0001 / numpy.pi self.m31image.wcs.wcs.cdelt[0] = -self.cellsize self.m31image.wcs.wcs.cdelt[1] = +self.cellsize self.m31image.wcs.wcs.radesys = 'ICRS' self.m31image.wcs.wcs.equinox = 2000.00
def create_named_configuration(name: str = 'LOWBD2', params={}): """ Standard configurations e.g. LOWBD2, MIDBD2 :param name: name of Configuration LOWBD2, LOWBD1, LOFAR, VLAA :type str: :returns: Configuration """ if name == 'LOWBD2': location = EarthLocation(lon="116.4999", lat="-26.7000", height=300.0) fc = create_configuration_from_file( antfile=crocodile_path("data/configurations/LOWBD2.csv"), location=location, mount='xy', names='LOWBD2_%d') elif name == 'LOWBD1': location = EarthLocation(lon="116.4999", lat="-26.7000", height=300.0) fc = create_configuration_from_file( antfile=crocodile_path("data/configurations/LOWBD1.csv"), location=location, mount='xy', names='LOWBD1_%d') elif name == 'LOFAR': fc = create_LOFAR_configuration( antfile=crocodile_path("data/configurations/LOFAR.csv")) elif name == 'VLAA': location = EarthLocation(lon="-107.6184", lat="34.0784", height=2124.0) fc = create_configuration_from_file( antfile=crocodile_path("data/configurations/VLA_A_hor_xyz.csv"), location=location, mount='altaz', names='VLA_%d') elif name == 'VLAA_north': location = EarthLocation(lon="-107.6184", lat="90.000", height=2124.0) fc = create_configuration_from_file( antfile=crocodile_path("data/configurations/VLA_A_hor_xyz.csv"), location=location, mount='altaz', names='VLA_%d') else: fc = Configuration() raise UserWarning("No such Configuration %s" % name) return fc
def test_visibility_from_oskar(self): for oskar_file in [ "data/vis/vla_1src_6h/test_vla.vis", "data/vis/vla_grid_6h/test_vla.vis" ]: vis = import_visibility_from_oskar(crocodile_path(oskar_file)) self.assertEqual( len(numpy.unique(vis.antenna1)) + 1, len(vis.configuration.xyz)) self.assertEqual( len(numpy.unique(vis.antenna2)) + 1, len(vis.configuration.xyz))
def create_test_image(canonical=True): """Create a useful test image This is the test image M31 widely used in ALMA and other simulations. It is actually part of an Halpha region in M31. :param canonical: Make the image into a 4 dimensional image :returns: Image """ im = import_image_from_fits(crocodile_path("data/models/M31.MOD")) if canonical: im = replicate_image(im) return im
from matplotlib import pylab from arl.parameters import crocodile_path def aaf_ns(a, m, c): """ """ r = numpy.hypot(*ucs(a)) return scipy.special.pro_ang1(m, m, c, r) if 1: import os vlas = numpy.genfromtxt(crocodile_path("test/VLA_A_hor_xyz.txt"), delimiter=",") vobs = genuv(vlas, numpy.arange(0, numpy.pi, 0.1), numpy.pi / 4) yy = genvis(vobs / 5, 0.01, 0.01) if 1: majorcycle(2 * 0.025, 2 * 15000, vobs / 5, yy, 0.1, 5, 100, 250000) if 0: # some other testing code bits mg = exmid(numpy.fft.fftshift(numpy.fft.fft2(aaf(a, 0, 3))), 5) ws = numpy.arange(p[:, 2].min(), p[:, 2].max(), wstep) wr = zip(ws[:-1], ws[1:]) + [(ws[-1], p[:, 2].max())] yy = genvis(vobs / 5, 0.001, 0.001) d, p, _ = doimg(2 * 0.025, 2 * 15000, vobs / 5, yy, lambda *x: wslicimg(*x, wstep=250)) pylab.matshow(p[740:850, 740:850])