예제 #1
0
def _getCurrentFileName(filenumber):
    ''' convert relative file number to its absolute path to the file with file extension as ".dat"'''
    filename = str(filenumber)
    if long(filenumber) < 0:
        filename = os.path.join(PathConstructor.createFromDefaultProperty(),str(int(NumTracker(LocalProperties.get(LocalProperties.GDA_BEAMLINE_NAME)).getCurrentFileNumber()+int(filenumber)))+".dat")
    else:
        filename = os.path.join(PathConstructor.createFromDefaultProperty(),str(filenumber)+ ".dat")
    return filename
예제 #2
0
파일: BSSC.py 프로젝트: openGDA/gda-scm
    def exportFinalBeans(self):
        """The samples are updated to include the datafile paths

        export readonly version of .biosaxs file to keep record of experiment"""
        fname = self.beanFile.split(os.path.sep)[-1].rsplit('.', 1)[0]
        now = datetime.datetime.now().strftime('_%Y%m%d_%H%M%S')

        user_visit = InterfaceProvider.getBatonStateProvider().getBatonHolder().getVisitID()
        prop = PathConstructor.getDefaultPropertyName()
        path = PathConstructor.createFromProperty(prop, HashMap({'visit': user_visit}))

        full_path = os.path.join(path, fname + now + '.biosaxs')
        BSSCSessionBean.writeToXML(self.bean, full_path)
        os.chmod(full_path, 0444)
예제 #3
0
    def __init__(self, filespec=None, dir=None):

        self.format = LocalProperties.get(
            "gda.data.scan.datawriter.dataFormat")
        if dir != None and dir != "None":
            self.dir = dir
        else:
            self.dir = PathConstructor.createFromDefaultProperty()
        self.beamline = GDAMetadataProvider.getInstance().getMetadataValue(
            "instrument", LocalProperties.GDA_INSTRUMENT, "tmp")
        if (self.format == "NexusDataWriter"):
            #really should use scanFileName prefix rather than forcing to beamline-
            self.prefix = LocalProperties.get("gda.data.filePrefix",
                                              self.beamline + "-")
            self.ext = "nxs"
            if filespec == None:
                filespec = "%d" % NumTracker(self.beamline).currentFileNumber

        else:
            self.prefix = ""
            self.ext = "dat"
            if filespec == None:
                filespec = "%d" % NumTracker().currentFileNumber

        filespec = filespec.__str__()

        self.filename = self.tryFiles([
            filespec, self.dir + "/" + filespec,
            self.prefix + filespec + "." + self.ext,
            self.dir + "/" + self.prefix + filespec + "." + self.ext,
            self.dir + "/" + filespec + "." + self.ext
        ])

        if (self.filename == None):
            raise Exception("no file found for %s" % filespec)
예제 #4
0
	def __init__(self, filespec=None, dir=None):
		
		self.format = LocalProperties.get("gda.data.scan.datawriter.dataFormat")
		if dir!=None and dir != "None":
			self.dir=dir
		else:
			self.dir = PathConstructor.createFromDefaultProperty()
		self.beamline = GDAMetadataProvider.getInstance().getMetadataValue("instrument", LocalProperties.GDA_INSTRUMENT, "tmp")
		if (self.format == "NexusDataWriter"):
			#really should use scanFileName prefix rather than forcing to beamline-
			self.prefix = LocalProperties.get("gda.data.filePrefix",self.beamline + "-")
			self.ext = "nxs"
			if filespec==None:
				filespec = "%d" % NumTracker(self.beamline).currentFileNumber
			
		else:
			self.prefix = ""
			self.ext = "dat"
			if filespec==None:
				filespec = "%d" % NumTracker().currentFileNumber
		
		filespec = filespec.__str__()
		
		self.filename = self.tryFiles([ filespec, self.dir+"/"+filespec, self.prefix+filespec+"."+self.ext, self.dir+"/"+self.prefix+filespec+"."+self.ext, self.dir+"/"+filespec+"."+self.ext ])
		
		if (self.filename == None):
			raise Exception("no file found for %s" % filespec)
