def generate_uv_coordinates(
    x, y, z, lon, lat, alt, ra, dec, num_times, num_baselines, mjd_start, dt_s, freq_hz, uv_cut_radius_wavelengths
):
    x, y, z = convert_enu_to_ecef(x, y, z, lon, lat, alt)
    uu, vv, ww = generate_baseline_uvw(x, y, z, ra, dec, num_times, num_baselines, mjd_start, dt_s)
    wave_length = 299792458.0 / freq_hz
    uu /= wave_length
    vv /= wave_length
    ww /= wave_length
    # uv_r_cut = uv_cut_radius_wavelengths
    # uv_r = (uu ** 2 + vv ** 2) ** 0.5
    # uv_sort_idx = numpy.argsort(uv_r)
    # uv_r = uv_r[uv_sort_idx]
    # uu = uu[uv_sort_idx]
    # vv = vv[uv_sort_idx]
    # ww = ww[uv_sort_idx]
    # i_uv_max = numpy.argmax(uv_r >= uv_r_cut)
    # uu = uu[:i_uv_max]
    # vv = vv[:i_uv_max]
    # ww = ww[:i_uv_max]
    uu = numpy.hstack((uu, -uu))
    vv = numpy.hstack((vv, -vv))
    ww = numpy.hstack((ww, -ww))
    return uu, vv, ww
def main():
    print("*" * 80)
    print("*" * 80)
    print("THIS SCRIPT IS DEPRECATED IN FAVOUR OF: generate_uv_coverage_2.py")
    print("*" * 80)
    print("*" * 80)
    return

    # Load station positions
    t0 = time.time()
    v4d_file = join("v4d.tm", "layout_enu_stations.txt")
    v4o1_file = join("v4o1.tm", "layout_enu_stations.txt")
    v4d = numpy.loadtxt(v4d_file)
    v4o1 = numpy.loadtxt(v4o1_file)
    station_radius_m = 35.0 / 2.0
    num_stations = v4d.shape[0]
    assert v4o1.shape[0] == v4d.shape[0]
    print("- loading coordinates took %.2f s" % (time.time() - t0))

    freq = 100.0e6
    wave_length = 299792458.0 / freq
    lon = radians(116.63128900)
    lat = radians(-26.69702400)
    alt = 0.0
    ra = radians(68.698903779331502)
    dec = radians(-26.568851215532160)
    mjd_mid = 57443.4375000000

    snapshot = True
    if snapshot:
        mjd_start = mjd_mid
        obs_length = 0.0
        dt_s = 0.0
        num_times = 1
    else:
        obs_length = 4.0 * 3600.0  # seconds
        num_times = int(obs_length / (3 * 60.0))
        dt_s = obs_length / float(num_times)
        mjd_start = mjd_mid - (obs_length / 2.0) / (3600.0 * 24.0)

    print("- obs_length = %.2f s (%.2f h)" % (obs_length, obs_length / 3600.0))
    print("- num_times =", num_times)

    num_baselines = num_stations * (num_stations - 1) / 2
    out_dir = "uv_%3.1fh" % (obs_length / 3600.0)
    if not os.path.isdir(out_dir):
        os.makedirs(out_dir)

    # plot_layouts(v4d, v4o1, station_radius_m, out_dir)
    #
    t0 = time.time()
    x, y, z = convert_enu_to_ecef(v4d[:, 0], v4d[:, 1], v4d[:, 2], lon, lat, alt)
    uu_v4d, vv_v4d, ww_v4d = generate_baseline_uvw(x, y, z, ra, dec, num_times, num_baselines, mjd_start, dt_s)
    x, y, z = convert_enu_to_ecef(v4o1[:, 0], v4o1[:, 1], v4o1[:, 2], lon, lat, alt)
    uu_v4o1, vv_v4o1, ww_v4o1 = generate_baseline_uvw(x, y, z, ra, dec, num_times, num_baselines, mjd_start, dt_s)
    print("- coordinate generation took %.2f s" % (time.time() - t0))
    print("- num vis = %i" % uu_v4d.shape[0])

    # t0 = time.time()
    # uv_plot(uu_v4d, vv_v4d, uu_v4o1, vv_v4o1, out_dir)
    # print('- uv scatter plot took %.2f s' % (time.time() - t0))

    # t0 = time.time()
    # v4d_uv_dist = (uu_v4d**2 + vv_v4d**2)**0.5
    # v4d_uv_dist.sort()
    # v4o1_uv_dist = (uu_v4o1**2 + vv_v4o1**2)**0.5
    # v4o1_uv_dist.sort()
    # hist_plot_1(v4d_uv_dist, v4o1_uv_dist, wave_length, 300.0, out_dir)
    # hist_plot_1(v4d_uv_dist, v4o1_uv_dist, wave_length * 5.0, 1500.0, out_dir)
    # hist_plot_1(v4d_uv_dist, v4o1_uv_dist, wave_length, 1500.0, out_dir)
    # hist_plot_1(v4d_uv_dist, v4o1_uv_dist, wave_length * 10.0, 3000.0, out_dir)
    # print('- histograms took %.2f s' % (time.time() - t0))
    #
    # hist_plot_2(v4d_uv_dist, v4o1_uv_dist, wave_length, out_dir)
    # hist_plot_3(v4d_uv_dist, v4o1_uv_dist, wave_length, out_dir)
    #
    plot_uv_images(uu_v4d, vv_v4d, uu_v4o1, vv_v4o1, wave_length, station_radius_m, out_dir)

    make_psf_images(uu_v4d, vv_v4d, ww_v4d, uu_v4o1, vv_v4o1, ww_v4o1, ra, dec, freq, out_dir)
