def unremovePixel(timeMaskPath,pixelRow,pixelCol,reasons=['manual hot pixel','manual cold pixel'],nodePath='/'):
    timeMaskFile = tables.openFile(timeMaskPath,mode='a')

    hotPixelsOb = readHotPixels(timeMaskFile)
    expTime = hotPixelsOb.expTime
    reasonEnum = hotPixelsOb.reasonEnum
    try:
        reasonValues = [reasonEnum[eachReason] for eachReason in reasons]
    except IndexError:
        outStr = 'reason given for removing pixel,{}, is not in the timeMaskReason enum'.format(reason)
        raise IndexError(outStr)

    tableName = constructDataTableName(x=pixelCol, y=pixelRow)
    eventListTable = timeMaskFile.getNode(nodePath + dataGroupName, name=tableName)
    print eventListTable.read()
    
    #find the rows where the reason flag matches one of those in the reasons list
    rowIndicesWithGivenReasons = np.where(np.in1d(eventListTable.cols.reason,reasonValues))[0]
    print rowIndicesWithGivenReasons

    #as we start iterating through and deleting rows, the row numbers will change
    #so we need to correct the row indices accordingly
    #subtract from each row the number of rows deleted before it
    rowIndicesWithGivenReasons.sort()
    correctedRowIndices = rowIndicesWithGivenReasons - np.arange(len(rowIndicesWithGivenReasons))
    #delete rows
    for eachRowIdx in correctedRowIndices:
        eventListTable.removeRows(eachRowIdx)

    timeMaskFile.flush()

    print eventListTable.read()

    timeMaskFile.close()
    def __init__(self,timeMaskPath,pixelRow,pixelCol,parent=None,nodePath='/'):
        super(EditTimeMaskDialog,self).__init__(parent=parent)
        self.parent=parent

        self.timeMaskFile = tables.openFile(timeMaskPath,mode='a')

        self.hotPixelsOb = readHotPixels(self.timeMaskFile)
        self.expTime = self.hotPixelsOb.expTime
        self.reasonEnum = self.hotPixelsOb.reasonEnum

        self.reasonList = self.hotPixelsOb.reasons[pixelRow,pixelCol]
        self.intervalList = self.hotPixelsOb.intervals[pixelRow,pixelCol]
        self.nEntries = len(self.reasonList)

        tableName = constructDataTableName(x=pixelCol, y=pixelRow)
        self.eventListTable = self.timeMaskFile.getNode(nodePath + dataGroupName, name=tableName)

        self.initUI()
        self.exec_()
def removePixel(timeMaskPath,pixelRow,pixelCol,reason='manual hot pixel',nodePath='/',timeInterval=None):
    timeMaskFile = tables.openFile(timeMaskPath,mode='a')

        

    hotPixelsOb = readHotPixels(timeMaskFile)
    expTime = hotPixelsOb.expTime
    reasonEnum = hotPixelsOb.reasonEnum

    if not timeInterval is None:
        if len(timeInterval) == 2:
            tBegin = timeInterval[0]*hotPixelsOb.ticksPerSec
            tEnd = timeInterval[1]*hotPixelsOb.ticksPerSec
        else:
            raise TypeError('timeInterval needs to be a tuple (tBegin,tEnd), instead given:{}'.format(timeInterval))
    else:
        tBegin = 0.
        tEnd = expTime*hotPixelsOb.ticksPerSec

    try:
        reasonValue = reasonEnum[reason]
    except IndexError:
        outStr = 'reason given for removing pixel,{}, is not in the enum embedded in the existing hot pixel file'.format(reason)
        raise TypeError(outStr)

    tableName = constructDataTableName(x=pixelCol, y=pixelRow)
    eventListTable = timeMaskFile.getNode(nodePath + dataGroupName, name=tableName)

    newRow = eventListTable.row
    newRow['tBegin'] = tBegin
    newRow['tEnd'] = tEnd
    newRow['reason'] = reasonValue
    newRow.append()

    timeMaskFile.flush()
    timeMaskFile.close()