コード例 #1
0
def main(labelfontsize = 16, ticksize= 11):
    k_perp_range = numpy.array([1e-4, 1.1e-1])
    u_range = numpy.logspace(-1, numpy.log10(500), 100)
    frequency_range = numpy.linspace(135, 165, 251) * 1e6
    eta = from_frequency_to_eta(frequency_range)

    start = time.time()
    position_covariance = PositionCovariance(position_precision=1e-2)
    position_covariance.compute_covariance(u=u_range, v=0, nu=frequency_range)
    position_error_power =position_covariance.compute_power()
    # position_error_power = calculate_sky_power_spectrum(u=u_range, nu=frequency_range)
    lapse = time.time() - start
    print(f"It took {lapse}")
    figure, axes = pyplot.subplots(1, 1, figsize=(5, 5))

    ps_norm = colors.LogNorm(vmin=1e3, vmax=1e15)

    plot_2dpower_spectrum(u_range, eta, frequency_range, position_error_power, title="Position Error", axes=axes,
                        axes_label_font=labelfontsize, tickfontsize=ticksize, colorbar_show=True,
                        xlabel_show=True, norm=ps_norm, ylabel_show=True, zlabel_show=True)

    figure.tight_layout()
    # pyplot.show()
    figure.savefig("../plots/Position_Class_Test.pdf")

    return
コード例 #2
0
def main(labelfontsize = 20, ticksize= 15):
    tile_precision = 1e-2
    broken_fraction = 0.25
    k_perp_range = numpy.array([1e-4, 1.1e-1])
    u_range = numpy.logspace(-1, numpy.log10(500), 100)
    frequency_range = numpy.linspace(135, 165, 251) * 1e6
    eta = from_frequency_to_eta(frequency_range)

    position_covariance = PositionCovariance(position_precision=tile_precision)
    position_covariance.compute_covariance(u=u_range, v=0, nu=frequency_range)
    beam_covariance = BeamCovariance(model_depth=10, calibration_type='redundant', broken_fraction=broken_fraction)
    beam_covariance.compute_covariance(u=u_range, v=0, nu = frequency_range)

    position_error_power = position_covariance.compute_power()
    beam_error_power = beam_covariance.compute_power()
    total_error_power = position_error_power + beam_error_power

    figure, axes = pyplot.subplots(1, 3, figsize=(15, 5))

    ps_norm = colors.LogNorm(vmin=1e3, vmax=1e15)

    plot_2dpower_spectrum(u_range, eta, frequency_range, position_error_power, title="Position Error", axes=axes[0],
                        axes_label_font=labelfontsize, tickfontsize=ticksize, colorbar_show=False,
                        xlabel_show=True, norm=ps_norm, ylabel_show=True)

    plot_2dpower_spectrum(u_range, eta, frequency_range, beam_error_power, title="Beam Model Error", axes=axes[1],
                        axes_label_font=labelfontsize, tickfontsize=ticksize, colorbar_show=False,
                        xlabel_show=True, norm=ps_norm)

    plot_2dpower_spectrum(u_range, eta, frequency_range, total_error_power, title="Total Error", axes=axes[2],
                        axes_label_font=labelfontsize, tickfontsize=ticksize, colorbar_show=True,
                        xlabel_show=True, norm=ps_norm, zlabel_show=True)

    figure.tight_layout()
    figure.savefig("../plots/Uncalibrated_redundant_residuals.pdf")


    return
