コード例 #1
0
 def __init__(self, shot, trange=None):
     self.shot = shot
     try:
         LiBD = dd.shotfile('LIN', shot, experiment='AUGD')
     except:
         LiBD = dd.shotfile('LIN', shot, experiment='LIBE')
     ne = LiBD('ne').data
     time = LiBD('ne').time
     rhoP = LiBD('ne').area
     LiBD.close
     # limit to the part in trange if given
     if trange:
         _idx = np.where(((time >= trange[0]) & (time <= trange[1])))[0]
         ne = ne[_idx, :]
         time = time[_idx]
         rhoP = rhoP[_idx, :]
     # load the equilibrium
     self.eq = eqtools.AUGDDData(self.shot)
     self.eq.remapLCFS()
     # now build your own basis on the same rhoPoloidal
     # outsize the separatrix
     self.neraw = ne[:, ::-1]
     self.rhoraw = rhoP.data[:, ::-1]
     self.rho = np.linspace(0.9, 1.1, 50)
     self.ne = np.zeros((time.size, self.rho.size))
     self.neNorm = np.zeros((time.size, self.rho.size))
     self.time = time
     # now compute the UnivariateSpline
     for t in range(time.size):
         S = UnivariateSpline(self.rhoraw[t, :], self.neraw[t, :], s=0)
         self.ne[t, :] = S(self.rho)
         self.neNorm[t, :] = S(self.rho) / S(1)
コード例 #2
0
def plotSIFGI():

    a = eqtools.EqdskReader(gfile='/afs/ipp-garching.mpg.de/home/i/ianf/codes/python/general/g33669.3000')
    a.remapLCFS()
    b = eqtools.AUGDDData(33669)
    tok = TRIPPy.Tokamak(b)
    cont = (pow(scipy.linspace(0,1,11),2)*(a.getFluxLCFS()-a.getFluxAxis())+a.getFluxAxis())

    print(a.getFluxAxis())
    print(a.getFluxLCFS())
    print(cont)
    temp = b.getMachineCrossSectionFull()
    plotEq.plot(a,33669,lims=temp,contours=-1*cont)
    
    GI = genGRW(tok)
    r = GI.r()[0][-2:]
    z = GI.r()[2][-2:]
    print(r,z)
    plt.plot(r,z,color='#0E525A',linewidth=2.)

    SIF = genSIF(tok)
    r = SIF.r()[0][-2:]
    z = SIF.r()[2][-2:]
    print(r,z)
    plt.plot(r,z,color='#228B22',linewidth=2.)
    plt.subplots_adjust(left=.2,right=.95)
    plt.gca().set_xlim([scipy.nanmin(temp[0].astype(float)),scipy.nanmax(temp[0].astype(float))])
    plt.gca().set_ylim([scipy.nanmin(temp[1].astype(float)),scipy.nanmax(temp[1].astype(float))])
    plt.text(1.4,.9,'CSXR',fontsize=22,zorder=10)
    plt.text(2.25,.1,'GI',fontsize=22,zorder=10)
    limy = plt.gca().get_ylim()
    limx = plt.gca().get_xlim()
    plt.gca().text(1.0075*(limx[1]-limx[0])+limx[0],.97*(limy[1]-limy[0])+limy[0],str(33669),rotation=90,fontsize=14)
コード例 #3
0
ファイル: augFilaments.py プロジェクト: nrnishta/topic21
 def __init__(self, shot, Probe='HFF', Xprobe=None, angle=80):
     self.shot = shot
     self.angle = angle
     # load the equilibria
     try:
         start = time.time()
         self.Eq = eqtools.AUGDDData(self.shot)
         print('Equilibrium loaded in %5.4f' % (time.time() - start) + ' s')
     except ImportError:
         print('Equilibrium not loaded')
     self.Xprobe = float(Xprobe)
     # open the shot file
     self.Probe = Probe
     if self.Probe == 'HFF':
         self._HHFGeometry(angle=self.angle)
         start = time.time()
         self._loadHHF()
         print('Probe signal loaded in %5.4f' % (time.time() - start) + ' s')
     elif self.Probe == '14Pin':
         self._14PGeometry(angle=self.angle)
         self._loadHHF()
     else:
         logging.warning('Other probe head not implemented yet')
     # load the data from Langmuir probes
     self.Target = langmuir.Target(self.shot)
     # load the profile of the Li-Beam so that
     # we can evaluate the Efolding length
     try:
         start = time.time()
         self.LiB = libes.Libes(self.shot)
         self._tagLiB = True
         print('LiB loaded in %5.4f' % (time.time() - start) + ' s')
     except ImportWarning:
         self._tagLiB = False
         logging.warning('Li-Beam not found for shot %5i' % shot)