def main():
    # Load station positions
    t0 = time.time()
    v4d_file = join('v4d.tm', 'layout_enu_stations.txt')
    v4o1_file = join('v4o1.tm', 'layout_enu_stations.txt')
    v4d = numpy.loadtxt(v4d_file)
    v4o1 = numpy.loadtxt(v4o1_file)
    station_radius_m = 35.0 / 2.0
    num_stations = v4d.shape[0]
    assert(v4o1.shape[0] == v4d.shape[0])
    print('- loading coordinates took %.2f s' % (time.time() - t0))

    freq = 100.0e6
    wave_length = 299792458.0 / freq
    lon = radians(116.63128900)
    lat = radians(-26.69702400)
    alt = 0.0
    ra = radians(68.698903779331502)
    dec = radians(-26.568851215532160)
    mjd_mid = 57443.4375000000

    snapshot = True
    if snapshot:
        mjd_start = mjd_mid
        obs_length = 0.0
        dt_s = 0.0
        num_times = 1
    else:
        obs_length = 4.0 * 3600.0  # seconds
        num_times = int(obs_length / (3 * 60.0))
        dt_s = obs_length / float(num_times)
        mjd_start = mjd_mid - (obs_length / 2.0) / (3600.0 * 24.0)

    print('- obs_length = %.2f s (%.2f h)' % (obs_length, obs_length / 3600.0))
    print('- num_times =', num_times)

    num_baselines = num_stations * (num_stations - 1) / 2
    out_dir = 'uv_%3.1fh' % (obs_length / 3600.0)

    # UV coordinate generation ================================================
    t0 = time.time()
    x, y, z = convert_enu_to_ecef(v4d[:, 0], v4d[:, 1], v4d[:, 2],
                                  lon, lat, alt)
    uu_v4d, vv_v4d, ww_v4d = \
        generate_baseline_uvw(x, y, z, ra, dec, num_times, num_baselines,
                              mjd_start, dt_s)
    x, y, z = convert_enu_to_ecef(v4o1[:, 0], v4o1[:, 1], v4o1[:, 2],
                                  lon, lat, alt)
    uu_v4o1, vv_v4o1, ww_v4o1 = \
        generate_baseline_uvw(x, y, z, ra, dec, num_times, num_baselines,
                              mjd_start, dt_s)
    print('- coordinate generation took %.2f s' % (time.time() - t0))
    print('- num vis = %i' % uu_v4d.shape[0])

    # Plotting ===============================================================
    if os.path.exists(out_dir):
        shutil.rmtree(out_dir)
    # plot_layouts(v4d, v4o1, station_radius_m, join(out_dir, 'layouts'))
    # plot_psf(uu_v4d, vv_v4d, ww_v4d, uu_v4o1, vv_v4o1, ww_v4o1, freq,
    #          join(out_dir, 'psf'))
    # uv_plot(uu_v4d, vv_v4d, uu_v4o1, vv_v4o1, join(out_dir, 'uv_scatter'))
    plot_uv_hist(uu_v4d, vv_v4d, uu_v4o1, vv_v4o1, wave_length,
                 join(out_dir, 'uv_hist'))
