INS Class

This is the INS (incoherent_noise_spectrum) class. This is the main product that RFI analysis is performed on.

class SSINS.INS(input, history='', label='', order=0, mask_file=None, match_events_file=None, spectrum_type='cross', use_integration_weights=False, nsample_default=1)[source]

Defines the incoherent noise spectrum (INS) class, which is a subclass of the UVFlag class, a member of the pyuvdata software package.

flag_uvf(uvf, inplace=False)[source]

Applies flags calculated from mask_to_flags method onto a given UVFlag object. Option to edit an existing uvf object inplace. Works by propagating the mask on sky-subtracted data to flags that can be applied to the original data, pre-subtraction. ORs the flags from the INS object and the input uvf object.

Parameters
  • uvf – A waterfall UVFlag object in flag mode to apply flags to. Must be constructed from the original data. Errors if not waterfall, in flag mode, or time ordering does not match INS object.

  • inplace – Whether to edit the uvf input inplace or not. Default False.

Returns

The UVFlag object in flag mode with the time-propagated flags.

Return type

uvf

mask_to_flags()[source]

Propagates the mask to construct flags for the original (non time-differenced) data. If a time is flagged in the INS, then both times that could have contributed to that time in the sky-subtraction step are flagged in the new array.

Returns

The time-propagated flags

Return type

tp_flags (array)

match_events

A list of tuples that contain information about events caught during match filtering

match_events_read(filename)[source]

Reads match events from file specified by filename argument

Parameters

filename – The yml file with the stored match_events

Returns

The match_events in the yml file

Return type

match_events

mean_subtract(freq_slice=slice(None, None, None), return_coeffs=False)[source]

A function which calculated the mean-subtracted spectrum from the regular spectrum. A spectrum made from a perfectly clean observation will be written as a z-score by this operation.

Parameters
  • freq_slice – The frequency slice over which to do the calculation. Usually not set by the user.

  • return_coeffs – Whether or not to return the mean/polynomial coefficients

Returns

The mean-subtracted data array.

Return type

MS (masked array)

metric_array

The baseline-averaged sky-subtracted visibility amplitudes (numpy masked array)

metric_ms

An array containing the z-scores of the data in the incoherent noise spectrum.

order

The order of polynomial fit for each frequency channel during mean-subtraction. Default is 0, which just calculates the mean.

select(inplace=True, **kwargs)[source]

Thin wrapper around UVFlag.select that also recalculates the ms array immediately afterwards.

Parameters

inplace – Whether to do the operation inplace or return a copy without touching the original.

Returns

INS object. Only returned if inplace is False.

Return type

ins

sig_array

An array that is initially equal to the z-score of each data point. During flagging, the entries are assigned according to their z-score at the time of their flagging.

spectrum_type

The type of visibilities the spectrum was made from.

weights_array

The number of baselines that contributed to each element of the metric_array

write(prefix, clobber=False, data_compression='lzf', output_type='data', mwaf_files=None, mwaf_method='add', metafits_file=None, Ncoarse=24, sep='_', uvf=None)[source]

Writes attributes specified by output_type argument to appropriate files with a prefix given by prefix argument. Can write mwaf files if required mwaf keywords arguments are provided. Required mwaf keywords are not required for any other purpose.

Parameters
  • prefix – The filepath prefix for the output file e.g. /analysis/SSINS_outdir/obsid

  • clobber – See UVFlag documentation

  • data_compression – See UVFlag documentation

  • output_type ('data', 'z_score', 'mask', 'flags', 'match_events') –

    data - outputs the metric_array attribute into an h5 file

    z_score - outputs the the metric_ms attribute into an h5 file

    mask - outputs the mask for the metric_array attribute into an h5 file

    flags - converts mask to flag using mask_to_flag() method and writes to an h5 file readable by UVFlag

    match_events - Writes the match_events attribute out to a human-readable yml file

    mwaf - Writes an mwaf file by converting mask to flags.

  • mwaf_files (seq) – A list of paths to mwaf files to use as input for each coarse channel

  • mwaf_method ('add' or 'replace') – Choose whether to add SSINS flags to current flags in input file or replace them entirely

  • metafits_file (str) – A path to the metafits file if writing mwaf outputs. Required only if writing mwaf files.

  • sep (str) – Determines the separator in the filename of the output file.