karabo.test package

Submodules

karabo.test.conftest module

Pytest global fixtures needs to be here!

class TFiles(cst_like_beam_port_1_txt: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/cst_like_beam_port_1.txt', cst_like_beam_port_2_txt: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/cst_like_beam_port_2.txt', detection_csv: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/detection.csv', detection_zip: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/detection.zip', detection_result_csv: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/detection_result_512.px.csv', filtered_sky_csv: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/filtered_sky.csv', run5_cst: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/run5.cst', visibilities_gleam_ms: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/visibilities_gleam.ms', poisson_vis_ms: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/poisson_vis.ms', gt_assignment: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/sdp/gt_assignment.npy', gt_plot: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/sdp/gt_plot.png', gt_plot_error_ra_dec: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/sdp/gt_plot_error_ra_dec.png', gt_plot_flux_histogram: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/sdp/gt_plot_flux_histogram.png', gt_plot_flux_ratio_to_distance: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/sdp/gt_plot_flux_ratio_to_distance.png', gt_plot_flux_ratio_to_ra_dec: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/sdp/gt_plot_flux_ratio_to_ra_dec.png', gt_plot_quiver_positions: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/sdp/gt_plot_quiver_positions.png', blank_image_file_for_source_detection: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/blank_image.fits')

Bases: object

Read-only repo-artifact paths.

It is assumed that all artifacts here exist in the repo

and therefore are not in the .gitignore.

The defined artifacts should reflect the `karabo/test/data/* file

and dir paths.

blank_image_file_for_source_detection: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/blank_image.fits'
cst_like_beam_port_1_txt: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/cst_like_beam_port_1.txt'
cst_like_beam_port_2_txt: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/cst_like_beam_port_2.txt'
detection_csv: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/detection.csv'
detection_result_csv: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/detection_result_512.px.csv'
detection_zip: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/detection.zip'
filtered_sky_csv: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/filtered_sky.csv'
gt_assignment: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/sdp/gt_assignment.npy'
gt_plot: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/sdp/gt_plot.png'
gt_plot_error_ra_dec: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/sdp/gt_plot_error_ra_dec.png'
gt_plot_flux_histogram: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/sdp/gt_plot_flux_histogram.png'
gt_plot_flux_ratio_to_distance: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/sdp/gt_plot_flux_ratio_to_distance.png'
gt_plot_flux_ratio_to_ra_dec: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/sdp/gt_plot_flux_ratio_to_ra_dec.png'
gt_plot_quiver_positions: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/sdp/gt_plot_quiver_positions.png'
poisson_vis_ms: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/poisson_vis.ms'
run5_cst: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/run5.cst'
visibilities_gleam_ms: str = '/usr/share/miniconda3/envs/karabo_dev_env/lib/python3.9/site-packages/karabo/test/data/visibilities_gleam.ms'
clean_disk() Generator[None, None, None]

Automatically clears FileHandler’s short-term-memory after each test file.

Needed in some cases where the underlying functions do use FileHandler

which could lead to IOError because of disk-space limitations.

default_sample_simulation_visibility() Visibility
minimal_casa_ms() Visibility
minimal_fits_restored() Image
minimal_oskar_vis() Visibility
normalized_norm_diff() Callable[[str, str], float]

Compare two images.

pytest_addoption(parser: Parser) None

Pytest custom argparse hook.

Add custom argparse options here.

Pytest argparse-options have to be declared in the root conftest.py. For some reason, the root conftest.py has to live near the project-root, even if only a single conftest.py exists. However, this prevents using pytest . with custom argparse-coptions from the root. Instead, either specify the test-dir or leave it out entirely.

Args:

parser: pytest.Parser

pytest_collection_modifyitems(config: Config, items: Iterable[Item]) None

Pytest modify-items hook.

Change pytest-behavior dependent on parsed input.

See https://docs.pytest.org/en/latest/example/simple.html#control-skipping-of-tests-according-to-command-line-option

Args:

config: pytest.Config items: iterable of pytest.Item

pytest_configure(config: Config) None

Pytest add ini-values.

Args:

config: pytest.Config

sky_data(sky_data_with_ids: ndarray[Any, dtype[object_]]) ndarray[Any, dtype[float64]]
sky_data_with_ids() ndarray[Any, dtype[object_]]
tobject() TFiles

karabo.test.test_beam module

test_eidosbeam()
test_fit_element(tobject: TFiles)
test_gaussian_beam()

We test that image reconstruction works also with a Gaussian beam and test both Imagers: Oskar and Rascil.

test_katbeam()

karabo.test.test_beam_ska-low module

karabo.test.test_casa module

class TestCasaMS

Bases: object

test_tables(minimal_casa_ms: Visibility) None

Minimal table-creation test.

This test currently just calls the table creation function of the particular

to ensure field-name correctness & data loading success.

Args:

minimal_casa_ms: Casa MS fixture.

karabo.test.test_dask module

env_vars() Dict[str, str]
simple_function(x: int, multiplier: int = 1) int
test_dask_job() None
test_extreme_range_of_nodes() None
test_get_base_string_node_list(env_vars: Dict[str, str]) None
test_get_lowest_node_id(env_vars: Dict[str, str]) None
test_get_lowest_node_name(env_vars: Dict[str, str]) None
test_get_min_max_of_node_id(env_vars: Dict[str, str]) None
test_get_node_id(env_vars: Dict[str, str]) None
test_get_node_name(env_vars: Dict[str, str]) None
test_get_number_of_nodes(env_vars: Dict[str, str]) None
test_is_first_node(env_vars: Dict[str, str]) None
test_is_on_slurm_cluster(env_vars: Dict[str, str]) None
test_multiple_nodes_and_ranges() None
test_parallelize_with_dask() None
test_single_node() None

karabo.test.test_data_util module

test_calculate_chunk_size_from_max_chunk_size_in_memory()
test_invalid_sizes(size_str)
test_valid_sizes(size_str: str, expected: float)

karabo.test.test_examples module

test_examples()

Test all examples in the documentation

karabo.test.test_filehandler module

test_file_handler()

Test global FileHandler functionality.

test_object_bound_file_handler()

Test obj unique FileHandler creation.

test_write_dir()

karabo.test.test_image module

test_cellsize_overwrite(tobject: TFiles)
test_cellsize_overwrite_false(tobject: TFiles)
test_dirty_image(tobject: TFiles)
test_dirty_image_N_cutout(tobject: TFiles)
test_dirty_image_cutout(tobject: TFiles)
test_dirty_image_resample(tobject: TFiles)
test_image_circle(tobject: TFiles)
test_imaging()

karabo.test.test_imager_oskar module

test_dirty_image(tobject: TFiles)
test_dirty_image_custom_output_path(tobject: TFiles)

karabo.test.test_imager_rascil module

test_create_cleaned_image()
test_dirty_image(tobject: TFiles)

karabo.test.test_imager_wsclean module

test_create_cleaned_image(default_sample_simulation_visibility: Visibility)
test_create_cleaned_image_custom_path(default_sample_simulation_visibility: Visibility)
test_create_cleaned_image_reuse_dirty(default_sample_simulation_visibility: Visibility)
test_create_image_custom_command(default_sample_simulation_visibility: Visibility)
test_create_image_custom_command_multiple_outputs(default_sample_simulation_visibility: Visibility)
test_dirty_image(tobject: TFiles)
test_dirty_image_custom_path(tobject: TFiles)

karabo.test.test_imaging_util module

test_get_compatible_dirty_imager(sky_data: ndarray[Any, dtype[float64]], backend: SimulatorBackend, telescope_name: str, visibility_format: Literal['MS', 'OSKAR_VIS'], combine_across_frequencies: bool) None

karabo.test.test_ionosphere module

sim_ion(screen_width_metres, r0, bmax, sampling, speed, rate, alpha_mag, num_times, frequency, fits_filename)

Example from OSKAR

test_ionosphere(sky_data: ndarray[Any, dtype[float64]])

karabo.test.test_line_emission module

test_compare_oskar_rascil_dirty_images()
test_line_emission_pipeline(simulator_backend, telescope_name)
test_primary_beam_effects(simulator_backend, telescope_name)

karabo.test.test_long_observation module

test_eidosbeam()
test_fit_element(tobject: TFiles)
test_katbeam()
test_long_observations(tobject: TFiles, sky_data: ndarray[Any, dtype[float64]])

karabo.test.test_mock_mightee module

test_mightee_download()
test_mock_mightee()

karabo.test.test_mosaic module

test_ImageMosaicker(tobject: TFiles)

karabo.test.test_mpi module

MPI tests according to https://mpi4py.readthedocs.io/en/stable/tutorial.html.

test_broadcast_dict()
test_broadcast_nparrays()
test_gather_nparrays()
test_gather_obj()
test_scatter_nparrays()
test_scatter_obj()

karabo.test.test_notebooks module

test_ImageMosaicker_notebook() None
test_LineEmission_notebook() None
test_imaging_notebook() None
test_source_detection_assessment_notebook() None
test_source_detection_big_files_notebook() None
test_source_detection_notebook() None

karabo.test.test_obscore module

class TestObsCoreMeta

Bases: object

test_from_image(minimal_fits_restored: Image) None
test_from_visibility(vis_fixture_name: str, request: FixtureRequest) None
test_ivoid(authority: str, path: str, query: str, fragment: str, expected: Any) None
test_sshapes() None
class TestRucioMeta

Bases: object

test_json_creation(minimal_fits_restored: Image) None

karabo.test.test_observation module

test_constructor_with_date_time()
test_constructor_with_string()
test_create_observations_oskar_settings_tree()

karabo.test.test_sim_format_imager_combos module

test_oskar_imager(simulator_backend: SimulatorBackend, visibility_format: Literal['MS', 'OSKAR_VIS']) None
test_rascil_imager(simulator_backend: SimulatorBackend, visibility_format: Literal['MS', 'OSKAR_VIS']) None
test_wsclean_imager(simulator_backend: SimulatorBackend, visibility_format: Literal['MS', 'OSKAR_VIS']) None

karabo.test.test_simulation module

continuous_fits_downloader(continuous_fits_filename: str) SingleFileDownloadObject
continuous_fits_filename() str
continuous_noise_fits_downloader(continuous_noise_fits_filename: str) SingleFileDownloadObject
continuous_noise_fits_filename() str
test_backend_simulations(sky_data: ndarray[Any, dtype[float64]], backend: SimulatorBackend, telescope_name: str) None
test_parallelization_by_observation() None
test_run_sample_simulation() None

Executes the ASKAP sample simulation, captures verbose output, validates the output files, and checks the sky model filtering.

test_simulation_meerkat(continuous_fits_filename: str, continuous_fits_downloader: SingleFileDownloadObject) None

Executes a simulation of continuous emission and validates the output files.

Args:
continuous_fits_filename:

Name of FITS file containing the simulated dirty image.

test_simulation_noise_meerkat(continuous_noise_fits_filename: str, continuous_noise_fits_downloader: SingleFileDownloadObject) None

Executes a simulation of continuous emission with noise and validates the output files.

Args:
continuous_noise_fits_filename:

Name of FITS file containing the simulated dirty image.

karabo.test.test_skymodel module

formattable() _ColsMappingDict

Matching _ColsMappingDict of formattable col-names.

gleam() SkyModel
non_formattable() _ColsMappingDict

Matching _ColsMappingType of non-formattable col-names.

test_SkySourcesColName_assumption()
test_convert_sky_to_backends()
test_cscs_resource_availability()
test_download_gleam_and_make_sky_model()
test_explore_sky(gleam: SkyModel)
test_extract_names_and_freqs(formattable: _ColsMappingDict)
test_filter_flux_sky_model(sky_data_with_ids: ndarray[Any, dtype[object_]])
test_filter_sky_model(gleam: SkyModel)
test_filter_sky_model_h5()
test_format_prefix_freq_mapping(formattable: _ColsMappingDict, non_formattable: _ColsMappingDict)
test_get_cartesian(sky_data_with_ids: ndarray[Any, dtype[object_]])
test_get_poisson_sky()
test_get_unit_scales(formattable: _ColsMappingDict, non_formattable: _ColsMappingDict)
test_init(sky_data_with_ids: ndarray[Any, dtype[object_]])
test_mals_v3()
test_mightee()
test_not_full_array()
test_pos_ids_to_ra_dec(pos_ids: Sequence[str] | str, expected: Any)
test_read_healpix_map()
test_read_sky_model(gleam: SkyModel)
test_read_write_sky_model(sky_data: ndarray[Any, dtype[float64]])

karabo.test.test_source_detection module

restored_filtered_example_gleam() str
test_automatic_assignment_of_ground_truth_and_prediction()
test_bdsf_image_blanked(tobject: TFiles)
test_create_detection_from_ms_cuda()
test_full_source_detection(test_restored_filtered_example_gleam_downloader: SingleFileDownloadObject)
test_restored_filtered_example_gleam_downloader(restored_filtered_example_gleam) SingleFileDownloadObject
test_source_detection_plot(tobject: TFiles, normalized_norm_diff: Callable[[str, str], float])

karabo.test.test_superimpose module

class SuperimposeTestCase(methodName='runTest')

Bases: TestCase

data_3d_1 = array([[[0, 0, 0],         [0, 0, 0],         [0, 0, 0]],         [[0, 0, 0],         [0, 0, 0],         [0, 0, 0]],         [[0, 0, 0],         [0, 0, 0],         [0, 0, 0]]])
data_3d_2 = array([[[1, 1, 1],         [1, 1, 1],         [1, 1, 1]],         [[1, 1, 1],         [1, 1, 1],         [1, 1, 1]],         [[1, 1, 1],         [1, 1, 1],         [1, 1, 1]]])
data_3d_3 = array([[[1, 2, 3],         [1, 2, 3],         [1, 2, 3]],         [[1, 2, 3],         [1, 2, 3],         [1, 2, 3]],         [[1, 2, 3],         [1, 2, 3],         [1, 2, 3]]])
im_2d_1 = Image2D(data=array([[0, 0, 0],        [0, 0, 0],        [0, 0, 0]]), x_label=[], y_label=[], redshift=0, box_dims=0)
im_2d_2 = Image2D(data=array([[1, 1, 1],        [1, 1, 1],        [1, 1, 1]]), x_label=[], y_label=[], redshift=0, box_dims=0)
im_2d_3 = Image2D(data=array([[1, 1, 1],        [2, 2, 2],        [3, 3, 3]]), x_label=[], y_label=[], redshift=0, box_dims=0)
im_3d_1 = Image3D(data=array([[[0, 0, 0],         [0, 0, 0],         [0, 0, 0]],         [[0, 0, 0],         [0, 0, 0],         [0, 0, 0]],         [[0, 0, 0],         [0, 0, 0],         [0, 0, 0]]]), x_label=[], y_label=[], redshift=0, box_dims=0, z_label=[])
im_3d_2 = Image3D(data=array([[[1, 1, 1],         [1, 1, 1],         [1, 1, 1]],         [[1, 1, 1],         [1, 1, 1],         [1, 1, 1]],         [[1, 1, 1],         [1, 1, 1],         [1, 1, 1]]]), x_label=[], y_label=[], redshift=0, box_dims=0, z_label=[])
im_3d_3 = Image3D(data=array([[[1, 2, 3],         [1, 2, 3],         [1, 2, 3]],         [[1, 2, 3],         [1, 2, 3],         [1, 2, 3]],         [[1, 2, 3],         [1, 2, 3],         [1, 2, 3]]]), x_label=[], y_label=[], redshift=0, box_dims=0, z_label=[])
test_akin_array_elem() None

Test if the multiple images, of the same dimension, are combined correctly.

test_different_array_elem() None

Test if the multiple images, of different dimension, are combined correctly.

test_empty() None

Test if the KaraboError is raised when trying to combine the elements of an empty list.

test_one_elem() None

Test if the same image comes out if only on is given to the superimpose.

test_tow_akin_elem() None

Test if the two images, of the same dimension, are combined correctly.

test_tow_different_elem() None

Test if the two images, of different dimension, are combined correctly.

karabo.test.test_system_noise module

test_basic(sky_data: ndarray[Any, dtype[float64]])

karabo.test.test_telescope module

rest_read_all_VLA_versions(version)
test_OSKAR_telescope_plot_file_created()
test_OSKAR_telescope_with_invalid_version()
test_OSKAR_telescope_with_missing_version()
test_OSKAR_telescope_with_version_but_version_not_required()
test_RASCIL_telescope()
test_RASCIL_telescope_no_plot_file_created()
test_RASCIL_telescope_plot_file_created()
test_RASCIL_telescope_with_version_triggers_logging(mock_logging_warning)
test_convert_to_oskar()
test_create_alma_telescope()
test_create_meerkat_telescope()
test_get_OSKAR_backend_information()
test_get_RASCIL_backend_information()
test_get_invalid_backend_information()
test_invalid_OSKAR_telescope()
test_invalid_RASCIL_telescope()
test_invalid_backend()
test_plot_invalid_backend(mock_logging_warning)
test_read_SKA_LOW()
test_read_SKA_MID()
test_read_VLBA()
test_read_WSRT()
test_read_all_ACA_versions(version)
test_read_all_ALMA_versions(version)
test_read_all_CARMA_versions(version)
test_read_all_NG_VLA_versions(version)
test_read_all_PDBI_versions(version)
test_read_all_SMA_versions(version)
test_write_and_read_tm_file(filename)

karabo.test.test_telescope_baselines module

test_baselines_based_cutoff(sky_data: ndarray[Any, dtype[float64]])

karabo.test.test_utils module

test_get_gpu_memory()
test_gpu_memory_error()
test_is_cuda_available()
test_is_cuda_available_true()
test_suppress_rascil_warning(caplog: LogCaptureFixture)
test_version()

karabo.test.util module

get_compatible_dirty_imager(visibility: Visibility, config: DirtyImagerConfig) DirtyImager

Automatically choose a suitable dirty imager based on a visibility object.

Temporary function until we have a general visibility object and functions to convert general objects to implementation-specific objects on demand.

Args:

visibility: Visibility object config: Config to initialize dirty imager

object with.

Returns:

DirtyImager: The created dirty imager object

Module contents