SOLPSxport.py
def populatePedFits(self, nemod='tanh', temod='tanh', ncmod='spl',
                        npsi=250, psinMax=None, plotit=False):
        """
        Get the fitted tanh profiles (need to have run loadProfDBPedFit already)

        Inputs:
          XXmod   Fit used for each parameter
          npsi    Number of points to populate full radial fit, from psin=0 (linearly distributed)
          psinMax End of radial grid to populate, in units of psin
                  (this defaults to be slightly larger than the SOLPS grid if nothing is given)
        """
        if psinMax is None:
            if 'psiSOLPS' in self.data['solpsData'].keys():
                psinMax = np.max(self.data['solpsData']['psiSOLPS']) + 0.001
            else:
                psinMax = 1.02

        psiProf = np.linspace(0, psinMax, npsi+1)
        
        self.data['pedData']['fitPsiProf'] = psiProf
        self.data['pedData']['fitProfs'] = {}
    
        # !!! Need to subtract shift from psiProf to move separatrix for power balance !!!

        # make ne profile
        if nemod == 'tnh0':
            necoef = self.data['pedData']['fitVals']['netnh0psi']['y']
            neprof = sut.calcTanhMulti(necoef,psiProf)
        elif nemod == 'tanh':
            necoef = self.data['pedData']['fitVals']['netanhpsi']['y']
            neprof = sut.calcTanhMulti(necoef,psiProf)
        self.data['pedData']['fitProfs']['neprof'] = neprof
            
        # make Te profile
        if temod == 'tnh0':
            tecoef = self.data['pedData']['fitVals']['tetnh0psi']['y']
            teprof = sut.calcTanhMulti(tecoef,psiProf)
        elif nemod == 'tanh':
            tecoef = self.data['pedData']['fitVals']['tetanhpsi']['y']
            teprof = sut.calcTanhMulti(tecoef,psiProf)
        self.data['pedData']['fitProfs']['teprof'] = teprof
        
        if ncmod == 'spl':
            zfzpsi = self.data['pedData']['fitVals']['zfz1splpsi']['x']
            zfzprof = self.data['pedData']['fitVals']['zfz1splpsi']['y']
            zfzfunc = interp1d(zfzpsi, zfzprof, bounds_error = False,
                               fill_value = zfzprof[np.argmax(zfzpsi)])
            # extrapolate to psin>1 using highest value of psin available
        
            self.data['pedData']['fitProfs']['ncprof'] = zfzfunc(psiProf) * neprof / 6
            
        elif ncmod == 'tanh':
            nccoef = self.data['pedData']['fitVals']['nztanhpsi']['y']
            ncprof = sut.calcTanhMulti(nccoef,psiProf)
            self.data['pedData']['fitProfs']['ncprof'] = ncprof * neprof / 6
            
        if plotit:
            f, ax = plt.subplots(2, sharex = 'all')

            ax[0].plot(psiProf, neprof, '-b', lw = 2, label = 'n$_e$')
            ax[0].plot(psiProf, 6*self.data['pedData']['fitProfs']['ncprof'], '--k', lw = 2, label = '6*n$_C$')
            ax[0].legend(loc='best')
            ax[0].set_ylabel('n (10$^{20}$ m$^{-3}$)')
            ax[0].grid('on')
    
            ax[1].plot(psiProf, teprof, '-r', lw = 2)
            ax[1].set_ylabel('T$_e$ (keV)')
            ax[1].grid('on')
            ax[1].set_xlabel('$\psi_n$')
            ax[1].set_xlim([0, psinMax+0.01])
            
            ax[0].set_title('Experimental Pedestal Fits')
            
            plt.show(block = False)

        Get the fitted tanh profiles (need to have run loadProfDBPedFit already)

        Inputs:
          XXmod   Fit used for each parameter
          npsi    Number of points to populate full radial fit, from psin=0 (linearly distributed)
          psinMax End of radial grid to populate, in units of psin
                  (this defaults to be slightly larger than the SOLPS grid if nothing is given)
        