コード例 #4
0
def genInp(num=1e-3,shot=34228):
    tok = TRIPPy.Tokamak(eqtools.AUGDDData(34228))
    ray = genSIF(tok)
    print(ray.norm.s)
    #inp = scipy.linspace(ray.norm.s[-2],ray.norm.s[-1],num)
    inp = scipy.mgrid[ray.norm.s[-2]:ray.norm.s[-1]:num]
    r = ray(inp).r()[0]
    z = ray(inp).r()[2]
    l = inp - inp[0]
    return [r,z,l]
コード例 #5
0
def plotCross(shot,time):
    eq = eqtools.AUGDDData(shot)
    eq.remapLCFS() #get that pretty boundary
    rl = eq.getRLCFS()[eq._getNearestIdx(eq.getTimeBase(),time)]
    zl = eq.getZLCFS()[eq._getNearestIdx(eq.getTimeBase(),time)]
    out = eq.getMachineCrossSectionFull()
    plt.plot(rl,zl,lw=2)
    plt.plot(out[0],out[1],'k')
    plt.gca().set_aspect('equal')
    plt.gca().autoscale(tight=True)
    plt.show()
コード例 #6
0
def weights2(inp, te, shot, time):
    """ pull out data vs time necessary to calculate the weights"""
    #condition initialized values

    output = scipy.zeros((len(time), 2))
    r = inp[0]
    z = inp[1]
    l = inp[2]

    #load GIW ne, Te data

    tped = goodGIW(time, shot, name="t_e_ped")
    tcore = goodGIW(time, shot, name="t_e_core")

    nped = goodGIW(time, shot, name="n_e_ped")
    ncore = goodGIW(time, shot, name="n_e_core")

    good = scipy.arange(len(time))[scipy.logical_and(
        ncore != 0, tcore != 0)]  #take only good data

    #use spline of the GIW data to solve for the proper Te, otherwise dont evaluate

    logte = scipy.log(te)
    halfte = scipy.exp(logte[1:] / 2. +
                       logte[:-1] / 2.)  #not going to worry about endpoints
    # because I trust te is big enough to be larger than the range of the profile

    #step 1, use array of r,z values to solve for rho

    eq = eqtools.AUGDDData(shot)
    rho = eq.rz2rho('psinorm', r, z, time[good], each_t=True,
                    sqrt=True)  #solve at each time
    rhomin = scipy.nanmin(rho, axis=1)
    temax = GIWprofiles.te(rhomin, tcore[good], tped[good])

    idx = 0

    #step 2, construct 2 splines of l(rho)
    for i in good:
        temp = calcArealDens(l, te, halfte, rho[idx], tped[i], tcore[i],
                             nped[i], ncore[i])
        temp[scipy.logical_not(scipy.isfinite(temp))] = 0.
        temp = scipy.sum(temp)
        output[i, 0] = temp
        output[i, 1] = temax[idx]
        idx += 1
        #print(idx),

    #step 8, return values for storage
    return output