예제 #5
0
    def exportFinalBeans(self):
        """The samples are updated to include the datafile paths

        export readonly version of .biosaxs file to keep record of experiment"""
        fname = self.beanFile.split(os.path.sep)[-1].rsplit('.', 1)[0]
        now = datetime.datetime.now().strftime('_%Y%m%d_%H%M%S')

        user_visit = InterfaceProvider.getBatonStateProvider().getBatonHolder(
        ).getVisitID()
        prop = PathConstructor.getDefaultPropertyName()
        path = PathConstructor.createFromProperty(
            prop, HashMap({'visit': user_visit}))

        full_path = os.path.join(path, fname + now + '.biosaxs')
        BSSCSessionBean.writeToXML(self.bean, full_path)
        os.chmod(full_path, 0444)
예제 #6
0
 def _getgdadir(self):
     try:
         import gda.data.PathConstructor as PathConstructor
         datadir = PathConstructor.createFromDefaultProperty()
     except ImportError:
         print "No gda configuration access so please specify data directory"
         raise
     return datadir
예제 #7
0
def pescan(function=2, frequency=0.1, amplitude=10.0, shift=0.0, symmetry=50.0, number_of_pre_cycles=1,number_of_points_per_cycle=40.0, detector=mythen, ng=1, nf=1):
    #setup function generator
    fg.setFunction(function)
    fg.setFrequency(frequency)
    fg.setAmplitude(amplitude)
    fg.setShift(shift)
    fg.setSymmetry(symmetry)
    sleep(2) 
    #derived parameters for pescan() function inputs
    fg_frequency=fg.getFrequency()
    fg_period=1/fg_frequency
    starttime=number_of_pre_cycles * fg_period
    stoptime=starttime+fg_period
    gatewidth=fg_period/number_of_points_per_cycle
    
    voltage.setNumberOfGates(ng)
    electrometer.setNumberOfGates(ng)
    voltage.addMonitor(1)
    electrometer.addMonitor(1)
    directory=PathConstructor.createFromDefaultProperty()
    scanNumber=scanNumTracker.incrementNumber()
    voltage.setFilename(directory+(str(scanNumber)))
    electrometer.setFilename(directory+(str(scanNumber)))

    #pre-conditioning
    fg.setOutput(1)
    timer=_Timer()
    timer.start()
    print "sample pre-conditioning cycles, please wait for %s" % starttime
    while(not timer.hasElapsed(starttime)):
        sleep(1)

    #collection
    collectionNumber=0
    try:
        for t1 in frange(starttime, stoptime, gatewidth):
            #print t1
            voltage.resetCounter()
            voltage.setRepetition(collectionNumber)
            electrometer.resetCounter()
            electrometer.setRepetition(collectionNumber)
            print "move event receiver to delay=%s width=%s" % (t1-starttime, gatewidth)
            evr.moveTo([t1-starttime,gatewidth])
            mythen.gated(nf, ng, scanNumber, collectionNumber)
            collectionNumber += 1
            #print "end loop"
            interruptable()
    except:
        raise
    finally:
        print "end loop"
        voltage.removeMonitor()
        electrometer.removeMonitor()

    #stop ramp output
    fg.setOutput(0)
    print "scan completed."
 def pescan(self, frequency=0.1,exposure=0.5,amplitude=5.0,numPoints=40, func=2, bncycle=1):
     self.directory=PathConstructor.createFromDefaultProperty()
     self.scanNumber=scanNumTracker.incrementNumber()
     self.filename=self.directory+(str(self.scanNumber))
     print self.filename
     if self.adc.getMode()=="Continuous":
         self.setupADC2()
     elif self.adc.getMode()=="Trigger":
         self.configADC(200, self.adcClockRate(frequency))
     self.calculateExperimentParameters(frequency, exposure, numPoints)
     self.setupFG(freq=frequency,amp=amplitude,bncycle=self.numGates)
     self.sampleConditioning(func=6, bncycle=1)
     self.configTFG(frequency)
     #self.setupDataCapturer()
     print "open fast shutter %d" % time()
     self.fastshutter.moveTo("OPEN")
     if self.adc.getMode()=="Trigger":
         print "enable adc sampling"
         self.adc.enable()
     try:
         for i in range(self.numCycles):
             GeneralCommands.pause()
             #while not self.gateDetectorCompleted or not self.adcStreamerCompleted:
                 #if not self.gateDetectorCompleted:
                     # print "wait PSD to complete..."
                 #if not self.adcStreamerCompleted:
                     #    print "wait ADC to finish PE data capture..."
                 #sleep(1.0)
             self.startDetector(frequency, self.scanNumber, i)
             #sleep(1.0)
             if self.adc.getMode()=="Trigger":
                 print "enable adc sampling"
                 self.adc.enable()
             elif self.adc.getMode()=="Continuous":
                 if frequency<=0.1:
                     self.startPEDataStreamer(self.filename+"_peg_"+str(i)+".h5", 1/frequency+TIME_FUDGE_FACTOR_IN_SECONDS)
                 else:
                     self.startPEDataStreamer(self.filename+"_peg_"+str(i)+".h5", 1/frequency*self.numGates*self.numFrames*self.numDefinedSequency+TIME_FUDGE_FACTOR_IN_SECONDS)
             self.tfg.start()
             if frequency<=0.1:
                 sleep(1/frequency+GDAPROCESSTIME)
             else:
                 sleep(1/frequency*self.numGates*self.numFrames*self.numDefinedSequency+GDAPROCESSTIME*self.numDefinedSequency)
             # while self.tfg.status() != "RUNNING":
                 # sleep(0.025)
             # while self.tfg.status() != "IDLE":
                 # print self.tfg.progress()
                 # sleep(self.livetime)
             #self.pedata.save(self.filename, i)
     except:
         raise
     finally:
         print "close fast shutter %d" % time()
         self.fastshutter.moveTo("CLOSE")
         print "collection completed at %d" % time()
         self.stop()
