-
Notifications
You must be signed in to change notification settings - Fork 0
/
sac3Dgetpic.m
69 lines (49 loc) · 1.57 KB
/
sac3Dgetpic.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
%getpicttest 3D version
% Read the npict-th picture from 1 or more files
%filename='/data/cs1mkg/smaug_spicule1/spicule4b1_3_3d/zerospic1__711000.out';
filename='zerospic1__711000.out';
fid=fopen((filename));
%fseek(fid,pictsize(ifile)*(npict(ifile)-1),'bof');
headline=(setstr(fread(fid,79,'char')'));
it=fread(fid,1,'integer*4'); time=fread(fid,1,'float64');
ndim=fread(fid,1,'integer*4');
neqpar=fread(fid,1,'integer*4');
nw=fread(fid,1,'integer*4');
nx=fread(fid,3,'integer*4');
nxs=nx(1)*nx(2)*nx(3);
varbuf=fread(fid,7,'float64');
gamma=varbuf(1);
eta=varbuf(2);
g(1)=varbuf(3);
g(2)=varbuf(4);
g(3)=varbuf(5);
varnames=(setstr(fread(fid,79,'char')'));
for idim=1:ndim
X(:,idim)=fread(fid,nxs,'float64');
end
for iw=1:nw
%fread(fid,4);
w(:,iw)=fread(fid,nxs,'float64');
%fread(fid,4);
end
nx1=nx(1);
nx2=nx(2);
nx3=nx(3);
xx=reshape(X(:,1),nx1,nx2,nx3);
yy=reshape(X(:,2),nx1,nx2,nx3);
zz=reshape(X(:,3),nx1,nx2,nx3);
% extract variables from w into variables named after the strings in wnames
wd=zeros(nw,nx1,nx2,nx3);
for iw=1:nw
tmp=reshape(w(:,iw),nx1,nx2,nx3);
wd(iw,:,:,:)=tmp;
end
%w=tmp(iw);
clear tmp;
fclose(fid);
% val=reshape(wd(1,:,1,:),128,128);
% surf(val,'LineStyle','none');
% colorbar;
%
% val1=reshape(wd(3,:,1,:),128,128)/(reshape(wd(1,:,1,:),128,128)+reshape(wd(10,:,1,:),128,128));
% val2=reshape(wd(4,:,1,:),128,128)/(reshape(wd(1,:,1,:),128,128)+reshape(wd(10,:,1,:),128,128));