示例#1
0
    def saveManager(self):
        self.rawoutput.close()
        self.jsonoutput.close()

        print("Data saved!")
        print("Uploading to Dropbox...")
        ssh = rpiDBUploader("apddata", "common")
        ssh.uploadFromNFS()
def main(dg, step, binsize):
    comm = MPI.COMM_WORLD
    rank = comm.Get_rank()
    print rank
    timestamp = time.strftime('%Y%m%d_%H%M')

    metadata = {
        'timestamp':    timestamp,
        'bin_duration': binsize,
        'step_size':    step,
        'degrees_moved':dg
    }

    check_dir(timestamp)

    with open(os.path.join(timestamp, 'metadata.json'), 'w') as f:
        json.dump(metadata,f)
    if rank == 0:
        print "on 2.188, scope control"
        c = scopeControl(binsize)
        c.timestamp = timestamp
        while True:
            a = comm.recv(source = 1, tag = 0)
            if a == "next":
		print "received from source 1"
                b = comm.recv(source = 1, tag = 1)
                c.id = b
                c.acquireData()
            else:
                break
            # clean up and data exporting
		tar = tarfile.open("apdflashCoincidences{}.tar.gz".format(timestamp), "w:gz")
		tar.add(timestamp, arcname = timestamp)
		tar.close()

		for i in os.listdir(timestamp):
			os.remove(os.path.join(timestamp,i))
		os.rmdir(timestamp)

		ssh = rpiDBUploader("apdflashCoincidences{}.tar.gz".format(timestamp), "apdflash")
		ssh.upload()

    elif rank == 1:
        print "on 2.194, motor control"
        b = thorControl(step, dg)
        b.timestamp = timestamp
        b.start()
示例#3
0
def main(kwargs):
	comm = MPI.COMM_WORLD
	#print "World size: {}".format(comm.Get_size())
	rank = comm.Get_rank()
	timestamp = time.strftime('%Y%m%d_%H%M')
	metadata = {'timestamp': timestamp,
				'bin_size': kwargs['binsize'],
				'step_size':kwargs['step'],
				'degrees_moved': kwargs['degree']}
	check_dir(timestamp)
	with open('copythis', 'w') as f:
		f.write(timestamp)
	with open(os.path.join(timestamp, 'metadata.json'), 'w') as f:
		json.dump(metadata, f)
	if rank == 0:
		print "on fruitcake0: apd control"
		#a = apdControl(kwargs['binsize'])
		while True:
			a = comm.recv(source = 1, tag = 0)
			if a == "next":
				b = comm.recv(source = 1, tag = 1)
				c = apdControl(kwargs['binsize'])
				c.id = b[1]
				c.timestamp = b[0]
				c.grabData()
			else:
				break
		tar = tarfile.open("apdflash{}.tar.gz".format(timestamp), "w:gz")
		tar.add(timestamp, arcname = timestamp)
		tar.close()

		for i in os.listdir(timestamp):
			os.remove(os.path.join(timestamp,i))
		os.rmdir(timestamp)

		ssh = rpiDBUploader("apdflash{}.tar.gz".format(timestamp), "apdflash")
		ssh.upload()

	elif rank == 1:
		print "on fruitcake1: motorised stage control"
		b = thorControl(kwargs['step'], kwargs['degree'])
		b.timestamp = timestamp
		b.start()
示例#4
0
 def saveManager(self):
     try:
         with open(self.savefp, 'wb+') as f:
             json.dump(self.data,f)
         with open(self.raw_savefp, 'wb+') as f:
             for i in xrange(len(self.data['counts'])):
                 dtpt = self.data['counts'][i]
                 f.write('{}\t{}\t{}\t{}\n'.format(dtpt[0], dtpt[1][0], dtpt[1][1], dtpt[1][2]))
         print "Data saved!"
         print "Uploading to Dropbox..."
         ssh = rpiDBUploader("apddata", "common")
         ssh.uploadFromNFS()
     except:
         fname = "~/arthur_{}.autosave".format(self.timestamp)
         with open("{}.json".format(fname), 'wb+') as f:
             json.dump(self.data,f)
         with open(fname, 'wb+') as f:
             for i in xrange(len(self.data['counts'])):
                 dtpt = self.data['counts'][i]
                 f.write('{}\t{}\t{}\t{}\n'.format(dtpt[0], dtpt[1][0], dtpt[1][1], dtpt[1][2]))
         print "Unable to save to original file. Data auto dumped at {} and {}.json".format(fname,fname)