hera_sim for large, accurate, simulations

Hugh Garsden, HERA Group, Queen Mary University of London

23 Nov 2020

1. Introduction

Motivation

We are using hera_sim for simulations of HERA beam perturbations, as the hera_sim interface is fairly simple, hera_sim is fast, and it has GPU support. Apart from pyuvsim, we have not evaluated other simulators like RIMEz/PRISim. We implemented a beam based on the Fagnoni beam for use in our work, and ran simulations using hera_sim and pyuvsim. Since pyuvsim was developed as a reference against which other simulators could be validated, we wanted to check that the hera_sim output matched pyuvsim, and found that it didn't. We could switch to pyuvsim, but found that is slower and more memory-intensive compared to hera_sim. Looking at the pyuvsim code, we could see that is far more sophisticated than hera_sim (hence why it is a reference), and that the difference in output is largely due to more accurate source positions calculated using Astropy. The issue then was whether we could include some of this Astropy code in hera_sim. That negates some of the simplicity of hera_sim, but perhaps we can strike a happy medium. After some reverse engineering of Astropy, we worked out how to enhance hera_sim so that it matches the pyuvsim output, but still has better performance.

pyuvsim can be fast when simulations are parallelized (MPI), but we also added MPI to hera_sim, so it still has the edge over pyuvsim. GPU support is also coming for pyuvsim, which we can evaluate in the future. For this notebook, I won't use parallelized simulations; the aim here is to compare the serial version of the enhanced hera_sim against pyuvsim. A comparison of parallelized simulations can be reported later.

Outline

This memo was generated from a Python notebook and contains Python code, text, and plots of results.

Section 2 establishes functions and objects to make the simulations and analysis manageable. There is a function to compare hera_sim and pyuvsim output values, and a function to setup simulation objects for different configurations.

Section 3 runs small simulations and compares the hera_sim and pyuvsim output values and simulation times. It's divided into two parts:

  • Compare original hera_sim and pyuvsim using a couple of values, and a plot of a baseline.
  • Compare enhanced hera_sim and pyuvsim in the same way.

Section 4 runs some variations on the test in Section 3, to show that the results are general.

Section 5 has results of scaling tests, showing how simulation time and memory use change as simulations increase in size.

Short Summary of Results

The enhanced hera_sim is >100 times faster than pyuvsim, and the output visibilities match pyuvsim to many decimal places. As an example, compare the autocorrelation of antenna 0, and cross-correlation between antennas 0,1, for a particular simulation:

                                 pyuvsim                    hera_sim
Auto corr ant 0 (Amplitude)      0.25656533815007254         0.25656533815007254
Cross corr ant (0,1) Amplitude   0.17087283751552645         0.17087283751552657
Cross corr ant (0,1) Phase       0.384381003442964           0.3843810034429456

Other simulations show that these results are general.

hera_sim uses less memory than pyuvsim. This is a plot of hera_sim and pyuvsim memory usage, by number of frequency channels in the simulation:

hera_sim_CPU_Channels_Memory_usage_both.png

There are other plots that compare the performance of pyuvsim and hera_sim as simulation size increases.

Caveats

The enhanced hera_sim contains Astropy code, and some parts of that code have been hardwired for HERA. Therefore, if Astropy changes, enhanced hera_sim will need updating, and it can only be used for HERA.

2. Initialization and setup

Define some functions to setup telescope and observing configuration. Return appropriate simulation objects for hera_sim and pyuvsim.

We use the polybeam-astropy branch of hera_sim, which has these enhancements:

  • The original hera_sim is still supported, so it can be run.
  • Analytic beams can be used. It was designed for use with the Fagnoni beam (class PolyBeam and PerturbedPolyBeam) but can be used with other beams like AnalyticBeam. PerturbedPolyBeam will be used for these tests. pyuvsim is able to call it.
  • More accurate beam interpolation can be used. This was achieved by adding some astropy code to hera_sim. It can only be used for HERA telescope because some shortcuts were made (although these are not the sole reason for the improved accuracy).
  • Simulations can be run using MPI. This is not demonstrated for the tests here, only serial versions are used.
Package versions:
hera_sim/polybeam-astropy: commit 5edaee90585aa2c097105ddcd96ccecdd708fa9f
pyuvsim: commit 9179bad3573856cefc03b7adfc9e5e23e8b54520
In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
from hera_sim.visibilities import VisCPU
from hera_sim import io
from hera_sim.beams import PerturbedPolyBeam
from astropy.coordinates import Latitude, Longitude
from astropy.units import Quantity
import numpy as np
from pyuvsim import uvsim
from pyuvsim.telescope import BeamList
from pyradiosky import SkyModel
from pyuvsim import simsetup
import healvis as hv
import time

plt.rcParams['figure.figsize'] = [12, 6]

def compare_val(puvsim_uvd, hera_sim_uvd, ant1=0, ant2=1, which_freq=0, which_time=0):
    """
    Compare the outputs of two simulations, using a couple of values.
    puvsim_uvd, hera_sim_uvd are UVData objects from the simulations. Extract the 
    autocorrelation and the cross-correlation between antennas
    and print the values. Values are converted to amplitude and phase.
    Print a table with values from pyuvsim in the first column and hera_sim in the second
    column.
    """
   
    sim1_auto = puvsim_uvd.get_data(ant1, ant1, "XX")[which_time][which_freq]
    sim1_cross = puvsim_uvd.get_data(ant1, ant2, "XX")[which_time][which_freq]
    sim2_auto = hera_sim_uvd.get_data(ant1, ant1, "XX")[which_time][which_freq]
    sim2_cross = hera_sim_uvd.get_data(ant1, ant2, "XX")[which_time][which_freq]
    
    print("\n---------------------------------- Accuracy --------------------------------------")
    print("Values from Channel", which_freq, "Time", which_time)
    print("\t\t\t\t pyuvsim \t\t\t hera_sim")
    print("Auto corr ant "+str(ant1), "\t\t", abs(sim1_auto), "\t\t", abs(sim2_auto)) 
    print("Cross corr ant ("+str(ant1)+","+str(ant2)+") Amp", "\t", abs(sim1_cross), "\t\t", abs(sim2_cross))
    print("Cross corr ant ("+str(ant1)+","+str(ant2)+") Phase", "\t", np.angle(sim1_cross), "\t\t", np.angle(sim2_cross))
    print("\n\n")

