コード例 #1
0
	def plot_series(self,voltages, dt, timestamp):
		
		times = self.card.get_times(dt, len(voltages))
		fig, [ax1,ax2] = plt.subplots(2)
		
		threshold = 0.4

		photon_count = dls_signal_postprocessing.count_photons(voltages,count_threshold=threshold)
		ax1.plot(times, voltages)
		ax1.set_xlabel("Time [s]")
		ax1.set_ylabel("Voltage [V]")
		ax1.set_title("Adlink9812 Capture, Timestamp: {0}, Photons: {1}".format(timestamp,photon_count))
		
		d_voltages = dls_signal_postprocessing.signal_diff(voltages)

		vmin = np.min(voltages)
		vmax = np.max(voltages)
		vspan = abs(vmax-vmin)

		voltages, dt = self.card.capture(sample_freq=self.sample_freq, sample_count=self.sample_count)

		ax2.plot(times[0:len(d_voltages)],abs(d_voltages))
		ax2.plot(times[0:len(d_voltages)],[threshold*vspan]*len(d_voltages),'r',label="count threshold")
		ax2.set_xlabel("Time [s]")
		ax2.set_ylabel("|$\Delta$Voltage| [V]")
		ax2.legend()
		ax2.set_title("Difference voltage plot".format(timestamp,photon_count))

		plt.tight_layout()
		plt.show()
		return
コード例 #2
0
ファイル: adlink9812.py プロジェクト: ivanalam/nplab
    def postprocess(self, voltages, dt, save, group, metadata):

        attributes = dict(metadata)

        #initial system parameters
        sample_count = len(voltages)
        sample_time = dt * sample_count

        #take difference of voltages
        rounded_diff = dls_signal_postprocessing.signal_diff(voltages)

        #thresholding
        thresholded = np.absolute(rounded_diff).astype(int)

        #binning
        time_bin_width = self.bin_width
        index_bin_width = dls_signal_postprocessing.binwidth_time_to_index(
            time_bin_width, dt)
        binned_counts = dls_signal_postprocessing.binning(
            thresholded=thresholded, index_bin_width=index_bin_width)
        time_bins = time_bin_width * np.arange(0, len(binned_counts))

        total_counts = np.sum(binned_counts)
        count_rate = float(total_counts) / float(sample_time)
        self.log("\tCounts: {0:.3g}, Rate:{1:.3g}".format(
            total_counts, count_rate))
        #correlation
        #note - truncating delay t=0, this is the zero frequency - not interesting
        times = time_bins[1:]
        autocorrelation = dls_signal_postprocessing.autocorrelation(
            binned_counts)[1:]

        #save data
        attributes.update({"averaged_data": "False"})
        stages = [("raw_voltage", self.raw_checkbox.isChecked(), voltages,
                   attributes),
                  ("voltage_difference", self.difference_checkbox.isChecked(),
                   rounded_diff, attributes),
                  ("photon_counts", self.binning_checkbox.isChecked(),
                   np.vstack((time_bins, binned_counts)), attributes),
                  ("autocorrelation", self.correlate_checkbox.isChecked(),
                   np.vstack((times, autocorrelation)), attributes)]
        for (datatype, checked, data, mdata) in stages:
            if save == True and checked == True:
                self.save_data(datatype=datatype,
                               data=data,
                               group=group,
                               metadata=mdata)
        return times, autocorrelation
コード例 #3
0
ファイル: adlink9812.py プロジェクト: ivanalam/nplab
    def current_count_rate(self):
        #measure for 0.05s for sampling photon count

        #fixed values of sampling - we want to keep things easy
        frequency = 2e7  #20MHz
        sample_count = int(1e6)  #0.05s
        voltages, dt = self.card.capture(sample_freq=frequency,
                                         sample_count=sample_count)
        sample_time = dt * sample_count
        #convert rounded difference to integers
        thresholded = np.absolute(
            dls_signal_postprocessing.signal_diff(voltages)).astype(int)
        total_counts = np.sum(thresholded)
        count_rate = old_div(total_counts, sample_time)
        self.log("Total Counts: {0} [counts], Rate: {1} [counts/s]".format(
            int(total_counts), count_rate))
        return total_counts, count_rate
コード例 #4
0
	def postprocess_difference(self,voltages,dt,save,plot,group,axes):
		#record/plot raw
		self.postprocess_raw(voltages=voltages,dt=dt,save=save,plot=plot,group=group,axes=axes[0:-1])
		
		#compute rounded difference
		rounded_diff = dls_signal_postprocessing.signal_diff(voltages)
		#metaparameters
		total_counts = np.sum(np.absolute(rounded_diff))
		sample_time_interval = dt*self.sample_count
		count_frequency = total_counts/float(sample_time_interval)

		print "---Difference---"

		attrs = attrs = {
			
			"device": "adlink9812",
			"type": "difference",
			"_units": "none",
			"total_counts" : total_counts,
			"sampling_time_interval":dt*self.sample_count,
			"count_frequency" : count_frequency,
			"X label": "Sample Index",
			"Y label": "Normalized Voltage Difference [V]"
			}
		if save and self.difference_checkbox.isChecked():
			print "Saving Difference stage"
			group.create_dataset("diff_voltage",data=rounded_diff, attrs = attrs)
			group.file.flush()

		if plot and self.difference_checkbox.isChecked():
			print "Plotting Difference stage"
			times = dt*np.arange(0,self.sample_count-1)
			axes[-1].plot(times,rounded_diff,'x')
			axes[-1].set_xlabel("Time [s] (interval lower bound)")
			axes[-1].set_ylabel("Voltage difference [V]")

		print "Total Counts:", total_counts
		print "Sampling Time Interval:", sample_time_interval
		print "Count freuquency:", count_frequency

		print "---/Difference---"

		return rounded_diff