[4] | 1 | function [x Bx,Bz,Px,Pz,Lu] = ReadRadiaMap(FileName) |
---|
| 2 | |
---|
| 3 | % plot the wiggler field map from radiamap. |
---|
| 4 | |
---|
| 5 | %FileName = 'w150g11pole20_fin.dat'; |
---|
| 6 | %FileName = 'w150g11pole20_fin.dat_interpolation'; |
---|
| 7 | |
---|
| 8 | |
---|
| 9 | fid = fopen(FileName); |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | |
---|
| 13 | %% read field map |
---|
| 14 | fopen(fid); |
---|
| 15 | %read the undulator length, number of horizontal and vertical points |
---|
| 16 | par = textscan(fid,'%f',1,'CommentStyle','#'); |
---|
| 17 | Lu = par{1};% undulator length [m] |
---|
| 18 | par = textscan(fid,'%d',2,'CommentStyle','#'); |
---|
| 19 | Px = par{1}(1); % horizontal points |
---|
| 20 | Pz = par{1}(2); % vertical points |
---|
| 21 | Bx = zeros(Pz,Px+1); |
---|
| 22 | Bz = zeros(Pz,Px+1); |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | %read the 'start' string; |
---|
| 26 | start = textscan(fid,'%s',1,'CommentStyle','#'); |
---|
| 27 | |
---|
| 28 | |
---|
| 29 | % read the first line,the horizontal coordinates when the fields are measured |
---|
| 30 | %the number of points data in this line is only 'Px' |
---|
| 31 | L = textscan(fid,'%f',Px,'CommentStyle','#'); |
---|
| 32 | x = L{:}; |
---|
| 33 | |
---|
| 34 | %%read horiztonal field map |
---|
| 35 | for i=1:Pz |
---|
| 36 | L = textscan(fid,'%f',Px+1,'CommentStyle','#'); % read the field strength line |
---|
| 37 | Bz(i,:) = L{:}; % assign each line values to array Bx |
---|
| 38 | end |
---|
| 39 | |
---|
| 40 | %read start line |
---|
| 41 | start = textscan(fid,'%s',1,'CommentStyle','#'); |
---|
| 42 | % skip the horizontal coordinates for the vertical field map |
---|
| 43 | % since it is read before. |
---|
| 44 | L = textscan(fid,'%f',Px,'CommentStyle','#'); |
---|
| 45 | |
---|
| 46 | %read vertical field map |
---|
| 47 | for i=1:Pz |
---|
| 48 | L = textscan(fid,'%f',Px+1,'CommentStyle','#'); % read the field strength line |
---|
| 49 | Bx(i,:) = L{:}; % assign each line values to array Bx |
---|
| 50 | end |
---|
| 51 | |
---|
| 52 | fclose(fid); |
---|