예제 #9
0
def plots(startNumber, endNumber, commonSuffix="mythen_summed.dat", dataType=PSD):
    firstPlot=True
    datadir=PathConstructor.createFromDefaultProperty()
    for filenumber in range(startNumber, endNumber+1):
        filename=str(filenumber)+"-"+commonSuffix
        if firstPlot:
            plot(dataType, os.path.join(datadir,filename))
            firstPlot=False
        else:
            plotover(dataType, os.path.join(datadir,filename))
예제 #10
0
	def setFile(self, subDir, newFilePrefix):
		"""Set file path and name"""
#		imagePath = PathConstructor.createFromProperty("gda.data.scan.datawriter.datadir");
		imagePath=PathConstructor.createFromDefaultProperty() + File.separator;
		
		fullPath = os.path.join(imagePath, subDir);
		print "Note: Current Pilatus image path: " + fullPath;
		
		self.imageProducer.setFilePath(fullPath);
		self.imageProducer.setFilePrefix(newFilePrefix);
def pescan(func=2,freq=0.125,amp=5.0,shift=0.0,symmetry=50.0,trig=1,bmode=0,bncycle=1,bstate=1,
           nprecycles=1,nptspercycle=40, det=mythen, 
           ng=1, nf=40):

    #setup func generator 2
    fg2.setFunction(func)       # 2 - ramp
    fg2.setAmplitude(amp)
    fg2.setShift(shift)
    fg2.setSymmetry(symmetry)
    fg2.setTriggerSource(trig)
    fg2.setBurstState(bstate)   # switch on burst mode
    fg2.setBurstMode(bmode)
    fg2.setOutput(1)

    fg2.setFrequency(freq)
    fg2.setBurstNCycle(ng)
    
    sleep(1)

    #setup ADC to capture PE data
    peobject.addMonitors()
    peobject.setFirstData(True)
    peobject.setNumberOfGates(ng)
    
    #setup file name 
    directory=PathConstructor.createFromDefaultProperty()
    scanNumber=scanNumTracker.incrementNumber()
    peobject.setFilename(directory+(str(scanNumber)))

    #collection
    collectionNumber=1  
    numberToCollect=0  
    try:
        peobject.reset()                          # reset the gate counter
        print "open fast shutter %d" % time()
        pos fastshutter "OPEN"
        if freq <= 0.03:
            print "GDA is ready for data collection, you need now to start TFG please. "
            mythen.gated(nf, ng, scanNumber, collectionNumber)  # block until all frames and gates are collected
        else:
            print "Please start PSD collection from QT window client"
            sleep(5)
            while (peobject.getCollectionNumber() <= nf):
                if numberToCollect != peobject.getCollectionNumber():   
                    numberToCollect=peobject.getCollectionNumber()
                    print "ready to collect frame %d, please wait..." % numberToCollect
        pos fastshutter "CLOSE"
        #peobject.save(collectionNumber)
        collectionNumber += 1
    except:
        raise
    finally:
        print "collection completed at %d" % time()
        peobject.removeMonitors()        # ensure monitor removed
