def createChangingTimeDomainDataPhaseMatch(baseFilename, low = 0, high = 10):
	dat0 = dataImport.readADSFile(baseFilename % low)
	dat1 = dataImport.readADSFile(baseFilename % high)
	sps = dataImport.getSPS(baseFilename % low)
	if dataImport.getSPS(baseFilename % high) != sps:
		raise Exception("samples per second do not match - FAIL")
	
	dataSources = [dat0, dat1]
	indeces = [0, 0]
	
	if dataLength < float(constants.windowSize) / constants.samplesPerSecond * 1.5:
		raise Exception("Data length is too short - not getting full ffts of a single data source")
	
	numSamples = int(dataLength * sps)
	result = []
	output = []
	
	for i in range(numSignalChunks * 2):
		newIndex = i % 2
			
		if i == 0:
			dataToAppend = centerAroundZero(dataSources[newIndex][indeces[newIndex] : indeces[newIndex] + numSamples])
			indeces[newIndex] += numSamples
		else:
			#gotta phase match
			newData = centerAroundZero(dataSources[newIndex][indeces[newIndex] : int(indeces[newIndex] + numSamples + sps * startIndexRange*2)])
			startOffset = getBestStartIndex(result, newData, sps)
			#print startOffset
			dataToAppend = newData[startOffset: startOffset + numSamples]
			indeces[newIndex] += numSamples + startOffset
			
		if len(dataToAppend) != numSamples:
			raise Exception("Data to be appended is not the correct length")
		
		oldIndex = len(result)
		result += dataToAppend
		output += [newIndex] * numSamples
		
		
	#down sample result and output
	result = fftDataExtraction.downSample(result, sps, interpolate = True)
	output = fftDataExtraction.downSample(output, sps,)
	return result, output
def getDownSampledData(filename):
	rawData = dataImport.readADSFile(filename)
	rawSps = dataImport.getSPS(filename)
	
	result = downSample(rawData, rawSps)
	return result