Example #1
0
def processAndPlotEnergyCalibrationData(energyCalibrationData):
	x = energyCalibrationData['Peak']
	x_err = energyCalibrationData['PeakErr']
	y = energyCalibrationData['Energy']
	y_err = energyCalibrationData['EnergyErr']
	(fig, axes) = createEmptyPlottingArea(config.energy_x_axis_label, config.energy_y_axis_label, fontsize = config.fontsize, figWidth=config.plotwidth, figHeight=config.plotheight)
	axes.set_title(config.energytitle)
	addDataWithErrorBarsToPlot(axes, x, y, x_err=x_err, y_err=y_err, fmt=config.energyplotformat, label=config.energyplotlabel)
	axes.legend()
	fig.show()
	
	#find fit for energy calibration
	output = fitFunctionOdr(x, y, x_err, y_err, fitFunction=lineOdr, startingParameters=[0.2,10.0])
	
	params = output.beta
	param_std_dev = output.sd_beta #seems to calculated this for us already
	
	print (params, param_std_dev)
	energyCalibrationFit = FitData(TestData(['Param','Value','Std Dev'], ['a','b'], params, param_std_dev), output.cov_beta, energyCalibrationData, 'Peak', residualVariance=output.res_var, inverseConditionNumber=output.inv_condnum, relativeError=output.rel_error, haltingReasons='\n'.join(output.stopreason))
	
	(a,b) = params #fits for line
	fittedLine = fittedOdrFunction(lineOdr, params)
	addFunctionToPlot(axes, x, fittedLine, config.energyfitplotformat, label=config.energyfitplotlabel)
	axes.legend()
	fig.show()
	return energyCalibrationFit
Example #2
0
	def init(self, start, end):
		(fig,axes) = createEmptyPlottingArea(config.test_x_axis_label, config.test_y_axis_label, x_majorticks=config.test_x_majorticks, x_minorticks=config.test_x_minorticks, x_length=end-start, fontsize = config.fontsize, figWidth=config.plotwidth, figHeight=config.plotheight)
		self.fig = fig
		self.axes = axes
		self.start = start
		self.end = end