예제 #12
0
    def setFile(self, subDir, newFilePrefix):
        """Set file path and name"""
        #		imagePath = PathConstructor.createFromProperty("gda.data.scan.datawriter.datadir");
        imagePath = PathConstructor.createFromDefaultProperty(
        ) + File.separator

        fullPath = os.path.join(imagePath, subDir)
        print "Note: Current Pilatus image path: " + fullPath

        self.imageProducer.setFilePath(fullPath)
        self.imageProducer.setFilePrefix(newFilePrefix)
예제 #13
0
def pescan(
    starttime=pre_condition_time,
    stoptime=stop_time,
    gatewidth=gate_width,
    mythen1=mythen,
    ng=number_gates,
    nf=number_frames,
):
    # setup
    voltage.setNumberOfGates(ng)
    electrometer.setNumberOfGates(ng)
    voltage.addMonitor(1)
    electrometer.addMonitor(1)
    directory = PathConstructor.createFromDefaultProperty()
    scanNumber = scanNumTracker.incrementNumber()
    voltage.setFilename(directory + ("/") + (str(scanNumber)))
    electrometer.setFilename(directory + ("/") + (str(scanNumber)))

    # pre-conditioning
    fg.setOutput(1)
    timer = _Timer()
    timer.start()
    print "sample pre-conditioning cycles, please wait for %s" % starttime
    while not timer.hasElapsed(starttime):
        sleep(1)

    # collection
    collectionNumber = 0
    try:
        for t1 in frange(starttime, stoptime, gatewidth):
            # print t1
            voltage.resetCounter()
            voltage.setCollectionNumber(collectionNumber)
            electrometer.resetCounter()
            electrometer.setCollectionNumber(collectionNumber)
            print "move event receiver to delay=%s width=%s" % (t1 - starttime, gatewidth)
            evr.moveTo([t1 - starttime, gatewidth])
            mythen.gated(nf, ng, scanNumber, mythen.getDataDirectory(), collectionNumber)
            collectionNumber += 1
            # print "end loop"
            interruptable()
    except:
        raise
    finally:
        print "end loop"
        voltage.removeMonitor()
        electrometer.removeMonitor()
    # clearup
    # voltage.removeMonitor()
    # electrometer.removeMonitor()
    # stop ramp output
    fg.setOutput(0)
    print "scan completed."
예제 #14
0
def loadMythenData(filename):
    '''load the mythen frame data.'''
    from gda.device.detector.mythen.data import MythenProcessedDataset, MythenMergedDataset
    
    if str(filename).startswith(File.separator):
        try:
            dataset = MythenProcessedDataset(java.io.File(filename))
        except:
            dataset = MythenMergedDataset(java.io.File(filename))
        return dataset
    if str(filename).find("merged") == -1:
        if str(filename).find("summed") == -1:
            #Not merged file or it is mythen data file
            try:
                dataset = MythenProcessedDataset(java.io.File(os.path.join(PathConstructor.createFromDefaultProperty(),str(filename))))
            except:
                dataset = MythenMergedDataset(java.io.File(os.path.join(PathConstructor.createFromDefaultProperty(),str(filename))))
        else:
            dataset = MythenMergedDataset(java.io.File(os.path.join(PathConstructor.createFromDefaultProperty(),str(filename))))
        return dataset
    else:
        #externally merged file in 'processing' sub-folder
        dataset = MythenMergedDataset(java.io.File(os.path.join(PathConstructor.createFromDefaultProperty(),str(filename))))
        return dataset
예제 #15
0
def loadMythenRawData(filename):
    '''load the mythen frame data.'''
    from gda.device.detector.mythen.data import MythenRawDataset
    
    if str(filename).startswith(File.separator):
        try:
            dataset = MythenRawDataset(java.io.File(filename))
        except:
            print "Fail to load data file: "+filename
        return dataset
    try:
        dataset = MythenRawDataset(java.io.File(os.path.join(PathConstructor.createFromDefaultProperty(),str(filename))))
    except:
        print "Fail to load data file: "+filename
    return dataset
