function out = reflect(in,lat, Sign);

%reflects data about the equator

%  in = input data
% data = latitude vector
% Sign = + for NH and - for SH
[a,b] =size(in);
nn=length(lat);

T=0; %will I take the transpose?
if b == nn; %If latitude is the second dimension- make it the first dimension 
    T=1; 
    in=in'; %make it a column vector
end

REV=0; %keep track of whether the latitude vector is reversed (low to high)
if lat(1) > lat(end);
    REV=1;
    in=in(end:-1:1,:);
    display('input latitude goes from high to low -- data outputters are taking stupid pills')
end


    if Sign > 0
    mid = length(lat) / 2;
    
        if mid == round(mid); %if length latitude is even;
        out = [ in(end:-1:mid+1,:) ; in(mid+1:1:end,:)];
    
        else % latitude length is odd (equator is a gridpoint)
            mid=roundup(mid);
            out = [in(end:-1:mid+1,:); in(mid,:) ; in(mid+1:1:end,:)];
        end
    end
    
    if Sign < 0
    mid = length(lat) / 2;
    
        if mid == round(mid); %if length latitude is even;
    
            out = [ in(1:1:mid,:) ; in(mid:-1:1,:)];
    
        else % latitude length is odd (equator is a gridpoint)
            mid=roundup(mid);
            out = [in(1:1:mid-1,:); in(mid,:) ; in(mid-1:-1:1,:)];
        end
    end

   
        
if REV == 1;
    out=out(end:-1:1,:); %re-reverse
end

if T == 1; %if I took the transpose, export so that the dimension
    out = out';
end