示例#1
0
 def _loadeq(self):
     # loading the equilibrium
     self.Eqm = map_equ.equ_map()
     status = self.Eqm.Open(self.shot, diag='EQH')
     self.Eqm._read_scalars()
     self.Eqm._read_profiles()
     self.Eqm._read_pfm()
     # load the wall for aug
     self.rg, self.zg = map_equ.get_gc()
     self._psi = self.Eqm.pfm.transpose()
     self._time_array = self.Eqm.t_eq
     nr = self._psi.shape[0]
     nz = self._psi.shape[1]
     self._r = self.Eqm.Rmesh
     self._z = self.Eqm.Zmesh
     self._psi_axis = self.Eqm.psi0
     self._psi_bnd = self.Eqm.psix
     # get the fpol in similar way
     # as done in eqtools
     self._jpol = self.Eqm.jpol
     # these are the lower xpoints
     self._rxpl = self.Eqm.ssq['Rxpu']
     self._zxpl = self.Eqm.ssq['Zxpu']
     # read also the upper xpoint
     self._rxpu = self.Eqm.ssq['Rxpo']
     self._zxpu = self.Eqm.ssq['Zxpo']
     # R magnetic axis
     self._axisr = self.Eqm.ssq['Rmag']
     # Z magnetic axis
     self._axisz = self.Eqm.ssq['Zmag']
     # eqm does not load the RBphi on axis
     Mai = dd.shotfile('MAI', self.shot)
     self.Rcent = 1.65
     # we want to interpolate on the same time basis
     Spl = UnivariateSpline(Mai('BTF').time, Mai('BTF').data, s=0)
     self._bphi = Spl(self._time_array) * self.Rcent
     Mai.close()
     Mag = dd.shotfile('MAG', self.shot)
     Spl = UnivariateSpline(Mag('Ipa').time, Mag('Ipa').data, s=0)
     self._cplasma = Spl(self._time_array)
     # we want to load also the plasma curent
     # now define the psiN
     self._psiN = (self._psi-self._psi_axis[:, np.newaxis, np.newaxis])/ \
         (self._psi_bnd[:, np.newaxis, np.newaxis]-self._psi_axis[:, np.newaxis, np.newaxis])
 def init_read_from_shotfile(self):
     self.equ = equ_map()
     self.state = 0
     if(not self.equ.Open(self.shot, diag=self.EQ_diag, exp=self.EQ_exp, ed=self.EQ_ed)):
         print("Failed to open shotfile")
         self.state = -1
         return
     self.EQ_ed = self.equ.ed
     if(self.EQ_diag == "EQH"):
         self.GQH = dd.shotfile("GQH", int(self.shot), experiment=self.EQ_exp, edition=self.EQ_ed)
         self.FPC = dd.shotfile("FPC", int(self.shot))
     elif(self.EQ_diag == "IDE"):
         self.GQH = dd.shotfile("IDG", int(self.shot), experiment=self.EQ_exp, edition=self.EQ_ed)
         self.IDF = dd.shotfile("IDF", int(self.shot), experiment=self.EQ_exp, edition=self.EQ_ed)
         self.FPC = None
     else:
         print("EQ diagnostic {0:s} not supported - only EQH and IDE are currently supported!".format(self.EQ_diag))
     self.MBI_shot = dd.shotfile('MBI', int(self.shot))
     self.equ.read_scalars()
     self.shotfile_ready = True
