Exemple #1
0
import numpy as np
import plotc
import pyfits as pf

it=0

graddir="/home/jishnu/project/magnetic_inversions/working/data/update/"
grad=pf.getdata(graddir+"gradient_vectorpsi_0"+str(it)+".fits")
grad/=grad.max()
z=np.loadtxt('/home/jishnu/project/magnetic_inversions/back/polytrope')[:,0];Rsun=695.8e3;z=(z-z[-1])*Rsun
x=np.linspace(-200,200,256,endpoint=False)

Atruedir="/home/jishnu/project/magnetic_inversions/working/true/"
Astartdir="/home/jishnu/project/magnetic_inversions/working/start/"

Atrue=pf.getdata(Atruedir+'true_vectorpsi.fits')
Astart=pf.getdata(Astartdir+'model_vectorpsi.fits')
Adiff=Atrue-Astart

plotc.colorplot(Adiff,x=x,y=z,yr=[-0.8e3,None],xr=[-100,100],vmax=1,centerzero=True,xbins=5,
title=r"$\Delta A$",xlabel="Horizontal Distance (Mm)",ylabel="Depth (km)",usetex=True,y_sci=False
,sp=121)
plotc.colorplot(grad,x=x,y=z,yr=[-0.8e3,None],xr=[-100,100],vmax=1,centerzero=True,xbins=5,
title=r"Normalized Vector Potential Kernel",xlabel="Horizontal Distance (Mm)",ylabel="Depth (km)",usetex=True,y_sci=False
,sp=122)
plotc.figuresize(13,5)
plotc.tight_layout()
plotc.savefig('/home/jishnu/project/magnetic_inversions/report/vector_potential_kernel_'+str(it)+'.eps')
#~ plotc.show()
Exemple #2
0
for j in xrange(nt):
  if (f[j] < f_low+df):
    fmode[:,0,j] = fmode[:,0,j]*0.5*(1.+cos(pi*(f[j]-(f_low+df))/df) )
  if (f[j] < f_low): fmode[:,0,j] = 0.


fmode=np.squeeze(fmode).T


g=plotc.gridlist(1,2)

good_quadrant=powsp[:nt/2,:nx/2]
goodk=kf[:nx/2]*Rsun
goodf=ff[:nt/2]
plotc.colorplot(good_quadrant,x=goodk,y=goodf,subplot_index=next(g),
xlabel="k$R_\odot$ ",ylabel="$\omega$ (mHz)",title="Power spectrum",cbar_sci=True,
yr=[0,5],xr=[0,1.5*Rsun],usetex=True,x_sci=False)

plotc.gca().text(550,2,"f-mode",fontsize="15")
plotc.gca().text(550,3.4,"p1-mode",fontsize="15")

#~ filter_low_cutoff=np.where(f0>f_low)[0][0]
#~ k_filt_line_low=k[filter_low_cutoff-1:nx/2]*Rsun
#~ f0_filt_line_low=f0[filter_low_cutoff-1:nx/2]
#~ plt.plot(k_filt_line_low,f0_filt_line_low,zorder=2,color='brown')
#~ plt.plot(-k_filt_line_low,f0_filt_line_low,zorder=2,color='brown')
#~ plt.plot(k_filt_line_low,-f0_filt_line_low,zorder=2,color='brown')
#~ plt.plot(-k_filt_line_low,-f0_filt_line_low,zorder=2,color='brown')
#~ 
#~ filter_low_cutoff=np.where(f1>f_low)[0][0]
#~ k_filt_line_low=k[filter_low_cutoff-1:nx/2]*Rsun
Exemple #3
0
    vzccf.append(vzccfarr)

    vzccparr = np.real(np.fft.ifft2(np.fft.fft2(vzccarr) * pmode)) / datapmax
    vzccp.append(vzccparr)

vzcc = None

Nrec = 12
recs = [105 + 5 * i for i in xrange(Nrec)]

plotc.colorplot(dataf,
                x=x,
                y=time,
                vmax=0.2,
                centerzero=True,
                sp=121,
                xr=[x[recs[0]] - 30, x[recs[-1]] + 30],
                yr=[0, 100],
                axes_properties=dict(locator_properties_x=dict(nbins=5),
                                     title="f mode"),
                colorbar=False)

plotc.draw_vlines(x=x[recs], ls='dashed')