def compare_baseline(pyuvsim_uvd, hera_sim_uvd, ant1=0, ant2=0, which_time=0):
    """
    Plot amplitude and phase of baseline. 
    """
    print("Plots of baseline("+str(ant1)+","+str(ant2)+")", "Time", which_time)
    
    f, (ax1, ax2) = plt.subplots(1, 2)
    
    ax1.plot(np.abs(pyuvsim_uvd.get_data(ant1, ant2, "XX")[which_time]), label="pyuvsim")
    ax1.plot(np.abs(hera_sim_uvd.get_data(ant1, ant2, "XX")[which_time]), label="hera_sim")
    ax1.set_ylabel("Amplitude")
    ax1.set_xlabel("Channel")
    ax1.legend()
    ax1.set_title("Amplitude for baseline ("+str(ant1)+","+str(ant2)+")")
 
    ax2.plot(np.angle(pyuvsim_uvd.get_data(ant1, ant2, "XX")[which_time]), label="pyuvsim")
    ax2.plot(np.angle(hera_sim_uvd.get_data(ant1, ant2, "XX")[which_time]), label="hera_sim")
    ax2.set_ylabel("Phase")
    ax2.set_xlabel("Channel")
    ax2.legend()
    ax2.set_title("Phase for baseline ("+str(ant1)+","+str(ant2)+")")
    plt.tight_layout()
    return f
 
def compare(pyuvsim_uvd, hera_sim_uvd, pyuvsim_time, hera_sim_time, ant1=0, ant2=0, which_freq=0, which_time=0):
    print("pyuvsim time:", pyuvsim_time)
    print("hera_sim time:", hera_sim_time)
    compare_val(pyuvsim_uvd, hera_sim_uvd, ant1, ant2, which_freq, which_time)
    compare_baseline(pyuvsim_uvd, hera_sim_uvd, ant1, ant2, which_time)

def telescope_config(which_package, nant=2, nfreq=2, ntime=1, nsource=1):
    """
    Setup the configuration parameters for pyuvsim/hera_sim/healvis.
    Different packages require different objects for simulation.
    healvis not used here.
    """
    if which_package not in [ "hera_sim", "pyuvsim", "healvis" ]:
        raise ValueError("Unknown package: "+which_package)
        
    np.random.seed(10)          # So we always get the same random values

    # Random antenna locations
    x = np.random.random(nant)*400     # Up to 400 metres
    y = np.random.random(nant)*400
    z = np.random.random(nant)
    ants = {}
    for i in range(nant):
        ants[i] = ( x[i], y[i], z[i] )
        
    # Observing parameters in a UVData object.
    uvdata = io.empty_uvdata(
        nfreq = nfreq,             # Need 2 freqs for healvis to work
        start_freq = 100e6,
        channel_width = 97.3e3,
        start_time = 2458902.4,
        integration_time = 40.0,
        ntimes = ntime,
        ants = ants,
        polarization_array = np.array([ "XX", "YY", "XY", "YX" ]),
        Npols = 4
    )
    
    # Random sources.
    sources = [
        [ 125.7, -30.72, 2, 0 ],     # Fix a source near zenith, which is at 130.7   -30.72
        ]
    if nsource > 1:                  # Add random others
        ra = 100+np.random.random(nsource-1)*50
        dec = -10.72+np.random.random(nsource-1)*40
        flux = np.random.random(nsource-1)*4
        for i in range(nsource-1): sources.append([ ra[i], dec[i], flux[i], 0])
    sources = np.array(sources)

    # Source locations and frequencies.
    ra_dec = np.deg2rad(sources[:, :2])
    freqs = np.unique(uvdata.freq_array)

    if which_package == "hera_sim":
        # calculate source fluxes for hera_sim. pyuvsim does it a different way.
        flux = (freqs[:,np.newaxis]/freqs[0])**sources[:,3].T*sources[:,2].T      
        beam_ids = list(ants.keys())

    # Beam model. PerturbedPolyBeam, which is not symmetrical.
    cfg_beam = dict(ref_freq=1.e8,
            spectral_index =        -0.6975,
            perturb =               True,
            mainlobe_width =        0.3 ,
            nmodes=                8,
            beam_coeffs=[ 0.29778665, -0.44821433, 0.27338272, 
                                  -0.10030698, -0.01195859, 0.06063853, 
                                  -0.04593295,  0.0107879,  0.01390283, 
                                  -0.01881641, -0.00177106, 0.01265177, 
                                  -0.00568299, -0.00333975, 0.00452368,
                                   0.00151808, -0.00593812, 0.00351559
                                 ] )

    beam = [PerturbedPolyBeam(np.array([-0.20437532, -0.4864951,  -0.18577532, -0.38053642,  0.08897764,  0.06367166,
                              0.29634711,  1.40277112]),
                              mainlobe_scale=1.0, xstretch=0.9, ystretch=0.8, **cfg_beam) 
                for i in range(len(ants.keys()))]
    beam_dict = {}
    for i in range(len(beam)): beam_dict[str(i)] = i

    # That's enough for hera_sim, but extra objects are required for pyuvsim and healvis.
    
    if which_package == "pyuvsim":
        # Need a sky model.
        
        # Stokes for the first frequency only. Stokes for other frequencies
        # are calculated later.
        stokes = np.zeros((4, 1, ra_dec.shape[0]))
        stokes[0, 0] = sources[:, 2]
        reference_frequency = np.full(len(ra_dec), freqs[0])
        
        # Setup sky model.
        sky_model = SkyModel(name=[ str(i) for i in range(len(ra_dec)) ],
            ra=Longitude(ra_dec[:, 0], "rad"), dec=Latitude(ra_dec[:, 1], "rad"),
            spectral_type="spectral_index",
            spectral_index=sources[:,3],
            stokes =stokes,
            reference_frequency=Quantity(reference_frequency, "Hz")
            )

        # Calculate stokes at all the frequencies.
        sky_model.at_frequencies(Quantity(freqs, "Hz"), inplace=True)
        
    if which_package == "healvis":
        # Need a GSM model and an Observatory.
        
        baselines = []
        for i in range(len(ants)):
            for j in range(i+1, len(ants)):
                bl = hv.observatory.Baseline(ants[i], ants[j], i, j)
                baselines.append(bl)

        times = np.unique(uvdata.get_times("XX"))

        obs_latitude=-30.7215277777
        obs_longitude = 21.4283055554
        obs_height = 1073

        # create the observatory
        fov = 360  # Deg
        obs = hv.observatory.Observatory(obs_latitude, obs_longitude, obs_height, array=baselines, freqs=freqs)
        obs.set_pointings(times)
        obs.set_fov(fov)
        obs.set_beam(beam)

        gsm = hv.sky_model.construct_skymodel('gsm', freqs=freqs, Nside=64)
    
    
        
    # Return what is relevant for each package, pyuvsim or hera_sim
    if which_package == "hera_sim":
        return uvdata, beam, beam_dict, freqs, ra_dec, flux
    elif which_package == "pyuvsim":
        return uvdata, beam, beam_dict, sky_model
    elif which_package == "healvis":
        return obs, gsm
/users/hgarsden/anaconda3_herasim/lib/python3.7/site-packages/hera_sim/visibilities/__init__.py:27: UserWarning: PRISim failed to import.
  warnings.warn("PRISim failed to import.")