示例#3
0
def main():
    #mdsserver = 'localhost'
    #MDSconn = MDSplus.Connection(mdsserver)
    #MDSconn.openTree('ACTIVESPEC', 141716)

    #mdsserver = 'skylark.pppl.gov:8501'
    #import MDSplus
    #try:
    #MDSconn = MDSplus.Connection(mdsserver)
    #except:
    mdsserver = 'localhost'
    MDSconn = MDSplus.Connection(mdsserver)
    TT = time()
    shot = 115559
    #shot = 204179
    shot = 141040
    shot = 141040
    rho_coord = 'rho_tor'

    print(shot)
    print_line('  * Fetching EFIT01 data ...')
    from map_equ import equ_map

    eqm = equ_map(MDSconn)
    eqm.Open(shot, 'EFIT01', exp='NSTXU')

    #load EFIT data from MDS+
    T = time()
    eqm._read_pfm()
    eqm.read_ssq()
    eqm._read_scalars()
    eqm._read_profiles()
    print('\t done in %.1f' % (time() - T))

    loader = data_loader(MDSconn, shot, eqm, rho_coord)

    import tkinter as tk
    myroot = tk.Tk(className=' Profiles')

    I = lambda x: tk.IntVar(value=x)
    S = lambda x: tk.StringVar(value=x)
    D = lambda x: tk.DoubleVar(value=x)

    ts_revisions = []
    CHERS_revisions = []

    default_settings = OrderedDict()

    default_settings['Ti']={'systems':{'CER system':([], )},\
        'load_options':{'CER system':{'Analysis':(S('CT2'), CHERS_revisions),
        'Corrections':{'Zeeman Splitting':I(1) }}}}

    default_settings['omega'] = {
        'systems': {
            'CER system': ([], )
        },
        'load_options': {
            'CER system': {
                'Analysis': (S('CT1'), CHERS_revisions)
            }
        }
    }

    default_settings['nC6'] = {
        'systems': {
            'CER system': ([], )
        },
        'load_options': {
            'CER system': {
                'Analysis': (S('CT1'), CHERS_revisions)
            }
        }
    }

    default_settings['Te'] = {
        'systems': {
            'TS system': (['LFS', I(1)], ['HFS', I(1)])
        },
        'load_options': {
            'TS system': {
                "TS revision": (S('BEST'), ts_revisions)
            }
        }
    }

    default_settings['ne'] = {
        'systems': {
            'TS system': (['LFS', I(1)], ['HFS', I(1)])
        },
        'load_options': {
            'TS system': {
                "TS revision": (S('BEST'), ts_revisions)
            }
        }
    }

    default_settings['Mach']= {\
        'systems':{'CER system':[]},
        'load_options':{'CER system':{'Analysis':(S('CT1'), CHERS_revisions)}}}

    default_settings['Te/Ti']= {\
        'systems':{'CER system':[]},
        'load_options':{'CER system':{'Analysis':(S('CT1'), CHERS_revisions)}}}

    #loader.load_splines()
    loader.load_mode_loc()

    try:
        data = loader('ne',
                      default_settings,
                      tbeg=eqm.t_eq[0],
                      tend=eqm.t_eq[-1])
    finally:
        MDSconn.disconnect()
    print('\t done in %.1f' % (time() - T))

    print('\n\t\t\t Total time %.1fs' % (time() - TT))
