Exemplo n.º 1
0
def main():

	print "Reading data...",
	print " %s."% options.rawFN,
	raw = rd( options.rawFN )
	print " %s." % options.projFN,
	P = Serializer.LoadFromHDF( options.projFN )
	print " %s." % options.msmFN
	msmDict = Serializer.LoadFromHDF( options.msmFN ) 

	lens = [ ( P['TrajLengths'][i], i ) for i in range( P['TrajLengths'].shape[0] ) ]
	lens = sorted(lens,reverse=True)

	print lens
	
	trajList = [ b for (a,b) in lens[:options.nTraj] ]
	print trajList
	# Generate the trajectory data:
	trajData = []
	
	for traj in trajList:
		trajData.append( array(rawObs( traj, P['TrajLengths'], raw ) ) )

	# Generate the autocorrelations:
	print "Calculating the convolutions ... "
	trajCorr = [ autocorrelate.fft_autocorrelate( thing ) for thing in trajData ]

	print "Plotting the data ... "
	plotData( msmDict, trajCorr, trajList )
Exemplo n.º 2
0
def main():

	print "Reading data...",
	print " %s."% options.rawFN,
	raw = rd( options.rawFN )
	print " %s." % options.msmFN,
	msm = rd( options.msmFN )
	msm = msm[:,1] # Use the center column (This is how my data is formated.)
	print " %s." % options.AsFN,
	As = Serializer.LoadData( options.AsFN )
	print " %s." % options.projFN,
	P = Serializer.LoadFromHDF( options.projFN )
	print " %s." % options.tFN
	T = mmread( options.tFN )
	

	lens = [ ( P['TrajLengths'][i], i ) for i in range( P['TrajLengths'].shape[0] ) ]
	lens = sorted(lens,reverse=True)
	
	trajList = [ b for (a,b) in lens[:options.nTraj] ]

	rawFmt = ones( As.shape ) * -1
	tempSum = 0

	print raw.shape

	for i in range( len( P['TrajLengths'] ) ):
		rawFmt[i][ : P['TrajLengths'][i] ] = raw[ tempSum : tempSum + P['TrajLengths'][i] ]
		tempSum += P['TrajLengths'][i]

	# Generate the trajectory data:
	trajData = []
	msmData = []
	N = int( P['TrajLengths'].max() / options.lag ) + 1
	
	for traj in trajList:
		print "\nCalculating trajectory %d" % traj,
		print "Raw data.",
		trajData.append( array(rawObs( traj, P['TrajLengths'], raw ) ) )
		print "MSM Average."
		start = zeros( len(msm) )
		start[ As[ traj ][0] ] += 1
		Cor, Traj, ObsTraj = Correlation.RawMSMCorrelation( T, rawFmt, As, Steps = N, StartingState = As[ traj ][0] ) 
		msmData.append( Cor )

	# Generate the autocorrelations:
	print "Calculating the convolutions ... "
	trajCorr = [ autocorrelate.fft_autocorrelate( thing ) for thing in trajData ]
	msmCorr = [ autocorrelate.fft_autocorrelate( thing ) for thing in msmData ]
	msmCorr = [ thing for thing in msmData ]

	for i in range(1000):
		if not os.path.exists('Autocorr%d'%i):
			outDir = 'Autocorr%d'%i
			os.mkdir( outDir )
			break

	if not outDir:
		print "You have a lot of Autocorr directories..."
		print "Writing output to ./ which could overwrite other data!"
		outDir = './'

	print "Writing the autocorrelation data"
	for index, traj in enumerate( trajList ):
		wd( [ 'autocorr','traj%d'%traj,'msm','lag%d'%options.lag ], msmCorr[index], dir=outDir )
		wd( [ 'autocorr','traj%d'%traj,'raw'], trajCorr[index], dir=outDir )

	plotData( msmCorr, trajCorr, trajList, options.lag )
Exemplo n.º 3
0
tProb = mmread(args.tProb)
try:
    raw_data = io.loadh(args.raw_data)["arr_0"]
except:
    raw_data = io.loadh(args.raw_data)["Data"]

num_frames = raw_data.shape[1]

num_lagtimes = num_frames / args.lagtime

# msm_acf = msm_analysis.msm_acf(tProb, msm_data, np.arange(num_lagtimes),
#                               num_modes=args.num_modes)

sampled_traj = msm_analysis.sample(tProb, np.random.randint(tProb.shape[0]), num_lagtimes)
data_traj = msm_data[sampled_traj]
msm_acf = autocorrelate.fft_autocorrelate(data_traj)

raw_acfs = []
for i in xrange(np.max([raw_data.shape[0], 10])):

    max_non_neg = np.where(raw_data[i] != -1)[0].max()
    row = raw_data[i][: max_non_neg + 1]

    raw_acfs.append(autocorrelate.fft_autocorrelate(row))

figure()
axes((0.18, 0.18, 0.72, 0.72))

raw_label = "Raw Data"

for i in xrange(len(raw_acfs)):