コード例 #3
0
def main(labelfontsize=20, ticksize=20):
    model_limit = 100e-3
    position_error = 0.01
    broken_fraction = 0.25
    compute = False
    save = False
    load = True
    telescope_position_path = "./data/MWA_Compact_Coordinates.txt"

    u_range = numpy.logspace(-1, numpy.log10(500), 100)
    frequency_range = numpy.linspace(135, 165, 251) * 1e6
    eta = from_frequency_to_eta(frequency_range)
    print(f"{eta.max()} blaah")
    eor_power_spectrum = fiducial_eor_power_spectrum(u_range, eta)

    telescope = RadioTelescope(load=True, path=telescope_position_path)
    redundant_table = redundant_baseline_finder(telescope.baseline_table)

    contour_levels = numpy.array([1e-1, 1e0, 1e2])
    sky_clocations = None  #[(6e-2, 0.21), (4e-2, 0.25), (1.1e-2, 0.35 )]
    beam_clocations = None  #[(6e-2, 0.21), (8e-2, 0.5), (1.1e-2, 0.35 )]
    linestyles = ['dotted', 'dashed', 'solid']

    if compute:
        #### Initialise Sky Errors ###
        sky_error = SkyCovariance(model_depth=model_limit)
        sky_error.compute_covariance(u=u_range, v=0, nu=frequency_range)
        sky_beam_covariance = BeamCovariance(model_depth=model_limit,
                                             calibration_type='sky',
                                             broken_fraction=broken_fraction)
        sky_beam_covariance.compute_covariance(u=u_range,
                                               v=0,
                                               nu=frequency_range)
        sky_total = sky_error + sky_beam_covariance

    if load:
        with open('unmodeled_sky.obj', 'rb') as f:
            sky_error = pickle.load(f)
        with open('sky_total.obj', 'rb') as f:
            sky_total = pickle.load(f)

    sky_gain = GainCovariance(sky_total,
                              calibration_type='sky',
                              baseline_table=redundant_table)

    if compute:
        ###### Initialise Redundant Errors
        position_covariance = PositionCovariance(
            position_precision=position_error)
        position_covariance.compute_covariance(u=u_range,
                                               v=0,
                                               nu=frequency_range)
        beam_covariance = BeamCovariance(model_depth=model_limit,
                                         calibration_type='relative',
                                         broken_fraction=broken_fraction)
        beam_covariance.compute_covariance(u=u_range, v=0, nu=frequency_range)
        redundant_total = position_covariance + beam_covariance
    if load:
        with open('redundant_residuals.obj', 'rb') as f:
            redundant_total = pickle.load(f)

    relative_gain = GainCovariance(redundant_total,
                                   calibration_type='relative',
                                   baseline_table=redundant_table)
    absolute_gain = GainCovariance(sky_total,
                                   calibration_type='absolute',
                                   baseline_table=redundant_table)
    redundant_gain = relative_gain + absolute_gain

    ##### Rescale unmodeled sky covariance to model (avoiding heavy computation)
    model_sky = residual_to_model_rescale(sky_error)

    ######### Compute residuals
    redundant_residuals = CalibratedResiduals(redundant_gain,
                                              model_matrix=model_sky,
                                              residual_matrix=sky_error)
    sky_residuals = CalibratedResiduals(sky_gain,
                                        model_matrix=model_sky,
                                        residual_matrix=sky_error)

    ###### Compute PS #########
    redundant_power = redundant_residuals.compute_power()
    sky_power = sky_residuals.compute_power()

    if save:
        ###### Save covariance matrices
        sky_error.save("unmodeled_sky")
        sky_beam_covariance.save("sky_beam_error")
        sky_total.save("sky_total")

        position_covariance.save("position_error")
        beam_covariance.save("redundant_beam")
        redundant_total.save("redundant_residuals")

    figure, axes = pyplot.subplots(1, 2, figsize=(11, 5))
    ps_norm = colors.LogNorm(vmin=1e3, vmax=1e15)

    plot_2dpower_spectrum(u_range,
                          eta,
                          frequency_range,
                          sky_power,
                          title="Sky Based",
                          axes=axes[0],
                          axes_label_font=labelfontsize,
                          tickfontsize=ticksize,
                          colorbar_show=False,
                          xlabel_show=True,
                          norm=ps_norm,
                          ylabel_show=True)

    plot_2dpower_spectrum(u_range,
                          eta,
                          frequency_range,
                          redundant_power,
                          title="Redundancy Based",
                          axes=axes[1],
                          axes_label_font=labelfontsize,
                          tickfontsize=ticksize,
                          colorbar_show=True,
                          zlabel_show=True,
                          xlabel_show=True,
                          norm=ps_norm,
                          ylabel_show=False)

    plot_power_contours(u_range,
                        eta,
                        frequency_range,
                        from_jansky_to_milikelvin(sky_power, frequency_range) /
                        eor_power_spectrum,
                        axes=axes[0],
                        ratio=True,
                        axes_label_font=labelfontsize,
                        tickfontsize=ticksize,
                        xlabel_show=True,
                        norm=ps_norm,
                        ylabel_show=False,
                        contour_levels=contour_levels,
                        contour_label_locs=sky_clocations,
                        smooth=3,
                        contour_styles=linestyles)

    plot_power_contours(
        u_range,
        eta,
        frequency_range,
        from_jansky_to_milikelvin(redundant_power, frequency_range) /
        eor_power_spectrum,
        axes=axes[1],
        ratio=True,
        axes_label_font=labelfontsize,
        tickfontsize=ticksize,
        xlabel_show=True,
        norm=ps_norm,
        ylabel_show=False,
        contour_levels=contour_levels,
        contour_label_locs=beam_clocations,
        smooth=3,
        contour_styles=linestyles)

    pyplot.tight_layout()
    pyplot.savefig("../plots/Calibrated_Residuals_Comparison_MWA.pdf")
    pyplot.show()
    return
