% m-file: driver_rotating_3d_globe_3_Moon_topography
%
% When using this driver or fuctions it calls, please cite the reference:
%  Bezdek A, Sebera J, 2013. MATLAB script for 3D visualizing geodata on a rotating globe.
%  Computers & geosciences 56, 127–130. http://dx.doi.org/10.1016/j.cageo.2013.03.007

% Ales Bezdek, bezdek@asu.cas.cz, 1/2015
% 6/2016 update to new Matlab versions up to R2015a

%% Visualization output (2D map, 3D picture/animation)
% Input: Moon_topography
% Output: select one of the following options
output='2';
%     'a'..2D map;
%     'b'..3D as PNG image; 'bhr'..3D as PNG image (high resolution)
%     'c'..3D as animated GIF
%     'd'..3D as WMV video
%     'e'..3D as both animated GIF and WMV video; 'ehr'..high resolution
%     '1'..all images
%     '2'..all images/animations (animations may take longer time)
%% Selection of Moon topographical data
model='LOLA_04';  %resolution: 1/4 degree = 15 arcmin
%       model='LOLA_16';  %resolution: 1/16 degree = 3.75 arcmin
fprintf('Loading Moon data: %s\n',model);
load (model);
%% Moon topography as 2D map
if strcmp(output,'a') || strcmp(output,'1') || strcmp(output,'2')
   [hc,htit,name_png]=elevation_2d_map(lond_moon,latd_moon,elev_moon_km,...
      'units','km',...
      'graph_label',sprintf('Moon topography (%s)',model),...
      'clbr_limits',[-6 7],'clbr_tick',-10:10,...
      'cptcmap_pm','GMT_wysiwygcont',...
      'preview_figure_visible',0,...
      'tn_width',150,...
      'window_height',650);
end
%% Moon topography in 3D as PNG image
if strcmp(output,'b') || strcmp(output,'1') || strcmp(output,'2')
   [hc,hlab,name_png]=rotating_3d_globe(lond_moon,latd_moon,elev_moon_km,...
      'exaggeration_factor',13,'radius',6378,'units','km',...
      'graph_label',sprintf('Moon topography (%s)',model),...
      'clbr_limits',[-6 7],'clbr_tick',-10:10,...
      'cptcmap_pm','GMT_wysiwygcont',...
      'azimuth',90,'elevation',0,...
      'preview_figure_visible',0,...
      'tn_width',200,...
      'window_height',650);
end
%% Moon topography in 3D as animated GIF
% For smoother animations, see below
if strcmp(output,'c')
   [hc,hlab,name_png]=rotating_3d_globe(lond_moon,latd_moon,elev_moon_km,...
      'exaggeration_factor',13,'radius',6378,'units','km',...
      'graph_label',sprintf('Moon topography (%s)',model),...
      'clbr_limits',[-6 7],'clbr_tick',-10:10,...
      'cptcmap_pm','GMT_wysiwygcont',...
      'azimuth',90,'elevation',0,...
      'preview_figure_visible',0,'clbr_anim',1,...
      'anim_gif',1,'anim_angle',360,'time_for_360deg',4,'fps',.5,...
      'window_height',650);
end
%% Moon topography in 3D as WMV video
% For smoother animations, see below
if strcmp(output,'d')
   [hc,hlab,name_png]=rotating_3d_globe(lond_moon,latd_moon,elev_moon_km,...
      'exaggeration_factor',13,'radius',6378,'units','km',...
      'graph_label',sprintf('Moon topography (%s)',model),...
      'clbr_limits',[-6 7],'clbr_tick',-10:10,...
      'cptcmap_pm','GMT_wysiwygcont',...
      'azimuth',90,'elevation',0,...
      'preview_figure_visible',0,'clbr_anim',1,...
      'video_format','wmv','anim_angle',360,'time_for_360deg',4,'fps',.5,...
      'window_height',650);
end
%% Moon topography in 3D as both animated GIF and WMV video
% For smoother animations, see below
if strcmp(output,'e') || strcmp(output,'2')
   [hc,hlab,name_png]=rotating_3d_globe(lond_moon,latd_moon,elev_moon_km,...
      'exaggeration_factor',13,'radius',6378,'units','km',...
      'graph_label',sprintf('Moon topography (%s)',model),...
      'clbr_limits',[-6 7],'clbr_tick',-10:10,...
      'cptcmap_pm','GMT_wysiwygcont',...
      'azimuth',90,'elevation',0,...
      'preview_figure_visible',0,'clbr_anim',1,...
      'video_format','wmv','anim_gif',1,'anim_angle',360,'time_for_360deg',4,'fps',.5,...
      'tn_width',100,...
      'window_height',650);
end
%% Moon topography in 3D as PNG image (high resolution)
if strcmp(output,'bhr') || strcmp(output,'1') || strcmp(output,'2')

   % model='LOLA_04';  %resolution: 1/4 degree = 15 arcmin
   if exist('LOLA_16.mat','file')
      model='LOLA_16';  %resolution: 1/16 degree = 3.75 arcmin; RAM of 4 GB is necessary
      fprintf('Loading Moon data: %s\n',model);
      load (model);
   else
      error_ab('chybi lola_16.mat');
   end

   [hc,hlab,name_png]=rotating_3d_globe(lond_moon,latd_moon,elev_moon_km,...
      'exaggeration_factor',13,'radius',6378,'units','km',...
      'graph_label',sprintf('Moon topography (%s)',model),...
      'clbr_limits',[-6 7],'clbr_tick',-10:10,...
      'cptcmap_pm','GMT_wysiwygcont',...
      'azimuth',90,'elevation',0,...
      'preview_figure_visible',0,...
      'font_size',18,...
      'tn_width',200,...
      'window_height',3000);
end