示例#4
0
    def load_AUG(self, shot, time, with_bfield=True, verbose=False):
        self.machine = 'AUG'
        self._shot = shot
        if not self._loaded:
            Eqm = map_equ.equ_map()
            status = Eqm.Open(self._shot, diag='EQH')
            Eqm._read_scalars()
            Eqm._read_profiles()
            Eqm._read_pfm()
            # Load in required data
            # The transpose is needed since in this way we have dimension of
            # the form (#samples, Rgrid, ZGrid)
            self._psi = Eqm.pfm.transpose()
            self._time_array = Eqm.t_eq
            nr = self._psi.shape[0]
            nz = self._psi.shape[1]
            self._r = Eqm.Rmesh
            self._z = Eqm.Zmesh
            self._psi_axis = Eqm.psi0
            self._psi_bnd = Eqm.psix
            # get the fpol in similar way
            # as done in eqtools
            self._jpol = Eqm.jpol
            # these are the lower xpoints
            self._rxpl = Eqm.ssq['Rxpu']
            self._zxpl = Eqm.ssq['Zxpu']
            # read also the upper xpoint
            self._rxpu = Eqm.ssq['Rxpo']
            self._zxpu = Eqm.ssq['Zxpo']
            # R magnetic axis
            self._axisr = Eqm.ssq['Rmag']
            # Z magnetic axis
            self._axisz = Eqm.ssq['Zmag']
            # eqm does not load the RBphi on axis
            Mai = dd.shotfile('MAI', self._shot)
            self.Rcent = 1.65
            # we want to interpolate on the same time basis
            Spl = UnivariateSpline(Mai('BTF').time, Mai('BTF').data, s=0)
            self._bphi = Spl(self._time_array) * self.Rcent
            Mai.close()
            Mag = dd.shotfile('MAG', self._shot)
            Spl = UnivariateSpline(Mag('Ipa').time, Mag('Ipa').data, s=0)
            self._cplasma = Spl(self._time_array)
            # we want to load also the plasma curent
            self._loaded = True
            self._Eqm = Eqm
        tind = np.abs(self._time_array - time).argmin()
        self.R = self._r  #.data[0,:]
        self.Z = self._z  #.data[0,:]
        psi_func = interp2d(self.R, self.Z, self._psi[tind])
        self.psi = equilibriumField(self._psi[tind], psi_func)
        self.nr = len(self.R)
        self.nz = len(self.Z)
        self.psi_axis = self._psi_axis[tind]
        self.psi_bnd = self._psi_bnd[tind]
        self.Btcent = self._bphi[tind]
        self.sigBp = np.sign(self._cplasma[tind])
        fpol = self._jpol[:, tind] * 2e-7
        fpol = fpol[:np.argmin(np.abs(fpol))]
        psigrid = np.linspace(self.psi_axis, self.psi_bnd, len(fpol))
        self.fpol = equilibriumField(fpol, UnivariateSpline(psigrid, fpol,
                                                            s=0))
        self.nxpt = 2
        tind_xpt = tind  #np.abs(self._xpoint1r.time - time).argmin()
        self.xpoints = {
            'xpl': Point(self._rxpl[tind], self._zxpl[tind]),
            'xpu': Point(self._rxpu[tind], self._zxpu[tind])
        }
        self.spoints = None
        #self.xpoint.append(Point(self._xpoint2r.data[tind_xpt],self._xpoint2z.data[tind_xpt]))
        self.axis = Point(self._axisr[tind], self._axisz[tind])
        self.fpol = None

        self._loaded = True
        self._time = self._time_array[tind]

        psiN_func = interp2d(self.R, self.Z, (self.psi[:] - self.psi_axis) /
                             (self.psi_bnd - self.psi_axis))
        self.psiN = equilibriumField(
            (self.psi[:] - self.psi_axis) / (self.psi_bnd - self.psi_axis),
            psiN_func)

        VesselFile = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                                  'augVesseldata.txt')
        x, y = np.loadtxt(VesselFile, unpack=True)
        self.wall = {'R': x, 'Z': y}
        if with_bfield: self.calc_bfield()
示例#5
0
if __name__ == "__main__":

    from time import time
    
    from map_equ import equ_map,get_gc 
    import matplotlib.pylab as plt
    
    
    mds_server = "atlas.gat.com"

    import MDSplus as mds
    c = mds.Connection(mds_server )

    
    eqm = equ_map(c,debug=False)
    
    
    
    eqm.Open(175699,diag='EFIT04')
    
    
    eqm._read_profiles()
    import IPython
    IPython.embed()
    
    #rho_tor = np.linspace(0,1,1000)
    
    #r_V = eqm.rho2rho( rho_tor, t_in=5,coord_in='rho_tor', coord_out='r_V' )
    #r_mn = eqm.rho2rho( rho_tor, t_in=5,coord_in='rho_tor', coord_out='RMNMP' )