Example #1
0
def handleRow(row):
    rowId = row[0]
    ra, dec = processUtil.getTNSRowRaDec(row)

    starRequestFunction = lambda: querySDSSHosts.searchNearestStar(
        ra, dec, starRadiusLimit)
    galaxyRequestFunction = lambda: querySDSSHosts.searchNearestGalaxy(
        ra, dec, galaxyRadiusLimit)

    star = processUtil.requestUntilSuccess(starRequestFunction,
                                           limit=requestAttempts,
                                           returnOnFailure=None)
    galaxy = processUtil.requestUntilSuccess(galaxyRequestFunction,
                                             limit=requestAttempts,
                                             returnOnFailure=None)

    global currRowNum
    currRowNum += 1
    print(currRowNum, rowId, "-" if star == None else 'S',
          "-" if galaxy == None else 'G')

    if star != None and galaxy != None:
        hostRow = getHostRow(star, galaxy)
        processUtil.appendRow(row + hostRow, outputFile)
        return True
    return False
Example #2
0
def handleRow(row):
	rowId = row[0]
	ra, dec = processUtil.getTNSRowRaDec(row)
	
	requestFunction = lambda: querySDSSHosts.searchNearestHosts(ra, dec, radiusLimit, 2)
	hosts = processUtil.requestUntilSuccess(requestFunction, limit=requestAttempts, returnOnFailure=[])
	
	global currRowNum
	currRowNum += 1
	print(currRowNum, rowId, "--" if len(hosts)<2 else (round(hosts[0]['offset']*60,1), round(hosts[1]['offset']*60,1)))
	
	if len(hosts) == 2:
		hostRow = getHostRow(hosts[0], hosts[1])
		processUtil.appendRow(row + hostRow, outputFile)
		return True
	return False
Example #3
0
def handleRow(row):
    rowId = row[0]
    ra, dec = row[raCol], row[decCol]

    requestFunction = lambda: querySDSSHosts.searchNearestHost(
        ra, dec, radiusLimit)
    host = processUtil.requestUntilSuccess(requestFunction,
                                           limit=requestAttempts,
                                           returnOnFailure=None)

    global currRowNum
    currRowNum += 1
    print(currRowNum, rowId, "--" if host == None else host['offset'])

    if host != None:
        hostRow = getHostRow(host)
        processUtil.appendRow(row + hostRow, outputFile)
        return True
    return False
Example #4
0
def handleRow(row):
    rowId = row[0]
    ra, dec = processUtil.getTNSRowRaDec(row)

    requestFunction = lambda: queryPS1Imaging.queryPS1ImageData(
        ra, dec, imageArcsec, imageOutputSize)
    imageData = processUtil.requestUntilSuccess(requestFunction,
                                                limit=requestAttempts,
                                                returnOnFailure=[])

    global currRowNum
    currRowNum += 1

    if len(imageData) == imageOutputData:
        print(currRowNum, rowId, len(imageData))
        processUtil.appendRow(row + imageData, outputFile)
        return True

    print(currRowNum, rowId, "No image")
    return False
Example #5
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)
Example #6
0
	hosts = processUtil.requestUntilSuccess(requestFunction, limit=requestAttempts, returnOnFailure=[])
	
	global currRowNum
	currRowNum += 1
	print(currRowNum, rowId, "--" if len(hosts)<2 else (round(hosts[0]['offset']*60,1), round(hosts[1]['offset']*60,1)))
	
	if len(hosts) == 2:
		hostRow = getHostRow(hosts[0], hosts[1])
		processUtil.appendRow(row + hostRow, outputFile)
		return True
	return False

# -- Script --

# User prompt
processUtil.confirmOverwrite(outputFile)

# Clears the file
processUtil.createOrClearFile(outputFile)

# Handles the headers
headerRow = reader.__next__()
processUtil.appendRow(headerRow + sdssHeaders, outputFile)

# Reads and filters the catalog rows
rows = [row for row in reader]
if rowLimit: rows = rows[:rowLimit]

# Requests and writes the desired image data
pool = Pool(threadNum)
pool.map(handleRow, rows)
	trainingExample.r1 = rowMap["SDSS_host1_r"]
	trainingExample.i1 = rowMap["SDSS_host1_i"]
	trainingExample.z1 = rowMap["SDSS_host1_z"]
	
	trainingExample.hostLabel2 = getHostLabel(rowMap["SDSS_host2_type"])
	trainingExample.offset2 = rowMap["SDSS_host2_offset"]
	trainingExample.redshift2 = rowMap["SDSS_host2_redshift"]
	trainingExample.u2 = rowMap["SDSS_host2_u"]
	trainingExample.g2 = rowMap["SDSS_host2_g"]
	trainingExample.r2 = rowMap["SDSS_host2_r"]
	trainingExample.i2 = rowMap["SDSS_host2_i"]
	trainingExample.z2 = rowMap["SDSS_host2_z"]

	# Generate and write the training row
	trainingRow = trainingExample.generateRow()
	return trainingRow

# -- Script --

# User prompt
processUtil.confirmOverwrite(outputFile)

# Clears output file
processUtil.createOrClearFile(outputFile)

# Handles headers
processUtil.appendRow(trainingHeaders, outputFile)

# Generates and writes training rows
trainingRows = [handleRowMap(rowMap) for rowMap in dictReader]
processUtil.appendRows(trainingRows, outputFile)
Example #8
0
    currRowNum += 1

    if len(imageData) == imageOutputData:
        print(currRowNum, rowId, len(imageData))
        processUtil.appendRow(row + imageData, outputFile)
        return True

    print(currRowNum, rowId, "No image")
    return False


# -- Script --

# User prompt
processUtil.confirmOverwrite(outputFile)

# Clears the file
processUtil.createOrClearFile(outputFile)

# Handles the headers
headerRow = reader.__next__()
processUtil.appendRow(headerRow + imageHeaders, outputFile)

# Reads and filters the catalog rows
rows = [row for row in reader if not shouldSkipRow(row)]
if rowLimit: rows = rows[:rowLimit]

# Requests and writes the desired image data
pool = Pool(threadNum)
pool.map(handleRow, rows)