def main():
    # Load station positions
    t0 = time.time()
    v4d_file = join('v4d.tm', 'layout_enu_stations.txt')
    v4o1_file = join('v4o1.tm', 'layout_enu_stations.txt')
    v4d = numpy.loadtxt(v4d_file)
    v4o1 = numpy.loadtxt(v4o1_file)
    station_radius_m = 35.0 / 2.0
    num_stations = v4d.shape[0]
    assert(v4o1.shape[0] == v4d.shape[0])
    print('- loading coordinates took %.2f s' % (time.time() - t0))

    freq = 120.0e6
    wave_length = 299792458.0 / freq
    lon = radians(116.63128900)
    lat = radians(-26.69702400)
    alt = 0.0
    ra = radians(68.698903779331502)
    dec = radians(-26.568851215532160)
    mjd_mid = 57443.4375000000

    snapshot = True
    if snapshot:
        mjd_start = mjd_mid
        obs_length = 0.0
        dt_s = 0.0
        num_times = 1
    else:
        obs_length = 4.0 * 3600.0  # seconds
        num_times = int(obs_length / (3 * 60.0))
        dt_s = obs_length / float(num_times)
        mjd_start = mjd_mid - (obs_length / 2.0) / (3600.0 * 24.0)

    print('- obs_length = %.2f s (%.2f h)' % (obs_length, obs_length / 3600.0))
    print('- num_times =', num_times)

    num_baselines = num_stations * (num_stations - 1) / 2
    out_dir = 'uv_%3.1fh' % (obs_length / 3600.0)

    if os.path.exists(out_dir):
        shutil.rmtree(out_dir)
    os.makedirs(out_dir)

    # UV coordinate generation ===============================================
    t0 = time.time()
    x, y, z = convert_enu_to_ecef(v4d[:, 0], v4d[:, 1], v4d[:, 2],
                                  lon, lat, alt)
    uu_v4d, vv_v4d, ww_v4d = \
        generate_baseline_uvw(x, y, z, ra, dec, num_times, num_baselines,
                              mjd_start, dt_s)
    print('- Coordinate generation took %.2f s' % (time.time() - t0))
    print('- Num vis = %i' % uu_v4d.shape[0])

    fov = 180.0  # deg
    im_size = 8192
    n = im_size
    c = n / 2
    z = 128

    cell_size_lm_arcsec = fov_to_cell_size(fov, im_size)
    cell_size_uv = grid_cell_size(cell_size_lm_arcsec, im_size)
    uv_max = ((im_size / 2) - 5) * cell_size_uv

    uv_r_cut = uv_max * wave_length
    uv_r = (uu_v4d**2 + vv_v4d**2)**0.5
    uv_sort_idx = numpy.argsort(uv_r)
    uv_r = uv_r[uv_sort_idx]
    uu_v4d = uu_v4d[uv_sort_idx]
    vv_v4d = vv_v4d[uv_sort_idx]
    ww_v4d = ww_v4d[uv_sort_idx]

    i_uv_max = numpy.argmax(uv_r >= uv_r_cut)
    uu_v4d = uu_v4d[:i_uv_max]
    vv_v4d = vv_v4d[:i_uv_max]
    ww_v4d = ww_v4d[:i_uv_max]
    print('- No. uv points after radial cut = %i' % uu_v4d.shape[0])

    fig = pyplot.figure(figsize=(8, 8))
    ax = fig.add_subplot(111, aspect='equal')
    ax.plot(uu_v4d, vv_v4d, '.', ms=2.0, alpha=0.2)
    ax.set_xlim(-uv_max * wave_length, uv_max * wave_length)
    ax.set_ylim(-uv_max * wave_length, uv_max * wave_length)
    fig.savefig(join(out_dir, 'uv_scatter.png'))
    pyplot.close(fig)

    psf_v4d = make_psf(uu_v4d, vv_v4d, ww_v4d, freq, fov, im_size)
    lm_max = psf_v4d['lm_max']
    lm_inc = psf_v4d['lm_inc']
    off = lm_inc / 2.0
    extent = [-lm_max - off, lm_max - off, -lm_max - off, lm_max - off]
    plot_image_log(psf_v4d['image'], extent, fov, join(out_dir, 'psf'))

    print('- Loading beam image.')
    prefix = 'b_TIME_AVG_CHAN_AVG_CROSS_POWER'
    beam_amp = pyfits.getdata(join('beams_180.0_120.0MHz',
                                   prefix + '_AMP_I_I.fits'))
    beam_phase = pyfits.getdata(join('beams_180.0_120.0MHz',
                                     prefix + '_PHASE_I_I.fits'))
    beam_amp = numpy.squeeze(beam_amp)
    beam_phase = numpy.squeeze(beam_phase)
    beam_amp[numpy.isnan(beam_amp)] = 0.0
    beam_phase[numpy.isnan(beam_phase)] = 0.0
    beam = beam_amp * numpy.exp(1.0j * beam_phase)
    # beam /= numpy.sum(beam)
    print('- beam sum = %f %f' % (numpy.sum(beam.real), numpy.sum(beam_amp)))

    beam_amp = beam_amp / numpy.nanmax(beam_amp)
    plot_image_lin(beam_amp, extent, fov, join(out_dir, 'beam_amp'))
    plot_image_lin(beam_phase, extent, fov, join(out_dir, 'beam_phase'))
    plot_image_lin(beam_amp[c - z:c + z, c - z:c + z],
                   [-z - 0.5, z - 0.5, -z + 0.5, z + 0.5],
                   0, join(out_dir, 'beam_amp_zoom'))
    plot_image_lin(numpy.real(beam[c - z: c + z, c - z: c + z]),
                   [-z - 0.5, z - 0.5, -z + 0.5, z + 0.5], 0,
                   join(out_dir, 'beam_re_zoom'))
    plot_image_lin(numpy.imag(beam[c - z: c + z, c - z: c + z]),
                   [-z - 0.5, z - 0.5, -z + 0.5, z + 0.5], 0,
                   join(out_dir, 'beam_im_zoom'))

    # Beam uv plane response
    uv_beam = numpy.fft.fftshift(numpy.fft.ifft2(numpy.fft.fftshift(beam)))
    plot_image_lin(numpy.real(uv_beam), extent, 0, join(out_dir, 'uv_beam_re'))
    plot_image_lin(numpy.imag(uv_beam), extent, 0, join(out_dir, 'uv_beam_im'))
    plot_image_lin(numpy.real(uv_beam[c - z: c + z, c - z: c + z]),
                   [-z - 0.5, z - 0.5, -z + 0.5, z + 0.5], 0,
                   join(out_dir, 'uv_beam_re_zoom'))
    plot_image_lin(numpy.imag(uv_beam[c - z: c + z, c - z: c + z]),
                   [-z - 0.5, z - 0.5, -z + 0.5, z + 0.5], 0,
                   join(out_dir, 'uv_beam_im_zoom'))

    print('- Beam x PSF.')
    beam_psf = beam * psf_v4d['image']
    plot_image_log(numpy.real(beam_psf), extent, fov,
                   join(out_dir, 'psf_beam_re'))
    plot_image_log(numpy.imag(beam_psf), extent, fov,
                   join(out_dir, 'psf_beam_im'))

    print('- UV image (beam convolved).')
    uv_psf_beam = numpy.fft.fftshift(numpy.fft.ifft2(numpy.fft.fftshift(beam_psf)))
    plot_image_lin(numpy.real(uv_psf_beam), [-1, 1, -1, 1], 0,
                   join(out_dir, 'uv_psf_beam_re'))
    plot_image_lin(numpy.imag(uv_psf_beam), [-1, 1, -1, 1], 0,
                   join(out_dir, 'uv_psf_beam_im'))

    print('- UV image (PSF only).')
    uv_psf = numpy.fft.fftshift(
        numpy.fft.ifft2(numpy.fft.fftshift(psf_v4d['image'])))
    print('- uv_psf grid sum = %f %f' % (numpy.sum(uv_psf.real),
                                         numpy.sum(uv_psf.real)))
    print('- uv_psf_beam grid sum = %f %f' % (numpy.sum(uv_psf_beam.real),
                                              numpy.sum(uv_psf_beam.real)))
    uv_psf /= numpy.sum(uv_psf)
    uv_psf_beam /= numpy.sum(uv_psf_beam)
    uv_psf *= uu_v4d.shape[0]
    uv_psf_beam *= uu_v4d.shape[0]

    plot_image_lin(numpy.real(uv_psf), [-1, 1, -1, 1], 0,
                   join(out_dir, 'uv_psf_re'))
    plot_image_lin(numpy.imag(uv_psf), [-1, 1, -1, 1], 0,
                   join(out_dir, 'uv_psf_im'))
    plot_image_lin(numpy.real(uv_psf[c - z: c + z, c - z: c + z]),
                   [-z - 0.5, z - 0.5, -z + 0.5, z + 0.5], 0,
                   join(out_dir, 'uv_psf_re_zoom'))
    plot_image_lin(numpy.imag(uv_psf[c - z: c + z, c - z: c + z]),
                   [-z - 0.5, z - 0.5, -z + 0.5, z + 0.5], 0,
                   join(out_dir, 'uv_psf_im_zoom'))
    plot_image_lin(numpy.real(uv_psf_beam[c - z: c + z, c - z: c + z]),
                   [-z - 0.5, z - 0.5, -z + 0.5, z + 0.5], 0,
                   join(out_dir, 'uv_psf_beam_re_zoom'))
    plot_image_lin(numpy.imag(uv_psf_beam[c - z: c + z, c - z: c + z]),
                   [-z - 0.5, z - 0.5, -z + 0.5, z + 0.5], 0,
                   join(out_dir, 'uv_psf_beam_im_zoom'))

    # # Grid uv data to compare with FT(psf) wrt normalisation
    # uv_grid = numpy.zeros((im_size, im_size))
    # for i in range(uu_v4d.shape[0]):
    #     gx = round(uu_v4d[i] / cell_size_uv) + (im_size / 2)
    #     gy = round(vv_v4d[i] / cell_size_uv) + (im_size / 2)
    #     uv_grid[gy, gx] += 1

    # print('- uv_grid sum = %f' % numpy.sum(uv_grid))
    print('- uv_psf sum = %f' % numpy.sum(uv_psf.real))
    plot_uv_image(uu_v4d, vv_v4d, cell_size_uv, 250 * cell_size_uv,
                  station_radius_m, join(out_dir, 'uv_image'))

    print('- Producing Azimuthal averaged plots')
    # Azimuthal average and plot vs radius
    _, _, r = image_coords(im_size, lm_inc)
    x = r.flatten()
    sort_idx = numpy.argsort(x)
    x = x[sort_idx]
    y1 = numpy.real(uv_psf).flatten()
    y1 = y1[sort_idx]
    y2 = numpy.real(uv_psf_beam).flatten()
    y2 = y2[sort_idx]

    fig = pyplot.figure(figsize=(8, 8))
    ax = fig.add_subplot(111)
    ax.plot(x, y1, 'b.', ms=3.0, alpha=0.1, label='uv')
    ax.plot(x, y2, 'r.', ms=3.0, alpha=0.1, label='uv convolved with PB')
    ax.legend()
    ax.set_xlim(0, 0.1)
    fig.savefig(join(out_dir, 'az_uv_r.png'))
    pyplot.close(fig)
