Commit 7155929a authored by Reza  ANSARI's avatar Reza ANSARI
Browse files

Merge branch 'master' of gitlab.in2p3.fr:baoradio/AnaPAON4

  Merge protection sur RA avec modifs Olivier ds p4autils.cc - Reza
parents 9fefb5a6 13d6684d
...@@ -395,12 +395,13 @@ r_8 Beam::Value(r_8 const xp[], r_8 const* Par) { ...@@ -395,12 +395,13 @@ r_8 Beam::Value(r_8 const xp[], r_8 const* Par) {
} else { } else {
#if TYPE_BEAM == 1 #if TYPE_BEAM == 1
lob = exp(-0.220544*x*x); //gaussian equivalent of J1 formula normalise a 1 //BUG JEC 20/9/19 the magic coeff was determined on spherical_bessel fonction and not the Bessel function lob = exp(-0.220544*x*x); //gaussian equivalent of J1 formula normalise a 1
lob = exp(-0.280092*x*x); //gaussian equivalent of J1 formula normalise a 1
#else #else
if(x==0.) { if(x==0.) {
lob = 1.; lob = 1.;
} else { } else {
lob = 3. * boost::math::cyl_bessel_j(1, x)/x; lob = 2. * boost::math::bessel_j(1, x)/x;
lob *= lob; lob *= lob;
} }
#endif #endif
......
...@@ -2,11 +2,13 @@ import math as math ...@@ -2,11 +2,13 @@ import math as math
import sys, platform, os import sys, platform, os
import numpy as np import numpy as np
from astropy.io import fits from astropy.io import fits
import matplotlib as matplotlib
from matplotlib import pyplot as plt from matplotlib import pyplot as plt
import itertools as itert import itertools as itert
from skimage import data, img_as_float from skimage import data, img_as_float
from skimage import exposure from skimage import exposure
from matplotlib.ticker import StrMethodFormatter
from matplotlib.ticker import FormatStrFormatter
import mynormalize as mynorm import mynormalize as mynorm
from matplotlib.widgets import Slider, Button, RadioButtons from matplotlib.widgets import Slider, Button, RadioButtons
import time import time
...@@ -14,14 +16,23 @@ from colorsys import hsv_to_rgb, hls_to_rgb ...@@ -14,14 +16,23 @@ from colorsys import hsv_to_rgb, hls_to_rgb
# Choices: ['auto', 'gtk', 'gtk3', 'inline', 'nbagg', 'notebook', 'osx', 'qt', 'qt4', 'qt5', 'tk', 'wx'] # Choices: ['auto', 'gtk', 'gtk3', 'inline', 'nbagg', 'notebook', 'osx', 'qt', 'qt4', 'qt5', 'tk', 'wx']
# values of the freqs for the slices # values of the freqs for the slices
rfreq = [1381.,1390.,1420.5,1430.] rfreq = [1347.,1390.,1420.5,1430.]
#rfreq = [1420.30,1420.35,1420.4,1420.45,1420.5,1420.55,1420.6,1420.65,1420.7,1420.75]
rfreq = [1420.30,1420.35,1420.4,1420.45,1420.5,1420.55,1420.6,1420.65,1420.7,1420.75]
rfreq=[1420.,1420.4,1420.8,1421.2,1421.6,1421.8,1422.,1422.25,1422.5]
rfreq=[1420.4,1422.8,1421.8,1421.06,1419.7,1419.0]
normf=[1325.,1465.] # "normal frequencies" normf=[1325.,1465.] # "normal frequencies"
names = ['1H','2H','3H','4H','1V','2V','3V','4V','1Hx2H','1Hx3H','1Hx4H','2Hx3H','2Hx4H','3Hx4H', names = ['1H','2H','3H','4H','1V','2V','3V','4V','1Hx2H','1Hx3H','1Hx4H','2Hx3H','2Hx4H','3Hx4H',
'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']
font = {'family' : 'normal',
'weight' : 'normal',
'size' : 20}
matplotlib.rc('font', **font)
# viewtfmap reads and returns data stored in the TF maps fits files build by visiavg (code in AnaPAON4) # viewtfmap reads and returns data stored in the TF maps fits files build by visiavg (code in AnaPAON4)
# all TF maps are stored as hdu in the fits file, with some additional data at the end. # all TF maps are stored as hdu in the fits file, with some additional data at the end.
...@@ -56,7 +67,8 @@ names = ['1H','2H','3H','4H','1V','2V','3V','4V','1Hx2H','1Hx3H','1Hx4H','2Hx3H' ...@@ -56,7 +67,8 @@ names = ['1H','2H','3H','4H','1V','2V','3V','4V','1Hx2H','1Hx3H','1Hx4H','2Hx3H'
# hasvar : to handle the cas where there are no variances # hasvar : to handle the cas where there are no variances
# ramod : to handle the case where the time-freq maps are ra-frequency maps [deprecated] # ramod : to handle the case where the time-freq maps are ra-frequency maps [deprecated]
# mask : if true, also looks for a 'mask' file (same name+'_mask') to mask RFIs and satellites # mask : if true, also looks for a 'mask' file (same name+'_mask') to mask RFIs and satellites
# yrcm : to use another color map ( # yrcm : to use another color map
# usecm : choice of colormap
# raplot : also shows slices at some frequencies [see array rfreq above] as a fct of RA [deprecated - don't ew # raplot : also shows slices at some frequencies [see array rfreq above] as a fct of RA [deprecated - don't ew
# timeplot : also shows slices at soem frequencies as a fct of time [deprecated - don't use] # timeplot : also shows slices at soem frequencies as a fct of time [deprecated - don't use]
...@@ -76,11 +88,11 @@ names = ['1H','2H','3H','4H','1V','2V','3V','4V','1Hx2H','1Hx3H','1Hx4H','2Hx3H' ...@@ -76,11 +88,11 @@ names = ['1H','2H','3H','4H','1V','2V','3V','4V','1Hx2H','1Hx3H','1Hx4H','2Hx3H'
# #
def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=False,mtitle="",clean=True,mod=False, def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=False,mtitle="",clean=True,mod=False,
arg=False,cmplx=False,noplo=False,verb=False,yrcm=False,cor=[],cimag=False,creal=False,hasvar=True, arg=False,cmplx=False,noplo=False,verb=False,yrcm=False,cor=[],cimag=False,creal=False,hasvar=True,submed=False,subhmed=False,
ramod=False,plras=[],nmras=[],mask=False,logsc=False,snratio=False): ramod=False,plras=[],nmras=[],mask=False,logsc=False,snratio=False,usecm="",extaxes=False,choose_cmap=False,nau=True) :
if verb : if verb :
print len(cor) print (len(cor))
filename = folder filename = folder
if noplo : if noplo :
clean=False clean=False
...@@ -113,14 +125,14 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F ...@@ -113,14 +125,14 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F
i=num # devrait etre juste la pour les sorties des voies th et rfi i=num # devrait etre juste la pour les sorties des voies th et rfi
if (verb) : if (verb) :
print hdulist[i].header print( hdulist[i].header)
# get the bin indexes for the slices & the "normal range" # get the bin indexes for the slices & the "normal range"
bfreq = [ (np.abs(freqs-rf)).argmin() for rf in rfreq ] bfreq = [ (np.abs(freqs-rf)).argmin() for rf in rfreq ]
bfnor = [(np.abs(freqs-rf)).argmin() for rf in normf ] bfnor = [(np.abs(freqs-rf)).argmin() for rf in normf ]
if (verb) : if (verb) :
print ' number of hdus ' + str(len(hdulist)) print (' number of hdus ' + str(len(hdulist)))
nfre = np.size(freqs) nfre = np.size(freqs)
...@@ -129,7 +141,7 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F ...@@ -129,7 +141,7 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F
if timin ==0. : if timin ==0. :
timin=times[0]/3600. timin=times[0]/3600.
timax = max(times)/3600. timax = max(times)/3600.
print ' timin/max = '+str(timin)+', ' +str(timax) print (' timin/max = '+str(timin)+', ' +str(timax))
if ramod : if ramod :
timin = min(ras) timin = min(ras)
timax= max(ras) timax= max(ras)
...@@ -148,13 +160,32 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F ...@@ -148,13 +160,32 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F
if(cimag): if(cimag):
img = hdulist[ i+1].data img = hdulist[ i+1].data
if (verb) : if (verb) :
print 'Image shape :' print ('Image shape :')
print np.shape(img) print (np.shape(img))
# module # module
meds=np.zeros(0)
if submed :
meds=np.median(img,axis=1)
print (len(meds))
print (np.shape(img))
for idx in np.arange(np.shape(img)[0]):
img[idx]=img[idx]-meds[idx]
if subhmed :
meds=np.median(img,axis=0)
print (len(meds))
print (np.shape(img))
for idx in np.arange(np.shape(img)[1]):
img[:,idx]=img[:,idx]-meds[idx]
if mod : if mod :
if num>7 : if num>7 :
imgi= hdulist[ i+1].data imgi= hdulist[ i+1].data
if submed :
medsi = np.median(imgi,axis=1)
for idx in np.arange(np.shape(imgi)[0]):
imgi[idx]=imgi[idx]-medsi[idx]
img = np.sqrt(img**2+imgi**2) img = np.sqrt(img**2+imgi**2)
if len(cor) ==2 : # for correlation coeff if len(cor) ==2 : # for correlation coeff
imca = hdulist[cor[0]].data imca = hdulist[cor[0]].data
...@@ -164,17 +195,25 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F ...@@ -164,17 +195,25 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F
if arg : if arg :
if num>7 : if num>7 :
imgi= hdulist[ i+1].data imgi= hdulist[ i+1].data
if submed :
medsi = np.median(imgi,axis=1)
for idx in np.arange(np.shape(imgi)[0]):
imgi[idx]=imgi[idx]-medsi[idx]
img = np.arctan2(imgi,img) * 180. / np.pi img = np.arctan2(imgi,img) * 180. / np.pi
mvmin=-180. mvmin=-180.
mvmax=180. mvmax=180.
mtitle= names[num]+" arg.(deg)" mtitle= names[num]+" arg.(deg)"
else : else :
print "arg demande mais auto selectionne : ERREUR " print ("arg demande mais auto selectionne : ERREUR ")
exit exit
mskdat=img*0. mskdat=img*0.
# complex number representation # complex number representation
if cmplx : if cmplx :
imgi= hdulist[ i+1].data imgi= hdulist[ i+1].data
if submed :
medsi = np.median(imgi,axis=1)
for idx in np.arange(np.shape(imgi)[0]):
imgi[idx]=imgi[idx]-medsi[idx]
zmod = np.sqrt(img**2+imgi**2) zmod = np.sqrt(img**2+imgi**2)
arg = np.arctan2(imgi,img) arg = np.arctan2(imgi,img)
...@@ -182,9 +221,9 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F ...@@ -182,9 +221,9 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F
aa = (aa+0.5)%1 aa = (aa+0.5)%1
bb = 1./(abs(zmod)**0.3 +1.) bb = 1./(abs(zmod)**0.3 +1.)
bb = -bb+1. bb = -bb+1.
print np.shape(aa)
cc = np.ndarray(np.shape(aa)) cc = np.ndarray(np.shape(aa))
print np.shape(cc)
cc.fill(1.) cc.fill(1.)
iimg =[] iimg =[]
for ii in np.arange(np.shape(aa)[0]): for ii in np.arange(np.shape(aa)[0]):
...@@ -197,15 +236,16 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F ...@@ -197,15 +236,16 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F
if mask : # reads mask file if mask : # reads mask file
if cmplx : if cmplx :
print "mask & cmplx not yet compatible " print ("mask & cmplx not yet compatible ")
exit exit
msknam = filename +'_masks.fits' msknam = filename +'_masks.fits'
print msknam+ " " + str(num)
hdmskl = fits.open(msknam) hdmskl = fits.open(msknam)
mskdat = np.fabs(hdmskl[num+1].data-1.) mskdat = np.fabs(hdmskl[num+1].data-1.)
img = img*mskdat img = img*mskdat
filename=filename+"_masked" filename=filename+"_masked"
if logsc : if logsc :
filename=filename+" (log)" filename=filename+" (log)"
if mod : if mod :
...@@ -224,48 +264,55 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F ...@@ -224,48 +264,55 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F
if mvmax !=0. : if mvmax !=0. :
vmax = mvmax vmax = mvmax
if verb : if verb :
print vmin, np.asarray(img[300:900,]).min() print (vmin, np.asarray(img[300:900,]).min())
print vmax,np.asarray(img[300:900,]).max() print (vmax,np.asarray(img[300:900,]).max())
if (not noplo) : if (not noplo) :
# plots TF image - dual axes with bin no and values # plots TF image - dual axes with bin no and values
im = ax1.imshow(img,aspect='auto' , interpolation='none',vmin=vmin,vmax=vmax) im = ax1.imshow(img,aspect='auto' ,extent=(timin,timax,frmax,frmin), interpolation='none',vmin=vmin,vmax=vmax)
#m = ax1.imshow(img,aspect='auto' ,extent=(timin,timax,frmax,frmin), interpolation='none',vmin=vmin,vmax=vmax) #m = ax1.imshow(img,aspect='auto' ,extent=(timin,timax,frmax,frmin), interpolation='none',vmin=vmin,vmax=vmax)
if (yrcm) : if (yrcm) :
im.set_cmap('YlOrBr_r') im.set_cmap(usecm)
cbar = plt.colorbar( im ) #,fraction=0.021,pad=.05) cbar = plt.colorbar( im ) #,fraction=0.021,pad=.05)
cbar.set_norm(mynorm.MyNormalize(vmin=vmin,vmax=vmax,stretch='linear')) cbar.set_norm(mynorm.MyNormalize(vmin=vmin,vmax=vmax,stretch='linear'))
cm_cycle = sorted([i for i in dir(plt.cm) if hasattr(getattr(plt.cm,i),'N')]) cm_cycle = sorted([i for i in dir(plt.cm) if hasattr(getattr(plt.cm,i),'N')])
cm_index = cm_cycle.index(cbar.get_cmap().name) cm_index = cm_cycle.index(cbar.get_cmap().name)
if nau :
cbar.ax.set_ylabel('signal (NAU) ', rotation=270,labelpad=20)
else:
cbar.ax.set_ylabel('signal ', rotation=270,labelpad=20)
plt.show() plt.show()
if mtitle =="": if mtitle =="":
plt.title(filename + ' ' + names[num],y=1.08) plt.title(filename + ' ' + names[num],y=1.08)
else : else :
plt.title(filename + ' ' +mtitle,y=1.08) plt.title(mtitle+ " - " + names[num] ,y=1.08)
plt.ylabel("Frequency (Mhz)") plt.ylabel("Frequency (Mhz)")
if ramod: if ramod:
plt.xlabel("RA (h)") plt.xlabel("RA (h)")
else: else:
plt.xlabel("Temps (h)") plt.xlabel("Time (h)")
if ramod : if ramod :
for rap in plras: for rap in plras:
ax1.plot([rap,rap],[frmax,frmin],color='red',linestyle='--') ax1.plot([rap,rap],[frmax,frmin],color='red',linestyle='--')
#ax1.annotate(nmras[plras.index(rap)],(rap,frmin),horizontalalignment='center',verticalalignment='bottom') #ax1.annotate(nmras[plras.index(rap)],(rap,frmin),horizontalalignment='center',verticalalignment='bottom')
ax1.annotate(nmras[plras.index(rap)],(rap,frmin),horizontalalignment='left',verticalalignment='bottom',rotation=30) ax1.annotate(nmras[plras.index(rap)],(rap,frmin),horizontalalignment='left',verticalalignment='bottom',rotation=30)
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.yaxis.set_view_interval(frmax,frmin ,ignore=True)
ax2.set_ylabel("Freq. bin",rotation=270.,y=0.9)
if not ramod :
ax3=ax1.twiny()
ax3.xaxis.set_view_interval( timin,timax ,ignore=True)
ax3.set_xlabel("time bin",x=0.85)
if extaxes :
ax2=ax1.twinx()
ax2.yaxis.set_view_interval(frmax,frmin ,ignore=True)
#ax2.set_ylabel("Freq. bin",rotation=270.,y=0.9)
if not ramod :
ax3=ax1.twiny()
ax3.xaxis.set_view_interval( timin,timax ,ignore=True)
#ax3.set_xlabel("time bin",x=0.85)
plt.tight_layout()
if save: # saves png with some name if save: # saves png with some name
ext="" ext=""
if creal : if creal :
...@@ -280,13 +327,8 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F ...@@ -280,13 +327,8 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F
else : else :
plt.savefig(filename+"_"+ names[num]+"_TFM"+ext+".png") plt.savefig(filename+"_"+ names[num]+"_TFM"+ext+".png")
# ------------ THIS IS TO SWITCH FROM ONE CMAP TO THE OTHER # ------------ THIS IS TO SWITCH FROM ONE CMAP TO THE OTHER
axnext = fig.add_axes([0.6, 0.04, 0.05, 0.05])
bnext = Button(axnext,cm_cycle[cm_index+1] )
axprev = fig.add_axes([0.7, 0.04, 0.05, 0.05])
bprev = Button(axprev,cm_cycle[cm_index-1] )
axcur = fig.add_axes([0.65, 0.04, 0.05, 0.05], )
bcur = Button(axcur,cm_cycle[cm_index])
def cm_next(val): def cm_next(val):
cm_cycle = sorted([i for i in dir(plt.cm) if hasattr(getattr(plt.cm,i),'N')]) cm_cycle = sorted([i for i in dir(plt.cm) if hasattr(getattr(plt.cm,i),'N')])
cm_index = cm_cycle.index(cbar.get_cmap().name) cm_index = cm_cycle.index(cbar.get_cmap().name)
...@@ -327,9 +369,16 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F ...@@ -327,9 +369,16 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F
indnext=0 indnext=0
bnext.label.set_text(cm_cycle[indnext]) bnext.label.set_text(cm_cycle[indnext])
bprev.label.set_text(cm_cycle[indprev]) bprev.label.set_text(cm_cycle[indprev])
if choose_cmap :
axnext = fig.add_axes([0.6, 0.04, 0.05, 0.05])
bnext = Button(axnext,cm_cycle[cm_index+1] )
axprev = fig.add_axes([0.7, 0.04, 0.05, 0.05])
bprev = Button(axprev,cm_cycle[cm_index-1] )
axcur = fig.add_axes([0.65, 0.04, 0.05, 0.05], )
bcur = Button(axcur,cm_cycle[cm_index])
bnext.on_clicked(cm_next)
bprev.on_clicked(cm_prev)
bnext.on_clicked(cm_next)
bprev.on_clicked(cm_prev)
#----------------- END CMAP SWITCH #----------------- END CMAP SWITCH
#plt.tight_layout() #plt.tight_layout()
...@@ -340,14 +389,21 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F ...@@ -340,14 +389,21 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F
if raplot : # does plots of signal vs RA at some frequencies if raplot : # does plots of signal vs RA at some frequencies
fig,ax1=plt.subplots(figsize=winwid) fig,ax1=plt.subplots(figsize=winwid)
[ plt.plot(ras, img[b,],label="F=%6.2f MHz" %(freqs[b]) ) for b in bfreq ] #[ plt.plot(ras, img[b,],label="F=%6.2f MHz" %(freqs[b]) ) for b in bfreq ]
# [ plt.scatter(np.mod(ras,24.)[np.argsort(np.mod(ras,24.))], img[b,np.argsort(np.mod(ras,24.))],label="F=%6.2f MHz" %(freqs[b]) ,marker='.', s=.5) for b in bfreq ]
[ plt.plot(np.mod(ras,24.)[np.argsort(np.mod(ras,24.))], img[b,np.argsort(np.mod(ras,24.))],label="F=%6.2f MHz" %(freqs[b])) for b in bfreq ]
plt.xlabel("RA (hour)") plt.xlabel("RA (hour)")
plt.ylabel("Signal ") plt.ylabel("Signal ")
plt.ylim(np.asarray(img[[bfreq],]).min(),np.asarray(img[[bfreq],]).max()) plt.ylim(np.asarray(img[[bfreq],]).min(),np.asarray(img[[bfreq],]).max())
leg = plt.legend() leg = plt.legend()
for legobj in leg.legendHandles: for legobj in leg.legendHandles:
legobj.set_linewidth(2.0) legobj.set_linewidth(2.0)
plt.ylim((mvmin,mvmax)) if( num<8) :
plt.ylim((.95,1.45))
else:
plt.ylim((-.05,.05))
plt.xlim((0.,24.)) plt.xlim((0.,24.))
if mtitle =="": if mtitle =="":
plt.title(filename + ' ' + names[num],y=1.08) plt.title(filename + ' ' + names[num],y=1.08)
...@@ -364,29 +420,35 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F ...@@ -364,29 +420,35 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F
if timeplot : # does plots of sig vs time at some frequencies if timeplot : # does plots of sig vs time at some frequencies
fig,ax1=plt.subplots(figsize=winwid) fig,ax1=plt.subplots(figsize=winwid)
[ plt.plot(times/3600., img[b,],label="F=%6.2f MHz" %(freqs[b]) ) for b in bfreq ] [ plt.plot(times/3600., img[b,],label="F=%6.2f MHz" %(freqs[b]) ) for b in bfreq ]
plt.xlabel('Time (TU, hour)') plt.xticks(fontsize=28)
plt.ylabel("Signal ") plt.yticks(fontsize=28)
#plt.gca().yaxis.set_major_formatter(StrMethodFormatter('{x:,.0f}')) # No decimal places
#plt.gca().yaxis.set_major_formatter(FormatStrFormatter('%g'))
plt.gca().ticklabel_format(axis='y', style='sci', scilimits=(5,5))
plt.xlabel('Time (TU, hour)',size=28)
plt.ylabel("Signal ",size=28)
plt.ylim(np.asarray(img[[bfreq],]).min(),np.asarray(img[[bfreq],]).max()) plt.ylim(np.asarray(img[[bfreq],]).min(),np.asarray(img[[bfreq],]).max())
#legend with thicker linewidth #legend with thicker linewidth
leg = plt.legend() leg = plt.legend(prop={'size': 28},loc=1 )
for legobj in leg.legendHandles: for legobj in leg.legendHandles:
legobj.set_linewidth(2.0) legobj.set_linewidth(2.0)
plt.ylim((mvmin,mvmax))
plt.ylim((mvmin,mvmax))
plt.tight_layout()
if mtitle =="": if mtitle =="":
plt.title(filename + ' ' + names[num],y=1.08) plt.title(filename + ' ' + names[num],y=1.08)
else : else :
plt.title(filename + ' ' +mtitle,y=1.08) plt.title(mtitle+ " - " + names[num] ,y=1.08,size=28)
plt.tight_layout()
if save: if save:
if mask : if mask :
plt.savefig(filename+"_"+ names[num]+"_TFM_mask_freq.png") plt.savefig(filename+"_"+ names[num]+"_TFM_mask_freq.png")
else: else:
plt.savefig(filename+"_"+ names[num]+"_TFM_freq.png") plt.savefig(filename+"_"+ names[num]+"_TFM_freq.png")
if (verb) : if (verb) :
print times.size print (times.size())
if (verb) : print (np.shape(img))
print np.shape(img)
#return values #return values
...@@ -395,7 +457,7 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F ...@@ -395,7 +457,7 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F
elif cmplx: elif cmplx:
return times/3600.,img,freqs,ras return times/3600.,img,freqs,ras
else : else :
return times/3600.,img,freqs,ras,[ img[b,] for b in bfreq],ax1,bnext,bprev,mskdat return times/3600.,img,freqs,ras,[ img[b,] for b in bfreq],ax1,mskdat
......
...@@ -141,14 +141,15 @@ public: ...@@ -141,14 +141,15 @@ public:
double Value(UnitVector const& uvo) double Value(UnitVector const& uvo)
{ {
// circular beam response // circular beam response
double alp=acos(bdir_.Psc(uvo))*DoL_; double alp=acos(bdir_.Psc(uvo))*DoL_;
// remplacer acos(...) par sin(acos(...)) ds l'expression ci-dessus pour avoir // remplacer acos(...) par sin(acos(...)) ds l'expression ci-dessus pour avoir l'expression exacte qui est sin(theta)
if (fggauss_) { if (fggauss_) {
// Reza / Sep 2019 : le facteur 2.61854 assure la meme largeur FWHM entre gaussian et Bessel // Reza / Sep 2019 : le facteur 2.61854 assure la meme largeur FWHM entre gaussian et Bessel
// On pose : a = D/lambda * gamma ( ou D/lambda * sin(gamma) // On pose : a = D/lambda * gamma ( ou D/lambda * sin(gamma)
// Beam Bessel : beamJ(a) = ( 2 J1(pi a) / (pi a) )^2 Beam Gaussian : beamG(a) = Exp[ - K a^2 ] // Beam Bessel : beamJ(a) = ( 2 J1(pi a) / (pi a) )^2 Beam Gaussian : beamG(a) = Exp[ - K a^2 ]
// BeamJ(a=1.238098) = 0.5 et beamG(a=1.238098) = 0.5 pour K = 2.61854 // BeamJ(a=1.238098) = 0.5 et beamG(a=1.238098) = 0.5 pour K = 2.61854
// K=2.61854 au lieu de K=2.1767 (valeur de JEC , mais avec SphericalBesselJ[1...] // K=2.61854 au lieu de K=2.1767 (valeur de JEC , mais avec SphericalBesselJ[1...]
// Jean-Eric donne 0.28 pi^2 = 2.76 avec un fit de BesselJ
//---- return ( exp(-2.1767*alp*alp)*NormFac_ ); // Jiao : Check the factor 2 in the exp( ) -> exp(-2.*alp*alp) //---- return ( exp(-2.1767*alp*alp)*NormFac_ ); // Jiao : Check the factor 2 in the exp( ) -> exp(-2.*alp*alp)
return ( exp(-2.61854*alp*alp)*NormFac_ ); // Jiao : Check the factor 2 in the exp( ) -> exp(-2.*alp*alp) return ( exp(-2.61854*alp*alp)*NormFac_ ); // Jiao : Check the factor 2 in the exp( ) -> exp(-2.*alp*alp)
} }
......
...@@ -357,11 +357,13 @@ int P4AnaParams::DecodeArgs(int narg, const char* arg[]) ...@@ -357,11 +357,13 @@ int P4AnaParams::DecodeArgs(int narg, const char* arg[])
else if (fbo=="-freq") { else if (fbo=="-freq") {
if (narg<2) { cout << "P4AnaParams::DecodeArgs missing/bad argument, -h for help " << endl; return -1; } if (narg<2) { cout << "P4AnaParams::DecodeArgs missing/bad argument, -h for help " << endl; return -1; }
double f0,df; double f0,df;
cout << " selecting freqs "<<endl;
sscanf(arg[2],"%lg,%lg",&f0,&df); fbands_.push_back(P4FreqBand(f0,df)); fgdtable_=true; sscanf(arg[2],"%lg,%lg",&f0,&df); fbands_.push_back(P4FreqBand(f0,df)); fgdtable_=true;
arg+=2; narg-=2; lastargs_.clear(); arg+=2; narg-=2; lastargs_.clear();
} }
else if (fbo=="-killfreq") { else if (fbo=="-killfreq") {
if (narg<2) { cout << "P4AnaParams::DecodeArgs missing/bad argument, -h for help " << endl; return -1; } if (narg<2) { cout << "P4AnaParams::DecodeArgs missing/bad argument, -h for help " << endl; return -1; }
cout << " killing freqs "<<endl;
double f0,df; double f0,df;
sscanf(arg[2],"%lg,%lg",&f0,&df); kill_fbands_.push_back(P4FreqBand(f0,df)); sscanf(arg[2],"%lg,%lg",&f0,&df); kill_fbands_.push_back(P4FreqBand(f0,df));
arg+=2; narg-=2; lastargs_.clear(); arg+=2; narg-=2; lastargs_.clear();
...@@ -598,8 +600,8 @@ ostream& P4AnaParams::Print(ostream& os) const ...@@ -598,8 +600,8 @@ ostream& P4AnaParams::Print(ostream& os) const
os<<" Right Ascension: center_="<<RAcenter_<<" Width="<<RAwidth_<<" (hours) Resolution="<<RAresol_mn_ os<<" Right Ascension: center_="<<RAcenter_<<" Width="<<RAwidth_<<" (hours) Resolution="<<RAresol_mn_
<<"("<<RAcenter_-RAwidth_/2<<"<ra<"<<RAcenter_-RAwidth_/2<<")"<<endl; <<"("<<RAcenter_-RAwidth_/2<<"<ra<"<<RAcenter_-RAwidth_/2<<")"<<endl;
if (fbands_.size()==0) os<<" No frequency band defined ..."<<endl; if (fbands_.size()==0) os<<" No frequency band defined ..."<<endl;
else for(size_t i=0; i<fbands_.size(); i++) os<<"FreqBand["<<i<<"]: "<<fbands_[i]<<endl; else for(size_t i=0; i<fbands_.size(); i++) os<<"Selected FreqBand["<<i<<"]: "<<fbands_[i]<<endl;
if (kill_fbands_.size()==0) { if (kill_fbands_.size()>0) {