예제 #16
0
def cdd(dirname):
    if dirname.startswith(File.separator):
        LocalProperties.set(LocalProperties.GDA_DATAWRITER_DIR, dirname)
    else:
        propertyValue=LocalProperties.get(LocalProperties.GDA_DATAWRITER_DIR)
        if propertyValue.contains("$subdirectory$"):
            propertyValue=propertyValue.replace("$subdirectory$", "")
        visitdir=PathConstructor.createFromTemplate(propertyValue)
        dirname=os.path.realpath(os.path.join(visitdir, "..", dirname))
        LocalProperties.set(LocalProperties.GDA_DATAWRITER_DIR, dirname)
    eventAdmin=Finder.getInstance().find("eventadmin")
    if eventAdmin is None:
        print "Cannot find 'eventAdmin' on the GDA server. Please create a Spring bean using 'Scriptcontroller' Java class"
    else:
        eventAdmin.update(LocalProperties.GDA_DATAWRITER_DIR, dirname)
    print "Data Directory changed to "+ LocalProperties.get(LocalProperties.GDA_DATAWRITER_DIR)
예제 #17
0
def loadMythenSRSFile(filename):
    '''load MythenSRSFile, supporting relative file number with respect to the current one (0).'''
    from gda.device.detector.mythen.data import MythenSrsFileLoader
    filenamelist=[]
    try:
        if filename == None:
            #current file
            filenamelist=MythenSrsFileLoader().load(_getCurrentFileName(0))
        elif representsInt(filename):
            #past file - relative path
            filenamelist=MythenSrsFileLoader().load(_getCurrentFileName(int(filename)))
        elif not str(filename).startswith(File.separator):
            #filename with extension
            filenamelist=MythenSrsFileLoader().load(os.path.join(PathConstructor.createFromDefaultProperty(),filename))
        else:
            #absolute file path
            filenamelist=MythenSrsFileLoader().load(filename)
    except IOException, err:
        print "MythenSrsFileLoader failed. " , err
예제 #18
0
def loadSRSData(filename):
    '''Load SRS data file into a ScanFileHolder object, 
    supporting relative loading with respect to the current collected data (0)'''
    sfh = ScanFileHolder()
    try:
        if filename == None:
            #current file
            sfh.load(SRSLoader(_getCurrentFileName(0)))
        elif representsInt(filename):
            #past file - relative path
            sfh.load(SRSLoader(_getCurrentFileName(int(filename))))
        elif not filename.startswith(File.separator):
            #filename with extension
            sfh.load(SRSLoader(os.path.join(PathConstructor.createFromDefaultProperty(),filename)))
        else:
            #absolute file path
            sfh.load(SRSLoader(filename))
    except ScanFileHolderException, err:
        print "File loader failed. " + err
예제 #19
0
 def atScanStart(self):
     self.collectionNumber=0
     self.directory=PathConstructor.createFromDefaultProperty()
     self.scanNumber=scanNumTracker.getCurrentFileNumber()
     self.filename=self.directory+(str(self.scanNumber))
예제 #20
0
 def pescan(self, frequency=0.1,exposure=0.5,amplitude=5.0,numPoints=40, function=2, bncycle=1):
     self.directory=PathConstructor.createFromDefaultProperty()
     self.scanNumber=scanNumTracker.incrementNumber()
     self.filename=self.directory+(str(self.scanNumber))
     print self.filename
     if self.adc.getMode()=="Gate":
         self.setupADC2()
     elif self.adc.getMode()=="Trigger":
         self.configADC(200, self.adcClockRate(frequency))
     self.calculateExperimentParameters(frequency, exposure, numPoints)
     self.setupFG(freq=frequency,amp=amplitude,bncycle=self.numGates, func=function)
     # must in following order
     if self.isSampleConditioning():
         self.sampleConditioning(func=6, bncycle=1)
     self.configTFG(frequency)
     self.setupDataCapturer(self.filename, self.numGates)
     print "open fast shutter %d" % time()
     self.fastshutter.moveTo("OPEN")
     try:
         if frequency <= self.boundaryFrequency:
             for i in range(self.numCycles):
                 GeneralCommands.pause()
                 self.pedata.reset()
                 self.pedata.setCollectionNumber(i)
                 print "\ncollecting %d frames, %d gates per frame, Scan number %d, Collection number %d" % (self.numFrames*self.numDefinedSequency, self.numGates, self.scanNumber, i)
                 Thread(target=self.gateDetector, name="MythenGatedCollection", args=(self.numFrames, self.numGates, self.scanNumber, i), kwargs={}).start()
                 sleep(1)
                 #self.startDetector(frequency, self.scanNumber, i)
                 if self.adc.getMode()=="Trigger":
                     print "enable adc sampling"
                     self.adc.enable()
                 #elif self.adc.getMode()=="Continuous":
                 self.startPEDataStreamer(self.filename+"_pe_"+str(i)+".h5", 1/frequency+TIME_FUDGE_FACTOR_IN_SECONDS)
                 self.tfg.start()
                 sleep(1/frequency+GDAPROCESSTIME)
         else:
             finder=Finder.getInstance()
             print "\nPlease start PSD collection from Mythen QT client ..."
             print "    1. select 'Gated' option in the 'Runs' box first"
             print "    2. then set 'Acquisition time' to %d, 'Repetitions' to %d" % (self.numGates, self.numFrames * self.numDefinedSequency*self.numCycles)
             print "    3. set 'Output Directory' to subdirector %s under 'processing' directory, 'File name root' to %d, 'Start index' to %d" % (finder.find("GDAMetadata").getMetadataValue("subdirectory"), self.scanNumber, 0)
             target = requestInput("Is PSD ready, Yes or No?")
             print str(target)
             if str(target)!="Yes":
                 raise "Exiting program"
             for j in range(self.startCycleNumber,self.numCycles):
                 self.pedata.reset()
                 self.pedata.setCollectionNumber(j)
                 #self.startDetector(frequency, self.scanNumber, j)
                 for i in range(self.startSeqNumber, self.numDefinedSequency):
                     GeneralCommands.pause()
                     sleep(4.0)
                     self.tfg.config_cycle_for_seq(i, self.numGates, 1)
                     sleep(4.0)
                     if self.adc.getMode()=="Trigger":
                         print "enable adc sampling"
                         self.adc.enable()
                     #elif self.adc.getMode()=="Continuous":
                     self.startPEDataStreamer(self.filename+"_pe_"+str(i)+".h5", 1/frequency*self.numGates+TIME_FUDGE_FACTOR_IN_SECONDS)
                     self.tfg.start()
                     sleep(1/frequency*self.numGates+GDAPROCESSTIME)
     except:
         self.stop()
         raise
     finally:
         print "close fast shutter %d" % time()
         self.fastshutter.moveTo("CLOSE")
         self.pedata.removeMonitors()
         print "collection completed at %d" % time()
예제 #21
0
파일: visit.py 프로젝트: kusamau/gda-core
 def datadir(self, *args):
     if len(args) > 0:
         raise ValueError(
             "The data directory now depends on the visit. Use the 'visit' command to change this."
         )
     return PathConstructor.createFromDefaultProperty()
예제 #22
0
파일: visit.py 프로젝트: openGDA/gda-core
 def datadir(self, *args):
     if len(args) > 0:
         raise ValueError("The data directory now depends on the visit. Use the 'visit' command to change this.")
     return PathConstructor.createFromDefaultProperty()
def nwf():
    '''query the next working file path root'''
    cwd = PathConstructor.createFromDefaultProperty()
    filenumber = i11NumTracker.getCurrentFileNumber();
    return os.path.join(cwd,str(filenumber+1))
def pwd():
    '''return the working directory'''
    cwd = PathConstructor.createFromDefaultProperty()
    return cwd
예제 #25
0
파일: visit.py 프로젝트: kusamau/gda-core
 def getVisitDirectory(self):
     return PathConstructor.createFromDefaultProperty()
예제 #26
0
def lwf():
    '''return the last working file path root'''
    cwd = PathConstructor.createFromDefaultProperty()
    filenumber = i11JNumTracker.getCurrentFileNumber();
    return os.path.join(cwd,str(filenumber))
