arrakis.rmsynth_oncuts

Run RM-CLEAN on cutouts in parallel

Attributes

TQDM_OUT

Classes

Spectrum

Single spectrum

StokesIFitResult

Stokes I fit results

StokesSpectra

Multi Stokes spectra

Functions

cli()

Command-line interface

cubelet_bane(→ Tuple[numpy.ndarray])

Background and noise estimation on a cubelet

extract_all_spectra(→ StokesSpectra)

Extract spectra from cubelets

extract_single_spectrum(→ Spectrum)

Extract a single spectrum from a cubelet

fit_stokes_I(→ StokesIFitResult)

main(→ None)

Run RMsynth on cutouts flow

rm_common_parser(→ argparse.ArgumentParser)

rmsynth_parser(→ argparse.ArgumentParser)

rmsynthoncut1d(→ pymongo.UpdateOne)

1D RM synthesis

rmsynthoncut3d(→ pymongo.UpdateOne)

3D RM-synthesis

sigma_clip_spectra(→ StokesSpectra)

Sigma clip spectra

update_rmtools_dict(→ dict)

Update the RM-Tools dictionary with the fit results from the Stokes I fit

Module Contents

class arrakis.rmsynth_oncuts.Spectrum[source]

Bases: NamedTuple

Single spectrum

bkg: numpy.ndarray[source]

The background of the spectrum

data: numpy.ndarray[source]

The spectrum data

filename: pathlib.Path[source]

The filename associated with the spectrum

header: astropy.io.fits.Header[source]

The header associated with the spectrum

rms: numpy.ndarray[source]

The RMS of the spectrum

class arrakis.rmsynth_oncuts.StokesIFitResult[source]

Bases: NamedTuple

Stokes I fit results

alpha: float | None[source]

The alpha parameter of the fit

amplitude: float | None[source]

The amplitude parameter of the fit

fit_dict: dict | None[source]

The dictionary of the fit results

modStokesI: numpy.ndarray | None[source]

The model Stokes I spectrum

model_repr: str | None[source]

The model representation of the fit

x_0: float | None[source]

The x_0 parameter of the fit

class arrakis.rmsynth_oncuts.StokesSpectra[source]

Bases: NamedTuple

Multi Stokes spectra

i: Spectrum[source]

The Stokes I spectrum

q: Spectrum[source]

The Stokes Q spectrum

u: Spectrum[source]

The Stokes U spectrum

arrakis.rmsynth_oncuts.cli()[source]

Command-line interface

arrakis.rmsynth_oncuts.cubelet_bane(cubelet: numpy.ndarray, header: astropy.io.fits.Header) Tuple[numpy.ndarray][source]

Background and noise estimation on a cubelet

Parameters:
  • cubelet (np.ndarray) – 3D array of data

  • header (fits.Header) – Header of cubelet

Returns:

Background and noise per channel

Return type:

Tuple[np.ndarray]

arrakis.rmsynth_oncuts.extract_all_spectra(coord: astropy.coordinates.SkyCoord, ion: bool, field_dict: dict, outdir: pathlib.Path) StokesSpectra[source]

Extract spectra from cubelets

arrakis.rmsynth_oncuts.extract_single_spectrum(coord: astropy.coordinates.SkyCoord, stokes: str, ion: bool, field_dict: dict, outdir: pathlib.Path) Spectrum[source]

Extract a single spectrum from a cubelet

arrakis.rmsynth_oncuts.fit_stokes_I(freq: numpy.ndarray, coord: astropy.coordinates.SkyCoord, tt0: str | None = None, tt1: str | None = None, do_own_fit: bool = False, iarr: numpy.ndarray | None = None, rmsi: numpy.ndarray | None = None, polyOrd: int | None = None) StokesIFitResult[source]
arrakis.rmsynth_oncuts.main(field: str, outdir: pathlib.Path, host: str, epoch: int, sbid: int | None = None, username: str | None = None, password: str | None = None, dimension: str = '1d', verbose: bool = True, database: bool = False, limit: int | None = None, savePlots: bool = False, weightType: str = 'variance', fitRMSF: bool = True, phiMax_radm2: float | None = None, dPhi_radm2: float | None = None, nSamples: int = 5, polyOrd: int = 3, noStokesI: bool = False, showPlots: bool = False, not_RMSF: bool = False, rm_verbose: bool = False, debug: bool = False, fit_function: str = 'log', tt0: str | None = None, tt1: str | None = None, ion: bool = False, do_own_fit: bool = False) None[source]

Run RMsynth on cutouts flow

