Compare commits

...

2 Commits

Author SHA1 Message Date
d4c8b6a98c Add h5 files and correct h5scan script 2025-04-15 10:16:29 +02:00
2e4d714206 Add inkscape directory 2025-04-15 10:16:18 +02:00
16 changed files with 156 additions and 220 deletions

18
figs/inkscape/convert_svg.sh Executable file
View File

@ -0,0 +1,18 @@
#!/bin/bash
# Directory containing SVG files
INPUT_DIR="."
# Loop through all SVG files in the directory
for svg_file in "$INPUT_DIR"/*.svg; do
# Check if there are SVG files in the directory
if [ -f "$svg_file" ]; then
# Output PDF file name
pdf_file="../${svg_file%.svg}.pdf"
png_file="../${svg_file%.svg}"
# Convert SVG to PDF using Inkscape
inkscape "$svg_file" --export-filename="$pdf_file" && \
pdftocairo -png -singlefile -cropbox "$pdf_file" "$png_file"
fi
done

View File

Before

Width:  |  Height:  |  Size: 20 MiB

After

Width:  |  Height:  |  Size: 20 MiB

View File

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,102 +1,61 @@
function [cntrs,tp] = h5scan(pth,smp,ds,sn,varargin) % function [cntrs,tp] = h5scan(pth,smp,ds,sn,varargin)
function [cntrs,tp] = h5scan(ds,sn)
i = cellfun(@(x) isa(x,'detector'),varargin);
if any(i), det = varargin{i}; varargin = varargin(~i); else, det = []; end;
if ~isstr(ds), ds = sprintf('%.4d',ds); end; if ~isstr(ds), ds = sprintf('%.4d',ds); end;
f = sprintf('%s/%s/%s_%s/%s_%s.h5',pth,smp,smp,ds,smp,ds); f = sprintf('%s.h5',ds);
h = h5info(f,sprintf('/%d.1/measurement',sn)); h = h5info(f,sprintf('/%d.1/measurement',sn));
fid = H5F.open(f); fid = H5F.open(f);
for i = 1:length(h.Links), for i = 1:length(h.Links)
nm = h.Links(i).Name; nm = h.Links(i).Name;
try, try
id = H5D.open(fid,h.Links(i).Value{1}); id = H5D.open(fid,h.Links(i).Value{1});
cntrs.(nm) = H5D.read(id); cntrs.(nm) = H5D.read(id);
H5D.close(id); H5D.close(id);
if ~isempty(det) & strcmp(nm,det.name), cntrs.(nm) = integrate(det,double(cntrs.(nm))); end; if ~isempty(det) & strcmp(nm,det.name), cntrs.(nm) = integrate(det,double(cntrs.(nm))); end;
catch, end
warning('solving problem with %s\n',nm);
cntrs.(nm) = vrtlds(sprintf('%s/%s/%s_%s/scan%.4d/',pth,smp,smp,ds,sn),nm,det);
end;
[~,tp.(nm)] = fileparts(h.Links(i).Value{1}); [~,tp.(nm)] = fileparts(h.Links(i).Value{1});
end; end
try, try
h = h5info(f,sprintf('/%d.2/measurement',sn)); h = h5info(f,sprintf('/%d.2/measurement',sn));
catch, catch
h = []; h = [];
end; end
if ~isempty(h), if ~isempty(h)
for i = 1:length(h.Links), for i = 1:length(h.Links)
nm = h.Links(i).Name; nm = h.Links(i).Name;
try, try
id = H5D.open(fid,h.Links(i).Value{1}); id = H5D.open(fid,h.Links(i).Value{1});
cntrs.part2.(nm) = H5D.read(id); cntrs.part2.(nm) = H5D.read(id);
H5D.close(id); H5D.close(id);
catch, end
warning('solving problem with %s\n',nm);
cntrs.part2.(nm) = vrtlds(sprintf('%s/%s/%s_%s/scan%.4d/',pth,smp,smp,ds,sn),nm,det);
end;
[~,tp.part2.(nm)] = fileparts(h.Links(i).Value{1}); [~,tp.part2.(nm)] = fileparts(h.Links(i).Value{1});
end; end
end; end
if length(varargin),
fn = sprintf('/%d.1/instrument/positioners/',sn);
h = h5info(f,fn);
[~,k,m] = intersect({h.Datasets.Name},varargin,'stable');
h.Datasets = h.Datasets(k);
for i = 1:length(h.Datasets),
id = H5D.open(fid,[fn h.Datasets(i).Name]);
cntrs.(h.Datasets(i).Name) = H5D.read(id);
H5D.close(id);
end;
end;
H5F.close(fid); H5F.close(fid);
%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%
function A = vrtlds(f,nm,det) function A = vrtlds(f,nm,det)
%try,
n = 0; A = []; n = 0; A = [];
fn = sprintf('%s/%s_%.4d.h5',f,nm,n); fn = sprintf('%s/%s_%.4d.h5',f,nm,n);
while exist(fn) == 2,
while exist(fn) == 2
fid = H5F.open(fn); n = n+1; fid = H5F.open(fn); n = n+1;
id = H5D.open(fid,sprintf('/entry_0000/ESRF-ID31/%s/data',nm)); id = H5D.open(fid,sprintf('/entry_0000/ESRF-ID31/%s/data',nm));
if 2 < nargin & strcmp(nm,'p3') & ~isempty(det), if 2 < nargin & strcmp(nm,'p3') & ~isempty(det)
fprintf('integrating %s\n',fn); fprintf('integrating %s\n',fn);
if isempty(A), if isempty(A)
A = integrate(det,double(H5D.read(id)),1); A = integrate(det,double(H5D.read(id)),1);
else, else
tmp = integrate(det,double(H5D.read(id)),1); A.y = cat(2,A.y,tmp.y); A.y0 = cat(2,A.y0,tmp.y0); tmp = integrate(det,double(H5D.read(id)),1); A.y = cat(2,A.y,tmp.y); A.y0 = cat(2,A.y0,tmp.y0);
end; end
else, else
fprintf('loading %s\n',fn); fprintf('loading %s\n',fn);
A = cat(3,A,H5D.read(id)); A = cat(3,A,H5D.read(id));
end; end
H5D.close(id); H5F.close(fid); H5D.close(id); H5F.close(fid);
fn = sprintf('%s/%s_%.4d.h5',f,nm,n); fn = sprintf('%s/%s_%.4d.h5',f,nm,n);
end; end
%catch, end
% A = []; end
%end;
% fid = H5F.open...
% id = H5D.open...
% sid = H5D.get_space(id);
% [ndims,h5_dims]=H5S.get_simple_extent_dims(sid)
% Read a 2x3 hyperslab of data from a dataset, starting in the 4th row and 5th column of the example dataset.
% Create a property list identifier, then open the HDF5 file and the dataset /g1/g1.1/dset1.1.1.
% fid = H5F.open('example.h5');
% id = H5D.open(fid,'/g1/g1.1/dset1.1.1');
% dims = ([500 1679 1475];
% msid = H5S.create_simple(3,dims,[]);
% sid = H5D.get_space(id);
% offset = [n*500 0 0];
% block = dims; % d1: 500 or min(d1tot-n*500,500)
% H5S.select_hyperslab(sid,'H5S_SELECT_SET',offset,[],[],block);
% data = H5D.read(id,'H5ML_DEFAULT',msid,sid,'H5P_DEFAULT');
% H5D.close(id);
% H5F.close(fid);

View File

@ -46,9 +46,9 @@ Hm = [ 0 1 0 -l2 0;
%% Angular alignment %% Angular alignment
% Load Data % Load Data
data_it0 = h5scan(data_dir, 'alignment', 'h1rx_h1ry', 1); data_it0 = h5scan('alignment_h1rx_h1ry', 1);
data_it1 = h5scan(data_dir, 'alignment', 'h1rx_h1ry_0002', 3); data_it1 = h5scan('alignment_h1rx_h1ry_0002', 3);
data_it2 = h5scan(data_dir, 'alignment', 'h1rx_h1ry_0002', 5); data_it2 = h5scan('alignment_h1rx_h1ry_0002', 5);
% Offset wrong points % Offset wrong points
i_it0 = find(abs(data_it0.Rx_int_filtered(2:end)-data_it0.Rx_int_filtered(1:end-1))>1e-5); i_it0 = find(abs(data_it0.Rx_int_filtered(2:end)-data_it0.Rx_int_filtered(1:end-1))>1e-5);
@ -81,8 +81,8 @@ ylim([-100, 800]);
%% Eccentricity alignment %% Eccentricity alignment
% Load Data % Load Data
data_it0 = h5scan(data_dir, 'alignment', 'h1rx_h1ry_0002', 5); data_it0 = h5scan('alignment_h1rx_h1ry_0002', 5);
data_it1 = h5scan(data_dir, 'alignment', 'h1dx_h1dy', 1); data_it1 = h5scan('alignment_h1dx_h1dy', 1);
% Offset wrong points % Offset wrong points
i_it0 = find(abs(data_it0.Dy_int_filtered(2:end)-data_it0.Dy_int_filtered(1:end-1))>1e-5); i_it0 = find(abs(data_it0.Dy_int_filtered(2:end)-data_it0.Dy_int_filtered(1:end-1))>1e-5);
@ -110,7 +110,7 @@ ylim([-8, 14]);
% This is estimated by moving the spheres using the micro-hexapod % This is estimated by moving the spheres using the micro-hexapod
% Dx % Dx
data_dx = h5scan(data_dir, 'metrology_acceptance_new_align', 'dx', 1); data_dx = h5scan('metrology_acceptance_new_align_dx', 1);
dx_acceptance = zeros(5,1); dx_acceptance = zeros(5,1);
@ -126,7 +126,7 @@ for i = [1:size(dx_acceptance, 1)]
end end
% Dy % Dy
data_dy = h5scan(data_dir, 'metrology_acceptance_new_align', 'dy', 1); data_dy = h5scan('metrology_acceptance_new_align_dy', 1);
dy_acceptance = zeros(5,1); dy_acceptance = zeros(5,1);
@ -142,7 +142,7 @@ for i = [1:size(dy_acceptance, 1)]
end end
% Dz % Dz
data_dz = h5scan(data_dir, 'metrology_acceptance_new_align', 'dz', 1); data_dz = h5scan('metrology_acceptance_new_align_dz', 1);
dz_acceptance = zeros(5,1); dz_acceptance = zeros(5,1);
@ -186,7 +186,7 @@ leg = legend('location', 'northeast', 'FontSize', 8, 'NumColumns', 1);
leg.ItemTokenSize(1) = 15; leg.ItemTokenSize(1) = 15;
%% X-Y scan with the micro-hexapod, and record of the vertical interferometer %% X-Y scan with the micro-hexapod, and record of the vertical interferometer
data = h5scan(data_dir, 'metrology_acceptance', 'after_int_align_meshXY', 1); data = h5scan('metrology_acceptance_after_int_align_meshXY', 1);
x = 1e3*detrend(data.h1tx, 0); % [um] x = 1e3*detrend(data.h1tx, 0); % [um]
y = 1e3*detrend(data.h1ty, 0); % [um] y = 1e3*detrend(data.h1ty, 0); % [um]

View File

@ -198,10 +198,10 @@ linkaxes([ax1,ax2],'x');
xlim([1, 1e3]); xlim([1, 1e3]);
%% Load Data %% Load Data
data_1_dx = h5scan(data_dir, 'align_int_enc_Rz', 'tx_first_scan', 2); data_1_dx = h5scan('align_int_enc_Rz_tx_first_scan', 2);
data_1_dy = h5scan(data_dir, 'align_int_enc_Rz', 'tx_first_scan', 3); data_1_dy = h5scan('align_int_enc_Rz_tx_first_scan', 3);
data_2_dx = h5scan(data_dir, 'align_int_enc_Rz', 'verif-after-correct-offset', 1); data_2_dx = h5scan('align_int_enc_Rz_verif-after-correct-offset', 1);
data_2_dy = h5scan(data_dir, 'align_int_enc_Rz', 'verif-after-correct-offset', 2); data_2_dy = h5scan('align_int_enc_Rz_verif-after-correct-offset', 2);
% Estimation of Rz misalignment % Estimation of Rz misalignment
p1 = polyfit(data_1_dx.Dx_int_filtered, data_1_dx.Dy_int_filtered, 1); p1 = polyfit(data_1_dx.Dx_int_filtered, data_1_dx.Dy_int_filtered, 1);

View File

@ -685,9 +685,9 @@ The remaining errors after alignment are in the order of $\pm5\,\mu\text{rad}$ i
#+begin_src matlab #+begin_src matlab
%% Angular alignment %% Angular alignment
% Load Data % Load Data
data_it0 = h5scan(data_dir, 'alignment', 'h1rx_h1ry', 1); data_it0 = h5scan('alignment_h1rx_h1ry', 1);
data_it1 = h5scan(data_dir, 'alignment', 'h1rx_h1ry_0002', 3); data_it1 = h5scan('alignment_h1rx_h1ry_0002', 3);
data_it2 = h5scan(data_dir, 'alignment', 'h1rx_h1ry_0002', 5); data_it2 = h5scan('alignment_h1rx_h1ry_0002', 5);
% Offset wrong points % Offset wrong points
i_it0 = find(abs(data_it0.Rx_int_filtered(2:end)-data_it0.Rx_int_filtered(1:end-1))>1e-5); i_it0 = find(abs(data_it0.Rx_int_filtered(2:end)-data_it0.Rx_int_filtered(1:end-1))>1e-5);
@ -728,8 +728,8 @@ exportFig('figs/test_id31_metrology_align_rx_ry.pdf', 'width', 'half', 'height',
#+begin_src matlab #+begin_src matlab
%% Eccentricity alignment %% Eccentricity alignment
% Load Data % Load Data
data_it0 = h5scan(data_dir, 'alignment', 'h1rx_h1ry_0002', 5); data_it0 = h5scan('alignment_h1rx_h1ry_0002', 5);
data_it1 = h5scan(data_dir, 'alignment', 'h1dx_h1dy', 1); data_it1 = h5scan('alignment_h1dx_h1dy', 1);
% Offset wrong points % Offset wrong points
i_it0 = find(abs(data_it0.Dy_int_filtered(2:end)-data_it0.Dy_int_filtered(1:end-1))>1e-5); i_it0 = find(abs(data_it0.Dy_int_filtered(2:end)-data_it0.Dy_int_filtered(1:end-1))>1e-5);
@ -793,7 +793,7 @@ The obtained lateral acceptance for pure displacements in any direction is estim
% This is estimated by moving the spheres using the micro-hexapod % This is estimated by moving the spheres using the micro-hexapod
% Dx % Dx
data_dx = h5scan(data_dir, 'metrology_acceptance_new_align', 'dx', 1); data_dx = h5scan('metrology_acceptance_new_align_dx', 1);
dx_acceptance = zeros(5,1); dx_acceptance = zeros(5,1);
@ -809,7 +809,7 @@ for i = [1:size(dx_acceptance, 1)]
end end
% Dy % Dy
data_dy = h5scan(data_dir, 'metrology_acceptance_new_align', 'dy', 1); data_dy = h5scan('metrology_acceptance_new_align_dy', 1);
dy_acceptance = zeros(5,1); dy_acceptance = zeros(5,1);
@ -825,7 +825,7 @@ for i = [1:size(dy_acceptance, 1)]
end end
% Dz % Dz
data_dz = h5scan(data_dir, 'metrology_acceptance_new_align', 'dz', 1); data_dz = h5scan('metrology_acceptance_new_align_dz', 1);
dz_acceptance = zeros(5,1); dz_acceptance = zeros(5,1);
@ -920,7 +920,7 @@ exportFig('figs/test_id31_interf_noise.pdf', 'width', 'half', 'height', 'normal'
#+begin_src matlab #+begin_src matlab
%% X-Y scan with the micro-hexapod, and record of the vertical interferometer %% X-Y scan with the micro-hexapod, and record of the vertical interferometer
data = h5scan(data_dir, 'metrology_acceptance', 'after_int_align_meshXY', 1); data = h5scan('metrology_acceptance_after_int_align_meshXY', 1);
x = 1e3*detrend(data.h1tx, 0); % [um] x = 1e3*detrend(data.h1tx, 0); % [um]
y = 1e3*detrend(data.h1ty, 0); % [um] y = 1e3*detrend(data.h1ty, 0); % [um]
@ -1305,10 +1305,10 @@ Results shown in Figure ref:fig:test_id31_Rz_align_correct are indeed indicating
#+begin_src matlab #+begin_src matlab
%% Load Data %% Load Data
data_1_dx = h5scan(data_dir, 'align_int_enc_Rz', 'tx_first_scan', 2); data_1_dx = h5scan('align_int_enc_Rz_tx_first_scan', 2);
data_1_dy = h5scan(data_dir, 'align_int_enc_Rz', 'tx_first_scan', 3); data_1_dy = h5scan('align_int_enc_Rz_tx_first_scan', 3);
data_2_dx = h5scan(data_dir, 'align_int_enc_Rz', 'verif-after-correct-offset', 1); data_2_dx = h5scan('align_int_enc_Rz_verif-after-correct-offset', 1);
data_2_dy = h5scan(data_dir, 'align_int_enc_Rz', 'verif-after-correct-offset', 2); data_2_dy = h5scan('align_int_enc_Rz_verif-after-correct-offset', 2);
#+end_src #+end_src
#+begin_src matlab #+begin_src matlab
@ -5208,108 +5208,67 @@ specs_ry_rms = 0.25; % [urad RMS]
:header-args:matlab+: :comments none :mkdirp yes :eval no :header-args:matlab+: :comments none :mkdirp yes :eval no
:END: :END:
#+begin_src matlab #+begin_src matlab
function [cntrs,tp] = h5scan(pth,smp,ds,sn,varargin) % function [cntrs,tp] = h5scan(pth,smp,ds,sn,varargin)
function [cntrs,tp] = h5scan(ds,sn)
i = cellfun(@(x) isa(x,'detector'),varargin);
if any(i), det = varargin{i}; varargin = varargin(~i); else, det = []; end;
if ~isstr(ds), ds = sprintf('%.4d',ds); end; if ~isstr(ds), ds = sprintf('%.4d',ds); end;
f = sprintf('%s/%s/%s_%s/%s_%s.h5',pth,smp,smp,ds,smp,ds); f = sprintf('%s.h5',ds);
h = h5info(f,sprintf('/%d.1/measurement',sn)); h = h5info(f,sprintf('/%d.1/measurement',sn));
fid = H5F.open(f); fid = H5F.open(f);
for i = 1:length(h.Links), for i = 1:length(h.Links)
nm = h.Links(i).Name; nm = h.Links(i).Name;
try, try
id = H5D.open(fid,h.Links(i).Value{1}); id = H5D.open(fid,h.Links(i).Value{1});
cntrs.(nm) = H5D.read(id); cntrs.(nm) = H5D.read(id);
H5D.close(id); H5D.close(id);
if ~isempty(det) & strcmp(nm,det.name), cntrs.(nm) = integrate(det,double(cntrs.(nm))); end; if ~isempty(det) & strcmp(nm,det.name), cntrs.(nm) = integrate(det,double(cntrs.(nm))); end;
catch, end
warning('solving problem with %s\n',nm);
cntrs.(nm) = vrtlds(sprintf('%s/%s/%s_%s/scan%.4d/',pth,smp,smp,ds,sn),nm,det);
end;
[~,tp.(nm)] = fileparts(h.Links(i).Value{1}); [~,tp.(nm)] = fileparts(h.Links(i).Value{1});
end; end
try, try
h = h5info(f,sprintf('/%d.2/measurement',sn)); h = h5info(f,sprintf('/%d.2/measurement',sn));
catch, catch
h = []; h = [];
end; end
if ~isempty(h), if ~isempty(h)
for i = 1:length(h.Links), for i = 1:length(h.Links)
nm = h.Links(i).Name; nm = h.Links(i).Name;
try, try
id = H5D.open(fid,h.Links(i).Value{1}); id = H5D.open(fid,h.Links(i).Value{1});
cntrs.part2.(nm) = H5D.read(id); cntrs.part2.(nm) = H5D.read(id);
H5D.close(id); H5D.close(id);
catch, end
warning('solving problem with %s\n',nm);
cntrs.part2.(nm) = vrtlds(sprintf('%s/%s/%s_%s/scan%.4d/',pth,smp,smp,ds,sn),nm,det);
end;
[~,tp.part2.(nm)] = fileparts(h.Links(i).Value{1}); [~,tp.part2.(nm)] = fileparts(h.Links(i).Value{1});
end; end
end; end
if length(varargin),
fn = sprintf('/%d.1/instrument/positioners/',sn);
h = h5info(f,fn);
[~,k,m] = intersect({h.Datasets.Name},varargin,'stable');
h.Datasets = h.Datasets(k);
for i = 1:length(h.Datasets),
id = H5D.open(fid,[fn h.Datasets(i).Name]);
cntrs.(h.Datasets(i).Name) = H5D.read(id);
H5D.close(id);
end;
end;
H5F.close(fid); H5F.close(fid);
%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%
function A = vrtlds(f,nm,det) function A = vrtlds(f,nm,det)
%try,
n = 0; A = []; n = 0; A = [];
fn = sprintf('%s/%s_%.4d.h5',f,nm,n); fn = sprintf('%s/%s_%.4d.h5',f,nm,n);
while exist(fn) == 2,
while exist(fn) == 2
fid = H5F.open(fn); n = n+1; fid = H5F.open(fn); n = n+1;
id = H5D.open(fid,sprintf('/entry_0000/ESRF-ID31/%s/data',nm)); id = H5D.open(fid,sprintf('/entry_0000/ESRF-ID31/%s/data',nm));
if 2 < nargin & strcmp(nm,'p3') & ~isempty(det), if 2 < nargin & strcmp(nm,'p3') & ~isempty(det)
fprintf('integrating %s\n',fn); fprintf('integrating %s\n',fn);
if isempty(A), if isempty(A)
A = integrate(det,double(H5D.read(id)),1); A = integrate(det,double(H5D.read(id)),1);
else, else
tmp = integrate(det,double(H5D.read(id)),1); A.y = cat(2,A.y,tmp.y); A.y0 = cat(2,A.y0,tmp.y0); tmp = integrate(det,double(H5D.read(id)),1); A.y = cat(2,A.y,tmp.y); A.y0 = cat(2,A.y0,tmp.y0);
end; end
else, else
fprintf('loading %s\n',fn); fprintf('loading %s\n',fn);
A = cat(3,A,H5D.read(id)); A = cat(3,A,H5D.read(id));
end; end
H5D.close(id); H5F.close(fid); H5D.close(id); H5F.close(fid);
fn = sprintf('%s/%s_%.4d.h5',f,nm,n); fn = sprintf('%s/%s_%.4d.h5',f,nm,n);
end; end
%catch, end
% A = []; end
%end;
% fid = H5F.open...
% id = H5D.open...
% sid = H5D.get_space(id);
% [ndims,h5_dims]=H5S.get_simple_extent_dims(sid)
% Read a 2x3 hyperslab of data from a dataset, starting in the 4th row and 5th column of the example dataset.
% Create a property list identifier, then open the HDF5 file and the dataset /g1/g1.1/dset1.1.1.
% fid = H5F.open('example.h5');
% id = H5D.open(fid,'/g1/g1.1/dset1.1.1');
% dims = ([500 1679 1475];
% msid = H5S.create_simple(3,dims,[]);
% sid = H5D.get_space(id);
% offset = [n*500 0 0];
% block = dims; % d1: 500 or min(d1tot-n*500,500)
% H5S.select_hyperslab(sid,'H5S_SELECT_SET',offset,[],[],block);
% data = H5D.read(id,'H5ML_DEFAULT',msid,sid,'H5P_DEFAULT');
% H5D.close(id);
% H5F.close(fid);
#+end_src #+end_src
*** =sphereFit= - Fit sphere from x,y,z points *** =sphereFit= - Fit sphere from x,y,z points