% This script makes the default structures required for the slipBERI code
% For details on what each parameter is, please see the help for slipBERI
%
% This structure is set up to run a VK inversion on the Napa Valley
% earthquake data. The structure options can be changed to run the other
% solutions found in Amey et al (2018), for example:
%       invert.inversion_type = 'laplacian'                            for Fig 9, Laplacianregularised solution
%       invert.regularise_moment = 'yes'                               for Fig 10, moment regulariasation
%       fault.fault_descriptor_file = 'napa_geom_ruth2f_biggerpatches' for Fig 10, bigger patches
%
% Amey, R. M. J., Hooper, A., & Walters, R. J. (2018). A Bayesian method 
% for incorporating self‐similarity into earthquake slip inversions. 
% Journal of Geophysical Research: Solid Earth, 123, 6052–6071. 
% https://doi.org/10.1029/2017JB015316
%
% R.M.J.Amey 2018

clear all

% first structure: 'fault'
fault = struct('fault_descriptor_file', 'napa_geom_ruth2f.txt',...
                'fault_coordinate_unit', 'utm');

% second structure: 'data'
data = struct('InSAR_datafile', {{'140807-140831_corrected.6cols'}}, ...
              'GPS_datafile_2d', '20140831-20140823_2d_gps.7cols',...
              'GPS_datafile_3d', '20140831-20140823_3d_gps.7cols',...
              'atolls_datafile', 'none',...
              'InSAR_coordinate_unit', 'utm',...
              'GPS_coordinate_unit', 'long/lat',...
              'UTMzone', 10,...
              'origin', [-124 38],...
              'EQ_epicenter', [], ...     % http://earthquake.usgs.gov/earthquakes/eventpage/nc72282711#origin
              'seismic_moment', 1.3250e+18, ...    % (Nm) from USGS
              'moment_std', 2.1310e+17,...
              'mindist', 0,...          % choose whether you want to remove faults a certain distance from the fault or not
              'weight_InSAR', 1,...
              'weight_GPS', 1,...
              'weight_atolls', 1,...
              'varcovar_deets', {{'napa_covar.txt'}},...
              'quadtree_n_points', {{'nesteddownsample_npoints.txt'}});
          
% third structure: 'testing'
testing = struct('testing_mode', 'no',...
                 'making_model', 'making_model_surfaceslip.mat',...
                 'var', 0.01,...
                 'add_noise', 0)  ;        
          
% fourth structure: 'invert'
invert = struct('inversion_type', 'bayesian', ...       % or 'least_squares'
                'smoothing', 'VK',...                 % or 'laplacian' or 'VK'
                'smooth_across_fault_strands', 'yes',... % or 'no', or [] if you want me to work out if you should smooth across them or not
                'iterations', 1000000, ...               % only relevant for bayesian inversions
                'regularise_moment', 'no', ...         % or 'no'
                'solve_for_dip', 'no',...
                'solve_for_correlation_length', 'no',... % or 'no'
                'solve_for_InSAR_offset', 'no',...      % or 'no'
                'solve_for_fault_size', 'no', ...
                'slip_initial', 0.6, ...                  % meters
                'step_size', 0.005, ...                   % metres
                'alpha2_initial', [0.5; 0.5],...                
                'probability_target_initial', 0.0001, ...
                'alpha2_step_size', 0.01,...    
                'pad_edges_with_zeros', 'no',...
                'variable_rake', 'yes',...             % other option: 'yes'
                'load_old_MCMC_chain', 'no',...
                'solve_for_beta', 'no',...
                'beta_initial', 1,...
                'beta_step_size', [],...
                'simulated_annealing_start', 'no',...
                'ensemble_sampling', 'no',...
                'ensemble_move_style', [],...
                'ensemble_start', [],...
                'select_patches', 'no',...
                'circular_harmonics', 'no',...
                'quickcheck', 'yes',...
                'add_correlation_matrix_stabiliser', 'no');       
            
priors = struct('min_dip', 90,...
        'max_dip', 90,...
        'slip_prior', 'boxcar', ...             % or 'logarithmic' 
        'min_slip', 0, ...                     % metres
        'max_slip', 50, ...                    % metres
        'min_rake', [135, 135],...                    % degrees.
        'max_rake', [225, 270],...                    % degrees.
        'alpha_prior', 'logarithmic',...
        'min_alpha2', [0, 0],...
        'max_alpha2', [100, 100],...
        'alpha2_flag', [],...
        'min_offset', [],...
        'max_offset', [],...
        'predominant_faulting_style', {{'ss'}},...
        'max_beta', [],...
        'min_beta', [],...
        'min_circharm_coeffs', [],...
        'max_circharm_coeffs', [],...
        'min_circharm_phi', [],...
        'max_circharm_phi', [],...
        'min_circharm_center', [],...
        'max_circharm_center', [],...
        'alpha2_prior', 'logarithmic',...
        'alpha2flag', []);
        
% fifth structure: 'elastic_params'
elastic_params = struct('lambda', 3.23e10,...
                        'mu_okada', 3.23e10);

% sixth structure: 'disp', within which 'figures' is a nested structure of which figures you'd like
display = struct('plot_resolution_matrix', 'no',...     
                 'plotmean', 'no',...                        % other option: 'yes'
                 'plotmode', 'no',...                        % other option: 'yes'
                 'plotmedian', 'no',...                      % other option: 'no'              
                 'plotmaxlikely', 'yes',...                  % other option: 'yes'  % IN FUTURE VERSIONS THIS WILL BE DELETED, coz I've replaced it with MAP
                 'plotallslips', 'yes',...                   % other option: 'no'
                 'plotprob', 'yes',...                       % other option: 'no'
                 'plothists', 'plothistsall',...              % other option: 'plothistsample' (i.e. choose some at random to plot)
                 'plotsurfacedisp', 'yes',...                % other option: 'no'
                 'plotmarginalPDFs', 'yes',...
                 'plotMAP', 'yes',...
                 'plot3d', 'yes') ;                % other option: 'no'
             
             
                     
 % last
 housekeeping = struct('save_name', 'napaVKslip');


% display all the structures so people actually look and check
disp('elastic_params'), disp(elastic_params)
disp('housekeeping ='); disp(housekeeping)
disp('testing ='), disp(testing)
disp('display ='), disp(display)
disp('fault ='); disp(fault)
disp('data ='); disp(data)
disp('invert ='); disp(invert)