コード例 #4
0
def main(labelfontsize = 20, ticksize= 15):
    model_limit = 100e-3
    position_error = 0.01
    broken_fraction = 0.25
    telescope_position_path = "./data/MWA_Compact_Coordinates.txt"

    u_range = numpy.logspace(-1, numpy.log10(500), 100)
    frequency_range = numpy.linspace(135, 165, 251 )* 1e6
    eta = from_frequency_to_eta(frequency_range)

    eor_power_spectrum = fiducial_eor_power_spectrum(u_range, eta)

    telescope = RadioTelescope(load=True, path=telescope_position_path)
    redundant_table = redundant_baseline_finder(telescope.baseline_table)

    contour_levels = numpy.array([1e0, 1e1, 1e2])
    sky_clocations = [(6e-2, 0.21), (4e-2, 0.17), (3e-2, 0.07 )]
    beam_clocations = [(6e-2, 0.21), (0.045, 0.15), (3e-2, 0.07 )]
    total_clocations = [(6e-2, 0.24), (0.045, 0.18), (3e-2, 0.10)]

    sky_covariance = SkyCovariance(model_depth=model_limit)
    sky_covariance.compute_covariance(u=u_range, v = 0, nu=frequency_range)

    model_sky = copy.deepcopy(sky_covariance)
    unmodeled_mu = sky_moment_returner(2, s_low=sky_covariance.s_low, s_mid=sky_covariance.s_mid,
                                       s_high=sky_covariance.model_depth, k1=sky_covariance.k1,
                                       gamma1=sky_covariance.alpha1, k2=sky_covariance.k2, gamma2=sky_covariance.alpha2)
    modeled_mu = sky_moment_returner(2, s_low=sky_covariance.model_depth, s_mid=sky_covariance.s_mid,
                                       s_high=sky_covariance.s_high, k1=sky_covariance.k1,
                                       gamma1=sky_covariance.alpha1, k2=sky_covariance.k2, gamma2=sky_covariance.alpha2)

    model_sky.matrix *= modeled_mu / unmodeled_mu

    position_covariance = PositionCovariance(position_precision=position_error)
    position_covariance.compute_covariance(u=u_range, v = 0, nu=frequency_range)
    beam_covariance = BeamCovariance(model_depth=model_limit, calibration_type='relative', broken_fraction=broken_fraction)
    beam_covariance.compute_covariance(u=u_range, v = 0, nu=frequency_range)
    total_covariance = position_covariance + beam_covariance

    position_gain = GainCovariance(position_covariance, calibration_type='relative', baseline_table=redundant_table)
    beam_gain = GainCovariance(beam_covariance, calibration_type='relative', baseline_table=redundant_table)
    total_gain= GainCovariance(total_covariance, calibration_type='relative', baseline_table=redundant_table)

    position_residuals = CalibratedResiduals(position_gain, model_matrix=model_sky, residual_matrix=sky_covariance)
    beam_residuals = CalibratedResiduals(beam_gain, model_matrix=model_sky, residual_matrix=sky_covariance)
    total_residuals = CalibratedResiduals(total_gain, model_matrix=model_sky, residual_matrix=sky_covariance)

    position_power = position_residuals.compute_power()
    beam_power = beam_residuals.compute_power()
    total_power = total_residuals.compute_power()

    figure, axes = pyplot.subplots(1, 3, figsize=(15, 5))

    ps_norm = colors.LogNorm(vmin=1e3, vmax=1e15)

    plot_2dpower_spectrum(u_range, eta, frequency_range, position_power, title="Position Error", axes=axes[0],
                        axes_label_font=labelfontsize, tickfontsize=ticksize, colorbar_show=False,
                        xlabel_show=True, norm=ps_norm, ylabel_show=True)

    plot_2dpower_spectrum(u_range, eta, frequency_range, beam_power, title="Beam Variations", axes=axes[1],
                        axes_label_font=labelfontsize, tickfontsize=ticksize, colorbar_show=False,
                        xlabel_show=True, norm=ps_norm, ylabel_show=False)

    plot_2dpower_spectrum(u_range, eta, frequency_range, total_power, title="Total Error", axes=axes[2],
                        axes_label_font=labelfontsize, tickfontsize=ticksize, colorbar_show=True,
                        xlabel_show=True, norm=ps_norm, zlabel_show=True, ylabel_show=False)

    # plot_power_contours(u_range, eta, frequency_range, from_jansky_to_milikelvin(position_calibrated, frequency_range)/eor_power_spectrum,
    #                     axes=axes[0], ratio=True, axes_label_font=labelfontsize, tickfontsize=ticksize, xlabel_show=True,
    #                     norm=ps_norm, ylabel_show=False, contour_levels=contour_levels, contour_label_locs=sky_clocations)
    #
    # plot_power_contours(u_range, eta, frequency_range, from_jansky_to_milikelvin(beam_calibrated, frequency_range)/eor_power_spectrum,
    #                     axes=axes[1], ratio=True, axes_label_font=labelfontsize, tickfontsize=ticksize, xlabel_show=True,
    #                     norm=ps_norm, ylabel_show=False, contour_levels=contour_levels, contour_label_locs=beam_clocations)
    #
    # plot_power_contours(u_range, eta, frequency_range, from_jansky_to_milikelvin(total_calibrated, frequency_range)/eor_power_spectrum,
    #                     axes=axes[2], ratio=True, axes_label_font=labelfontsize, tickfontsize=ticksize, xlabel_show=True,
    #                     norm=ps_norm, ylabel_show=False, contour_levels=contour_levels, contour_label_locs=total_clocations)
    #

    pyplot.tight_layout()
    pyplot.savefig("../plots/Calibrated_Residuals_Relative_MWA.pdf")
    pyplot.show()
    return
