%parseCraterPopulationAtUnconformity
%Edwin Kite
%1 March 2014

NameOfCraterCountArcGISShapefile = 'craters_candidate_at_sub_delta_unconformity_3rd_Pass_Princeton_Feb_2014.shp';
[cxc,cyc,crc] = parseCraterCountFromArcGISShapefile(NameOfCraterCountArcGISShapefile);
cand = shaperead(NameOfCraterCountArcGISShapefile);

NameOfCraterCountArcGISShapefile = 'craters_at_sub_delta_unconformity_3rd_Pass_Princeton_Feb_2014.shp';
[cx,cy,cr] = parseCraterCountFromArcGISShapefile(NameOfCraterCountArcGISShapefile);
sure = shaperead(NameOfCraterCountArcGISShapefile);
%sure(28).FrmdInSqnc = NaN;
%warning('Manual Override!')

uc = shaperead('base_Y_combined.shp')%unconformity 

scatter(cxc,cyc,100,log10(crc.*2),'LineWidth',2); axis equal; colorbar
hold on; box on; set(gca,'FontSize',18); axis equal
scatter(cx,cy,100,log10(cr.*2),'Filled'); axis equal; colorbar
title('log10(crater diameter)')
as = shaperead('craters_at_sub_delta_unconformity_Areas_Searched.shp'); %area searched
scatter([as(:).X],[as(:).Y],10,'r.')
for l = 1:length(uc)
    line(uc(l).X,uc(l).Y)
end
            saveas(gca, ...
            strcat('ParseCraterPopulationAtUnconformityA.eps'), ...
            'epsc');

figure
scatter(cxc,cyc,100,log10([cand(:).MarginStyl])./log10(2),'LineWidth',2); axis equal; colorbar
hold on; box on; set(gca,'FontSize',18); axis equal
scatter(cx,cy,100,log10([sure(:).MarginStyl])./log10(2),'Filled'); axis equal; colorbar
title('log2(MarginStyle)')
scatter([as(:).X],[as(:).Y],10,'r.')
for l = 1:length(uc)
    line(uc(l).X,uc(l).Y)
end
            saveas(gca, ...
            strcat('ParseCraterPopulationAtUnconformityB.eps'), ...
            'epsc');

figure
scatter(cxc,cyc,100,log10([cand(:).InfillStyl])./log10(2),'LineWidth',2); axis equal; colorbar
hold on; box on; set(gca,'FontSize',18); axis equal
scatter(cx,cy,100,log10([sure(:).InfillStyl])./log10(2),'Filled'); axis equal; colorbar
title('log2(InfillStle)')
scatter([as(:).X],[as(:).Y],10,'r.')
for l = 1:length(uc)
    line(uc(l).X,uc(l).Y)
end
            saveas(gca, ...
            strcat('ParseCraterPopulationAtUnconformityC.eps'), ...
            'epsc');

figure
scatter(cxc,cyc,100,([cand(:).FrmdInSqnc]),'LineWidth',2); axis equal; colorbar
hold on; box on; set(gca,'FontSize',18); axis equal
scatter(cx,cy,100,([sure(:).FrmdInSqnc]),'Filled'); axis equal; colorbar
title('FrmdInSqnc')
scatter([as(:).X],[as(:).Y],10,'r.')
for l = 1:length(uc)
    line(uc(l).X,uc(l).Y)
end
            saveas(gca, ...
            strcat('ParseCraterPopulationAtUnconformityD.eps'), ...
            'epsc');

figure
scatter([cand(:).FrmdInSqnc]-0.1+0.05.*log10([cand(:).MarginStyl])./log10(2),crc*2,100,log10([cand(:).MarginStyl])./log10(2),'LineWidth',2); colorbar
hold on; set(gca,'FontSize',18); 
scatter([sure(:).FrmdInSqnc]-0.1+0.05.*log10([sure(:).MarginStyl])./log10(2),cr*2,100,log10([sure(:).MarginStyl])./log10(2),'Filled'); colorbar
title('Crater diameter versus crater-hosting sequence, color is log(2) margin style')
    set(gca,'yscale','log'); grid minor
xlim([0.5 3.5]); ylim([80 12000]); box on
            saveas(gca, ...
            strcat('ParseCraterPopulationAtUnconformityE.eps'), ...
            'epsc');    

summarize = [[sure.Latitude]',[sure.Longitude]',2.*cr'./1e3]

findCraterDensityAtUnconformity
