Exemple #1
0
idCol = 0
labelCol = 1
firstPixelCol = 5


def handleRow(row):
    transientId = row[idCol]
    transientLabel = row[labelCol]
    pixelData = row[firstPixelCol:]

    trainingRow = [transientId, transientLabel] + pixelData
    return trainingRow


# -- Script --

# User prompt
processUtil.confirmOverwrite(outputFile)

# Clears output file
processUtil.createOrClearFile(outputFile)

# Handles headers
headers = reader.__next__()
processUtil.appendRow(transientHeaders + headers[firstPixelCol:], outputFile)

# Generates and writes training rows
trainingRows = [handleRow(row) for row in reader]
processUtil.appendRows(trainingRows, outputFile)
    return labelMap[transType] if transType in tnsLabelMap else otherType


def processTNSRow(tnsRow):
    survey = 'TNS'
    transId = processUtil.generateUUID()
    label = getLabel(tnsRow['Type'], tnsLabelMap)
    ra, dec = tnsRow['RA'], tnsRow['DEC']
    mag = tnsRow['Discovery Mag']
    return [transId, label, ra, dec, mag, survey]


def processOldPSRow(psRow):
    survey = 'OldPS'
    transId = processUtil.generateUUID()
    label = getLabel(psRow['class'], oldPSLabelMap)
    ra, dec = psRow['ra'], psRow['dec']
    mag = psRow['first_detect_mag']
    return [transId, label, ra, dec, mag, survey]


# -- Script --

processUtil.confirmOverwrite(outputFile)

processUtil.createOrClearFile(outputFile)

processUtil.appendRow(headers, outputFile)
processUtil.appendRows([processTNSRow(r) for r in tnsReader], outputFile)
processUtil.appendRows([processOldPSRow(r) for r in oldPSReader], outputFile)