Skip to content

RMclean1D

Cameron-Van-Eck edited this page Jan 31, 2022 · 4 revisions

The 1D RM-Clean tool uses the RM-Clean algorithm to reduce the effects of sidelobes on RM spectra. RMclean1D is designed to operate on the outputs of RMsynth1D (when using the -S flag).

Running

If RMtools has been installed with terminal commands, then RMclean1D can be invoked from the command line as rmclean1d <datafile> <options>, otherwise it must be invoked as a Python script as python <RMtools directory>/RMtools1D/do_RMclean_1D.py <datafile> <options>. The data file should be the same file that was input to RMsynth1D; the filenames for the dirty spectrum and RMSF are inferred from this.

Invoking with the -h flag set will produce the help text with the list of option flags.

Inputs

RMclean1D uses the -S outputs from RMsynth1D, which must be run first before running RMclean1D. While the input filename is the original file, this file is not used and only the _FDFdirty.dat, _RMSF.dat, and _weight.dat files are opened.

Outputs

The following files are automatically saved (without requiring a flag to be set):

  • _FDFclean.dat: the cleaned FDF as a 3 column file similar to the dirty spectrum: Faraday depth, Stokes Q, Stokes U.
  • _FDFmodel.dat: the (complex) clean component model, with the same 3 columns.
  • _RMclean.dat: a text file with a list of outputs of the FDF and peak fitting, in a '<parameter>=<value>' format. Mostly the same as the _RMsynth.dat file, but after Cleaning and with additional outputs.
  • _RMclean.json: the same outputs as _RMclean.dat, but in JSON format.

If the -v flag is set, some (but not all) of the results of the peak fitting are printed to the terminal.

If the -p flag is set, a pair of plots showing the dirty and cleaned FDF, clean components, residuals and clean threshold are displayed.

Output values

The RMclean_1D output values are the same as for RMsynth1D, with the following additions and changes:

cleanCutoff: The cutoff threshold (in polarized intensity) for the CLEAN algorithm.
nIter: The number of iterations of CLEAN that were used (if this number is equal to the iteration limit set with the -n flag, then CLEAN did not reach the cutoff threshold).
mom2CCFDF: The 2nd moment of the clean components, which is sometimes used as a metric for Faraday complexity.
dPhiObserved_rm2, dAmpObserved, dPolAngleFitObserved_deg, dPolAngleFit0Observed_deg: Each of these is computed by rescaling the default uncertainties (which use the theoretical FDF noise) using the MAD FDF noise (dFDFcorMAD).

Parameters/Options

-h Print the help documentation to the terminal.
-c CUTOFF Supply a number to set the CLEAN cutoff, in flux units or in sigma. Positive values are treated as flux units (same units as FDF). Negative values are treated as multiples of the theoretical noise level in the spectrum. Default value is -3 (3 sigma CLEAN threshold).
-n MAXITER Supply an integer to set the maximum number of clean components/iterations run on the FDF. Default value is 1000.
-g GAIN Supply a number to set the CLEAN loop gain (fraction of identified peak to be modeled as Clean component and subtracted). Default value is 0.1.
-p Show the output plots. Default is to not show plots.
-v Print verbose messages (including fit results) to terminal.

Calling inside a script

The current implementation of RMclean1D is strongly tied to the format of the outputs of RMsynth1D, so it is not recommended to run inside a script. Users who wish to try this are advised to look at the functions in RMtools_1D/do_RMclean_1D.py for information on how the outputs of RMsynth1D are processed to become inputs for RMclean1D.

Algorithms

I will add a more detailed description of the underlying algorithms at a later date.