icecube.radcube.TAXIArtifactRemover module

class icecube.radcube.TAXIArtifactRemover.TAXIArtifactRemover(chipLength)

Bases: object

General tool for removing the chip/bin artifacts from the TAXI waveforms. All functions are expected to be given numpy arrays corresponding to the amplitudes of the waveform bins. It is assumed that all amplitudes being given are in units of ADC bins. In general the functions require the waveforms to be NxM in shape where N is the number of copies of that waveform, depending on the cascading mode being used and M is the length of the waveform. To ensure that this class is properly used, use the GetCascadeReshaped, apply any corrections, and then use FlattenWaveforms.

example: | tar = TAXIArtifactRemover(1024) | times, amps = radcube.RadTraceToPythonList(timeSeries) | amps = tar.GetCascadeReshaped(amps) | amps = tar.RemoveChipOffsets(amps, myROI) | amps = tar.FlattenWaveforms(amps) | timeSeries = radcube.PythonListToRadTrace(times, amps)

Parameters:

chipLength – The number of bins in each waveform copy (typically 1024)

BinSpikeRemover(xamps, maxDeviance=1024, medianLength=5)

Identifies individual bins that are broken (e.g. by bit flips) and corrects them depending on how many copies of the waveform are recorded

Parameters:
  • xamps (numpy.array) – N by M array of waveforms where N is the number of copies of the same waveform when using non-fully-cascaded waveforms and M is the length of each waveform copy. If a 1D array is given, it will be assumed to be a 1 by M array.

  • maxDeviance (int) – the tolerance (in ADC bins) to define when a bin is considered in error

  • medianLength (int) – for the algorithms that replace the spike bin with a median of the nearby bins this variable defines the half-width, in bins, of the neighbors to consider

Returns:

a copy of xamps after removing bad bins

Algorithms: For non-cascaded waveforms, for each bin, there is a search to identify if any of the copies has an average deviance above the maxDeviance w.r.t. the bin amplitudes of the other copies. If found, the offending bin is set to the median of the amplitudes of the non-offending bins.

For semi-cascaded waveforms, the absolute difference of each bin for the two copies is checked against the chosen maxDeviance. If larger, there is a check to see which copy has an amplitude for that bin which is least similar to its (+/- medianLength) neighboring bins. That bin is replaced with the median of the bins (+/- medianLength) around it

For fully-cascaded waveforms, all the bins are checked against the two neighboring bins. If a bin is Abs(val - neighbor) > maxDeviance for both neighbors, that bin is set to the median value of the +/- medianLength neighboring bins

BinwiseMedian(xamps)

Applies the median algorithm on the copies of the waveforms

Parameters:

xamps (numpy.array) – N by M array of waveforms where N is the number of copies of the same waveform when using non-fully-cascaded waveforms and M is the length of each waveform copy. If a 1D array is given, it will be assumed to be a 1 by M array.

Returns:

a copy of xamps after applying median

FlattenWaveforms(xamps)
GetCascadeReshaped(xamps, desiredLength)

Does a reshaping of the waveform, which is expected for all other functions

Parameters:
  • xamps (numpy.array) – 1 dimensional array of data where each time bin has N sequential copies of the same waveform

  • desiredLength (int) – the length, in bins, of the N concatinated waveforms

Returns:

a copy of xamps after removing the chip offsets

Return type:

numpy.array

RemoveChipOffsets(xamps, roi, desiredBaseline=0)

Removes the offsets of individual chips based on the median amplitude of each chip

Parameters:
  • xamps (numpy.array) – N by M array of waveforms where N is the number of copies of the same waveform when using non-fully-cascaded waveforms and M is the length of each waveform copy. If a 1D array is given, it will be assumed to be a 1 by M array.

  • roi (int) – the roi value which indicates the bin index where the waveform starts

  • desiredBaseline (int) – (optional) the median value of all waveforms will be set to this value

Returns:

a copy of xamps after removing the chip offsets

ReplaceMissingBins(xamps)

Replaces the -1 values with the average of the two closest neighboring bins. If the -1 is at the end of the trace, it just take the value of the bin before divided by two.

Parameters:

xamps (numpy.array) – N by M array that needs to be corrected

Returns:

a the passed in xamps object after correction

icecube.radcube.TAXIArtifactRemover.bin_to_dec(byte_array)

Converts the binary arry to a number

icecube.radcube.TAXIArtifactRemover.checkInt(str)

Checks if string is made of integers The standard bin should be 0b###, but some bin are put to ADC = -1 and breaks the conversion

icecube.radcube.TAXIArtifactRemover.dec_to_bin(bin_value)

Converts from dec to bin, give back the binary into a list

icecube.radcube.TAXIArtifactRemover.flipFirstBit(badBin)

Flips the most significant bit of the 14 bits

icecube.radcube.TAXIArtifactRemover.shiftByte(badBin)

Shifts towards the most significant bit (left)