-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Splitting part of source_detection.ipynb off into separate imaging.ip…
…ynb example notebook (#610) * Split part of source_detection.ipynb off into imaging.ipynb examples. Update docs accordingly 🈴 * Fix line endings to unix format. 😆 * Add test for new imaging notebook 🎎 * Add function to simulate visibilities, reducing duplication ☎️ * Add Type Annotations to new function ✋ * Fix function input types ☎️ * Add failsave in case list of vis is generated 📗 * Fix return variable type 🚐 * Update run_simulation to accept path in addition to str, fix type hints 👇 * Undo run_simulation to accept paths, cast to str instead 🚚 * Make verbose parameter kw-only and remove mutable default↕️ * Add deduplication to source detection notebook, fix todo text 🐅 * Add deduplication to source detection notebook, fix todo text 🌾
- Loading branch information
1 parent
45adff6
commit 08b76aa
Showing
7 changed files
with
1,303 additions
and
1,197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
from datetime import datetime | ||
from typing import Union | ||
|
||
from karabo.simulation.interferometer import InterferometerSimulation | ||
from karabo.simulation.observation import Observation | ||
from karabo.simulation.sky_model import SkyModel | ||
from karabo.simulation.telescope import Telescope | ||
from karabo.simulation.visibility import Visibility | ||
from karabo.simulator_backend import SimulatorBackend | ||
|
||
|
||
def run_sample_simulation( | ||
phase_center: Union[list[float], None] = None, *, verbose: bool = False | ||
) -> tuple[Visibility, SkyModel]: | ||
""" | ||
Creates example visibilities for use in tests, experiments and examples. | ||
Args: | ||
phase_center: ra and dec of the sky. Defaults to [250, -80] if not provided. | ||
verbose: Boolean to decide if console outputs are made during simulation | ||
(e.g. for use in ipynb) | ||
Returns: | ||
Visibility: visibilities created by the simulation | ||
SkyModel: Sky model used for the simulation | ||
""" | ||
|
||
if phase_center is None: | ||
phase_center = [250, -80] | ||
|
||
if verbose: | ||
print("Getting Sky Survey") | ||
# Get GLEAM Survey Sky | ||
gleam_sky = SkyModel.get_GLEAM_Sky(min_freq=72e6, max_freq=80e6) | ||
|
||
if verbose: | ||
print("Filtering Sky Model") | ||
sky = gleam_sky.filter_by_radius(0, 0.55, phase_center[0], phase_center[1]) | ||
sky.setup_default_wcs(phase_center=phase_center) | ||
|
||
if verbose: | ||
print("Setting Up Telescope") | ||
askap_tel = Telescope.constructor( | ||
"ASKAP", version=None, backend=SimulatorBackend.OSKAR | ||
) | ||
|
||
if verbose: | ||
print("Setting Up Observation") | ||
observation_settings = Observation( | ||
start_frequency_hz=100e6, | ||
start_date_and_time=datetime(2024, 3, 15, 10, 46, 0), | ||
phase_centre_ra_deg=phase_center[0], | ||
phase_centre_dec_deg=phase_center[1], | ||
number_of_channels=16, | ||
number_of_time_steps=24, | ||
) | ||
|
||
if verbose: | ||
print("Generating Visibilities") | ||
|
||
vis = Visibility() | ||
vis_path = str(vis.vis_path) | ||
|
||
print(f"Saving file to {vis_path}") | ||
interferometer_sim = InterferometerSimulation( | ||
vis_path=vis_path, channel_bandwidth_hz=1e6 | ||
) | ||
visibility_askap = interferometer_sim.run_simulation( | ||
askap_tel, sky, observation_settings, backend=SimulatorBackend.OSKAR | ||
) | ||
|
||
# In case run_simulation returns a list of vis (allowed by type hint) | ||
if isinstance(visibility_askap, list): | ||
visibility_askap = visibility_askap[0] | ||
|
||
return visibility_askap, sky |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters