From 9a5acfd6f3438e3d59ced3c5833769bde5e3b588 Mon Sep 17 00:00:00 2001 From: sakul-45 <81963567+sakul-45@users.noreply.github.com> Date: Tue, 27 Jul 2021 14:38:34 +0200 Subject: [PATCH] finished basic functionality for printing figures --- .gitignore | 2 ++ print_figure_pdf.m | 63 ++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 3e3461a..392ae2d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ *.asv +*.pdf +*.xml diff --git a/print_figure_pdf.m b/print_figure_pdf.m index a53a380..7305ace 100644 --- a/print_figure_pdf.m +++ b/print_figure_pdf.m @@ -1,7 +1,60 @@ -function [outputArg1,outputArg2] = print_figure_pdf(inputArg1,inputArg2) -%PRINT_FIGURE_PDF Summary of this function goes here -% Detailed explanation goes here -outputArg1 = inputArg1; -outputArg2 = inputArg2; +function [] = print_figure_pdf(data,params,type) +%PRINT_FIGURE_PDF creates pdf figures of TREPR data +% +% Usage: PRINT_FIGURE_PDF(data,params,type), where data are TREPR data +% loaded by LOAD_MATLAB or LOAD_BRUKER, params is a struct created by +% SIMULATION_TREPR and type a number. +% +% type = 1: 2D plot of data and simulation with magnetic field as x-axis +% type = 2: 3D plot of data without simulation + +if type == 1 + %getting simulation values + 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 = params.Triplett_pop; + Sys = params.Fitted_Simulation; + %calculate simulation + [~,spec] = pepper(Sys,Exp); + spec_norm = spec/max(spec); % normalize the simulation + %plot invisible and print + figure('Visible','off') + plot(0.1*params.Field_Vector,params.max_mean,'r',... + 0.1*params.Field_Vector,spec_norm,'b','LineWidth',1.2) + xlabel 'Magnetic Field / mT' + ylabel 'EPR signal / A. U.' + legend('experimental','simulation') + title(params.Name, 'Interpreter','none') + axis tight + set(gcf,'Units','Inches'); + pos = get(gcf,'Position'); + set(gcf,'PaperPositionMode','Auto','PaperUnits','Inches','PaperSize',[pos(3), pos(4)]); + figurepath = strcat(params.Path,"/",params.Name,"_Sim.pdf"); %create full filename + print(gcf,figurepath,'-dpdf','-r0'); + +elseif type == 2 + %plot invisible and print + figure('Visible','off') + surf(0.1*params.Field_Vector, params.TimeBase*1e6, data) + colormap default + shading interp + view(305,10) + axis tight + xlabel 'Magnetic Field / mT' + ylabel 'Time / \mus' + zlabel 'EPR Signal / A.U.' + title(params.Name, 'Interpreter','none') + set(gcf,'Units','Inches'); + pos = get(gcf,'Position'); + set(gcf,'PaperPositionMode','Auto','PaperUnits','Inches','PaperSize',[pos(3), pos(4)]); + figurepath = strcat(params.Path,"/",params.Name,"_3D.pdf"); %create full filename + print(gcf,figurepath,'-dpdf','-r0'); + +else + error('Unknown plot type.'); +end + end