Get the fitted tanh profiles (need to have run loadProfDBPedFit already)
Inputs:
XXmod   Fit used for each parameter
npsi    Number of points to populate full radial fit, from psin=0 (linearly distributed)
psinMax End of radial grid to populate, in units of psin
(this defaults to be slightly larger than the SOLPS grid if nothing is given)
Get the fitted tanh profiles ( need to have run loadProfDBPedFit already ) Inputs : XXmod Fit used for each parameter npsi Number of points to populate full radial fit from psin = 0 ( linearly distributed ) psinMax End of radial grid to populate in units of psin ( this defaults to be slightly larger than the SOLPS grid if nothing is given )
def populatePedFits(self, nemod='tanh', temod='tanh', ncmod='spl',
                        npsi=250, psinMax=None, plotit=False):
        if psinMax is None:
            if 'psiSOLPS' in self.data['solpsData'].keys():
                psinMax = np.max(self.data['solpsData']['psiSOLPS']) + 0.001
            else:
                psinMax = 1.02
        psiProf = np.linspace(0, psinMax, npsi+1)
        self.data['pedData']['fitPsiProf'] = psiProf
        self.data['pedData']['fitProfs'] = {}
        if nemod == 'tnh0':
            necoef = self.data['pedData']['fitVals']['netnh0psi']['y']
            neprof = sut.calcTanhMulti(necoef,psiProf)
        elif nemod == 'tanh':
            necoef = self.data['pedData']['fitVals']['netanhpsi']['y']
            neprof = sut.calcTanhMulti(necoef,psiProf)
        self.data['pedData']['fitProfs']['neprof'] = neprof
        if temod == 'tnh0':
            tecoef = self.data['pedData']['fitVals']['tetnh0psi']['y']
            teprof = sut.calcTanhMulti(tecoef,psiProf)
        elif nemod == 'tanh':
            tecoef = self.data['pedData']['fitVals']['tetanhpsi']['y']
            teprof = sut.calcTanhMulti(tecoef,psiProf)
        self.data['pedData']['fitProfs']['teprof'] = teprof
        if ncmod == 'spl':
            zfzpsi = self.data['pedData']['fitVals']['zfz1splpsi']['x']
            zfzprof = self.data['pedData']['fitVals']['zfz1splpsi']['y']
            zfzfunc = interp1d(zfzpsi, zfzprof, bounds_error = False,
                               fill_value = zfzprof[np.argmax(zfzpsi)])
            self.data['pedData']['fitProfs']['ncprof'] = zfzfunc(psiProf) * neprof / 6
        elif ncmod == 'tanh':
            nccoef = self.data['pedData']['fitVals']['nztanhpsi']['y']
            ncprof = sut.calcTanhMulti(nccoef,psiProf)
            self.data['pedData']['fitProfs']['ncprof'] = ncprof * neprof / 6
        if plotit:
            f, ax = plt.subplots(2, sharex = 'all')
            ax[0].plot(psiProf, neprof, '-b', lw = 2, label = 'n$_e$')
            ax[0].plot(psiProf, 6*self.data['pedData']['fitProfs']['ncprof'], '--k', lw = 2, label = '6*n$_C$')
            ax[0].legend(loc='best')
            ax[0].set_ylabel('n (10$^{20}$ m$^{-3}$)')
            ax[0].grid('on')
            ax[1].plot(psiProf, teprof, '-r', lw = 2)
            ax[1].set_ylabel('T$_e$ (keV)')
            ax[1].grid('on')
            ax[1].set_xlabel('$\psi_n$')
            ax[1].set_xlim([0, psinMax+0.01])
            ax[0].set_title('Experimental Pedestal Fits')
            plt.show(block = False)
