Crystalball Module

This is a customized version of crystalball packagge, https://github.com/caracal-pipeline/crystalball.git, for MeerSOLAR pipeline

meersolar.crystalball.budget module

meersolar.crystalball.budget.get_budget(nr_sources, nr_rows, nr_chans, nr_corrs, data_type, cb_args, fudge_factor=1.25, row2source_ratio=100)[source]

meersolar.crystalball.crystalball module

meersolar.crystalball.crystalball.create_parser()[source]
meersolar.crystalball.crystalball.fill_correlations(vis, pol)[source]

Expands single correlation produced by wsclean_predict to the full set of correlations.

Parameters:
  • vis (dask.array.Array) – dask array of visibilities of shape (row, chan, 1)

  • pol (xarray.Dataset) – MS Polarisation dataset.

Returns:

vis – dask array of visibilities of shape (row, chan, corr)

Return type:

dask.array.Array

meersolar.crystalball.crystalball.predict()[source]
meersolar.crystalball.crystalball.source_model_to_dask(source_model, chunks)[source]
meersolar.crystalball.crystalball.support_tables(args, tables)[source]
Parameters:
  • args (object) – Script argument objects

  • tables (list of str) – List of support tables to open

Returns:

table_map – {name: dataset}

Return type:

dict of xarray.Dataset

meersolar.crystalball.filtering module

meersolar.crystalball.filtering.filter_datasets(datasets, field_id)[source]
Parameters:
  • datasets (list of daskms.Dataset) – List of datasets representing partitions of the Measurement Set. Should be partitioned by FIELD_ID and DATA_DESC_ID at least

  • field_id (list of ints) – List of valid fields

Returns:

datasets – Filtered list of datasets

Return type:

list of daskms.Dataset

meersolar.crystalball.filtering.select_field_id(field_datasets, field=None)[source]
Parameters:
  • field_datasets (list of daskms.Dataset)

  • field (None or str) –

    if None, will try and return the only field in the MS.

    select_field_id(field_ds, "PKS-1934")
    

Returns:

fields_id – Selected field ID

Return type:

int

meersolar.crystalball.logger_init module

class meersolar.crystalball.logger_init.InterceptHandler(level=0)[source]

Bases: Handler

Intercept logging messages and reroute them to the loguru.

emit(record)[source]

Do whatever it takes to actually log the specified logging record.

This version is intended to be implemented by subclasses and so raises a NotImplementedError.

meersolar.crystalball.ms module

meersolar.crystalball.ms.ms_preprocess(args)[source]

Adds output column if missing.

Returns:

ms_rows – number of Measurement Set Rows

Return type:

int

meersolar.crystalball.region module

meersolar.crystalball.region.load_regions(region_file)[source]
Parameters:

region_file (str) – Region File

Return type:

list of CircleSkyRegions

meersolar.crystalball.wsclean module

class meersolar.crystalball.wsclean.WSCleanModel(source_type, radec, flux, spi, ref_freq, log_poly, gauss_shape)

Bases: tuple

flux

Alias for field number 2

gauss_shape

Alias for field number 6

log_poly

Alias for field number 5

radec

Alias for field number 1

ref_freq

Alias for field number 4

source_type

Alias for field number 0

spi

Alias for field number 3

meersolar.crystalball.wsclean.import_from_wsclean(wsclean_comp_list, include_regions=[], point_only=False, num=None)[source]

Imports sources from wsclean, sorted from brightest to faintest. If include_regions is specified only those sources within are returned. Similarly if num is specified, num brightest sources are returned.

Parameters:
  • wsclean_comp_list (str) – wsclean component list file.

  • include_regions (List[regions.CircleSkyRegion]) – List of valid region’s. Only sources within these regions will be loaded. Defaults to [] in which case, all sources are loaded.

  • point_only (bool, optional) – Only include point sources. Defaults to False

  • num (integer, optional) – Number of sources to include. If None all sources are returned.

Returns:

  • source_type (numpy.ndarray) – Source types of shape (source,)

  • radec (numpy.ndarray) – Source radec coordinates of shape (source, 2).

  • stokes (numpy.ndarray) – Source stokes paramters of shape (source, 4).

  • spectral_index (numpy.ndarray) – Spectral index of shape (source, spi)

  • ref_freq (numpy.ndarray) – Reference frequency of shape (source,)

  • log_si (bool) – Boolean indicated whether to use the logarithmic spectral index.

  • gauss_shape (numpy.ndarray) – Gaussian shape parameters of shape (source, 3). The three components are MajorAxis, MinorAxis and Orientation, respectively.