-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrun_globe.m
125 lines (113 loc) · 3.47 KB
/
run_globe.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
function run_Globe
%%run_Globe recontruct spherical data from shape planetary data files
% found at:
% https://geodesy.curtin.edu.au/research/models/Earth2012/
% http://www.ipgp.fr/~wieczor/SH/SH.html
%
% This demonstrates the inverse sphericsal harmonic transform, that is,
% going from the spectral domain to the spatial domain.
%%
L_max=100; % maximum included spherical harmonic degree 2600
ntt=max(21,L_max+1); % number of points in theta
npp=max(41,2*L_max+1); % number of points in phi (here first and last phi are the same)
bump=0.05;
doScale=1;
radius=0.0; % use file value
%% Iterate over celestial bodies (files need to be downloaded and in the path)
for bodyIndex=4:4
switch bodyIndex
case 1
globe='Earth2012.topo_bathy_bed.SHCto2160.shape';
name='Earth2012-bed';
cmap='parula';
radius=6371000;
bump=0.035;
az=40; el=-15;
case 2
globe='Earth2012.topo_bathy.SHCto2160.shape';
name='Earth2012';
cmap='parula';
radius=6371000;
bump=0.035;
az=40; el=-15;
case 3
globe='Earth2012.topo_air.SHCto2160.shape';
name='Earth2012_air';
cmap='parula';
radius=6371000;
bump=0.035;
az=40; el=-15;
case 4
globe='MarsTopo2600.shape';
name='Mars';
cmap='parula';
bump=0.05;
az=180; el=0;
case 5
globe='VenusTopo719.shape';
name='Venus';
cmap='parula';%'hot';
bump=0.035;
az=180; el=0;
case 6
globe='MoonTopo2600p.shape';
name='Moon';
cmap='parula';
bump=0.02;
az=180; el=0;
end
%% Get the data from the shape file
[F,theta,phi,L_max,rad]=ishtFromShapeFile(L_max,ntt,npp,globe,doScale);
if radius==0
radius=rad;
end
%% Figure and data output directores
base=strrep(userpath,':',''); % ~/Documents/MATLAB (matlab changed behavior in 2016)
figs_folder=[base '/figs/'];
frames_basename=sprintf('%s_%04d',[base '/frames/' name],L_max);
figs_basename=sprintf('%s_%04d',[figs_folder name],L_max);
%% Save spatial data
save([figs_basename '.mat'],'F','theta','phi');
% thinking of making the rest a function so the F,theta,phi data in a *.mat
% file can be drawn
% renderGlobe(F,theta,phi,L_max,name,0.05,1.0,2,cmap,az,el,figs_basename,frames_basename)
%% Render the globe to figure
figure
s=spatialPlot(F,theta,phi,bump,1.0,2);%0.05
colormap(cmap)
s.EdgeColor='none'; % no lines
%% Annotate the figure
llabel=sprintf('$L_{\\mathrm{max}}=%d$',L_max);
delete(findall(gcf,'Tag','myLabel'));
a=annotation('textbox',[0.7,0.89,0.28,0.1],'String',llabel);
a.Interpreter='latex';
a.FontSize=18;
a.LineStyle='none';
a.Tag='myLabel';
fig=gcf;
fig.Name=name;
fig.Position(3)=600;
fig.Position(4)=600;
%% Output png file to current directory
set(gcf,'InvertHardCopy','off');
set(gcf,'color',[1.0 1.0 1.0]); % Set the figure frame color to white
set(gcf,'PaperUnits','inches','PaperPosition',[0 0 6 6]) %150dpi
saveas(gcf,figs_basename,'png')
%% Render movie on osx; needs avconv - get via 'brew install libav'
if ~system('which avconv >/dev/null')
view(az,el) % set viewpoint
for i=0:358 % :358
set(gcf,'PaperUnits','inches','PaperPosition',[0 0 6 6]) %150dpi
rotname=sprintf('%s_%04d',frames_basename,i);
disp(rotname);
camorbit(1.0,0.0); drawnow; saveas(gcf,rotname,'png')
end
renderMovWithAvconv=sprintf(...
'avconv -framerate 30 -y -v quiet -f image2 -i %s_%%04d.png %s.mov',...
frames_basename,frames_basename);
if ~system(renderMovWithAvconv) % make compressed mov
cleanup=sprintf('rm %s*.png',frames_basename);
system(cleanup); % delete frames
end
end
end