|
| 1 | +"""Compare vis_cpu with pyuvsim visibilities.""" |
| 2 | +import numpy as np |
| 3 | +from pyuvsim.analyticbeam import AnalyticBeam |
| 4 | + |
| 5 | +from vis_cpu import conversions, plot |
| 6 | + |
| 7 | +nsource = 10 |
| 8 | + |
| 9 | + |
| 10 | +def test_source_az_za_beam(): |
| 11 | + """Test function that calculates the Az and ZA positions of sources.""" |
| 12 | + # Observation latitude and LST |
| 13 | + hera_lat = -30.7215 |
| 14 | + lst = 0.78 |
| 15 | + |
| 16 | + # Add random sources |
| 17 | + ra = np.random.uniform(low=0.0, high=360.0, size=nsource - 1) |
| 18 | + dec = -30.72 + np.random.random(nsource - 1) * 10.0 |
| 19 | + ra = np.deg2rad(ra) |
| 20 | + dec = np.deg2rad(dec) |
| 21 | + |
| 22 | + # Point source coordinate transform, from equatorial to Cartesian |
| 23 | + crd_eq = conversions.point_source_crd_eq(ra, dec) |
| 24 | + |
| 25 | + # Beam model |
| 26 | + beam = AnalyticBeam(type="gaussian", diameter=14.0) |
| 27 | + |
| 28 | + # Calculate source locations and positions |
| 29 | + az, za, beamval = plot._source_az_za_beam( |
| 30 | + lst, crd_eq, beam, ref_freq=100.0e6, latitude=np.deg2rad(hera_lat) |
| 31 | + ) |
| 32 | + assert np.all(np.isfinite(az)) |
| 33 | + assert np.all(np.isfinite(za)) |
| 34 | + # (Values of beamval should be NaN below the horizon) |
| 35 | + |
| 36 | + |
| 37 | +def test_animate_source_map(): |
| 38 | + """Test function that animates source positions vs LST.""" |
| 39 | + # Observation latitude and LSTs |
| 40 | + hera_lat = -30.7215 |
| 41 | + lsts = np.linspace(0.0, 2.0 * np.pi, 5) |
| 42 | + |
| 43 | + # Add random sources |
| 44 | + ra = np.random.uniform(low=0.0, high=360.0, size=nsource - 1) |
| 45 | + dec = -30.72 + np.random.random(nsource - 1) * 10.0 |
| 46 | + ra = np.deg2rad(ra) |
| 47 | + dec = np.deg2rad(dec) |
| 48 | + |
| 49 | + # Beam model |
| 50 | + beam = AnalyticBeam(type="gaussian", diameter=14.0) |
| 51 | + |
| 52 | + # Generate animation |
| 53 | + anim = plot.animate_source_map( |
| 54 | + ra, |
| 55 | + dec, |
| 56 | + lsts, |
| 57 | + beam, |
| 58 | + interval=200, |
| 59 | + ref_freq=100.0e6, |
| 60 | + latitude=np.deg2rad(hera_lat), |
| 61 | + ) |
| 62 | + assert anim is not None |
0 commit comments