source: MML/trunk/machine/SOLEIL/StorageRing/RadiaMapGui/ReadRadiaMap.m @ 4

Last change on this file since 4 was 4, checked in by zhangj, 10 years ago

Initial import--MML version from SOLEIL@2013

File size: 1.4 KB
Line 
1function [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
9fid = fopen(FileName);
10
11
12
13%% read field map
14fopen(fid);
15%read the undulator length, number of horizontal and vertical points
16par = textscan(fid,'%f',1,'CommentStyle','#');
17Lu = par{1};% undulator length [m]
18par = textscan(fid,'%d',2,'CommentStyle','#');
19Px  = par{1}(1);  % horizontal points
20Pz  = par{1}(2);  % vertical points
21Bx  = zeros(Pz,Px+1);
22Bz  = zeros(Pz,Px+1);
23
24
25%read the 'start' string;
26start = 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'
31L = textscan(fid,'%f',Px,'CommentStyle','#');     
32x = L{:};
33
34%%read horiztonal field map   
35for 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
38end
39
40%read start line
41start = textscan(fid,'%s',1,'CommentStyle','#');
42% skip the horizontal coordinates for the vertical field map
43% since it is read before.
44L = textscan(fid,'%f',Px,'CommentStyle','#');
45 
46%read vertical field map
47for 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
50end
51
52fclose(fid);
Note: See TracBrowser for help on using the repository browser.