Commit f166eb70 authored by perdereau's avatar perdereau
Browse files

viewtfmap : add trace des positions de sources , cosmetique

rotation des phases : changement du decodate des params des polynomes
(pour accomoder des polynomes de degre eleve et variable)
parent b5e317e0
...@@ -19,7 +19,7 @@ names = ['1H','2H','3H','4H','1V','2V','3V','4V','1Hx2H','1Hx3H','1Hx4H','2Hx3H' ...@@ -19,7 +19,7 @@ names = ['1H','2H','3H','4H','1V','2V','3V','4V','1Hx2H','1Hx3H','1Hx4H','2Hx3H'
'1Vx2V','1Vx3V','1Vx4V','2Vx3V','2Vx4V','3Vx4V','1Hx1V','1Hx2V','1Hx3V','1Hx4V','2Hx1V','2Hx2V','2Hx3V','2Hx4V', '1Vx2V','1Vx3V','1Vx4V','2Vx3V','2Vx4V','3Vx4V','1Hx1V','1Hx2V','1Hx3V','1Hx4V','2Hx1V','2Hx2V','2Hx3V','2Hx4V',
'3Hx1V','3Hx2V','3Hx3V','3Hx4V','4Hx1V','4Hx2V','4Hx3V','4Hx4V'] '3Hx1V','3Hx2V','3Hx3V','3Hx4V','4Hx1V','4Hx2V','4Hx3V','4Hx4V']
def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=False,mtitle="",clean=True,mod=False,arg=False,noplo=False,verb=False,yrcm=False,cor=[],cimag=False,creal=False,hasvar=True,ramod=False): def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=False,mtitle="",clean=True,mod=False,arg=False,noplo=False,verb=False,yrcm=False,cor=[],cimag=False,creal=False,hasvar=True,ramod=False,plras=[],nmras=[]):
print len(cor) print len(cor)
filename = folder filename = folder
#print i #print i
...@@ -129,22 +129,32 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F ...@@ -129,22 +129,32 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F
else: else:
plt.xlabel("Temps (h)") plt.xlabel("Temps (h)")
if ramod :
for rap in plras:
ax1.plot([rap,rap],[frmax,frmin],color='red',linestyle='--')
ax1.annotate(nmras[plras.index(rap)],(rap,frmin),horizontalalignment='center',verticalalignment='bottom')
ax1.yaxis.grid(which="major", color='gray', linestyle='-', linewidth=.5) ax1.yaxis.grid(which="major", color='gray', linestyle='-', linewidth=.5)
ax1.xaxis.grid(which="major", color='gray', linestyle='-', linewidth=.5) ax1.xaxis.grid(which="major", color='gray', linestyle='-', linewidth=.5)
ax2=ax1.twinx() ax2=ax1.twinx()
ax2.yaxis.set_view_interval(len(freqs),0.,ignore=True) ax2.yaxis.set_view_interval(len(freqs),0.,ignore=True)
ax2.set_ylabel("Freq. bin",rotation=270.,y=0.9) ax2.set_ylabel("Freq. bin",rotation=270.,y=0.9)
ax3=ax1.twiny() if not ramod :
ax3.xaxis.set_view_interval(0.,len(times)) ax3=ax1.twiny()
ax3.set_xlabel("time bin",x=0.85) ax3.xaxis.set_view_interval(0.,len(times))
ax3.set_xlabel("time bin",x=0.85)
if save: if save:
ext="" ext=""
if creal : if creal :
ext = ext+"_real" ext = ext+"_real"
plt.savefig(filename+"_"+ names[num]+"_rawTFM.png") if ramod :
if len(plras) >0 :
plt.savefig(filename+"_"+ names[num]+"_RAM"+ext+"_srcs.png")
else :
plt.savefig(filename+"_"+ names[num]+"_RAM"+ext+".png")
else :
plt.savefig(filename+"_"+ names[num]+"_TFM"+ext+".png")
axcolor = 'lightgoldenrodyellow' axcolor = 'lightgoldenrodyellow'
axmin = fig.add_axes([0.075, 0.05, 0.35, 0.03], facecolor = axcolor ) axmin = fig.add_axes([0.075, 0.05, 0.35, 0.03], facecolor = axcolor )
...@@ -257,7 +267,7 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F ...@@ -257,7 +267,7 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F
plt.title(filename + ' ' +mtitle,y=1.08) plt.title(filename + ' ' +mtitle,y=1.08)
if save: if save:
plt.savefig(filename+"_"+ names[num]+"_rawTFM_freq.png") plt.savefig(filename+"_"+ names[num]+"_TFM_ra.png")
if timeplot : if timeplot :
...@@ -277,7 +287,7 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F ...@@ -277,7 +287,7 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F
else : else :
plt.title(filename + ' ' +mtitle,y=1.08) plt.title(filename + ' ' +mtitle,y=1.08)
if save: if save:
plt.savefig(filename+"_"+ names[num]+"_rawTFM_freq.png") plt.savefig(filename+"_"+ names[num]+"_TFM_freq.png")
if (verb) : if (verb) :
print times.size print times.size
if (verb) : if (verb) :
......
...@@ -60,7 +60,7 @@ P4PhaseCor::P4PhaseCor(string const & filename) ...@@ -60,7 +60,7 @@ P4PhaseCor::P4PhaseCor(string const & filename)
readFitParamFile(filename); readFitParamFile(filename);
} }
double P4PhaseCor::jec_phase_poly(double freq, double * p){ double P4PhaseCor::jec_phase_poly(double freq, vector <double> p){
double ret = 0.; double ret = 0.;
double del = 1.; double del = 1.;
for (int k=0 ; k<int(p[0])+1 ; k++,del *= freq-p[1] ){ for (int k=0 ; k<int(p[0])+1 ; k++,del *= freq-p[1] ){
...@@ -68,10 +68,13 @@ double P4PhaseCor::jec_phase_poly(double freq, double * p){ ...@@ -68,10 +68,13 @@ double P4PhaseCor::jec_phase_poly(double freq, double * p){
} }
return(ret); return(ret);
} }
double P4PhaseCor::phase_pypoly(double freq, double * p){
// nouvelle incarnatino, parametres pas ds le mm ordre ...
double P4PhaseCor::phase_pypoly(double freq, vector<double> p){
double ret = 0.; double ret = 0.;
double del = 1.;
int deg = p[0]; int deg = p[0];
double delta = freq-p[1]; double delta = freq-p[1];
for (int k=0 ; k <= deg ; k ++){ for (int k=0 ; k <= deg ; k ++){
...@@ -88,21 +91,31 @@ void P4PhaseCor::readFitParamFile(string const & filename) ...@@ -88,21 +91,31 @@ void P4PhaseCor::readFitParamFile(string const & filename)
string line; string line;
char mot[32], ftype[32], key[4], feed[3]; char mot[32], ftype[32], key[4], feed[3];
double p[12] ;
char dummy[4];
while (!is.eof()) { while (!is.eof()) {
vector <double> p ;
line = ""; line = "";
getline(is, line); getline(is, line);
if ((is.good() || is.eof()) && (line.length()>0) && (line[0]!='#')) { if ((is.good() || is.eof()) && (line.length()>0) && (line[0]!='#')) {
for (int k=0 ; k<12 ; k++) p[k] = -9e-99;
sscanf(line.c_str(),"%s %s %lg %lg %lg %lg %lg %lg %lg %lg %lg %lg %lg %lg %lg", mot, ftype, p, p+1, p+2,p+3,p+4,p+5,p+6,p+7,p+8,p+9,p+10,p+11,p+12); //sscanf(line.c_str(),"%s %s %lg %lg %lg %lg %lg %lg %lg %lg %lg %lg %lg %lg %lg", mot, ftype, p, p+1, p+2,p+3,p+4,p+5,p+6,p+7,p+8,p+9,p+10,p+11,p+12);
sscanf(line.c_str(),"%s %s %s",mot,ftype,dummy);
key[0]=mot[0]; key[1]=mot[1]; key[2]=mot[2]; key[3]='\0'; key[0]=mot[0]; key[1]=mot[1]; key[2]=mot[2]; key[3]='\0';
feed[0]=mot[3]; feed[1]=mot[4]; feed[2]='\0'; feed[0]=mot[3]; feed[1]=mot[4]; feed[2]='\0';
if (strcmp(key,"Phi")!=0) { if (strcmp(key,"Phi")!=0) {
cout << " Phi not in "<<key<<endl; cout << " Phi not in "<<key<<endl;
continue; continue;
} }
sa_size_t fid = P4AVisiNumEncoder::getFeedNum(feed);
string sftyp = ftype; string sftyp = ftype;
cout << "P4PhaseCor::readFitParamFile() Info : parm type "<<sftyp<<" all params "<< endl;
sa_size_t fid = P4AVisiNumEncoder::getFeedNum(feed);
cout << "P4PhaseCor::readFitParamFile() Info : feed "<<feed << endl;
if (fid < 0) { if (fid < 0) {
cout<<"P4PhaseCor::readFitParamFile()/ERROR bad feed name= "<<feed<<" -> fid="<<fid<<endl; cout<<"P4PhaseCor::readFitParamFile()/ERROR bad feed name= "<<feed<<" -> fid="<<fid<<endl;
continue; continue;
...@@ -111,14 +124,44 @@ void P4PhaseCor::readFitParamFile(string const & filename) ...@@ -111,14 +124,44 @@ void P4PhaseCor::readFitParamFile(string const & filename)
cout<<"P4PhaseCor::readFitParamFile()/ERROR bad fitted function type= "<<sftyp<<endl; cout<<"P4PhaseCor::readFitParamFile()/ERROR bad fitted function type= "<<sftyp<<endl;
continue; continue;
} }
istringstream iss(line);
int cnt =0;
do
{
string subs;
iss >> subs;
cout << "Substring: |" << subs << "| cnt "<< cnt << " " << subs.size()<<endl;
cnt++;
if (cnt> 2 && subs.size()>0 ) {
double tst;
sscanf(subs.c_str(),"%lg",&tst);
p.push_back(tst);
}
} while (iss);
cout << "P4PhaseCor::readFitParamFile() Info : parm type "<<sftyp<<" param number= "<< p.size()<<endl;
for (sa_size_t np=0 ; np<p.size() ; np++) cout<<" parm "<<np<<" = "<<p[np]<<endl;
TVector<double> phases((sa_size_t)P4FreqBand::getP4NbFreqChannels()); TVector<double> phases((sa_size_t)P4FreqBand::getP4NbFreqChannels());
for (sa_size_t k=0; k<phases.Size(); k++) { for (sa_size_t k=0; k<phases.Size(); k++) {
double freq = P4FreqBand::getP4Frequency((int)k); double freq = P4FreqBand::getP4Frequency((int)k);
if (sftyp=="Linear") phases(k) = jec_phase_linear(freq, p); if (sftyp=="Linear") {
else if (sftyp=="Sawtooth") phases(k) = jec_phase_sawtooth(freq, p); phases(k) = jec_phase_linear(freq, p);
else if (sftyp=="Polynomial") phases(k) = jec_phase_poly(freq, p); }
else phases(k) = phase_pypoly(freq, p); else if (sftyp=="Sawtooth") {
phases(k) = jec_phase_sawtooth(freq, p);
}
else if (sftyp=="Polynome"){
phases(k) = phase_pypoly(freq, p);
}
else if (sftyp=="Polynomial"){
phases(k) = jec_phase_poly(freq, p);
}
} }
cout << " P4PhaseCor::readFitParamFile()/Info: Setting phases (fit-type="<<sftyp<<") for feed="<<feed<<" -> fid="<<fid<<endl; cout << " P4PhaseCor::readFitParamFile()/Info: Setting phases (fit-type="<<sftyp<<") for feed="<<feed<<" -> fid="<<fid<<endl;
......
...@@ -71,13 +71,13 @@ public: ...@@ -71,13 +71,13 @@ public:
//---- See AnaFringes/postFringeV2.cc //---- See AnaFringes/postFringeV2.cc
/*! \brief return the phase value as a linear function of frequency, using Jean-Eric linear fit /*! \brief return the phase value as a linear function of frequency, using Jean-Eric linear fit
parameters p[0,1,2] : p[1]+(freq-p[0])*p[2] */ parameters p[0,1,2] : p[1]+(freq-p[0])*p[2] */
static inline double jec_phase_linear(double freq, double * p) static inline double jec_phase_linear(double freq, vector <double> p)
{ {
return p[1]+p[2]*(freq-p[0]); return p[1]+p[2]*(freq-p[0]);
} }
/*! \brief return the phase value as a sawtooth function of frequency, using Jean-Eric Sawtooth fit /*! \brief return the phase value as a sawtooth function of frequency, using Jean-Eric Sawtooth fit
parameters p[0,1] : 2 ArgTan[Cot(Pi{p[0](x+p[1])+0.5})] */ parameters p[0,1] : 2 ArgTan[Cot(Pi{p[0](x+p[1])+0.5})] */
static inline double jec_phase_sawtooth(double freq, double * p) static inline double jec_phase_sawtooth(double freq, vector<double> p)
{ {
return 2.*atan(1./tan(M_PI*((p[0]*(freq+p[1]))+0.5))); return 2.*atan(1./tan(M_PI*((p[0]*(freq+p[1]))+0.5)));
} }
...@@ -85,12 +85,12 @@ public: ...@@ -85,12 +85,12 @@ public:
/*! \brief return the phase value as a polynom function of frequency, using Jean-Eric Sawtooth fit /*! \brief return the phase value as a polynom function of frequency, using Jean-Eric Sawtooth fit
parameters p[0,1,...] : p[0] center freq p[1]= degree of poly, p[2].... p[n] coeffs parameters p[0,1,...] : p[0] center freq p[1]= degree of poly, p[2].... p[n] coeffs
p[2]+p[3]*(freq-p[0])+... */ p[2]+p[3]*(freq-p[0])+... */
static double jec_phase_poly(double freq, double * p); static double jec_phase_poly(double freq, vector <double> p);
/*! \brief return the phase value as a polynom function of frequency, using Jean-Eric Sawtooth fit /*! \brief return the phase value as a polynom function of frequency, using Jean-Eric Sawtooth fit
parameters p[0,1,...] : p[0] center freq p[1]= degree of poly, p[2].... p[n] coeffs parameters p[0,1,...] : p[0] center freq p[1]= degree of poly, p[2].... p[n] coeffs
in decreasing power order (python-like convention)*/ in decreasing power order (python-like convention)*/
static double phase_pypoly(double freq, double * p); static double phase_pypoly(double freq, vector<double> p);
protected: protected:
// for each feed, there is a vector which contains the value of the phase as a function of frequency // for each feed, there is a vector which contains the value of the phase as a function of frequency
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment