Skip to content

Commit

Permalink
Rerun tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lmachadopolettivalle committed Nov 6, 2023
1 parent b9dfb0c commit 5bafc98
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
export RUN_GPU_TESTS=false
export RUN_NOTEBOOK_TESTS=true
pip install . --no-deps
pytest karabo/test/test_simulation.py
pytest --cov=./ --cov-report=xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
Expand Down
2 changes: 0 additions & 2 deletions karabo/simulation/sky_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,6 @@ def filter_by_radius(
raise KaraboSkyModelError(
"`sources` is None, add sources before calling `filter_by_radius`."
)
print(copied_sky.sources)
inner_circle = SphericalCircle(
(ra0_deg * u.deg, dec0_deg * u.deg),
inner_radius_deg * u.deg, # pyright: ignore
Expand All @@ -536,7 +535,6 @@ def filter_by_radius(
)
outer_sources = outer_circle.contains_points(copied_sky[:, 0:2])
inner_sources = inner_circle.contains_points(copied_sky[:, 0:2])
print(np.version.version)
filtered_sources = np.logical_and(outer_sources, np.logical_not(inner_sources))
filtered_sources_idxs = np.where(filtered_sources == True)[0] # noqa
copied_sky.sources = copied_sky.sources[filtered_sources_idxs]
Expand Down
70 changes: 35 additions & 35 deletions karabo/test/test_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,41 @@ def continuous_noise_fits_downloader(
)


def test_parallelization_by_observation() -> None:
sky = SkyModel.get_GLEAM_Sky([76])
phase_center = [250, -80]
CENTER_FREQUENCIES_HZ = [100e6, 101e6]
CHANNEL_BANDWIDTHS_HZ = [1.0, 2.0]
N_CHANNELS = [2, 4]

sky = sky.filter_by_radius(0, 2.0, phase_center[0], phase_center[1])
telescope = Telescope.constructor("ASKAP")

simulation = InterferometerSimulation(channel_bandwidth_hz=1e6, time_average_sec=1)

obs_parallized = ObservationParallized(
center_frequencies_hz=CENTER_FREQUENCIES_HZ,
channel_bandwidths_hz=CHANNEL_BANDWIDTHS_HZ,
phase_centre_ra_deg=phase_center[0],
phase_centre_dec_deg=phase_center[1],
number_of_time_steps=24,
n_channels=N_CHANNELS,
)

visibilities = simulation.run_simulation(telescope, sky, obs_parallized)

for i, vis in enumerate(visibilities):
imager = Imager(
vis, imaging_npixel=512, imaging_cellsize=3.878509448876288e-05
) # imaging cellsize is over-written in the Imager based on max uv dist.
dirty = imager.get_dirty_image()
with tempfile.TemporaryDirectory() as tmpdir:
dirty.write_to_file(os.path.join(tmpdir, f"dirty_{i}.fits"), overwrite=True)
assert dirty.header["CRVAL4"] == CENTER_FREQUENCIES_HZ[i]
assert dirty.header["NAXIS4"] == N_CHANNELS[i]
assert dirty.header["CDELT4"] == CHANNEL_BANDWIDTHS_HZ[i]


def test_oskar_simulation_basic(sky_data: NDArray[np.float64]) -> None:
# Tests oskar simulation. Should use GPU if available and if not, CPU.
sky = SkyModel()
Expand Down Expand Up @@ -242,38 +277,3 @@ def test_simulation_noise_meerkat(
assert set(golden_continuous_noise_fits_header.keys()) == set(
continuous_noise_fits_header.keys()
)


def test_parallelization_by_observation() -> None:
sky = SkyModel.get_GLEAM_Sky([76])
phase_center = [250, -80]
CENTER_FREQUENCIES_HZ = [100e6, 101e6]
CHANNEL_BANDWIDTHS_HZ = [1.0, 2.0]
N_CHANNELS = [2, 4]

sky = sky.filter_by_radius(0, 2.0, phase_center[0], phase_center[1])
telescope = Telescope.constructor("ASKAP")

simulation = InterferometerSimulation(channel_bandwidth_hz=1e6, time_average_sec=1)

obs_parallized = ObservationParallized(
center_frequencies_hz=CENTER_FREQUENCIES_HZ,
channel_bandwidths_hz=CHANNEL_BANDWIDTHS_HZ,
phase_centre_ra_deg=phase_center[0],
phase_centre_dec_deg=phase_center[1],
number_of_time_steps=24,
n_channels=N_CHANNELS,
)

visibilities = simulation.run_simulation(telescope, sky, obs_parallized)

for i, vis in enumerate(visibilities):
imager = Imager(
vis, imaging_npixel=512, imaging_cellsize=3.878509448876288e-05
) # imaging cellsize is over-written in the Imager based on max uv dist.
dirty = imager.get_dirty_image()
with tempfile.TemporaryDirectory() as tmpdir:
dirty.write_to_file(os.path.join(tmpdir, f"dirty_{i}.fits"), overwrite=True)
assert dirty.header["CRVAL4"] == CENTER_FREQUENCIES_HZ[i]
assert dirty.header["NAXIS4"] == N_CHANNELS[i]
assert dirty.header["CDELT4"] == CHANNEL_BANDWIDTHS_HZ[i]

0 comments on commit 5bafc98

Please sign in to comment.