You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.7 KiB

9 years ago
  1. clear all
  2. close all
  3. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% fastP %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  4. cut1=2700;cut2=18400;
  5. xMAX=8154;
  6. xf=(cut1-xMAX:1:cut2-xMAX);
  7. xcmfp=0;
  8. xcmfm=0;
  9. ymeanP=xf*0;
  10. ymeanM=xf*0;
  11. %%%%%%%%% legge i file con eterodina positiva fast %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  12. limBKGD=7000;
  13. filecommon='caf2_maggio11_1757';
  14. figure(50)
  15. fi=dir([filecommon '*']);
  16. index1=[];
  17. index2=[];
  18. for kk=[1:10];
  19. index1=[index1,kk];
  20. kk
  21. file=[filecommon '_' num2str(kk)];
  22. str=['load ' file '.dat'];eval(str);
  23. str=['x=' file '(:,1);'];eval(str);
  24. str=['y=' file '(:,2);'];eval(str);
  25. str=['N=' file '(:,3);'];eval(str);
  26. nn=find(x>cut1 & x<cut2);x=x(nn);y=y(nn);
  27. nn=find(x<limBKGD);y=y-mean(y(nn)); %y=y/max(y);
  28. [A,B]=butter(20,0.2,'low');
  29. yf=filter(A,B,y);
  30. nn=find(yf>0.85*max(yf));xcm=sum(x(nn).*yf(nn))/sum(yf(nn));x=x-xcm;
  31. y=interp1(x,yf,xf,'linear',NaN);
  32. figure(333);
  33. plot(xf,y);ylim([-0.02 0.02])
  34. ymeanP=ymeanP+y;
  35. xcmfp=xcmfp+xcm;
  36. str=['clear ' file ];eval(str);
  37. figure(50);
  38. hold on;plot(xf,y,'g');
  39. end
  40. hold on
  41. plot(xf,(ymeanM+ymeanP)/(length(index1)+length(index2)),'r');
  42. hold off
  43. YY=(ymeanM+ymeanP)/(length(index1)+length(index2));
  44. jj=find(isnan(YY)==0); xfnew=xf(jj); Ynew=YY(jj);
  45. jj=find(isnan(YY)==0);
  46. figure(101)
  47. xx=xf(jj)*0.52733333; yy=YY(jj)/max(YY(jj));
  48. plot(xx,yy)
  49. nn1=find(xx<-1000); nn2=find(xx>3000); nn=[nn1 nn2]; P=polyfit(xx(nn),yy(nn),1);
  50. Ybkg=polyval(P,xx);
  51. figure(11)
  52. subplot(2,1,1); semilogy(xx,yy-Ybkg,xx,yy)
  53. subplot(2,1,2); plot(xx,yy,xx,Ybkg)
  54. if 0,
  55. AA=[xx' (yy-Ybkg)']; str=['save ' filecommon '.dat AA -ascii;'];eval(str);
  56. end;