lagged_feedback_strengths_plot_strength_composites.m 5.17 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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                 %
%    STRENGTH OF LAGGED BJERKNES FEEDBACK ELEMENTS                %
%    VARIABLE ANALYSIS TYPE: ACC, REGRESSION, ROBUST REGRESSION   %
%    PLOT negative and positive feedback strength composites      %
%                                                                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

disp('plotting feedback strength composites');

% plot all anomaly types
for anomaly_type = all_anomalies

    % assign correct anomaly type
    switch anomaly_type
        case -1
            type_string = 'negative';
        case 0
            type_string = 'full';
        case 1
            type_string = 'positive';
    end

    disp(sprintf('\t%s',type_string));

    % SET UP FIGURE
    % +++++++++++++

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

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

        font_size    = floor(hax.FontSize*scale_font_size);
        hax.FontSize = font_size;

        hold(hax,'on');

        % naming the regions
        x_ticks        = [];
        x_tick_labels  = {};

    % SET NEGATIVE LAGS TO NAN
    % ++++++++++++++++++++++++

        % correct dimensions
        if ( size(is_negative_lag,1) ~= 12 )
            is_negative_lag = is_negative_lag';
        end

        % pick correct feedback strengts and set negative lags to NaN
        use_feedback                  = feedback_strengths.(type_string);
        use_feedback(is_negative_lag) = NaN;

    % PLOT DATA
    % +++++++++

        % checkerboard, as in the dynamics analysis
        image(central_longitudes,[1:12],use_feedback,...
                'CDataMapping','scaled');
        colorbar(hax);

    % NINO REGIONS
    % ++++++++++++

        % include small coloured boxes to indicate the Nino regions
        hax_labels = axes('XLim',lon_cover,'YLim',[0.5 12.5],...
                 'XTick',[],'XTickLabel',{},'YTick',[],'YTickLabel',{},...
                 'Visible','off',...
                 'FontSize',font_size);
        set(hax_labels,'Color','none');

        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

    % HATCHING SIGNIFICANCE VALUES
    % ++++++++++++++++++++++++++++++++++++++++++++++

        % hatch everything that is significant or negative lag
        for month = 1:12

            % choose data: boolean for now
            use_sigs     = squeeze(significance.(type_string)(month,:));
            use_neg_lags = squeeze(is_negative_lag(month,:));

            % set significance to 0 where the lags are negative
            use_sigs(use_neg_lags) = false;

            % convert boolean significances into indices for plotting
            use_sigs = find(use_sigs);

            % SIGNIFICANCES
            % =============

                % plot black crosses
                plot(hax,central_longitudes(use_sigs),ones(1,length(use_sigs)).*month,...
                        'x','LineWidth',line_width_significance_outline,...
                        'MarkerSize',size_significance_marker+2,...
                        'Color',my_white);
                plot(hax,central_longitudes(use_sigs),ones(1,length(use_sigs)).*month,...
                        'x','LineWidth',line_width_significance_markers,...
                        'MarkerSize',size_significance_marker,...
                        'Color',hax.XColor);

        % for: hatch significances and negative lags for all months
        end

    % POLISHING AND PRINTING
    % ++++++++++++++++++++++

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

        % title
        fig_title = strrep(title_dummy,'@ANOMALYTYPE@',...
                [upper(type_string(1)),type_string(2:end)]);
        h_title = title(hax_labels,fig_title);
        set(h_title,'Visible','on');

        % align axes
        hax.Position             = axes_position;
        hax_labels.Position      = axes_position;

        % offset the patches
        hax_labels.Position(2)   = hax_labels.Position(2)+hax_labels_height_offset.(basin_name);

        % colormap and number of displayed colours
        hax.CLim = c_limits;
        colormap(use_cmap);

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

% for: plot all anomaly types
end