예제 #27
0
def pescan(func=2,freq=0.125,amp=5.0,shift=0.0,symmetry=50.0,trig=1,bmode=0,bncycle=1,bstate=0,
           nprecycles=1,nptspercycle=40, det=mythen, ng=1, nf=1):

    #setup func generator 2
    fg2.setFunction(1)          # square wave
    fg2.setAmplitude(5.0)
    fg2.setShift(2.5)
    fg2.setDutyCycle(50.0)
    fg2.setTriggerSource(trig)
    fg2.setBurstState(0)        # switch off burst mode before change burst parameters
    if (freq<=0.125):              # slow HV ramping
        fg2.setFrequency(freq*nptspercycle)
        fg2.setBurstNCycle(nptspercycle)
    else:                       # fast HV ramping
        fg2.setFrequency(freq)
        fg2.setBurstNCycle(1)
    fg2.setBurstMode(bmode)
    fg2.setBurstState(1)        #switch on burst mode
    
    sleep(1)

    #setup func generator 1
    fg1.setFunction(func)       # 2 - ramp
    fg1.setFrequency(freq)
    fg1.setAmplitude(amp)
    fg1.setShift(shift)
    fg1.setSymmetry(symmetry)
    fg1.setTriggerSource(trig)
    fg1.setBurstState(bstate)   # switch off burst mode
    fg1.setBurstMode(bmode)
    fg1.setBurstNCycle(bncycle)
    
    sleep(1)

    #calculate acquisition parameters 
    fg1_frequency=fg1.getFrequency()
    fg1_period=1/fg1_frequency
    starttime=nprecycles * fg1_period
    stoptime=starttime+fg1_period       # only one cycle
    gatewidth=fg1_period/nptspercycle    # no need to minus file writing time as FIFO can buffer 4 frames
    
    #setup ADC to capture PE data
    peobject.addMonitor(1)
    peobject.setFirstData(True)
    
    #setup file name 
    directory=PathConstructor.createFromDefaultProperty()
    scanNumber=scanNumTracker.incrementNumber()
    peobject.setFilename(directory+(str(scanNumber)))

    #pre-conditioning
    evr.disable()
    timer=_Timer()
    timer.start()
    fg2.setOutput(1)
    fg1.setOutput(1)
    print "sample pre-conditioning cycles, please wait for %s" % starttime
    while(not timer.hasElapsed(starttime)):
        sleep(0.01)
    
    #collection
    collectionNumber=0    
    evr.enableField()
    try:
        if (freq<=0.125):               # 8sec period, 200ms per point
            peobject.reset()
            peobject.setFastMode(False)
            evr.moveTo([0.0,gatewidth-0.15])    #150 ms writing to disk allowed
            print "move event receiver to delay=%s width=%s" % (evr.getDelay(), evr.getWidth())
            print "start mythen %d" % time()
            pos fastshutter "OPEN"
            mythen.gated(nptspercycle, ng, scanNumber)
            pos fastshutter "CLOSE"
            peobject.save()       
        else:
            peobject.setFastMode(True)
            for t1 in frange(starttime, stoptime, gatewidth)[:-1]:
                #print t1
                peobject.reset()                             # reset the gate counter
                print "move event receiver to delay=%s width=%s" % (t1-starttime, gatewidth)
                evr.moveTo([t1-starttime,gatewidth])
                print "start mythen %d" % time()
                pos fastshutter "OPEN"
                mythen.gated(nf, ng, scanNumber, collectionNumber)  # block until all frames and gates are collected
                pos fastshutter "CLOSE"
                collectionNumber += 1
                peobject.save(collectionNumber)
                interruptable()                                     # allow "StopAll" to work
    except:
        raise
    finally:
        print "collection completed at %d" % time()
        peobject.removeMonitor()        # ensure monitor removed
        pestop()
 
    #stop ramp output
    fg2.setOutput(0)
    fg1.setOutput(0)
예제 #28
0
def wd():
    dir = PathConstructor.createFromDefaultProperty()
    return dir
예제 #29
0
def nwd():
    dir = PathConstructor.createFromDefaultProperty()
    filenumber = i11NumTracker.getCurrentFileNumber();
    return os.path.join(dir, str(filenumber + 1))
예제 #30
0
파일: visit.py 프로젝트: openGDA/gda-core
 def getVisitDirectory(self):
     return PathConstructor.createFromDefaultProperty()