function Cal_hr=calc_hr(hr,Cal,calfile)

argpix=[72 94 129 144 179];%the (pixels sent back from argos)
pixinc=4;%*Pixel Increment 
FirstPix=350;%+350 (FirstPix from the machine)) to correspond to 412,443,490,510,555

%Should not need to modify below this point
Pixel=argpix.*pixinc+FirstPix;

if isfield(calfile,'sr')
    for pix=1:length(Pixel)
        Cal_hr.Es(pix,:)=(Cal.SrA.Caldat(Pixel(pix)).e)*(Cal.SrA.Caldat(Pixel(pix)).immer).*(hr.Zero(pix,:));
        Cal_hr.Ed(pix,:)=(Cal.HrA.Caldat(Pixel(pix)).e)*(Cal.HrA.Caldat(Pixel(pix)).immer).*(hr.One(pix,:));
        Cal_hr.Lu(pix,:)=(Cal.HrB.Caldat(Pixel(pix)).e)*(Cal.HrB.Caldat(Pixel(pix)).immer).*(hr.Two(pix,:));
    end;
    
    for lambda=1:5
        Cal_hr.Lambda.Es(lambda)=round((Cal.SrA.W(1))+(Pixel(lambda)*Cal.SrA.W(2))+((Pixel(lambda)^2)*Cal.SrA.W(3)));
        Cal_hr.Lambda.Ed(lambda)=round((Cal.HrA.W(1))+(Pixel(lambda)*Cal.HrA.W(2))+((Pixel(lambda)^2)*Cal.HrA.W(3)));
        Cal_hr.Lambda.Lu(lambda)=round((Cal.HrB.W(1))+(Pixel(lambda)*Cal.HrB.W(2))+((Pixel(lambda)^2)*Cal.HrB.W(3)));
    end;
elseif isfield(calfile, 'hr2')
    for pix=1:length(Pixel)
        Cal_hr.Ed(pix,:)=(Cal.HrB.Caldat(Pixel(pix)).e)*(Cal.HrA.Caldat(Pixel(pix)).immer).*(hr.One(pix,:));
        Cal_hr.Lu(pix,:)=(Cal.HrA.Caldat(Pixel(pix)).e)*(Cal.HrB.Caldat(Pixel(pix)).immer).*(hr.Two(pix,:));
    end;
    
    for lambda=1:5
        Cal_hr.Lambda.Ed(lambda)=round((Cal.HrA.W(1))+(Pixel(lambda)*Cal.HrA.W(2))+((Pixel(lambda)^2)*Cal.HrA.W(3)));
        Cal_hr.Lambda.Lu(lambda)=round((Cal.HrB.W(1))+(Pixel(lambda)*Cal.HrB.W(2))+((Pixel(lambda)^2)*Cal.HrB.W(3)));
    end;
else
    for pix=1:length(Pixel)
        Cal_hr.Es(pix,:)=(Cal.SrA.Caldat(Pixel(pix)).e)*(Cal.SrA.Caldat(Pixel(pix)).immer).*(hr.Two(pix,:));
        Cal_hr.Ed(pix,:)=(Cal.HrA.Caldat(Pixel(pix)).e)*(Cal.HrA.Caldat(Pixel(pix)).immer).*(hr.One(pix,:));
        Cal_hr.Lu(pix,:)=(Cal.HrB.Caldat(Pixel(pix)).e)*(Cal.HrB.Caldat(Pixel(pix)).immer).*(hr.Zero(pix,:));
    end;
    
    for lambda=1:5
        Cal_hr.Lambda.Es(lambda)=round((Cal.SrA.W(1))+(Pixel(lambda)*Cal.SrA.W(2))+((Pixel(lambda)^2)*Cal.SrA.W(3)));
        Cal_hr.Lambda.Ed(lambda)=round((Cal.HrA.W(1))+(Pixel(lambda)*Cal.HrA.W(2))+((Pixel(lambda)^2)*Cal.HrA.W(3)));
        Cal_hr.Lambda.Lu(lambda)=round((Cal.HrB.W(1))+(Pixel(lambda)*Cal.HrB.W(2))+((Pixel(lambda)^2)*Cal.HrB.W(3)));
    end;

end
    

Cal_hr.Time=hr.time;
