decadal_sst_event_variations_settings.m 5.95 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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                            %
%   DECADAL VARIATIONS OF EVENT PARAMETERS   %
%   SETTINGS                                 %
%                                            %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% ------- %
% GENERAL %
% ------- %

    % dataset and basin name specified in the wrapper

    var_name     = 'sst';

    % which parameter to plot?
    plot_parameter = 'strengths';

    % resolution
    res_flag = '-r200';

    % timing
    start_year   = 1958;
    stop_year    = 2012;
    window_width = 25;  % have to use a 20-year chunk such that the 1993-2012 AVISO period is covered exactly

    % event identification and testing testing
    t_id = 0.5;    % identification threshold
    significance_level = 0.1;

    % how many entries at least?
    min_number = 1;

    % analysis region
    divert_south = false;
    zonal_analysis_region_definition;

    % for monthy labelling
    month_ids = {'J','F','M','A','M','J','J','A','S','O','N','D'};
    season_tag = char(month_ids{season_def})';

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

    load_data            = false;
        sort_longitude_data = true; % swap 0E away from the matrix edge -- does this change anything?
                                                % Sadly, it does ... Why?
    perform_calculations = load_data;
        use_anomalies_instead_of_events = false;
    save_data            = load_data;
    load_previous_data   = ~load_data;
    produce_plots        = true;

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

    data_path = '<SST dataset path>';
    data_file = [data_path,'<SST dataset name>'];
    gmt_file  = [data_path,'<Name of global mean SST dataset for long-term detrending'>];
    mask_file = [data_path,'<Name of a dataset that contains a mask for the SST dataset that excludes corrupted grid points>'];
    grid_file = '<path of the grid file>';

    out_file  = ['<path of the output file>/'...
                 'decadal_variations_',...
                 num2str(start_year),'-',num2str(stop_year),'_',...
                 'ww',num2str(window_width),'_',...
                 basin_name,'_',...
                 dataset_name,'-',var_name,'_',...
                 season_tag,'.mat'];

    if use_anomalies_instead_of_events
        out_file = strrep(out_file,'.mat','_anomalies.mat');
    end

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

    % GENERAL SETTINGS
    % ++++++++++++++++

        atlantic_asymmetric_bjf_plot_settings;

    % AXES FINE TUNING
    % ++++++++++++++++

        x_axes_offset      = 0;
        y_axes_offset      = 0;
        width_axes_offset  = 0.025;
        height_axes_offset = -0.07;
        axes_offset        = [x_axes_offset y_axes_offset width_axes_offset height_axes_offset];

        % need to adapt y positions of stretches here ...
        if strcmp(basin_name,'Pacific')
            highlight_y_values = [1986.4 1987; 1987.4 1988; 1986.4 1987];
        else
            highlight_y_values = [1987.4 1988; 1987.4 1988];
        end

    % LIMITS AND LEVELS
    % +++++++++++++++++

        % colour limits and levels
        % strengths: Atlantic
        if strcmp(plot_parameter,'strengths')
            if strcmp(basin_name,'Atlantic')
                c_limits              = [0.4 1.3];  % [0.1 0.7] for anomalies
                c_limits_diff         = [-0.4 0.4];
                c_increment           = 0.1;
                colours_per_increment = 4;

            % strengths: Pacific
            else
                c_limits              = [0.5 3.0]; % [0.1 1.7] for anomalies
                c_limits_diff         = [-2 2];
                c_increment           = 0.2;
                colours_per_increment = 4;
            end

        % counts: Atlantic
        else
            if strcmp(basin_name,'Atlantic')
                c_limits      = [0 10];
                c_limits_diff = [0 10];   % this is a dummy
                c_increment   = 1;
                colours_per_increment = 1;

            % counts: Pacific
            else
                c_limits      = [1 17];
                c_limits_diff = [1 17];   % this is a dummy
                c_increment   = 1;
                colours_per_increment = 1;
            end
        end

        n_colors      = int16((c_limits(2)-c_limits(1))/c_increment*colours_per_increment);
        n_colors_diff = ...
                int16((c_limits_diff(2)-c_limits_diff(1))/c_increment*colours_per_increment);

        use_cmap      = sunset(n_colors);
        use_cmap_diff = centered(n_colors_diff);

        % add a white patch for NaN values:
        % flip cmap upside down, attach a white row, flip it back to have
        % the white as the first entry
        if ~strcmp(plot_parameter,'counts')
            use_cmap(1,:)      = [0.75 0.75 0.75];
            use_cmap_diff(1,:) = [0.75 0.75 0.75];
        end

    % THE NINO BOXES
    % ++++++++++++++

        % height offset for the offset for the hax_labels
        hax_labels_height_offset = struct('Atlantic',0.035,'Pacific',0.057);    % units: y label values, have to set this

    % TITLE AND NAME
    % ++++++++++++++

%          title_dummy = [basin_name,', @ANOMALYTYPE@ event ',plot_parameter,', ',...
%                  num2str(window_width),'-year windows, ',season_tag,', ',...
%                  num2str(start_year),'-',num2str(stop_year)];
        title_dummy = [basin_name,' @ANOMALYTYPE@ ',season_tag];
        name_dummy = [basin_name,'_@ANOMALYTYPE@_',...
                dataset_name,'-',var_name,'_',plot_parameter,'_',...
                'ww',num2str(window_width),'_',season_tag,'_',num2str(start_year),'-',num2str(stop_year),'.png'];

        if use_anomalies_instead_of_events
            name_dummy = strrep(name_dummy,'.png','_anomalies.png');
        end

        % ignore the season tag if you analyse the entire year
        if ( length(season_def) == 12 )
            title_dummy = strrep(title_dummy,[', ',season_tag],'');
            name_dummy  = strrep(name_dummy,['_',season_tag],'_yearly');
        end