Esempio n. 5
0
def main():
    """
    1. Generate a large-ish core of stations using random generator.
         a. overlap some stations in the core to have a very dense station
            region
    2. After core area start using arms but generate some randomness in the arms
       by placing antennas randomly near the outer stations keeping them along
       the spiral
    3. Remove radius redundancy in the spiral arms
    """

    # =========================================================================

    # ====== Core
    seed = 1
    num_tries = 10
    num_core_stations = (1 + 5 + 11 + 17) * 6 + (3 * 6)
    core_radius_m = 480.0
    inner_core_radius_m = 280.0
    station_radius_m = 35.0 / 2.0
    sll = -28
    # ====== Core arms
    num_arms = 3
    core_arm_count = 4
    stations_per_arm_cluster = 6
    arm_cluster_radius = 75.0
    # a = 300.0
    # b = 0.513
    a = 300.0
    b = 0.513
    delta_theta = math.radians(37.0)
    arm_offsets = numpy.radians([35.0, 155.0, 270.0])
    num_core_arm_stations = num_arms * core_arm_count * stations_per_arm_cluster
    # ====== Outer arms
    outer_arm_count = 12
    stations_per_outer_cluster = 6
    num_clusters_outer = outer_arm_count * num_arms
    v4a_ss_enu_file = 'v7ska1lowN1v2rev3R.enu.94x4.fixed.txt'
    outer_arm_cluster_radius = 80.0

    # ===== uvw coordinate generation.
    lon = radians(116.63128900)
    lat = radians(-26.69702400)
    alt = 0.0
    ra = radians(68.698903779331502)
    dec = radians(-26.568851215532160)
    mjd_mid = 57443.4375000000

    obs_length = 0.0
    mjd_start = mjd_mid
    dt_s = 0.0
    num_times = 1

    obs_length = 2.0 * 3600.0  # seconds
    num_times = int(obs_length / (3.0 * 60.0))
    dt_s = obs_length / float(num_times)
    mjd_start = mjd_mid - ((obs_length / 2.0) / 3600.0 * 24.0)
    print('num times = %i' % num_times)

    out_dir = 'v5c-2h'
    # =========================================================================
    if not os.path.isdir(out_dir):
        os.makedirs(out_dir)

    # Generate core stations
    x_core, y_core, weights, r_weights = \
        generate_random_core(num_core_stations, core_radius_m,
                             inner_core_radius_m, sll, station_radius_m,
                             num_tries, seed)

    # Core arms
    x_arm, y_arm, cx_arm, cy_arm = \
        generate_core_arms(num_arms, core_arm_count, stations_per_arm_cluster,
                           arm_cluster_radius, station_radius_m,
                           a, b, delta_theta, arm_offsets, num_tries)

    # Outer stations.
    x_arm_outer, y_arm_outer, cx_outer, cy_outer = \
        generate_outer_arms(v4a_ss_enu_file, num_clusters_outer,
                            stations_per_outer_cluster,
                            outer_arm_cluster_radius, station_radius_m,
                            num_tries)

    # Plotting
    plot_layout(x_core, y_core, x_arm, y_arm, x_arm_outer, y_arm_outer,
                cx_arm, cy_arm, cx_outer, cy_outer, station_radius_m,
                inner_core_radius_m, core_radius_m, arm_cluster_radius,
                outer_arm_cluster_radius, out_dir)
    plot_core_thinning_profile(r_weights, weights, core_radius_m,
                               inner_core_radius_m, out_dir)

    if uvwsim_found:
        x = numpy.hstack((x_core, x_arm, x_arm_outer))
        y = numpy.hstack((y_core, y_arm, y_arm_outer))
        print('total stations = %i' % x.shape[0])
        num_stations = x.shape[0]
        z = numpy.zeros_like(x)

        num_baselines = num_stations * (num_stations - 1) / 2
        x, y, z = convert_enu_to_ecef(x, y, z, lon, lat, alt)
        uu, vv, ww = generate_baseline_uvw(x, y, z, ra, dec, num_times,
                                           num_baselines, mjd_start,
                                           dt_s)
        plot_hist(uu, vv, join(out_dir, 'uv_hist_%.2fh.png'
                               % (obs_length/3600.0)),
                  'v5c %.2f h' % (obs_length/3600.0))
        plot_uv_dist(uu, vv, station_radius_m, join(out_dir, 'uv_%.2fh'
                                                    % (obs_length/3600.0)))
        # TODO-BM see ALMA memo for plots?
        # TODO-BM Plot of azimuthal variation
        # TODO-BM movie of uv coverage histogram improvement with time?
        # TODO-BM convolve uv response with station beam?!

    print('making image...')
    imager = Imager('single')
    fov = 1.0
    im_size = 2048
    freq = 150.0e6
    wavelength = 299792458.0 / freq
    uu /= wavelength
    vv /= wavelength
    ww /= wavelength
    amp = numpy.ones(uu.shape, dtype='c16')
    weight = numpy.ones(uu.shape, dtype='f8')
    image = imager.make_image(uu, vv, ww, amp, weight, fov, im_size)
    fig = pyplot.figure(figsize=(8, 8))
    ax = fig.add_subplot(111, aspect='equal')
    ax.imshow(image, interpolation='nearest')
    pyplot.show()

    cell = math.degrees(imager.fov_to_cellsize(math.radians(fov), im_size))
    save_fits_image_2(join(out_dir, 'psf.fits'), image, cell, math.degrees(ra),
                      math.degrees(dec), freq)