function polycz() % autogenerated function wrapper
    % crosssel.m                      Alexander Allmann
    % function to select earthquakes in a cross-section and make them the
    % current catalog in the main map windo
    %
    %
    % turned into function by Celso G Reyes 2017
    
    ZG=ZmapGlobal.Data; % used by get_zmap_globals
    
    global newa
    
    report_this_filefun(mfilename('fullpath'));
    
    figNumber=findobj('Type','Figure','-and','Name','Z-Value-Cross-section');
    
    figure(figNumber);
    
    ax=findobj(gcf,'Tag','mainmap_ax');
    [x,y, mouse_points_overlay] = select_polygon(ax);
    
    hold on
    plot(x,y,'b-');
    YI = -newa.Depth;          % this substitution just to make equation below simple
    XI = newa(:,end);
    lb = polygon_filter(x,y, XI, YI, 'inside');
    
    %plot the selected eqs and mag freq curve
    ZG.newt2 = newa.subset(lb);
    newcat = newa.subset(lb);
    pl = plot(ZG.newt2(:,length(ZG.newt2.subset(1))),-ZG.newt2.Depth,'xk'); %FIXME huh? what are they trying to do? looks like indexing are mixed up
    set(pl,'MarkerSize',8, 'LineWidth',1)
    timeplot()
end