Parameters:
  • field (str) – RACS field

  • outdir (Path) – Output directory

  • host (str) – MongoDB host

  • epoch (int) – Epoch

  • sbid (Union[int, None], optional) – SBID. Defaults to None.

  • username (Union[str, None], optional) – MongoDB username. Defaults to None.

  • password (Union[str, None], optional) – MongoDB password. Defaults to None.

  • dimension (str, optional) – RMsynth dimension. Defaults to “1d”.

  • verbose (bool, optional) – Verbose output. Defaults to True.

  • database (bool, optional) – Update MongoDB. Defaults to False.

  • do_validate (bool, optional) – Validate RMsynth. Defaults to False.

  • limit (Union[int, None], optional) – Limit number of components. Defaults to None.

  • savePlots (bool, optional) – Save plots. Defaults to False.

  • weightType (str, optional) – Weight type. Defaults to “variance”.

  • fitRMSF (bool, optional) – Fit RMSF. Defaults to True.

  • phiMax_radm2 (Union[float, None], optional) – Max FD. Defaults to None.

  • dPhi_radm2 (Union[float, None], optional) – Delta FD. Defaults to None.

  • nSamples (int, optional) – Samples across RMSF. Defaults to 5.

  • polyOrd (int, optional) – Order of fit to I. Defaults to 3.

  • noStokesI (bool, optional) – Ignore Stokes I. Defaults to False.

  • showPlots (bool, optional) – Show plots. Defaults to False.

  • not_RMSF (bool, optional) – Not RMSF. Defaults to False.

  • rm_verbose (bool, optional) – Verbose RMsynth. Defaults to False.

  • debug (bool, optional) – Debug plots. Defaults to False.

  • fit_function (str, optional) – Fit function. Defaults to “log”.

  • tt0 (Union[str, None], optional) – Total intensity T0 image. Defaults to None.

  • tt1 (Union[str, None], optional) – Total intensity T1 image. Defaults to None.

  • ion (bool, optional) – Ion. Defaults to False.

  • do_own_fit (bool, optional) – Do own fit. Defaults to False.

arrakis.rmsynth_oncuts.rm_common_parser(parent_parser: bool = False) argparse.ArgumentParser[source]
arrakis.rmsynth_oncuts.rmsynth_parser(parent_parser: bool = False) argparse.ArgumentParser[source]
arrakis.rmsynth_oncuts.rmsynthoncut1d(comp_tuple: Tuple[str, pandas.Series], beam_tuple: Tuple[str, pandas.Series], outdir: pathlib.Path, freq: numpy.ndarray, field: str, sbid: int | None = None, polyOrd: int = 3, phiMax_radm2: float | None = None, dPhi_radm2: float | None = None, nSamples: int = 5, weightType: str = 'variance', fitRMSF: bool = True, noStokesI: bool = False, showPlots: bool = False, savePlots: bool = False, debug: bool = False, rm_verbose: bool = False, fit_function: str = 'log', tt0: str | None = None, tt1: str | None = None, ion: bool = False, do_own_fit: bool = False) pymongo.UpdateOne[source]

1D RM synthesis

Parameters:
  • comp_id (str) – RACS component ID

  • outdir (str) – Output directory

  • freq (list) – Frequencies in Hz

  • host (str) – MongoDB host

  • field (str) – RACS field

  • sbid (int, optional) – SBID. Defaults to None.

  • database (bool, optional) – Update MongoDB. Defaults to False.

  • polyOrd (int, optional) – Order of fit to I. Defaults to 3.

  • phiMax_radm2 (float, optional) – Max FD. Defaults to None.

  • dPhi_radm2 (float, optional) – Delta FD. Defaults to None.

  • nSamples (int, optional) – Samples across RMSF. Defaults to 5.

  • weightType (str, optional) – Weight type. Defaults to ‘variance’.

  • fitRMSF (bool, optional) – Fit RMSF. Defaults to False.

  • noStokesI (bool, optional) – Ignore Stokes I. Defaults to False.

  • showPlots (bool, optional) – Show plots. Defaults to False.

  • savePlots (bool, optional) – Save plots. Defaults to False.

  • debug (bool, optional) – Turn on debug plots. Defaults to False.

  • rm_verbose (bool, optional) – Verbose RMsynth. Defaults to False.

arrakis.rmsynth_oncuts.rmsynthoncut3d(island_id: str, beam_tuple: Tuple[str, pandas.Series], outdir: pathlib.Path, freq: numpy.ndarray, field: str, sbid: int | None = None, phiMax_radm2: float | None = None, dPhi_radm2: float | None = None, nSamples: int = 5, weightType: str = 'variance', fitRMSF: bool = True, not_RMSF: bool = False, rm_verbose: bool = False, ion: bool = False) pymongo.UpdateOne[source]

3D RM-synthesis

Parameters:
  • island_id (str) – RACS Island ID

  • freq (list) – Frequencies in Hz

  • host (str) – Host of MongoDB

  • field (str) – RACS field ID

  • database (bool, optional) – Update MongoDB. Defaults to False.

  • phiMax_radm2 (float, optional) – Max Faraday depth. Defaults to None.

  • dPhi_radm2 (float, optional) – Faraday dpeth channel width. Defaults to None.

  • nSamples (int, optional) – Samples acorss RMSF. Defaults to 5.

  • weightType (str, optional) – Weighting type. Defaults to ‘variance’.

  • fitRMSF (bool, optional) – Fit RMSF. Defaults to False.

  • not_RMSF (bool, optional) – Skip calculation of RMSF. Defaults to False.

  • rm_verbose (bool, optional) – Verbose RMsynth. Defaults to False.

arrakis.rmsynth_oncuts.sigma_clip_spectra(stokes_spectra: StokesSpectra) StokesSpectra[source]

Sigma clip spectra

Find outliers in the RMS spectra and set them to NaN

Parameters:

stokes_spectra (StokesSpectra) – The Stokes spectra

Returns:

The filtered Stokes spectra

Return type:

StokesSpectra

arrakis.rmsynth_oncuts.update_rmtools_dict(mDict: dict, fit_dict: dict) dict[source]

Update the RM-Tools dictionary with the fit results from the Stokes I fit

Parameters:
  • mDict (dict) – The RM-Tools dictionary

  • fit_dict (dict) – The fit results dictionary

Returns:

The updated RM-Tools dictionary

Return type:

dict

arrakis.rmsynth_oncuts.TQDM_OUT[source]