コード例 #7
0
both the parallel connection length from midplane to LFS and from
Xpoint height to the LFS. We will also save the distance as R-Rsep and
rho_p
"""

from cyfieldlineTracer import get_fieldline_tracer
from copy import deepcopy as copy
import numpy as np
import eqtools
import matplotlib as mpl
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

shotList = (34102, 34103, 34104, 34105, 34106)
for shot in shotList:
    Eq = eqtools.AUGDDData(shot)
    Eq.remapLCFS()
    
    # load now the tracer for the same shot all at 3s
    myTracer = get_fieldline_tracer('RK4', machine='AUG', shot=shot, time=3, interp='quintic', rev_bt=True)
    # height of magnetic axis
    zMAxis = myTracer.eq.axis.__dict__['z']
    # height of Xpoint
    zXPoint = myTracer.eq.xpoints['xpl'].__dict__['z']
    rXPoint = myTracer.eq.xpoints['xpl'].__dict__['r']
    # now determine at the height of the zAxis the R of the LCFS
    _idTime = np.argmin(np.abs(Eq.getTimeBase()-3))
    RLcfs = Eq.getRLCFS()[_idTime, :]
    ZLcfs = Eq.getZLCFS()[_idTime, :]
    # onlye the part greater then xaxis
    ZLcfs = ZLcfs[RLcfs > myTracer.eq.axis.__dict__['r']]
コード例 #8
0
def plotSIF2(num=1e-4):

    a = eqtools.EqdskReader(gfile='/afs/ipp-garching.mpg.de/home/i/ianf/codes/python/general/g33669.3000')
    a.remapLCFS()
    b = eqtools.AUGDDData(33669)
    tok = TRIPPy.Tokamak(b)
    cont = (pow(scipy.linspace(0,1,11),2)*(a.getFluxLCFS()-a.getFluxAxis())+a.getFluxAxis())

    print(a.getFluxAxis())
    print(a.getFluxLCFS())
    print(cont)
    temp = b.getMachineCrossSectionFull()
    plotEq.plot(a,33669,lims=temp,contours=-1*cont[[0,10]],alpha=.15)

    ray = genSIF(tok)
    print(ray.norm.s)
    #inp = scipy.linspace(ray.norm.s[-2],ray.norm.s[-1],num)
    inp = scipy.mgrid[ray.norm.s[-2]:ray.norm.s[-1]:num]
    r = ray(inp).r()[0]
    z = ray(inp).r()[2]
    l = inp - inp[0]

    print(r.shape,z.shape,l.shape)

    plt.plot(r,z,color='#228B22',linewidth=2.)

    plt.subplots_adjust(left=.2,right=.95)
    plt.gca().set_xlim([scipy.nanmin(temp[0].astype(float)),scipy.nanmax(temp[0].astype(float))])
    plt.gca().set_ylim([scipy.nanmin(temp[1].astype(float)),scipy.nanmax(temp[1].astype(float))])
    limy = plt.gca().get_ylim()
    limx = plt.gca().get_xlim()
    plt.gca().text(1.0075*(limx[1]-limx[0])+limx[0],.97*(limy[1]-limy[0])+limy[0],str(33669),rotation=90,fontsize=14)
    
    ax1 = plt.gca()
    ax1.arrow(1.8,-.608,.025,0.0,head_width=.05,head_length=.1,fc='k',ec='k',zorder=10)
    ax1.arrow(1.8,0.728,.025,0.0,head_width=.05,head_length=.1,fc='k',ec='k',zorder=10)

    iax = plt.axes([0,0,1,1])

    x0 = (r.min()-limx[0])/(limx[1]-limx[0])
    y0 = (z.min()-limy[0])/(limy[1]-limy[0])
    y1 = (z.max()-limy[0])/(limy[1]-limy[0])

    print(limx)
    print(limy)

    print([x0+.05,y0,.2,y1-y0])

    ip = InsetPosition(ax1, [x0+.1,y0,.3,y1-y0])
    #ip = plt.axes([.05,.05,.02,.02])
    iax.set_axes_locator(ip)
    

    tempData = scipy.squeeze(GIWprofiles.te(b.rz2psinorm(r,z,[3.0],sqrt=True,each_t=True),4e3,1e3))
    print(tempData.shape)
    iax.semilogx(tempData,l,color='#0E525A',linewidth=2.)
    iax.set_ylim(l.max(),l.min())
    iax.set_xlim(1e2,1e4)
    iax.set_xlabel('$T_e$ [eV]')
    iax.text(2e2,1.0,'$l(T_e)$')
    iax.yaxis.tick_right()
    iax.set_axis_bgcolor('#eaeaea')