arrakis.rmsynth_oncuts ====================== .. py:module:: arrakis.rmsynth_oncuts .. autoapi-nested-parse:: Run RM-CLEAN on cutouts in parallel .. !! processed by numpydoc !! Attributes ---------- .. autoapisummary:: arrakis.rmsynth_oncuts.TQDM_OUT Classes ------- .. autoapisummary:: arrakis.rmsynth_oncuts.Spectrum arrakis.rmsynth_oncuts.StokesIFitResult arrakis.rmsynth_oncuts.StokesSpectra Functions --------- .. autoapisummary:: arrakis.rmsynth_oncuts.cli arrakis.rmsynth_oncuts.cubelet_bane arrakis.rmsynth_oncuts.extract_all_spectra arrakis.rmsynth_oncuts.extract_single_spectrum arrakis.rmsynth_oncuts.fit_stokes_I arrakis.rmsynth_oncuts.main arrakis.rmsynth_oncuts.rm_common_parser arrakis.rmsynth_oncuts.rmsynth_parser arrakis.rmsynth_oncuts.rmsynthoncut1d arrakis.rmsynth_oncuts.rmsynthoncut3d arrakis.rmsynth_oncuts.sigma_clip_spectra arrakis.rmsynth_oncuts.update_rmtools_dict Module Contents --------------- .. py:class:: Spectrum Bases: :py:obj:`NamedTuple` Single spectrum .. !! processed by numpydoc !! .. py:attribute:: bkg :type: numpy.ndarray The background of the spectrum .. !! processed by numpydoc !! .. py:attribute:: data :type: numpy.ndarray The spectrum data .. !! processed by numpydoc !! .. py:attribute:: filename :type: pathlib.Path The filename associated with the spectrum .. !! processed by numpydoc !! .. py:attribute:: header :type: astropy.io.fits.Header The header associated with the spectrum .. !! processed by numpydoc !! .. py:attribute:: rms :type: numpy.ndarray The RMS of the spectrum .. !! processed by numpydoc !! .. py:class:: StokesIFitResult Bases: :py:obj:`NamedTuple` Stokes I fit results .. !! processed by numpydoc !! .. py:attribute:: alpha :type: float | None The alpha parameter of the fit .. !! processed by numpydoc !! .. py:attribute:: amplitude :type: float | None The amplitude parameter of the fit .. !! processed by numpydoc !! .. py:attribute:: fit_dict :type: dict | None The dictionary of the fit results .. !! processed by numpydoc !! .. py:attribute:: modStokesI :type: numpy.ndarray | None The model Stokes I spectrum .. !! processed by numpydoc !! .. py:attribute:: model_repr :type: str | None The model representation of the fit .. !! processed by numpydoc !! .. py:attribute:: x_0 :type: float | None The x_0 parameter of the fit .. !! processed by numpydoc !! .. py:class:: StokesSpectra Bases: :py:obj:`NamedTuple` Multi Stokes spectra .. !! processed by numpydoc !! .. py:attribute:: i :type: Spectrum The Stokes I spectrum .. !! processed by numpydoc !! .. py:attribute:: q :type: Spectrum The Stokes Q spectrum .. !! processed by numpydoc !! .. py:attribute:: u :type: Spectrum The Stokes U spectrum .. !! processed by numpydoc !! .. py:function:: cli() Command-line interface .. !! processed by numpydoc !! .. py:function:: cubelet_bane(cubelet: numpy.ndarray, header: astropy.io.fits.Header) -> tuple[numpy.ndarray, numpy.ndarray] 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 :rtype: Tuple[np.ndarray] .. !! processed by numpydoc !! .. py:function:: extract_all_spectra(coord: astropy.coordinates.SkyCoord, ion: bool, field_dict: dict, outdir: pathlib.Path) -> StokesSpectra Extract spectra from cubelets .. !! processed by numpydoc !! .. py:function:: extract_single_spectrum(coord: astropy.coordinates.SkyCoord, stokes: str, ion: bool, field_dict: dict, outdir: pathlib.Path) -> Spectrum Extract a single spectrum from a cubelet .. !! processed by numpydoc !! .. py:function:: 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 .. py:function:: 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', 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 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". * **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. .. !! processed by numpydoc !! .. py:function:: rm_common_parser(parent_parser: bool = False) -> argparse.ArgumentParser .. py:function:: rmsynth_parser(parent_parser: bool = False) -> argparse.ArgumentParser .. py:function:: 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 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. .. !! processed by numpydoc !! .. py:function:: 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 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 across 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. .. !! processed by numpydoc !! .. py:function:: sigma_clip_spectra(stokes_spectra: StokesSpectra) -> StokesSpectra 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 :rtype: StokesSpectra .. !! processed by numpydoc !! .. py:function:: update_rmtools_dict(mDict: dict, fit_dict: dict) -> dict 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 :rtype: dict .. !! processed by numpydoc !! .. py:data:: TQDM_OUT