calculate_instantaneous_feedback_settings.m 4.61 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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                      %
%   CALCULATE INSTANTANEOUS FEEDBACK   %
%   SETTINGS                           %
%                                      %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% ----- %
% BASIC %
% ----- %

    % variable and basin names are defined in the wrapper

    % general
    start_year = 1993;
    stop_year  = 2012;

    % datasets
    dataset_names = struct('ssh','aviso',...
                           'sst','ersst',...
                           'ustr','era_sfcstress');

    % analysis type
    analysis_type = 'rreg';

% ----- %
% FLAGS %
% ----- %

    perform_calculations = true;
    save_data            = true;
    plot_results         = true;

    divert_south = false;
    zonal_analysis_region_definition;

% --------------- %
% FILES AND PATHS %
% --------------- %

    in_path  = '<input path>';
    in_dummy = [in_path,...
                'equatorial_indices_',...
                num2str(start_year),'-',num2str(stop_year),'_',...
                basin_name,'_',...
                '@DATASET_NAME@-@VAR_NAME@.mat'];

    out_file = [in_path,...
                'instantaneous_feedback_strengths_',...
                analysis_type,'_',...
                num2str(start_year),'-',num2str(stop_year),'_',...
                basin_name,'_',...
                dataset_names.(reference_name),'-',reference_name,'_',...
                dataset_names.(response_name),'-',response_name,'.mat'];

% -------- %
% PLOTTING %
% -------- %

    % COLOURS AND COLORBAR
    % ++++++++++++++++++++

        % colorbar (!) handles (!)
        sunset   = <absolute colorbar>
        centered = <colorbar for differences>;

        % colour limits and levels, colormap, colorbar settings
        % for correlations:
        if ( strcmp(analysis_type,'acc') )

            c_limits  = [-1 1];
            n_colours = 20;

        % regressions
        else

            all_c_limits    = struct('ssh',35,'sst',0.05,'ustr',7);  % ssh: 30
            all_c_increment = struct('ssh',2,'sst',0.005,'ustr',1);
            all_n_colours   = struct('ssh',35,'sst',30,'ustr',28);   % ssh: 30

            c_limits  = [-all_c_limits.(reference_name) all_c_limits.(reference_name)];
            n_colours = all_n_colours.(reference_name);

        end

        % replace first entrance (used for NaNs) for a nicer view
        use_cmap = centered(n_colours);

    % HIGHLIGHT REGIONS
    % +++++++++++++++++

        % which background regions to plot? Define longitudinal extent here
        % i.e., mark WAtl, Atl3 in the Atlantic, and Nino4, Nino34, and Nino12
        % in the Pacific
        if strcmp(basin_name,'Pacific')

            % longitudinal boundaries of standard regions
            highlight_regions = [...
                    160 210; ...
                    190 240; ...
                    270 280];

            % and the names of the regions
            region_names = {'Nino4','Nino34','Nino12'};

        else
            highlight_regions = [...
                    -40 -20; ...
                    -20 0];
            region_names = {'WAtl','Atl3'};
        end

        region_colours = [my_left; my_right; my_middle];

    % NAMING
    % ++++++

        % full title
        title_dummy = [basin_name,' ',...
            upper(reference_name),'-',upper(response_name),' ',...
            analysis_type,' instantaneous strengths @ANOMALYTYPE@, ', ...
            num2str(start_year),'-',num2str(stop_year)];

        name_dummy = ['instantaneous_',basin_name,'_',...
            dataset_names.(reference_name),'-',reference_name,'_',...
            dataset_names.(response_name),'-',response_name,'_',...
            analysis_type,'_feedback_strengths_@ANOMALYTYPE@_',...
            num2str(start_year),'-',num2str(stop_year),'.png'];

    % AXES POSITION
    % +++++++++++++

        height_offset = -0.05;
        width_offset  = -0.05;

        % scaling of the figure?
        scale_figure_height = 1;
        scale_figure_width  = 1;

        % position of the axes
        x_axes_offset      = 0;
        y_axes_offset      = 0;
        width_axes_offset  = -0.05;
        height_axes_offset = -0.05;

        axes_offset = [x_axes_offset y_axes_offset ...
                       width_axes_offset height_axes_offset];

    % OTHER
    % +++++

        res_flag        = '-r200';
        font_size_scale = 1.5;

% ------------- %
% MISCELLANEOUS %
% ------------- %

    month_ids = {'J','F','M','A','M','J','J','A','S','O','N','D'};

    % mute warning from robust regression
    % query the last warning, including it's ID with
    % w = warning('query','last').
    warn_id = 'stats:statrobustfit:IterationLimit';