Commit b7fd8034 authored by perdereau's avatar perdereau
Browse files

add view for complex

parent dd96558c
......@@ -10,23 +10,29 @@ from skimage import exposure
import mynormalize as mynorm
from matplotlib.widgets import Slider, Button, RadioButtons
import time
from colorsys import hsv_to_rgb, hls_to_rgb
# Choices: ['auto', 'gtk', 'gtk3', 'inline', 'nbagg', 'notebook', 'osx', 'qt', 'qt4', 'qt5', 'tk', 'wx']
rfreq = [1381.,1390.,1420.5,1430.]
normf=[1325.,1465.]
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',
'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,plras=[],nmras=[]):
print len(cor)
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,
ramod=False,plras=[],nmras=[],mask=False):
if verb :
print len(cor)
filename = folder
#print i
#print num
if noplo :
clean=False
if clean:
plt.close("all")
hdulist = fits.open(folder+'.fits')
winwid = (18,8)
......@@ -54,8 +60,9 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F
print hdulist[i].header
bfreq = [ (np.abs(freqs-rf)).argmin() for rf in rfreq ]
print ' number of hds ' + str(len(hdulist))
bfnor = [(np.abs(freqs-rf)).argmin() for rf in normf ]
if (verb) :
print ' number of hds ' + str(len(hdulist))
nfre = np.size(freqs)
ntim = np.size(times)
......@@ -72,7 +79,9 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F
img = hdulist[ i].data
if(cimag):
img = hdulist[ i+1].data
print np.shape(img)
if (verb) :
print 'Image shape :'
print np.shape(img)
if mod :
if num>7 :
......@@ -90,14 +99,47 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F
img = np.arctan2(imgi,img) * 180. / np.pi
mvmin=-180.
mvmax=180.
mtitle= names[num]+" arg(deg)"
mtitle= names[num]+" arg.(deg)"
else :
print "arg demande mais auto selectionne : ERREUR "
exit
vmin = np.asarray(img[300:900,]).min()
vmax = np.asarray(img[300:900,]).max()
mskdat=img*0.
if cmplx :
imgi= hdulist[ i+1].data
zmod = np.sqrt(img**2+imgi**2)
arg = np.arctan2(imgi,img)
aa = (arg+np.pi) /(2.*np.pi)
aa = (aa+0.5)%1
bb = 1./(abs(zmod)**0.3 +1.)
bb = -bb+1.
print np.shape(aa)
cc = np.ndarray(np.shape(aa))
print np.shape(cc)
cc.fill(1.)
iimg =[]
for ii in np.arange(np.shape(aa)[0]):
for jj in np.arange(np.shape(aa)[1]):
iimg.append( hls_to_rgb(aa[ii,jj], bb[ii,jj],cc[ii,jj] ))
img = np.reshape( iimg,(np.shape(aa)[0],np.shape(aa)[1],3))
if mask :
if cmplx :
print "mask & cmplx not yet compatible "
exit
msknam = filename +'_masks.fits'
print msknam+ " " + str(num)
hdmskl = fits.open(msknam)
mskdat = np.fabs(hdmskl[num+1].data-1.)
img = img*mskdat
filename=filename+"_masked"
if not cmplx :
vmin = np.asarray(img[bfnor[0]:bfnor[1],]).min()
vmax = np.asarray(img[bfnor[0]:bfnor[1],]).max()
else :
vmin=0
vmax=1
if mvmin !=0. :
vmin = mvmin
......@@ -132,7 +174,8 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F
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.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.yaxis.grid(which="major", color='gray', linestyle='-', linewidth=.5)
ax1.xaxis.grid(which="major", color='gray', linestyle='-', linewidth=.5)
......@@ -148,6 +191,8 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F
ext=""
if creal :
ext = ext+"_real"
if mask :
ext=ext+"_mask"
if ramod :
if len(plras) >0 :
plt.savefig(filename+"_"+ names[num]+"_RAM"+ext+"_srcs.png")
......@@ -267,7 +312,10 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F
plt.title(filename + ' ' +mtitle,y=1.08)
if save:
plt.savefig(filename+"_"+ names[num]+"_TFM_ra.png")
if mask :
plt.savefig(filename+"_"+ names[num]+"_mask_TFM_ra.png")
else:
plt.savefig(filename+"_"+ names[num]+"_TFM_ra.png")
if timeplot :
......@@ -287,15 +335,20 @@ def viewtfmap(folder,num,mvmin=0.,mvmax=0.,save=False, raplot=False,timeplot=F
else :
plt.title(filename + ' ' +mtitle,y=1.08)
if save:
plt.savefig(filename+"_"+ names[num]+"_TFM_freq.png")
if mask :
plt.savefig(filename+"_"+ names[num]+"_TFM_mask_freq.png")
else:
plt.savefig(filename+"_"+ names[num]+"_TFM_freq.png")
if (verb) :
print times.size
if (verb) :
print np.shape(img)
if noplo :
return times/3600.,img,freqs,ras,[ img[b,] for b in bfreq]
return times/3600.,img,freqs,ras,[ img[b,] for b in bfreq],mskdat
elif cmplx:
return times/3600.,img,freqs,ras
else :
return times/3600.,img,freqs,ras,[ img[b,] for b in bfreq],ax1,bnext,bprev,smin,smax
return times/3600.,img,freqs,ras,[ img[b,] for b in bfreq],ax1,bnext,bprev,smin,smax,mskdat
......
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