plotc.colorplot(datap,
                x=x,
                y=time,
                vmax=0.2,
                centerzero=True,
                sp=122,
                xr=[x[recs[0]] - 30, x[recs[-1]] + 30],
Exemple #4
0
rho = -(hz + dzp) / (grav * convert)
rho -= rho[0] - rho0
drho = rho / rho0 - 1

if drho.min() < -1:
    print "Negative density"
    sys.exit(0)

soundspeed_squared = c2 * rho0 / p0 * p / rho  # This works even if c2 etc are 1D, since x is the leading dimension and multiplication is along z
soundspeed = np.sqrt(soundspeed_squared)
alfven_speed = np.sqrt((bx**2 + bz**2) / rho)
alf_c_ratio = alfven_speed / soundspeed

plotc.plt.figure()
plotc.colorplot(bz.T * np.sqrt(4 * np.pi), y=z, x=x, sp=221, title="Bz true")
plotc.colorplot(bz_start.T * np.sqrt(4 * np.pi),
                y=z,
                x=x,
                sp=222,
                title="Bz start")
plotc.colorplot(bx.T * np.sqrt(4 * np.pi), y=z, x=x, sp=223, title="Bx true")
plotc.colorplot(bx_start.T * np.sqrt(4 * np.pi),
                y=z,
                x=x,
                sp=224,
                title="Bx start")

#~ plotc.plt.figure()
#~ plotc.colorplot(dp.T,x=x,y=z,title="Relative Pressure Difference",sp=121,
#~ ylim=[-2.5,-0.39],
Exemple #5
0
surf_cutoff = -1
nrows = 3
ncols = 2
gridlist = plotc.gridlist(nrows, ncols)

#~ plotc.colorplot(KBx,y=z,subplot_index=next(gridlist),yr=[z[inner_cutoff],yax_ul],
#~ title="KBx",ylabel="Depth from surface (Mm)")
#~ plotc.colorplot(KBz,y=z,subplot_index=next(gridlist),yr=[z[inner_cutoff],yax_ul],
#~ title="KBz",ylabel="Depth from surface (Mm)")

KA_inner_cutoff = 270

KA_plot = KA[KA_inner_cutoff:]
plotc.colorplot(KA_plot,
                y=z[KA_inner_cutoff:],
                subplot_index=next(gridlist),
                title="A Kernel",
                vmin=-KA_plot.max())
dA = A_true - A_start
dA = dA[KA_inner_cutoff:]
plotc.colorplot(dA,
                y=z[KA_inner_cutoff:],
                subplot_index=next(gridlist),
                title="A true - A start")

Kcplot = Kc[inner_cutoff:surf_cutoff]
plotc.colorplot(Kcplot,
                y=z[inner_cutoff:surf_cutoff],
                subplot_index=next(gridlist),
                cbar_sci=True,
                title="c Kernel",
Exemple #6
0
int_Bx_true=int_Bx_true.T

A_start=int_Bz_start - int_Bx_start
A_true=int_Bz_true - int_Bx_true

Bz_true_fromA=fc.differentiate(A_true,axis=1,period=L,discontinuity=A_true[:,-1]-A_true[:,0])
Bx_true_fromA=-zderiv(A_true,z)

z-=1
yax_ll=z[200]
yax_ul=None
inner_cutoff=270
surf_cutoff=-1
gridlist=plotc.gridlist(2,3)

ploty=z[inner_cutoff:]*Rsun/1e8

dA=A_true-A_start;dA=dA[inner_cutoff:]
plotc.colorplot(A_start[inner_cutoff:],y=ploty,subplot_index=next(gridlist),title="A start")
plotc.colorplot(dA,y=ploty,subplot_index=next(gridlist),title="A true - A start")
plotc.colorplot(Bz_true[inner_cutoff:],y=ploty,subplot_index=next(gridlist),title="Bz true")
plotc.colorplot(Bz_true_fromA[inner_cutoff:],y=ploty,subplot_index=next(gridlist),title="Bz true from A")
plotc.colorplot(Bx_true[inner_cutoff:],y=ploty,subplot_index=next(gridlist),title="Bx true")
plotc.colorplot(Bx_true_fromA[inner_cutoff:],y=ploty,subplot_index=next(gridlist),title="Bx true from A")

plotc.plt.show()
write_vector_potential=False
if write_vector_potential: 
	pf.writeto(os.path.join(start_field_dir,'model_vectorpsi_ls00.fits'),A_start,clobber=True)
	pf.writeto(os.path.join(true_field_dir,'true_vectorpsi.fits'),A_true,clobber=True)
Exemple #7
0
densitypoly2D = np.atleast_2d(densitypoly).T
densitypoly2D = np.tile(densitypoly2D, [1, 256])

drho = density - densitypoly2D

pressurepoly2D = np.atleast_2d(pressurepoly).T
pressurepoly2D = np.tile(pressurepoly2D, [1, 256])

dp = pressure - pressurepoly2D

plotc.colorplot(dp / pressurepoly2D,
                x=x,
                y=z,
                sp=121,
                yr=[-0.2e3, None],
                xr=[-100, 100],
                xlabel="Horizontal Distance (Mm)",
                ylabel="Depth (km)",
                usetex=True,
                title="Relative Pressure Difference",
                titley=1.02)
plotc.colorplot(drho / densitypoly2D,
                x=x,
                y=z,
                sp=122,
                yr=[-0.2e3, None],
                xr=[-100, 100],
                xlabel="Horizontal Distance (Mm)",
                ylabel="Depth (km)",
                usetex=True,
                title="Relative Density Difference",
Exemple #8
0
import plotc
from matplotlib import pyplot as plt
import pyfits as pf

Btruedir="/home/jishnu/project/magnetic_inversions/working/true/"

z=np.loadtxt('/home/jishnu/project/magnetic_inversions/back/polytrope')[:,0];Rsun=695.8e3;z=(z-z[-1])*Rsun
x=np.linspace(-200,200,256,endpoint=False)

Bztrue=pf.getdata(Btruedir+'B_z2D.fits')
Bxtrue=pf.getdata(Btruedir+'B_x2D.fits')

soundspeed=pf.getdata(Btruedir+'soundspeed2D.fits')
density=pf.getdata(Btruedir+'density2D.fits')

calf=np.sqrt((Bztrue**2+Bxtrue**2)/density/(4*np.pi))
cratio=calf/soundspeed

plotc.quiver2D(Bxtrue,Bztrue,x=x,y=z,every=[3,1],sp=121,yr=[-0.5e3,None],xr=[-100,100],key=True,
keysuffix=" Gauss",title="Magnetic Field",titley=1.01,usetex=True,
xlabel="Horizontal Distance (Mm)",ylabel="Depth (km)")
plotc.colorplot(cratio,x=x,y=z,sp=122,yr=[-0.5e3,None],xr=[-100,100],vmax=2,title="$c_A/c_S$",titley=1.01,usetex=True,
xlabel="Horizontal Distance (Mm)")

plt.setp(plt.gca().get_yticklabels(),visible=False)
plt.subplots_adjust(wspace=0)

plotc.figuresize(13,5)
plotc.show()
#~ plotc.savefig('/home/jishnu/project/departmental_talk/field_cratio.eps')
Exemple #9
0
    sourcedir = 'forward_src' + str(sourceno + 1).zfill(2) + '_ls00'

    vzcc = np.squeeze(pf.getdata(os.path.join(datadir, sourcedir,
                                              'data.fits')))
    Nx = vzcc.shape[1]
    sourcepix = int(np.floor(sourceloc / Lx * Nx) + Nx / 2 - 1)
    if fmode:

        plotc.plt.figure()

        fmode_filter = np.squeeze(
            pf.getdata(os.path.join(codedir, 'fmode_filter.fits')))

        vzcc_f = np.real(np.fft.ifft2(np.fft.fft2(vzcc) * fmode_filter))
        vzcc_f /= abs(vzcc_f).max()
        plotc.colorplot(vzcc_f, vmax=0.01, centerzero=True)
        datacursor(display='multiple', draggable='True')

        Npoints = 5
        xpix = np.array([-30 - ind * 6 for ind in xrange(Npoints)]) + sourcepix
        xpoints = (xpix - 127) / 256 * 400

        plotc.draw_vlines(xpix)

        t_cutoff = np.zeros((Npoints, 2))

        #~ Line fit to bottom of wavepacket
        def bot_time(x):
            return (89.2 - 161) / (89.2 - 60.1) * (x - sourcepix) + 20

        #~ Line fit to top of wavepacket