コード例 #5
0
def main(labelfontsize = 20, ticksize= 15):
    model_limit = 100e-3
    broken_fraction = 0.25
    u_plot = 7

    telescope_position_path = "./data/MWA_Compact_Coordinates.txt"

    u_range = numpy.logspace(-1, numpy.log10(500), 100)
    frequency_range = numpy.linspace(135, 165,251 )* 1e6
    eta = from_frequency_to_eta(frequency_range)

    eor_power_spectrum = fiducial_eor_power_spectrum(u_range, eta)

    telescope = RadioTelescope(load=True, path=telescope_position_path)
    redundant_table = redundant_baseline_finder(telescope.baseline_table)

    sky_covariance = SkyCovariance(model_depth=model_limit)
    sky_covariance.compute_covariance(u=u_range, v = 0, nu=frequency_range)

    model_sky = copy.deepcopy(sky_covariance)
    unmodeled_mu = sky_moment_returner(2, s_low=sky_covariance.s_low, s_mid=sky_covariance.s_mid,
                                       s_high=sky_covariance.model_depth, k1=sky_covariance.k1,
                                       gamma1=sky_covariance.alpha1, k2=sky_covariance.k2, gamma2=sky_covariance.alpha2)
    modeled_mu = sky_moment_returner(2, s_low=sky_covariance.model_depth, s_mid=sky_covariance.s_mid,
                                       s_high=sky_covariance.s_high, k1=sky_covariance.k1,
                                       gamma1=sky_covariance.alpha1, k2=sky_covariance.k2, gamma2=sky_covariance.alpha2)

    model_sky.matrix *= modeled_mu / unmodeled_mu

    beam_covariance = BeamCovariance(model_depth=model_limit, calibration_type='sky', broken_fraction=broken_fraction)
    beam_covariance.compute_covariance(u=u_range, v = 0, nu=frequency_range)
    total_covariance = sky_covariance + beam_covariance

    sky_gain = GainCovariance(sky_covariance, calibration_type='absolute', baseline_table=redundant_table)
    beam_gain = GainCovariance(beam_covariance, calibration_type='absolute', baseline_table=redundant_table)
    total_gain= GainCovariance(total_covariance, calibration_type='absolute', baseline_table=redundant_table)

    sky_residuals = CalibratedResiduals(sky_gain, model_matrix=model_sky, residual_matrix=sky_covariance)
    beam_residuals = CalibratedResiduals(beam_gain, model_matrix=model_sky, residual_matrix=sky_covariance)
    total_residuals = CalibratedResiduals(total_gain, model_matrix=model_sky, residual_matrix=sky_covariance)

    sky_power = sky_residuals.compute_power()
    beam_power = beam_residuals.compute_power()
    total_power = total_residuals.compute_power()

    index = numpy.where(numpy.abs(u_range - u_plot) == numpy.min(numpy.abs(u_range - u_plot)))[0]

    sky_calibrated = sky_power[index, ...]
    beam_calibrated= beam_power[index,...]
    total_calibrated= total_power[index, ...]

    eor_power_spectrum = eor_power_spectrum[index,...]

    figure, axes = pyplot.subplots(1, 3, figsize=(15, 5))
    plot_1dpower_spectrum(eta, frequency_range, sky_calibrated[0,:], title="Sky Error", axes=axes[0],
                        axes_label_font=labelfontsize, tickfontsize=ticksize, xlabel_show=True, ylabel_show=True)

    plot_1dpower_spectrum(eta, frequency_range, beam_calibrated[0,:], title="Beam Variations", axes=axes[1],
                        axes_label_font=labelfontsize, tickfontsize=ticksize, xlabel_show=True, ylabel_show=False)

    plot_1dpower_spectrum(eta, frequency_range, total_calibrated[0,:], title="Total Error", axes=axes[2],
                        axes_label_font=labelfontsize, tickfontsize=ticksize, xlabel_show=True, ylabel_show=False)


    plot_1dpower_spectrum(eta, frequency_range, eor_power_spectrum[0, :], axes=axes[0], ratio=True, color = 'k')
    plot_1dpower_spectrum(eta, frequency_range, eor_power_spectrum[0, :], axes=axes[1], ratio=True, color = 'k')
    plot_1dpower_spectrum(eta, frequency_range, eor_power_spectrum[0, :], axes=axes[2], ratio=True, color = 'k')

    pyplot.tight_layout()
    pyplot.savefig("../plots/Calibrated_Residuals_Absolute_MWA.pdf")
    pyplot.show()
    return
