
function ave_a = plot_ea_sub(drc, dat_f, lbl_f)

dat_fnm = [drc, dat_f]
lbl_fnm = [drc, lbl_f]

tl = dlmread(lbl_fnm, ' ', [0 0 2 2]);
G_FCTR = tl(2,1);
NOTHNG = tl(2,2);
AVE_E =  tl(2,3);

%[ENERGY, ALPHA, SECTOR] = dlmread(lbl_fnm,' ', [0 0 0 2]);
%[G_FCTR, NOTHNG, AVE_E] = dlmread(lbl_fnm,' ', [1 0 1 2]);
%[TAG] = textread(lbl_fnm,'%s', 1);

[ENERGY, ALPHA, SECTOR] = textread(dat_fnm,'%f %f %f', 1);

% TATE YOKO
range=[1 0 ENERGY 1];
ee = dlmread(dat_fnm, ' ', range);
range=[ENERGY+1 0 ENERGY+ALPHA 1];
aa = dlmread(dat_fnm, ' ', range);
range=[ENERGY+ALPHA+1 0 ENERGY+ALPHA+SECTOR 1];
pp = dlmread(dat_fnm, ' ', range);
range=[ENERGY+ALPHA+SECTOR+1 0 2*ENERGY+ALPHA+SECTOR ALPHA-1];
ea = dlmread(dat_fnm, ' ', range);

delt_a(1) = abs(aa(2,1) - aa(1,1));
delt_a(ALPHA) = abs(aa(ALPHA,1) - aa(ALPHA-1,1));
for i = 2:ALPHA-1
    delt_a(i) = abs(delt_a(i+1) - delt_a(i-1))/2.;
end
sum_a = 0.;
sum_d = 0.;
for i = 1:ALPHA
    %if aa(i,1) > 45
    %    continue;
    %end
    sum_a = sum_a + aa(i,2)*aa(i,1)*delt_a(i);
    sum_d = sum_d + aa(i,2)*delt_a(i);
end
ave_a = sum_a/sum_d;

%return

