138 lines
4.5 KiB
Matlab
138 lines
4.5 KiB
Matlab
% high-spin S=1 simulation
|
|
% Inputs requested in command line at certain points
|
|
|
|
clear variables
|
|
close all
|
|
|
|
%% Baseline Correcting
|
|
% loading Data
|
|
path = input('Path to dataset: ','s');
|
|
load(path)
|
|
|
|
whos % what variables have been loaded
|
|
params % what information is contained in the structure called 'params'
|
|
|
|
% plot the raw data & check the number of points before the signal (pre-trigger)
|
|
plot(Data)
|
|
title('raw data')
|
|
|
|
% substract the pre-trigger
|
|
pre_trigger = input('Number of pre-trigger points: ');
|
|
signal_baseline_field = bsxfun(@minus, Data, mean(Data(1:pre_trigger,:)));
|
|
plot(signal_baseline_field) % plot the corrected data set
|
|
title('corrected data')
|
|
return
|
|
|
|
% plot the transpose and check the number of points to the lower and higher fields of the signal
|
|
% plot(signal_baseline_field')
|
|
% use the smaller value below
|
|
% return
|
|
|
|
% BASLINE correction
|
|
time_points = 140; % number of points from the plot above
|
|
l1 = mean(signal_baseline_field(:,1:time_points),2); % calculate the mean on the left along the time axis
|
|
l2 = mean(signal_baseline_field(:,end-time_points:end),2); %calculate the mean on the right along the time axis
|
|
baseline_time = (l1 +l2)/2; %take the average
|
|
|
|
signal_baseline_field_time = bsxfun(@minus, signal_baseline_field, baseline_time); % subtract the background in the time-domain
|
|
|
|
% plot the corrected data set
|
|
% plot(signal_baseline_field_time')
|
|
% return
|
|
|
|
% plot the transpose to find the region of maximum signal. Use this below
|
|
% plot(signal_baseline_field_time)
|
|
% return
|
|
|
|
% contour plot: The index gives the number of contours
|
|
% contourf(signal_baseline_field_time,6)
|
|
% return
|
|
|
|
%%
|
|
figure(1)
|
|
set(gcf,'PaperUnits','centimeters')
|
|
set(gcf,'Position',[0,0,750, 750])
|
|
set(gcf,'InvertHardcopy','off','Color',[1 1 1])
|
|
set(0,'DefaultAxesFontSize', 14,'DefaultAxesLineWidth',2)
|
|
|
|
% contour plot: add the time and field axes
|
|
subplot(2,1,2)
|
|
contourf(0.1*params.Field_Vector, TimeBase*1e6 ,signal_baseline_field_time,'LineColor','none')
|
|
|
|
% contour plot: add the time and field axes
|
|
% surf(0.1*params.Field_Vector, TimeBase*1e6 ,signal_baseline_field_time)
|
|
% colormap default
|
|
% shading interp
|
|
|
|
xlabel('Magnetic Field / mT')
|
|
ylabel('Time / \mus')
|
|
% colorbar
|
|
% print('TR_EPR_Chichibabin_80K_frozen_solution_532_01_3D' , '-dpng', '-r300')
|
|
% return
|
|
|
|
subplot(2,1,1)
|
|
|
|
% take the mean over the maxium region. You can decide how wide it is
|
|
signal_baseline_field_time_mean = (mean(signal_baseline_field_time(1300:1390,:)));
|
|
% normalise the amplitude to 1
|
|
signal_baseline_field_time_mean_norm = signal_baseline_field_time_mean/max(signal_baseline_field_time_mean);
|
|
% plot the spectrum
|
|
plot(0.1*params.Field_Vector,signal_baseline_field_time_mean_norm,'LineWidth',2)
|
|
|
|
xlabel('Magnetic Field / mT')
|
|
|
|
axis('tight')
|
|
box off
|
|
return
|
|
|
|
% print('TR_EPR_Chichibabin_80K_frozen_solution_570_01' , '-dpng', '-r300')
|
|
return
|
|
%% Simulation section. Use the "Run Section" button to avoid running the previous section every time
|
|
|
|
Exp.mwFreq = params.mwFreq; % GHz
|
|
Exp.nPoints = length(params.Field_Vector);
|
|
Exp.CenterSweep = 0.1*[params.Field_Center params.Field_Sweep]; % mT (converted from Gauss)
|
|
Exp.Harmonic = 0; % zeroth harmonic
|
|
|
|
Exp.Temperature = [0 0.67 0.33]; % populations of the triplet sub-levels. These need to be varied manually to get the right shape
|
|
|
|
Sys.S = 1; % Total Spin
|
|
Sys.g = 1.9951; % needs to be optimised
|
|
Sys.D = [2148.02 75.35]; % mT; The D and E values need to be optimised
|
|
Sys.lw = [8.1034 0]; % mT; linewidth needs to be optimised
|
|
|
|
Vary.g = 0.01;
|
|
Vary.D = [10 10];
|
|
Vary.lw = [1 0];
|
|
|
|
FitOpt.Method = 'simplex fcn';
|
|
FitOpt.Scaling = 'lsq';
|
|
|
|
% When you have got a good fit by eye, use esfit to optimise
|
|
% esfit('pepper',signal_baseline_field_time_mean_norm,Sys,Vary,Exp,[],FitOpt);%fitting route
|
|
% return
|
|
|
|
[bfield,spec] = pepper(Sys,Exp); % perform a simulation with the parameters above
|
|
spec_norm = spec/max(spec); % normalize the simulation
|
|
|
|
figure(2)
|
|
set (gcf,'PaperUnits','centimeters')
|
|
set (gcf,'Position',[-900,100,800,400]) % set the position, size and shape of the plot
|
|
set (gcf,'InvertHardcopy','off','Color',[1 1 1])
|
|
set(0,'DefaultAxesFontSize', 16,'DefaultAxesLineWidth',1.5)
|
|
|
|
plot(0.1*params.Field_Vector,signal_baseline_field_time_mean_norm,'r', bfield,spec_norm,'b','LineWidth',1);
|
|
axis('tight')
|
|
|
|
legend('experimental','simulation')
|
|
legend boxoff
|
|
xlabel('Magnetic Field / mT')
|
|
ylabel('EPR signal / A. U.')
|
|
set(gca,'Box','Off','XMinorTick','On',...
|
|
'YMinorTick','On','TickDir','Out','YColor','k')
|
|
return
|
|
|
|
set(gcf,'Units','Inches');
|
|
pos = get(gcf,'Position');
|
|
set(gcf,'PaperPositionMode','Auto','PaperUnits','Inches','PaperSize',[pos(3), pos(4)]);
|
|
print(gcf,'..\Abbildungen\Regression5','-dpdf','-r0'); |