diagnose_zonal_feedback_lags_plots.m 10.9 KB
Newer Older
Claas Faber's avatar
Claas Faber committed
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 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                               %
%   DIAGNOSE FEEDBACK LAGS FOR EACH LONGITUDE   %
%   PLOTS                                       %
%   Sub-script of the main script               %
%   Do not attempt to run alone                 %
%                                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if plot_lag_values
% --------------- %
% PLOT LAG VALUES %
% --------------- %

    disp('plotting lag values')

    % PREPARATIONS 
    % ++++++++++++
    
        % need grids for pcolor
        [lon_grid,time_grid] = meshgrid(central_longitudes,double(1:12));

        % initialize figure
        hf  = figure;
        hf.Position(3) = scale_figure_width*hf.Position(3);
        hf.Position(4) = scale_figure_height*hf.Position(4);

        % initialize axes
        hax = axes('XLim',lon_cover,'YLim',[0.5 12.5],...
                'YTick',[1:1:12],'YTickLabel',months_single,...
                'XGrid','on','Layer','top');

        % additional settings: position, font size
        hax.Position = axes_position;
        hax.FontSize = floor(scale_font_size*hax.FontSize);

        hold(hax,'on');

    % PLOT 
    % ++++
        
        % checkerboard, as in the dynamics analysis
        % I definitely can't use pcolor here -- in fact, I should never
        % use it -- because it is averaging the adjacent values together
        % to produce the cell value. Hence, I'm effectively losing data,
        % and this is very much not what I want to do.
        image(lon_cover,[1 12],lag_values,...
                'CDataMapping','scaled');
        hcb = colorbar(hax,'Location','EastOutside');

    % NINO REGIONS 
    % ++++++++++++
    
        % label boxes in a different axis
        hax_labels = axes('XLim',lon_cover,'YLim',[0.5 12.5],'Visible','off');
        set(hax_labels,'Color','none','XAxisLocation','top',...
                'Position',axes_position);
        hax_labels.FontSize = hax.FontSize;
        
        hold(hax_labels,'on'); 
    
        for c_region = 1:length(region_names)

            x_values = [highlight_regions(c_region,1) highlight_regions(c_region,2) ...
                        highlight_regions(c_region,2) highlight_regions(c_region,1) ...
                        highlight_regions(c_region,1)];
                        
            y_values = [highlight_y_values(c_region,1) highlight_y_values(c_region,1) ...
                        highlight_y_values(c_region,2) highlight_y_values(c_region,2) ...
                        highlight_y_values(c_region,1)];
            
            h_patch = patch(x_values,y_values,region_colours(c_region,:),...
                    'EdgeColor','none'); 

        % plot in highlight regions
        end

    % POLISHING 
    % +++++++++
    
        xlabel(hax,'\circ lon');
        ylabel(hax,'Month');

        % align axes
        hax_labels.Position = axes_position;
        hax.Position        = axes_position;
        
        % offset the patches 
        hax_labels.Position(2) = hax_labels.Position(2)+hax_labels_height_offset.(basin_name); 
        
        % title: display it and shift the y position 
        fig_title = strrep(title_dummy,'@PLOT_TYPE@','Lags');
        h_title = title(hax_labels,fig_title);
        set(h_title,'Visible','on');
        h_title.Position(2) = title_y_position; 

        % colormap and number of displayed colours
        hax.CLim = lag_limits;
        colormap(use_cmap_lags);

        % colorbar ticks
        hcb_tick_labels          = {};
        
        for c_tick = 1:length(all_lags)
            if ( mod(c_tick,2) == 0 )
                hcb_tick_labels{c_tick} = ' '; 
            else 
                hcb_tick_labels{c_tick} = num2str(all_lags(c_tick)); 
            end 
        end
        
        set(hcb,'Ticks',c_ticks,'TickLabels',hcb_tick_labels);

        % print
        fig_name = strrep(name_dummy,'@PLOT_TYPE@','lags');
        print(hf,res_flag,fig_name,'-dpng');
        % close(hf);

