function []=shutdown_seizmo()
%SHUTDOWN_SEIZMO    Removes SEIZMO from dynamic path & javaclasspath
%
% This script will remove SEIZMO from the current session except for jar
% files on the static javaclasspath.  This is meant to compliment
% STARTUP_SEIZMO so you can quickly work with SEIZMO as desired.  There is
% no neccessity to edit the path unless you are dealing with multiple
% installs.
if(exist('validseizmo','file'))
    path=fileparts(fileparts(which('validseizmo'))); % root directory
else
    error('seizmo:shutdown_seizmo:noSEIZMO',...
        'No SEIZMO found to shutdown!');
end
%path='/opt/seizmo/seizmo'; % Modify & Uncomment for multi-SEIZMO install

% path separator
fs=filesep;

% removing seizmo folders
rmpath(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

% removing irisws jar
jars{1}=[path fs 'ws' fs 'IRIS-WS-2.0.6.jar'];
for i=1:numel(jars)
    if(java_in_octave && ismember(jars{1},javaclasspath))
        javarmpath(jars{1});
    end
end
clear jars;

% removing the jars for mattaup
jars{1}=[path fs 'mattaup' fs 'lib' fs 'TauP-2.1.1.jar'];
jars{2}=[path fs 'mattaup' fs 'lib' fs 'seisFile-1.5.1.jar'];
jars{3}=[path fs 'mattaup' fs 'lib' fs 'MatTauP-2.1.1.jar'];
for i=1:numel(jars)
    if(java_in_octave && ismember(jars{i},javaclasspath))
        javarmpath(jars{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']))
    rmpath([path fs 'export_fig']);
end
if(isdir([path fs 'gshhg']))
    rmpath([path fs 'gshhg']);
end
if(isdir([path fs 'm_map']))
    rmpath([path fs 'm_map_fixes'],...
        [path fs 'm_map']);
else
    rmpath([path fs 'm_map_fixes']);
end
njtbx_path=[path fs 'njtbx' fs 'njToolbox-2.0'];
if(isdir(njtbx_path))
    rmpath(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}=[path fs 'njtbx' fs 'njTools-2.0.12_jre1.5.jar'];
jars{2}=[path fs 'njtbx' fs 'toolsUI-4.0.49.jar'];
for i=1:numel(jars)
    if(java_in_octave && ismember(jars{i},javaclasspath))
        javarmpath(jars{i});
    end
end
clear jars;

end

