diff --git a/opi/Scripts/ExtracData.py b/opi/Scripts/ExtracData.py index c3ea07aad081385e85d160892411196bc4e486fc..3f59b9fc50bc4dff6153c92b7e1bd76e666fedeb 100644 --- a/opi/Scripts/ExtracData.py +++ b/opi/Scripts/ExtracData.py @@ -1,11 +1,6 @@ from org.csstudio.opibuilder.scriptUtil import PVUtil from os.path import expanduser - -#! /usr/bin/env python -#from org.csstudio.opibuilder.scriptUtil import PVUtil import struct -#import matplotlib.pyplot as plt -#import urllib2 import json from random import betavariate import math @@ -54,21 +49,21 @@ PlotFile.write("fichier emittance: X\n") PlotFile.write("HT ion (kV) : %d\n"%(Energie)) PlotFile.write("frequence (Hz) : %d\n"%(Frequence)) PlotFile.write("N points temps : 1\n") -PlotFile.write("pas de position (mm) : %d\n"%(PasMM)) +PlotFile.write("pas de position (mm) : %f\n"%(PasMM)) PlotFile.write("N points position (mm) : %i\n"%(NbPos)) PlotFile.write("N points angle (mrad) : %i\n"%(NbAngle)) ## POSITION PlotFile.write("vecteur positions (mm) : ") for value in range(0,NbPos): - PlotFile.write("%d "%tabPos[value]); + PlotFile.write("%.2f "%tabPos[value]); value=value+1 ## ANGLES PlotFile.write("\nvecteur angles (mrad) : ") indAngle=0 for value in range(0,NbAngle): - PlotFile.write("%f "%tabAng[indAngle]); + PlotFile.write("%.2f "%tabAng[indAngle]); indAngle=indAngle+NbPos PlotFile.write("\ntype d'ion : PROTON...") @@ -76,10 +71,10 @@ PlotFile.write("\ncolonnes de 1 a 4 : indice de temps / indice position / indice ## POSITION/ANGLE/INTENSITY indCurrent=NbPos-1 -indPos=NbPos-1 +indPos=NbPos for valuePos in range(0,NbPos): for valueAngle in range(0,NbAngle): - PlotFile.write("0\t%i\t%i\t%f\n" %(valuePos,valueAngle,tabCurr[indCurrent])); + PlotFile.write("0\t%i\t%i\t%.4f\n" %(valuePos,valueAngle,tabCurr[indCurrent])); indCurrent=indCurrent+NbPos indPos=indPos-1 indCurrent=indPos @@ -92,21 +87,19 @@ PlotFile.close() ################################################################################### #### OPEN FILE -#PlotFile = open('/home/catane/data/'+NameFile+"-avg.txt", 'w+') +PlotFile = open(home+'/data/emit/averageDataEmit/'+"avg-"+NameFile, 'w+') ## POSITION/ANGLE/INTENSITY -#indTab=NbPos-1 -#indPos=NbPos-1 - -##for valuePos in tabPos: -# for valueAngle in range(0,NbAngle): - #PlotFile.write("0\t%d\t%d\t%d\n" %(valuePos[indPos],valueAngle[indAngle],tabCurr[indCurrent])); -# PlotFile.write("%d\t%d\t%d\n" %(valuePos,tabAng[indTab],tabCurr[indTab])); - - #indCurrent=indCurrent+NbPos -## indTab=indTab+NbPos -# indPos=indPos-1 - #indCurrent=indPos -# indTab=indPos +indAngle=NbPos-1 +indCurrent=NbPos-1 +indPos=NbPos +for valuePos in range(0,(NbPos)): + for valueAngle in range(0,NbAngle): + PlotFile.write("\n%.2f\t\t%.2f\t\t%.4f\n " %(tabPos[valuePos],tabAng[indAngle],tabCurr[indCurrent])); + indAngle=indAngle+NbPos + indCurrent=indCurrent+NbPos + indPos=indPos-1 + indAngle=indPos + indCurrent=indPos -#PlotFile.close() +PlotFile.close()