コード例 #6
0
def main(labelfontsize=20, ticksize=15):
    model_limit = 100e-3
    broken_fraction = 0.25
    u_range = numpy.logspace(-1, numpy.log10(500), 100)
    frequency_range = numpy.linspace(135, 165, 251) * 1e6
    eta = from_frequency_to_eta(frequency_range)

    sky_covariance = SkyCovariance(model_depth=model_limit)
    sky_covariance.compute_covariance(u=u_range, v=0, nu=frequency_range)
    beam_covariance = BeamCovariance(model_depth=model_limit,
                                     calibration_type='sky',
                                     broken_fraction=broken_fraction)
    beam_covariance.compute_covariance(u=u_range, v=0, nu=frequency_range)

    sky_error_power = sky_covariance.compute_power()
    beam_error_power = beam_covariance.compute_power()
    total_error_power = sky_error_power + beam_error_power

    figure, axes = pyplot.subplots(1, 3, figsize=(15, 5))

    ps_norm = colors.LogNorm(vmin=1e3, vmax=1e15)

    plot_2dpower_spectrum(u_range,
                          eta,
                          frequency_range,
                          sky_error_power,
                          title="Sky Model Error",
                          axes=axes[0],
                          axes_label_font=labelfontsize,
                          tickfontsize=ticksize,
                          colorbar_show=False,
                          xlabel_show=True,
                          norm=ps_norm,
                          ylabel_show=True)

    plot_2dpower_spectrum(u_range,
                          eta,
                          frequency_range,
                          beam_error_power,
                          title="Beam Model Error",
                          axes=axes[1],
                          axes_label_font=labelfontsize,
                          tickfontsize=ticksize,
                          colorbar_show=False,
                          xlabel_show=True,
                          norm=ps_norm)

    plot_2dpower_spectrum(u_range,
                          eta,
                          frequency_range,
                          total_error_power,
                          title="Total Error",
                          axes=axes[2],
                          axes_label_font=labelfontsize,
                          tickfontsize=ticksize,
                          colorbar_show=True,
                          xlabel_show=True,
                          norm=ps_norm,
                          zlabel_show=True)

    figure.tight_layout()
    figure.savefig("../plots/Uncalibrated_sky_residuals.pdf")

    return