function []=startup_seizmo()
%STARTUP_SEIZMO    Adds SEIZMO to dynamic path & javaclasspath
%
% If you can't edit your paths or don't want seizmo on your default
% path then run this script (or add it to your own startup file)
% to get seizmo working.  Note you may need to edit the value of the
% variable "path" below to match the directory seizmo is installed
% in -- I have seizmo as directory "/opt/seizmo/seizmo" on my system.
% The current setting is only valid when this file is in the seizmo
% directory.  If you run this script from anywhere else you need the
% variable "path" to be the absolute path to your seizmo directory.
% !!! MODIFY & UNCOMMENT PATH TO MATCH YOUR SEIZMO INSTALL DIRECTORY !!!
%path='/opt/seizmo/seizmo';            % Valid anywhere on my system.
path=fileparts(mfilename('fullpath')); % Valid only in seizmo directory.

% path separator
fs=filesep;

% adding seizmo folders to the top of the path
addpath(path,...
    [path fs 'lowlevel'],...
    [path fs 'uninstall'],...
    [path fs 'behavior'],...
    [path fs 'toc'],...
    [path fs 'rw'],...
    [path fs 'hdr'],...
    [path fs 'sz'],...       % from here up is the "core" of seizmo
    [path fs 'misc'],...
    [path fs 'time'],...
    [path fs 'position'],...
    [path fs 'audio'],...
    [path fs 'cmap'],...
    [path fs 'cmb'],...
    [path fs 'cmt'],...
    [path fs 'decon'],...
    [path fs 'event'],...
    [path fs 'filtering'],...
    [path fs 'fixes'],...
    [path fs 'fk'],...
    [path fs 'ftran'],...
    [path fs 'gui'],...
    [path fs 'invert'],...
    [path fs 'mapping'],...
    [path fs 'models'],...
    [path fs 'multi'],...
    [path fs 'noise'],...
    [path fs 'ocean'],...
    [path fs 'pick'],...
    [path fs 'plotting'],...
    [path fs 'resampling'],...
    [path fs 'response'],...
    [path fs 'shortnames'],...
    [path fs 'solo'],...
    [path fs 'sphpoly'],...
    [path fs 'synth'],...
    [path fs 'tomo'],...
    [path fs 'topo'],...
    [path fs 'tpw'],...
    [path fs 'ttcorrect'],...
    [path fs 'win'],...
    [path fs 'ww3'],...
    [path fs 'ws'],...
    [path fs 'xc'],...
    [path fs 'xcalign'],...
    [path fs 'mattaup']);

% check that java pkg is installed
java_in_octave=true;
if(exist('OCTAVE_VERSION','builtin')==5 && isempty(ver('java')))
    java_in_octave=false;
end

% adding irisws jar
jars{1}='IRIS-WS-2.0.6.jar';
pjars=strcat(path,fs,'ws',fs,jars);
for i=1:numel(jars)
    if(java_in_octave && ...
            all(cellfun('isempty',strfind(javaclasspath('-all'),jars{i}))))
        javaaddpath(pjars{i});
    end
end
clear jars;

% adding the jars for mattaup is not necessary for
% taup*.m but you might want to do this now if you
% directly use the jars or objects for some reason
jars{1}='TauP-2.1.1.jar';
jars{2}='seisFile-1.5.1.jar';
jars{3}='MatTauP-2.1.1.jar';
pjars=strcat(path,fs,'mattaup',fs,'lib',fs,jars);
for i=1:numel(jars)
    if(java_in_octave && ...
            all(cellfun('isempty',strfind(javaclasspath('-all'),jars{i}))))
        javaaddpath(pjars{i});
    end
end
clear jars;

% these are the additional folders for external programs
% - skip attempt at adding them to the path if they don't exist
if(isdir([path fs 'export_fig']))
    addpath([path fs 'export_fig']);
end
if(isdir([path fs 'gshhg']))
    addpath([path fs 'gshhg']);
end
if(isdir([path fs 'm_map']))
    addpath([path fs 'm_map_fixes'],...
        [path fs 'm_map']);
end
njtbx_path=[path fs 'njtbx' fs 'njToolbox-2.0'];
if(isdir(njtbx_path))
    addpath(njtbx_path,...
        [njtbx_path fs 'examples'],...
        [njtbx_path fs 'njFunc'],...
        [njtbx_path fs 'njTBX-2.0'],...
        [njtbx_path fs 'njTBX-2.0' fs 'Utilities']);
end

% jars (2 of them) for external program njtbx
% - used by WW3 functions (analyze ocean waves & seismic noise)
jars{1}='njTools-2.0.12_jre1.5.jar';
jars{2}='toolsUI-4.0.49.jar';
pjars=strcat(path,fs,'njtbx',fs,jars);
for i=1:numel(jars)
    if(java_in_octave && ...
            all(cellfun('isempty',strfind(javaclasspath('-all'),jars{i}))))
        javaaddpath(pjars{i});
    end
end
clear jars;

end