/users/hgarsden/anaconda3_herasim/lib/python3.7/site-packages/hera_sim/visibilities/__init__.py:33: UserWarning: VisGPU failed to import.
  warnings.warn("VisGPU failed to import.")
/users/hgarsden/anaconda3_herasim/lib/python3.7/site-packages/hera_sim/__init__.py:37: FutureWarning: 
In the next major release, all HERA-specific variables will be removed from the codebase. The following variables will need to be accessed through new class-like structures to be introduced in the next major release: 

noise.HERA_Tsky_mdl
noise.HERA_BEAM_POLY
sigchain.HERA_NRAO_BANDPASS
rfi.HERA_RFI_STATIONS

Additionally, the next major release will involve modifications to the package's API, which move toward a regularization of the way in which hera_sim methods are interfaced with; in particular, changes will be made such that the Simulator class is the most intuitive way of interfacing with the hera_sim package features.
  FutureWarning)

3. Accuracy and timings

Using a reasonably small simulation.

Compare original hera_sim against pyuvsim

Run hera_sim

Antennas: 50, Frequencies: 50, Times: 1, Sources: 50

In [2]:
uvdata, beam, beam_dict, freqs, ra_dec, flux = telescope_config("hera_sim", nant=50, nfreq=50, ntime=1, nsource=50)

simulator = VisCPU(
        uvdata = uvdata,
        beams = beam,
        beam_ids = list(beam_dict.values()),
        sky_freqs = freqs,
        point_source_pos = ra_dec,
        point_source_flux = flux,
        bm_pix = 20,
        precision = 2
    ) 

start = time.time()
simulator.simulate() 
hera_sim_time = time.time()-start
invalid value encountered in sqrt