def populatePedFits ( self , nemod = 'tanh' , temod = 'tanh' , ncmod = 'spl' , npsi = 250 , psinMax = None , plotit = False ) : if psinMax is None : if 'psiSOLPS' in self . data [ 'solpsData' ] . keys ( ) : psinMax = np . max ( self . data [ 'solpsData' ] [ 'psiSOLPS' ] ) + 0.001 else : psinMax = 1.02 psiProf = np . linspace ( 0 , psinMax , npsi + 1 ) self . data [ 'pedData' ] [ 'fitPsiProf' ] = psiProf self . data [ 'pedData' ] [ 'fitProfs' ] = { } if nemod == 'tnh0' : necoef = self . data [ 'pedData' ] [ 'fitVals' ] [ 'netnh0psi' ] [ 'y' ] neprof = sut . calcTanhMulti ( necoef , psiProf ) elif nemod == 'tanh' : necoef = self . data [ 'pedData' ] [ 'fitVals' ] [ 'netanhpsi' ] [ 'y' ] neprof = sut . calcTanhMulti ( necoef , psiProf ) self . data [ 'pedData' ] [ 'fitProfs' ] [ 'neprof' ] = neprof if temod == 'tnh0' : tecoef = self . data [ 'pedData' ] [ 'fitVals' ] [ 'tetnh0psi' ] [ 'y' ] teprof = sut . calcTanhMulti ( tecoef , psiProf ) elif nemod == 'tanh' : tecoef = self . data [ 'pedData' ] [ 'fitVals' ] [ 'tetanhpsi' ] [ 'y' ] teprof = sut . calcTanhMulti ( tecoef , psiProf ) self . data [ 'pedData' ] [ 'fitProfs' ] [ 'teprof' ] = teprof if ncmod == 'spl' : zfzpsi = self . data [ 'pedData' ] [ 'fitVals' ] [ 'zfz1splpsi' ] [ 'x' ] zfzprof = self . data [ 'pedData' ] [ 'fitVals' ] [ 'zfz1splpsi' ] [ 'y' ] zfzfunc = interp1d ( zfzpsi , zfzprof , bounds_error = False , fill_value = zfzprof [ np . argmax ( zfzpsi ) ] ) self . data [ 'pedData' ] [ 'fitProfs' ] [ 'ncprof' ] = zfzfunc ( psiProf ) * neprof / 6 elif ncmod == 'tanh' : nccoef = self . data [ 'pedData' ] [ 'fitVals' ] [ 'nztanhpsi' ] [ 'y' ] ncprof = sut . calcTanhMulti ( nccoef , psiProf ) self . data [ 'pedData' ] [ 'fitProfs' ] [ 'ncprof' ] = ncprof * neprof / 6 if plotit : f , ax = plt . subplots ( 2 , sharex = 'all' ) ax [ 0 ] . plot ( psiProf , neprof , '-b' , lw = 2 , label = 'n$_e$' ) ax [ 0 ] . plot ( psiProf , 6 * self . data [ 'pedData' ] [ 'fitProfs' ] [ 'ncprof' ] , '--k' , lw = 2 , label = '6*n$_C$' ) ax [ 0 ] . legend ( loc = 'best' ) ax [ 0 ] . set_ylabel ( 'n (10$^{20}$ m$^{-3}$)' ) ax [ 0 ] . grid ( 'on' ) ax [ 1 ] . plot ( psiProf , teprof , '-r' , lw = 2 ) ax [ 1 ] . set_ylabel ( 'T$_e$ (keV)' ) ax [ 1 ] . grid ( 'on' ) ax [ 1 ] . set_xlabel ( '$\psi_n$' ) ax [ 1 ] . set_xlim ( [ 0 , psinMax + 0.01 ] ) ax [ 0 ] . set_title ( 'Experimental Pedestal Fits' ) plt . show ( block = False )
Get the fitted tanh profiles (need to have run loadProfDBPedFit already)
Inputs:
XXmod   Fit used for each parameter
npsi    Number of points to populate full radial fit, from psin=0 (linearly distributed)
psinMax End of radial grid to populate, in units of psin
(this defaults to be slightly larger than the SOLPS grid if nothing is given)
Get the fitted tanh profiles ( need to have run loadProfDBPedFit already ) Inputs : XXmod Fit used for each parameter npsi Number of points to populate full radial fit from psin = 0 ( linearly distributed ) psinMax End of radial grid to populate in units of psin ( this defaults to be slightly larger than the SOLPS grid if nothing is given )
"""
        Get the fitted tanh profiles (need to have run loadProfDBPedFit already)

        Inputs:
          XXmod   Fit used for each parameter
          npsi    Number of points to populate full radial fit, from psin=0 (linearly distributed)
          psinMax End of radial grid to populate, in units of psin
                  (this defaults to be slightly larger than the SOLPS grid if nothing is given)
        """ # !!! Need to subtract shift from psiProf to move separatrix for power balance !!! # make ne profile # make Te profile # extrapolate to psin>1 using highest value of psin available
self
nemod
temod
ncmod
npsi
psinMax
plotit