% if: plot lag values
end

%  if plot_lag_feedbacks
%  % ---------------------- %
%  % PLOT PEAK CORRELATIONS %
%  % ---------------------- %
%  
%      disp('plotting peak strengths')
%  
%      % need grids for pcolor
%      [lon_grid,time_grid] = meshgrid(central_longitudes,double(1:12));
%  
%      % initialize figure
%      hf  = figure;
%      hf.Position(3) = scale_width*hf.Position(3);
%      hf.Position(4) = scale_height*hf.Position(4);
%  
%      % initialize axes
%      hax = axes('XLim',lon_cover,'YLim',[0.5 12.5],...
%                 'YTick',[],'YTickLabel','',...
%                 'XGrid','on','Layer','top');
%  
%      % additional settings: position, font size
%      hax.Position = hax.Position+axes_offset;
%      hax.FontSize = floor(font_size_scale*hax.FontSize);
%  
%      hold(hax,'on');
%  
%      % naming the regions
%      x_ticks        = [];
%      x_tick_labels  = {};
%  
%      % checkerboard, as in the dynamics analysis
%      % I definitely can't use pcolor here -- in fact, I should never
%      % use it -- because it is averaging the adjacent values together
%      % to produce the cell value. Hence, I'm effectively losing data,
%      % and this is very much not what I want to do.
%      image(lon_cover,[1 12],peak_strengths,...
%              'CDataMapping','scaled');
%      hcb = colorbar(hax,'Location','EastOutside');
%  
%      % Nino regions
%      for c_region = 1:length(region_names)
%  
%          x_values = [highlight_regions(c_region,1) highlight_regions(c_region,2) ...
%                      highlight_regions(c_region,2) highlight_regions(c_region,1) ...
%                      highlight_regions(c_region,1)];
%          y_values = [hax.YLim(1) hax.YLim(1) hax.YLim(2) hax.YLim(2) hax.YLim(1)];
%  
%          plot(x_values,y_values,'LineWidth',4,'Color',my_white);
%          plot(x_values,y_values,'LineWidth',2,'Color',region_colours(c_region,:));
%  
%          x_ticks(end+1)       = mean(highlight_regions(c_region,:));
%          x_tick_labels{end+1} = region_names{c_region};
%  
%      % plot in highlight regions
%      end
%  
%      % label boxes in a different axis
%      hax_labels = axes('XLim',lon_cover,'YLim',[1 13],...
%              'YTick',[1.5:1:12.5],'YTickLabel',months_single);
%      set(hax_labels,'Color','none','XAxisLocation','top',...
%              'Position',hax.Position);
%      hax_labels.FontSize = hax.FontSize;
%  
%      % polishing
%      xlabel(hax,'\circ lon');
%      ylabel(hax_labels,'Month');
%  
%      fig_title = strrep(title_dummy,'@PLOT_TYPE@','peak strength');
%      title(hax_labels,fig_title);
%  
%      % align axes
%      axes_position = hax_labels.Position;
%  
%      hax_labels.Position = axes_position;
%      hax.Position        = axes_position;
%  
%      % colormap and number of displayed colours
%      % for correlation
%      if ( analysis_id == 1 )
%          hax.CLim = [-1 1];
%          n_colors = 21;
%      % for regression
%      else
%          hax.CLim = [-strength_limits.(reference_name) strength_limits.(reference_name)];
%          n_colors = strength_colors.(reference_name);
%      end
%  
%      % set colormap
%      colormap(centered(n_colors));
%  
%      % display region names
%      set(hax_labels,'XTick',x_ticks,'XTickLabel',x_tick_labels);
%  
%      % print
%      fig_name = strrep(name_dummy,'@PLOT_TYPE@','peak_strengths');
%      print(hf,res_flag,fig_name,'-dpng');
%      % close(hf);
%  
%  % if: plot peak feedback_strengths
%  end
%  
%  if plot_all_strengths
%  % ---------------------- %
%  % PLOT PEAK CORRELATIONS %
%  % ---------------------- %
%  for c_lag = 1:n_lags
%  
%      lag = all_lags(c_lag);
%      disp(sprintf('plotting correlation for lag %d',lag));
%  
%      % need grids for pcolor
%      [lon_grid,time_grid] = meshgrid(central_longitudes,double(1:12));
%  
%      % initialize figure
%      hf  = figure;
%      hf.Position(3) = scale_width*hf.Position(3);
%      hf.Position(4) = scale_height*hf.Position(4);
%  
%      % initialize axes
%      hax = axes('XLim',lon_cover,'YLim',[0.5 12.5],...
%                 'YTick',[],'YTickLabel','',...
%                 'XGrid','on','Layer','top');
%  
%      % additional settings: position, font size
%      hax.Position = hax.Position+axes_offset;
%      hax.FontSize = floor(font_size_scale*hax.FontSize);
%  
%      hold(hax,'on');
%  
%      % naming the regions
%      x_ticks        = [];
%      x_tick_labels  = {};
%  
%      % checkerboard, as in the dynamics analysis
%      % I definitely can't use pcolor here -- in fact, I should never
%      % use it -- because it is averaging the adjacent values together
%      % to produce the cell value. Hence, I'm effectively losing data,
%      % and this is very much not what I want to do.
%      image(lon_cover,[1 12],squeeze(feedback_strengths(:,:,c_lag)'),...
%              'CDataMapping','scaled');
%      hcb = colorbar(hax,'Location','EastOutside');
%  
%      % Nino regions
%      for c_region = 1:length(region_names)
%  
%          x_values = [highlight_regions(c_region,1) highlight_regions(c_region,2) ...
%                      highlight_regions(c_region,2) highlight_regions(c_region,1) ...
%                      highlight_regions(c_region,1)];
%          y_values = [hax.YLim(1) hax.YLim(1) hax.YLim(2) hax.YLim(2) hax.YLim(1)];
%  
%          plot(x_values,y_values,'LineWidth',4,'Color',my_white);
%          plot(x_values,y_values,'LineWidth',2,'Color',region_colours(c_region,:));
%  
%          x_ticks(end+1)       = mean(highlight_regions(c_region,:));
%          x_tick_labels{end+1} = region_names{c_region};
%  
%      % plot in highlight regions
%      end
%  
%      % label boxes in a different axis
%      hax_labels = axes('XLim',lon_cover,'YLim',[1 13],...
%              'YTick',[1.5:1:12.5],'YTickLabel',months_single);
%      set(hax_labels,'Color','none','XAxisLocation','top',...
%              'Position',hax.Position);
%      hax_labels.FontSize = hax.FontSize;
%  
%      % polishing
%      xlabel(hax,'\circ lon');
%      ylabel(hax_labels,'Month');
%  
%      fig_title = strrep(title_dummy,'@PLOT_TYPE@',sprintf('Lag %d strengths.',lag));
%      title(hax_labels,fig_title);
%  
%      % align axes
%      axes_position = hax_labels.Position;
%  
%      hax_labels.Position = axes_position;
%      hax.Position        = axes_position;
%  
%      % colormap and number of displayed colours
%      % for correlation
%      if ( analysis_id == 1 )
%          hax.CLim = [-1 1];
%          n_colors = 21;
%      % for regression
%      else
%          hax.CLim = [-strength_limits.(reference_name) strength_limits.(reference_name)];
%          n_colors = strength_colors.(reference_name);
%      end
%  
%      % colormap
%      colormap(centered(n_colors));
%  
%      % display region names
%      set(hax_labels,'XTick',x_ticks,'XTickLabel',x_tick_labels);
%  
%      % print
%      fig_name = strrep(name_dummy,'@PLOT_TYPE@',sprintf('lag_%d_strengths',lag));
%      print(hf,res_flag,fig_name,'-dpng');
%      % close(hf);
%  
%  % for: plot all feedback_strengths
%  end
%  
%  % if: plot all feedback_strengths
%  end