Esempio n. 1
0
def make_image(uu_m,
               vv_m,
               amps,
               freq_hz,
               im_size,
               cell_size_uv_m,
               image_root_name,
               algorithm='fft'):
    """Make a FITS image from the specified data.

    This function is slightly unusual in that the image size is specified
    using a grid pixel size rather than image pixel size or field-of-view.

    Args:
        uu_m (array_like, float): Baseline uu coordinates, in metres
        vv_m (array_like, float): Baseline vv coordinates, in metres
        amps (array_like, complex): Visibility amplitudes
        freq_hz (float): Observation frequency, in Hz
        im_size (int): Image dimension (assumes square image)
        cell_size_uv_m (float): Image grid pixel separation, in metres
        image_root_name (str): Output FITS image root name.
        algorithm (str): Imaging algorithm to use (FFT or W-projection)

    Returns:
        (dict, str): Dictionary containing the grid used to make the image,
        filename of the output fits image created.
    """
    ra_deg, dec_deg = 0, 90
    ww_m = np.zeros_like(uu_m)
    image_type = 'I'
    wavelength = const.c.value / freq_hz
    uv_cellsize_wavelengths = cell_size_uv_m / wavelength
    fov_rad = Imager.uv_cellsize_to_fov(uv_cellsize_wavelengths, im_size)

    # Create FITS image
    imager = Imager(precision='double')
    imager.set(fov_deg=degrees(fov_rad),
               size=im_size,
               algorithm=algorithm,
               weighting='natural',
               image_type=image_type,
               wprojplanes=-1,
               output_root=image_root_name)
    imager.set_vis_frequency(freq_hz)
    imager.set_vis_phase_centre(ra_deg, dec_deg)
    imager_data = imager.run(uu_m, vv_m, ww_m, amps, return_grids=1)
    image_grid = imager_data['grids'].squeeze()
    return image_grid, '%s_%s.fits' % (image_root_name, image_type)