(The error message can be ignored, it's just because of zeros in unused values).

Run pyuvsim

Antennas: 50, Frequencies: 50, Times: 1, Sources: 50

In [3]:
uvdata, beam, beam_dict, sky_model = telescope_config("pyuvsim", nant=50, nfreq=50, ntime=1, nsource=50)
start = time.time()
pyuvsim_uvd = uvsim.run_uvdata_uvsim(uvdata, BeamList(beam), beam_dict=beam_dict,
         catalog=simsetup.SkyModelData(sky_model))
pyuvsim_time = time.time()-start
Nbls: 1275
Ntimes: 1
Nfreqs: 50
Nsrcs: 50
Tasks:  63750.0
1.00% completed. 0:00:00.930597  elapsed. 0:01:32.056155 remaining. 

2.00% completed. 0:00:01.702671  elapsed. 0:01:23.364162 remaining. 

3.00% completed. 0:00:02.455240  elapsed. 0:01:19.321970 remaining. 

4.00% completed. 0:00:03.202887  elapsed. 0:01:16.806543 remaining. 

5.00% completed. 0:00:04.034935  elapsed. 0:01:16.600512 remaining. 

6.00% completed. 0:00:04.805564  elapsed. 0:01:15.224396 remaining. 

7.01% completed. 0:00:05.582396  elapsed. 0:01:14.103620 remaining. 

8.01% completed. 0:00:06.331475  elapsed. 0:01:12.749933 remaining. 

9.01% completed. 0:00:07.103192  elapsed. 0:01:11.759309 remaining. 

10.01% completed. 0:00:07.877976  elapsed. 0:01:10.840048 remaining. 

11.01% completed. 0:00:08.660177  elapsed. 0:01:10.007001 remaining. 

12.01% completed. 0:00:09.422736  elapsed. 0:01:09.038529 remaining. 

13.01% completed. 0:00:10.203698  elapsed. 0:01:08.224772 remaining. 

14.01% completed. 0:00:11.001813  elapsed. 0:01:07.520979 remaining. 

15.01% completed. 0:00:11.757444  elapsed. 0:01:06.564087 remaining. 

16.01% completed. 0:00:12.516029  elapsed. 0:01:05.647847 remaining. 

17.01% completed. 0:00:13.272935  elapsed. 0:01:04.741963 remaining. 

18.01% completed. 0:00:14.108792  elapsed. 0:01:04.211957 remaining. 

19.01% completed. 0:00:14.853514  elapsed. 0:01:03.261611 remaining. 

20.02% completed. 0:00:15.638927  elapsed. 0:01:02.494429 remaining. 

21.02% completed. 0:00:16.422918  elapsed. 0:01:01.720164 remaining. 

22.02% completed. 0:00:17.183439  elapsed. 0:01:00.861888 remaining. 

23.02% completed. 0:00:17.942919  elapsed. 0:01:00.008634 remaining. 

24.02% completed. 0:00:18.703037  elapsed. 0:00:59.165212 remaining. 

25.02% completed. 0:00:19.479728  elapsed. 0:00:58.378120 remaining. 

26.02% completed. 0:00:20.236633  elapsed. 0:00:57.535574 remaining. 

27.02% completed. 0:00:20.998324  elapsed. 0:00:56.712298 remaining. 

28.02% completed. 0:00:21.748078  elapsed. 0:00:55.862757 remaining. 

29.02% completed. 0:00:22.519701  elapsed. 0:00:55.073583 remaining. 

30.02% completed. 0:00:23.273005  elapsed. 0:00:54.242882 remaining. 

31.02% completed. 0:00:24.070108  elapsed. 0:00:53.514551 remaining. 

32.03% completed. 0:00:24.850688  elapsed. 0:00:52.746852 remaining. 

33.03% completed. 0:00:25.619211  elapsed. 0:00:51.953920 remaining. 

34.03% completed. 0:00:26.374438  elapsed. 0:00:51.136646 remaining. 

35.03% completed. 0:00:27.135357  elapsed. 0:00:50.333475 remaining. 

36.03% completed. 0:00:27.902503  elapsed. 0:00:49.543709 remaining. 

37.03% completed. 0:00:28.669584  elapsed. 0:00:48.755052 remaining. 

38.03% completed. 0:00:29.430855  elapsed. 0:00:47.958067 remaining. 

39.03% completed. 0:00:30.199322  elapsed. 0:00:47.174152 remaining. 

40.03% completed. 0:00:30.953141  elapsed. 0:00:46.369066 remaining. 

41.03% completed. 0:00:31.712868  elapsed. 0:00:45.574973 remaining. 

42.03% completed. 0:00:32.480111  elapsed. 0:00:44.792881 remaining. 

43.03% completed. 0:00:33.254761  elapsed. 0:00:44.021284 remaining. 

44.03% completed. 0:00:34.033911  elapsed. 0:00:43.255268 remaining. 

45.04% completed. 0:00:34.780748  elapsed. 0:00:42.449231 remaining. 

46.04% completed. 0:00:35.526285  elapsed. 0:00:41.644243 remaining. 

47.04% completed. 0:00:36.276241  elapsed. 0:00:40.846761 remaining. 

48.04% completed. 0:00:37.027222  elapsed. 0:00:40.052369 remaining. 

49.04% completed. 0:00:37.777796  elapsed. 0:00:39.259326 remaining. 

50.04% completed. 0:00:38.527283  elapsed. 0:00:38.466895 remaining. 

51.04% completed. 0:00:39.276240  elapsed. 0:00:37.675641 remaining. 

52.04% completed. 0:00:40.026917  elapsed. 0:00:36.887598 remaining. 

53.04% completed. 0:00:40.780515  elapsed. 0:00:36.103552 remaining. 

54.04% completed. 0:00:41.526811  elapsed. 0:00:35.314424 remaining. 

55.04% completed. 0:00:42.294720  elapsed. 0:00:34.544505 remaining. 

56.04% completed. 0:00:43.038630  elapsed. 0:00:33.755835 remaining. 

57.04% completed. 0:00:43.872784  elapsed. 0:00:33.036691 remaining. 

58.05% completed. 0:00:44.647293  elapsed. 0:00:32.270471 remaining. 

59.05% completed. 0:00:45.405733  elapsed. 0:00:31.492824 remaining. 

60.05% completed. 0:00:46.176914  elapsed. 0:00:30.724294 remaining. 

61.05% completed. 0:00:47.000404  elapsed. 0:00:29.989055 remaining. 

62.05% completed. 0:00:47.782058  elapsed. 0:00:29.225380 remaining. 

63.05% completed. 0:00:48.539383  elapsed. 0:00:28.446875 remaining. 

64.05% completed. 0:00:49.293715  elapsed. 0:00:27.667353 remaining. 

65.05% completed. 0:00:50.056354  elapsed. 0:00:26.893069 remaining. 

66.05% completed. 0:00:50.815760  elapsed. 0:00:26.117476 remaining. 

67.05% completed. 0:00:51.599047  elapsed. 0:00:25.354101 remaining. 

68.05% completed. 0:00:52.398696  elapsed. 0:00:24.597820 remaining. 

69.05% completed. 0:00:53.205148  elapsed. 0:00:23.843332 remaining. 

70.05% completed. 0:00:54.048657  elapsed. 0:00:23.103199 remaining. 

71.06% completed. 0:00:54.793667  elapsed. 0:00:22.320030 remaining. 

72.06% completed. 0:00:55.552059  elapsed. 0:00:21.543112 remaining. 

73.06% completed. 0:00:56.308415  elapsed. 0:00:20.765950 remaining. 

74.06% completed. 0:00:57.053117  elapsed. 0:00:19.985267 remaining. 

75.06% completed. 0:00:57.808201  elapsed. 0:00:19.208995 remaining. 

76.06% completed. 0:00:58.556441  elapsed. 0:00:18.431125 remaining. 

77.06% completed. 0:00:59.304301  elapsed. 0:00:17.653912 remaining. 

78.06% completed. 0:01:00.063543  elapsed. 0:00:16.880651 remaining. 

79.06% completed. 0:01:00.815935  elapsed. 0:00:16.105930 remaining. 

80.06% completed. 0:01:01.577115  elapsed. 0:00:15.333956 remaining. 

81.06% completed. 0:01:02.384955  elapsed. 0:00:14.573149 remaining. 

82.06% completed. 0:01:03.156706  elapsed. 0:00:13.803306 remaining. 

83.07% completed. 0:01:03.995696  elapsed. 0:00:13.047127 remaining. 

84.07% completed. 0:01:04.747651  elapsed. 0:00:12.272478 remaining. 

85.07% completed. 0:01:05.509998  elapsed. 0:00:11.500188 remaining. 

86.07% completed. 0:01:06.270911  elapsed. 0:00:10.727897 remaining. 

87.07% completed. 0:01:07.016600  elapsed. 0:00:09.953606 remaining. 

88.07% completed. 0:01:07.760478  elapsed. 0:00:09.179720 remaining. 

89.07% completed. 0:01:08.514885  elapsed. 0:00:08.407800 remaining. 

90.07% completed. 0:01:09.260255  elapsed. 0:00:07.635274 remaining. 

91.07% completed. 0:01:10.015838  elapsed. 0:00:06.864345 remaining. 

92.07% completed. 0:01:10.765210  elapsed. 0:00:06.093215 remaining. 

93.07% completed. 0:01:11.515529  elapsed. 0:00:05.322624 remaining. 

94.07% completed. 0:01:12.260343  elapsed. 0:00:04.552117 remaining. 

95.07% completed. 0:01:13.016604  elapsed. 0:00:03.782744 remaining. 

96.08% completed. 0:01:13.813783  elapsed. 0:00:03.015316 remaining. 

97.08% completed. 0:01:14.636374  elapsed. 0:00:02.248040 remaining. 

98.08% completed. 0:01:15.430670  elapsed. 0:00:01.479080 remaining. 

99.08% completed. 0:01:16.177208  elapsed. 0:00:00.709164 remaining. 

Calculations Complete.

Compare the results

In [4]:
compare(pyuvsim_uvd, simulator.uvdata, pyuvsim_time, hera_sim_time, ant1=0, ant2=1, which_freq=0, which_time=0)
pyuvsim time: 77.89970016479492
hera_sim time: 0.5270650386810303

---------------------------------- Accuracy --------------------------------------
Values from Channel 0 Time 0
				 pyuvsim 			 hera_sim
Auto corr ant 0 		 0.25656533815007254 		 0.6149630678179203
Cross corr ant (0,1) Amp 	 0.17087283751552645 		 0.38821203721738645
Cross corr ant (0,1) Phase 	 0.384381003442964 		 2.1692171259440327



Plots of baseline(0,1) Time 0

RESULT : hera_sim is fast, but the output values don't match pyuvsim.

Compare enhanced hera_sim against pyuvsim

Run hera_sim using enhancements

Antennas: 50, Frequencies: 50, Times: 1, Sources: 50 (as before)

In [5]:
uvdata, beam, beam_dict, freqs, ra_dec, flux = telescope_config("hera_sim", nant=50, nfreq=50, ntime=1, nsource=50)

simulator = VisCPU(
        uvdata = uvdata,
        beams = beam,
        beam_ids = list(beam_dict.values()),
        sky_freqs = freqs,
        point_source_pos = ra_dec,
        point_source_flux = flux,
        precision = 2,
        # These parameters use the enhancements
        split_I = True,
        use_pixel_beams=False,
        az_za_corrections=[ "level_2", "precompute", "uvbeam_az" ]
    )

start = time.time()
simulator.simulate()
herasim_time = time.time()-start
Initializing AzZaTransforms for az_za_corrections
Pre-computing az/za for all times.
Finished pre-computing. Execution time: 0.009714

Brief explanation of the new parameters used:

split_I = True
    We use unpolarized sources, and pyuvsim splits the source intensity between XX and YY pols. 
    hera_sim calculates one polarization ("XX") and uses the total intensity.
    For hera_sim to match the pyuvsim output for XX, hera_sim must use half the input source
    intensity. This option tells hera_sim to do that.
use_pixel_beams = False
    Don't convert the beam to pixels. Calculate beam values from az/za.
az_za_corrections=[ "level_2", "precompute", "uvbeam_az" ]
    - Use astropy to calculate az/za angles for beam interpolation using the most accurate method (level_2). 
    - Precompute az/za values for all times in the simulation.
    - Apply the pyuvsim UVBeam correction to the azimuth. The azimuth gets rotated.

It is important to apply the UVBeam azimuth correction when using PerturbedPolyBeam, because the beam is not symmetrical.

The "precompute" option is important for hera_sim speed. hera_sim has a loop that recalculates the source az/za for every frequency. Since the source az/za doesn't change by frequency (not here anyway), this is unnecessary. The source az/za can be calculated once. It may be possible to precompute values in pyuvsim.

Compare

Use the previous pyuvsim result, which has the same configuration. Make the same comparisons as before. hera_sim visibilities now match pyuvsim.

In [6]:
compare(pyuvsim_uvd, simulator.uvdata, pyuvsim_time, hera_sim_time, ant1=0, ant2=1, which_freq=0, which_time=0)
pyuvsim time: 77.89970016479492
hera_sim time: 0.5270650386810303

---------------------------------- Accuracy --------------------------------------
Values from Channel 0 Time 0
				 pyuvsim 			 hera_sim
Auto corr ant 0 		 0.25656533815007254 		 0.25656533815007254
Cross corr ant (0,1) Amp 	 0.17087283751552645 		 0.17087283751552657
Cross corr ant (0,1) Phase 	 0.384381003442964 		 0.3843810034429456



Plots of baseline(0,1) Time 0

The hera_sim values are so close to pyuvsim, that they can't be distinguished in the plot.

RESULT : hera_sim is 100s of times faster than pyusim for the same accuracy.

4. Additional test cases

These demonstrate that the previous test case is not a "one off". Use different numbers of ants/frequencies/times/sources, and look at different values.

Case 1

Different configuration. Antennas: 10, Frequencies: 120, Times: 10, Sources: 100.

Run hera_sim

In [7]:
uvdata, beam, beam_dict, freqs, ra_dec, flux = telescope_config("hera_sim", nant=10, nfreq=120, ntime=10, nsource=100)

simulator = VisCPU(
        uvdata = uvdata,
        beams = beam,
        beam_ids = list(beam_dict.values()),
        sky_freqs = freqs,
        point_source_pos = ra_dec,
        point_source_flux = flux,
        split_I = True,
        use_pixel_beams=False,
        az_za_corrections=[ "level_2", "precompute", "uvbeam_az" ],
        precision = 2
    )

start = time.time()
simulator.simulate()
herasim_time = time.time()-start
Initializing AzZaTransforms for az_za_corrections
Pre-computing az/za for all times.
Finished pre-computing. Execution time: 0.088781

Run pyuvsim

In [8]:
uvdata, beam, beam_dict, sky_model = telescope_config("pyuvsim", nant=10, nfreq=120, ntime=10, nsource=100)
start = time.time()
pyuvsim_uvd = uvsim.run_uvdata_uvsim(uvdata, BeamList(beam), beam_dict=beam_dict,
         catalog=simsetup.SkyModelData(sky_model))
pyuvsim_time = time.time()-start
Nbls: 55
Ntimes: 10
Nfreqs: 120
Nsrcs: 100
Tasks:  66000.0
1.00% completed. 0:00:00.810688  elapsed. 0:01:20.258137 remaining. 

2.00% completed. 0:00:01.636726  elapsed. 0:01:20.199569 remaining. 

3.00% completed. 0:00:02.425225  elapsed. 0:01:18.415609 remaining. 

4.00% completed. 0:00:03.212550  elapsed. 0:01:17.101204 remaining. 

5.00% completed. 0:00:03.999224  elapsed. 0:01:15.985250 remaining. 

6.00% completed. 0:00:04.786294  elapsed. 0:01:14.985280 remaining. 

7.00% completed. 0:00:05.578458  elapsed. 0:01:14.113803 remaining. 

8.00% completed. 0:00:06.365444  elapsed. 0:01:13.202605 remaining. 

9.00% completed. 0:00:07.146800  elapsed. 0:01:12.262092 remaining. 

10.00% completed. 0:00:07.941679  elapsed. 0:01:11.475115 remaining. 

11.00% completed. 0:00:08.731253  elapsed. 0:01:10.643774 remaining. 

12.00% completed. 0:00:09.521851  elapsed. 0:01:09.826906 remaining. 

13.00% completed. 0:00:10.315372  elapsed. 0:01:09.033645 remaining. 

14.00% completed. 0:00:11.109944  elapsed. 0:01:08.246800 remaining. 

15.00% completed. 0:00:11.926121  elapsed. 0:01:07.581354 remaining. 

16.00% completed. 0:00:12.716147  elapsed. 0:01:06.759770 remaining. 

17.00% completed. 0:00:13.501845  elapsed. 0:01:05.920773 remaining. 

18.00% completed. 0:00:14.289499  elapsed. 0:01:05.096608 remaining. 

19.00% completed. 0:00:15.082661  elapsed. 0:01:04.299766 remaining. 

20.00% completed. 0:00:15.884467  elapsed. 0:01:03.537869 remaining. 

21.00% completed. 0:00:16.672004  elapsed. 0:01:02.718489 remaining. 

22.00% completed. 0:00:17.461543  elapsed. 0:01:01.909106 remaining. 

23.00% completed. 0:00:18.252648  elapsed. 0:01:01.106690 remaining. 

24.00% completed. 0:00:19.040949  elapsed. 0:01:00.296337 remaining. 

25.00% completed. 0:00:19.830173  elapsed. 0:00:59.490519 remaining. 

26.00% completed. 0:00:20.619491  elapsed. 0:00:58.686243 remaining. 

27.00% completed. 0:00:21.452964  elapsed. 0:00:58.002459 remaining. 

28.00% completed. 0:00:22.265988  elapsed. 0:00:57.255397 remaining. 

29.00% completed. 0:00:23.062021  elapsed. 0:00:56.462189 remaining. 

30.00% completed. 0:00:23.883992  elapsed. 0:00:55.729315 remaining. 

31.00% completed. 0:00:24.736108  elapsed. 0:00:55.057789 remaining. 

32.00% completed. 0:00:25.528896  elapsed. 0:00:54.248903 remaining. 

33.00% completed. 0:00:26.323792  elapsed. 0:00:53.445275 remaining. 

34.00% completed. 0:00:27.114443  elapsed. 0:00:52.633918 remaining. 

35.00% completed. 0:00:27.902700  elapsed. 0:00:51.819299 remaining. 

36.00% completed. 0:00:28.691462  elapsed. 0:00:51.007043 remaining. 

37.00% completed. 0:00:29.484567  elapsed. 0:00:50.203452 remaining. 

38.00% completed. 0:00:30.277356  elapsed. 0:00:49.399897 remaining. 

39.00% completed. 0:00:31.070442  elapsed. 0:00:48.597358 remaining. 

40.00% completed. 0:00:31.940655  elapsed. 0:00:47.910982 remaining. 

41.00% completed. 0:00:32.738305  elapsed. 0:00:47.111220 remaining. 

42.00% completed. 0:00:33.531827  elapsed. 0:00:46.305857 remaining. 

43.00% completed. 0:00:34.327867  elapsed. 0:00:45.504382 remaining. 

44.00% completed. 0:00:35.128210  elapsed. 0:00:44.708631 remaining. 

45.00% completed. 0:00:35.927554  elapsed. 0:00:43.911455 remaining. 

46.00% completed. 0:00:36.726116  elapsed. 0:00:43.113267 remaining. 

47.00% completed. 0:00:37.525142  elapsed. 0:00:42.315586 remaining. 

48.00% completed. 0:00:38.312129  elapsed. 0:00:41.504806 remaining. 

49.00% completed. 0:00:39.114144  elapsed. 0:00:40.710640 remaining. 

50.00% completed. 0:00:39.919416  elapsed. 0:00:39.919416 remaining. 

51.00% completed. 0:00:40.742548  elapsed. 0:00:39.144801 remaining. 

52.00% completed. 0:00:41.569368  elapsed. 0:00:38.371724 remaining. 

53.00% completed. 0:00:42.362661  elapsed. 0:00:37.566888 remaining. 

54.00% completed. 0:00:43.188217  elapsed. 0:00:36.789962 remaining. 

55.00% completed. 0:00:43.986103  elapsed. 0:00:35.988629 remaining. 

56.00% completed. 0:00:44.795406  elapsed. 0:00:35.196391 remaining. 

57.00% completed. 0:00:45.615032  elapsed. 0:00:34.411340 remaining. 

58.00% completed. 0:00:46.419780  elapsed. 0:00:33.614324 remaining. 

59.00% completed. 0:00:47.215638  elapsed. 0:00:32.810867 remaining. 

60.00% completed. 0:00:48.010758  elapsed. 0:00:32.007172 remaining. 

61.00% completed. 0:00:48.800319  elapsed. 0:00:31.200204 remaining. 

62.00% completed. 0:00:49.590669  elapsed. 0:00:30.394281 remaining. 

63.00% completed. 0:00:50.381744  elapsed. 0:00:29.589278 remaining. 

64.00% completed. 0:00:51.197975  elapsed. 0:00:28.798861 remaining. 

65.00% completed. 0:00:52.001514  elapsed. 0:00:28.000815 remaining. 

66.00% completed. 0:00:52.790259  elapsed. 0:00:27.194982 remaining. 

67.00% completed. 0:00:53.583218  elapsed. 0:00:26.391734 remaining. 

68.00% completed. 0:00:54.367774  elapsed. 0:00:25.584835 remaining. 

69.00% completed. 0:00:55.160768  elapsed. 0:00:24.782374 remaining. 

70.00% completed. 0:00:55.963134  elapsed. 0:00:23.984200 remaining. 

71.00% completed. 0:00:56.755075  elapsed. 0:00:23.181651 remaining. 

72.00% completed. 0:00:57.549635  elapsed. 0:00:22.380414 remaining. 

73.00% completed. 0:00:58.344012  elapsed. 0:00:21.579292 remaining. 

74.00% completed. 0:00:59.138988  elapsed. 0:00:20.778563 remaining. 

75.00% completed. 0:00:59.930592  elapsed. 0:00:19.976864 remaining. 

76.00% completed. 0:01:00.722017  elapsed. 0:00:19.175374 remaining. 

77.00% completed. 0:01:01.543291  elapsed. 0:00:18.383061 remaining. 

78.00% completed. 0:01:02.327118  elapsed. 0:00:17.579444 remaining. 

79.00% completed. 0:01:03.118132  elapsed. 0:00:16.778238 remaining. 

80.00% completed. 0:01:03.916485  elapsed. 0:00:15.979121 remaining. 

81.00% completed. 0:01:04.705477  elapsed. 0:00:15.177828 remaining. 

82.00% completed. 0:01:05.496649  elapsed. 0:00:14.377313 remaining. 

83.00% completed. 0:01:06.286068  elapsed. 0:00:13.576665 remaining. 

84.00% completed. 0:01:07.074180  elapsed. 0:00:12.776034 remaining. 

85.00% completed. 0:01:07.860785  elapsed. 0:00:11.975433 remaining. 

86.00% completed. 0:01:08.648530  elapsed. 0:00:11.175342 remaining. 

87.00% completed. 0:01:09.437701  elapsed. 0:00:10.375748 remaining. 

88.00% completed. 0:01:10.218912  elapsed. 0:00:09.575306 remaining. 

89.00% completed. 0:01:10.999833  elapsed. 0:00:08.775260 remaining. 

90.00% completed. 0:01:11.844905  elapsed. 0:00:07.982767 remaining. 

91.00% completed. 0:01:12.648282  elapsed. 0:00:07.184995 remaining. 

92.00% completed. 0:01:13.464875  elapsed. 0:00:06.388250 remaining. 

93.00% completed. 0:01:14.277653  elapsed. 0:00:05.590791 remaining. 

94.00% completed. 0:01:15.095784  elapsed. 0:00:04.793348 remaining. 

95.00% completed. 0:01:15.906862  elapsed. 0:00:03.995098 remaining. 

96.00% completed. 0:01:16.726121  elapsed. 0:00:03.196922 remaining. 

97.00% completed. 0:01:17.530446  elapsed. 0:00:02.397849 remaining. 

98.00% completed. 0:01:18.328116  elapsed. 0:00:01.598533 remaining. 

99.00% completed. 0:01:19.130269  elapsed. 0:00:00.799296 remaining. 

100.00% completed. 0:01:19.939065  elapsed. 0:00:00 remaining. 

Calculations Complete.
In [9]:
compare(pyuvsim_uvd, simulator.uvdata, pyuvsim_time, hera_sim_time, ant1=5, ant2=7, which_freq=100, which_time=3)
pyuvsim time: 79.9674870967865
hera_sim time: 0.5270650386810303

---------------------------------- Accuracy --------------------------------------
Values from Channel 100 Time 3
				 pyuvsim 			 hera_sim
Auto corr ant 5 		 0.25346837824535984 		 0.2534683782453598
Cross corr ant (5,7) Amp 	 0.10915574854972665 		 0.10915574854972793
Cross corr ant (5,7) Phase 	 1.4179611001259622 		 1.4179611001259473



Plots of baseline(5,7) Time 3

RESULT : hera_sim still fast and accurate.

Case 2

Antennas: 20, Frequencies: 4, Times: 100, Sources: 1000.

Run hera_sim

In [10]:
uvdata, beam, beam_dict, freqs, ra_dec, flux = telescope_config("hera_sim", nant=20, nfreq=4, ntime=100, nsource=1000)

simulator = VisCPU(
        uvdata = uvdata,
        beams = beam,
        beam_ids = list(beam_dict.values()),
        sky_freqs = freqs,
        point_source_pos = ra_dec,
        point_source_flux = flux,
        split_I = True,
        use_pixel_beams=False,
        az_za_corrections=[ "level_2", "precompute", "uvbeam_az" ],
        precision = 2
    )

start = time.time()
simulator.simulate()
herasim_time = time.time()-start
Initializing AzZaTransforms for az_za_corrections
Pre-computing az/za for all times.
Finished pre-computing. Execution time: 0.937149

Run pyuvsim

In [11]:
uvdata, beam, beam_dict, sky_model = telescope_config("pyuvsim", nant=20, nfreq=4, ntime=100, nsource=1000)
start = time.time()
pyuvsim_uvd = uvsim.run_uvdata_uvsim(uvdata, BeamList(beam), beam_dict=beam_dict,
         catalog=simsetup.SkyModelData(sky_model))
pyuvsim_time = time.time()-start
Nbls: 210
Ntimes: 100
Nfreqs: 4
Nsrcs: 1000
Tasks:  84000.0
1.00% completed. 0:00:01.883609  elapsed. 0:03:06.477249 remaining. 

2.00% completed. 0:00:03.757842  elapsed. 0:03:04.134238 remaining. 

3.00% completed. 0:00:05.672903  elapsed. 0:03:03.423850 remaining. 

4.00% completed. 0:00:07.546105  elapsed. 0:03:01.106512 remaining. 

5.00% completed. 0:00:09.425936  elapsed. 0:02:59.092784 remaining. 

6.00% completed. 0:00:11.295756  elapsed. 0:02:56.966849 remaining. 

7.00% completed. 0:00:13.172642  elapsed. 0:02:55.007955 remaining. 

8.00% completed. 0:00:15.078364  elapsed. 0:02:53.401185 remaining. 

9.00% completed. 0:00:16.954720  elapsed. 0:02:51.431063 remaining. 

10.00% completed. 0:00:18.833255  elapsed. 0:02:49.499298 remaining. 

11.00% completed. 0:00:20.715190  elapsed. 0:02:47.604720 remaining. 

12.00% completed. 0:00:22.610006  elapsed. 0:02:45.806710 remaining. 

13.00% completed. 0:00:24.540987  elapsed. 0:02:44.235839 remaining. 

14.00% completed. 0:00:26.422393  elapsed. 0:02:42.308988 remaining. 

15.00% completed. 0:00:28.307187  elapsed. 0:02:40.407393 remaining. 

16.00% completed. 0:00:30.201466  elapsed. 0:02:38.557698 remaining. 

17.00% completed. 0:00:32.085489  elapsed. 0:02:36.652679 remaining. 

18.00% completed. 0:00:33.968824  elapsed. 0:02:34.746863 remaining. 

19.00% completed. 0:00:35.874463  elapsed. 0:02:32.938499 remaining. 

20.00% completed. 0:00:37.746773  elapsed. 0:02:30.987093 remaining. 

21.00% completed. 0:00:39.630226  elapsed. 0:02:29.085136 remaining. 

22.00% completed. 0:00:41.503590  elapsed. 0:02:27.149092 remaining. 

23.00% completed. 0:00:43.370826  elapsed. 0:02:25.197984 remaining. 

24.00% completed. 0:00:45.349902  elapsed. 0:02:23.608024 remaining. 

25.00% completed. 0:00:47.311036  elapsed. 0:02:21.933108 remaining. 

26.00% completed. 0:00:49.239921  elapsed. 0:02:20.144390 remaining. 

27.00% completed. 0:00:51.124816  elapsed. 0:02:18.226355 remaining. 

28.00% completed. 0:00:53.027591  elapsed. 0:02:16.356664 remaining. 

29.00% completed. 0:00:54.963554  elapsed. 0:02:14.565942 remaining. 

30.00% completed. 0:00:56.869214  elapsed. 0:02:12.694833 remaining. 

31.00% completed. 0:00:58.823817  elapsed. 0:02:10.930432 remaining. 

32.00% completed. 0:01:00.738840  elapsed. 0:02:09.070035 remaining. 

33.00% completed. 0:01:02.633077  elapsed. 0:02:07.164126 remaining. 

34.00% completed. 0:01:04.563751  elapsed. 0:02:05.329634 remaining. 

35.00% completed. 0:01:06.448028  elapsed. 0:02:03.403480 remaining. 

36.00% completed. 0:01:08.356367  elapsed. 0:02:01.522431 remaining. 

37.00% completed. 0:01:10.256731  elapsed. 0:01:59.626325 remaining. 

38.00% completed. 0:01:12.145921  elapsed. 0:01:57.711767 remaining. 

39.00% completed. 0:01:14.028878  elapsed. 0:01:55.788758 remaining. 

40.00% completed. 0:01:15.935754  elapsed. 0:01:53.903631 remaining. 

41.00% completed. 0:01:17.820028  elapsed. 0:01:51.984918 remaining. 

42.00% completed. 0:01:19.716566  elapsed. 0:01:50.084781 remaining. 

43.00% completed. 0:01:21.592419  elapsed. 0:01:48.157393 remaining. 

44.00% completed. 0:01:23.472756  elapsed. 0:01:46.238054 remaining. 

45.00% completed. 0:01:25.396673  elapsed. 0:01:44.373711 remaining. 

46.00% completed. 0:01:27.323261  elapsed. 0:01:42.509915 remaining. 

47.00% completed. 0:01:29.219419  elapsed. 0:01:40.609132 remaining. 

48.00% completed. 0:01:31.120903  elapsed. 0:01:38.714311 remaining. 

49.00% completed. 0:01:33.031279  elapsed. 0:01:36.828474 remaining. 

50.00% completed. 0:01:34.973624  elapsed. 0:01:34.973624 remaining. 

51.00% completed. 0:01:36.853438  elapsed. 0:01:33.055264 remaining. 

52.00% completed. 0:01:38.744159  elapsed. 0:01:31.148455 remaining. 

53.00% completed. 0:01:40.626191  elapsed. 0:01:29.234546 remaining. 

54.00% completed. 0:01:42.518920  elapsed. 0:01:27.330932 remaining. 

55.00% completed. 0:01:44.431848  elapsed. 0:01:25.444239 remaining. 

56.00% completed. 0:01:46.311526  elapsed. 0:01:23.530485 remaining. 

57.00% completed. 0:01:48.191885  elapsed. 0:01:21.618439 remaining. 

58.00% completed. 0:01:50.087575  elapsed. 0:01:19.718589 remaining. 

59.00% completed. 0:01:51.970555  elapsed. 0:01:17.810046 remaining. 

60.00% completed. 0:01:53.849487  elapsed. 0:01:15.899658 remaining. 

61.00% completed. 0:01:55.795993  elapsed. 0:01:14.033503 remaining. 

62.00% completed. 0:01:57.735731  elapsed. 0:01:12.160609 remaining. 

63.00% completed. 0:01:59.608612  elapsed. 0:01:10.246328 remaining. 

64.00% completed. 0:02:01.484558  elapsed. 0:01:08.335064 remaining. 

65.00% completed. 0:02:03.365769  elapsed. 0:01:06.427722 remaining. 

66.00% completed. 0:02:05.268160  elapsed. 0:01:04.532083 remaining. 

67.00% completed. 0:02:07.139680  elapsed. 0:01:02.621036 remaining. 

68.00% completed. 0:02:09.019882  elapsed. 0:01:00.715239 remaining. 

69.00% completed. 0:02:10.898482  elapsed. 0:00:58.809463 remaining. 

70.00% completed. 0:02:12.776255  elapsed. 0:00:56.904109 remaining. 

71.00% completed. 0:02:14.715197  elapsed. 0:00:55.024517 remaining. 

72.00% completed. 0:02:16.587485  elapsed. 0:00:53.117355 remaining. 

73.00% completed. 0:02:18.478710  elapsed. 0:00:51.218153 remaining. 

74.00% completed. 0:02:20.354010  elapsed. 0:00:49.313571 remaining. 

75.00% completed. 0:02:22.229885  elapsed. 0:00:47.409962 remaining. 

76.00% completed. 0:02:24.151657  elapsed. 0:00:45.521576 remaining. 

77.00% completed. 0:02:26.075334  elapsed. 0:00:43.632892 remaining. 

78.00% completed. 0:02:27.980643  elapsed. 0:00:41.738130 remaining. 

79.00% completed. 0:02:29.896139  elapsed. 0:00:39.845809 remaining. 

80.00% completed. 0:02:31.809877  elapsed. 0:00:37.952469 remaining. 

81.00% completed. 0:02:33.728671  elapsed. 0:00:36.059812 remaining. 

82.00% completed. 0:02:35.683236  elapsed. 0:00:34.174369 remaining. 

83.00% completed. 0:02:37.579948  elapsed. 0:00:32.275411 remaining. 

84.00% completed. 0:02:39.466196  elapsed. 0:00:30.374513 remaining. 

85.00% completed. 0:02:41.354380  elapsed. 0:00:28.474302 remaining. 

86.00% completed. 0:02:43.243711  elapsed. 0:00:26.574558 remaining. 

87.00% completed. 0:02:45.192402  elapsed. 0:00:24.683922 remaining. 

88.00% completed. 0:02:47.098084  elapsed. 0:00:22.786102 remaining. 

89.00% completed. 0:02:49.178009  elapsed. 0:00:20.909642 remaining. 

90.00% completed. 0:02:51.062314  elapsed. 0:00:19.006924 remaining. 

91.00% completed. 0:02:52.937568  elapsed. 0:00:17.103716 remaining. 

92.00% completed. 0:02:54.832252  elapsed. 0:00:15.202805 remaining. 

93.00% completed. 0:02:56.707835  elapsed. 0:00:13.300590 remaining. 

94.00% completed. 0:02:58.610064  elapsed. 0:00:11.400642 remaining. 

95.00% completed. 0:03:00.488995  elapsed. 0:00:09.499421 remaining. 

96.00% completed. 0:03:02.367676  elapsed. 0:00:07.598653 remaining. 

97.00% completed. 0:03:04.274431  elapsed. 0:00:05.699209 remaining. 

98.00% completed. 0:03:06.197152  elapsed. 0:00:03.799942 remaining. 

99.00% completed. 0:03:08.098332  elapsed. 0:00:01.899983 remaining. 

100.00% completed. 0:03:09.983264  elapsed. 0:00:00 remaining. 

Calculations Complete.
In [12]:
compare(pyuvsim_uvd, simulator.uvdata, pyuvsim_time, hera_sim_time, ant1=4, ant2=18, which_freq=3, which_time=40)
pyuvsim time: 190.02294158935547
hera_sim time: 0.5270650386810303

---------------------------------- Accuracy --------------------------------------
Values from Channel 3 Time 40
				 pyuvsim 			 hera_sim
Auto corr ant 4 		 1.5138302265573047 		 1.5138302265573045
Cross corr ant (4,18) Amp 	 0.07026149336152489 		 0.07026149336152546
Cross corr ant (4,18) Phase 	 -2.5768727741044004 		 -2.5768727741043764



Plots of baseline(4,18) Time 40

RESULT : hera_sim still fast and accurate.

5. Performance of enhanced hera_sim vs. pyuvsim at large scales

Each parameter (antennas/frequencies/times/sources) is scaled up while holding the others constant.

Method:

  • Start with these parameters: Antennas=10, Frequencies=10, Times=10, Sources=10
  • Pick one of those parameters. Increase its value and measure the simulation time and memory use. For both hera_sim and pyuvsim.
  • Plot the results.

For each parameter there will be two plots:

  • Simulation Time versus parameter value
  • Memory usage versus parameter value

The number of antennas will be plotted as the number of baselines.

Simulations were run on ILIFU in South Africa. No MPI is used, these are all serial runs. The maximum allowed run time was 72 hours. The maximum allowed memory was 232GB. Some pyuvsim runs failed to complete because of these limits. That will be seen in the plots, where the pyuvsim plot does not extend over the complete x-axis range.

Increase number of baselines

Simulation time hera_sim_CPU_Baselines_Simulation_Time_both.png

As hera_sim is not visibile in this plot, I show the same plot but clipped on the y-axis: hera_sim_CPU_Baselines_Simulation_Time_both_clipped.png

Memory usage

hera_sim_CPU_Baselines_Memory_usage_both.png

Increase number of frequencies

Simulation time hera_sim_CPU_Channels_Simulation_Time_both.png

Memory usage hera_sim_CPU_Channels_Memory_usage_both.png

Increase number of times

Simulation time hera_sim_CPU_Times_Simulation_Time_both.png Memory usage hera_sim_CPU_Times_Memory_usage_both.png

Increase number of sources

Simulation time hera_sim_CPU_Sources_Simulation_Time_both.png

Memory usage hera_sim_CPU_Sources_Memory_usage_both.png

In [ ]: