SOLPSxport_dr.py
def track_inputfile_iterations(rundir=None, carbon=True, cmap='viridis', Dn_scalar = 100):
    """
    Track the evolution of the b2.transport.inputfile transport
    coefficients through and evolving transport matching job

    Append b2.transport.inputfile filenames with numbers and leave them
    in the same run directory

    Requires everything to be on the same grid with the same species
    """
    from SOLPSutils import read_b2_transport_inputfile

    if rundir is None:
        print("No run directory given, selecting cwd:")
        rundir = os.getcwd()
        print(rundir)

    cm = get_cmap(cmap)

    _, _, filenames = next(os.walk(rundir), (None, None, []))
    inputfile_list = [fn for fn in filenames if
                      (fn[:22] == 'b2.transport.inputfile' and fn[-1] != '~')]
    inputfile_list.sort()
    if len(inputfile_list[0]) == 22:  # most recent, unnumbered inputfile should be at the end
        inputfile_list = inputfile_list[1:] + [inputfile_list[0]]

    ninfiles = len(inputfile_list)

    if rundir[-1] != '/': rundir += '/'

    dn_sep = np.zeros(ninfiles)
    ki_sep = np.zeros(ninfiles)
    ke_sep = np.zeros(ninfiles)
    dn_bdy = np.zeros(ninfiles)
    ki_bdy = np.zeros(ninfiles)
    ke_bdy = np.zeros(ninfiles)

    f, ax = plt.subplots(3, sharex='all')

    for i in range(ninfiles):
        infile = read_b2_transport_inputfile(rundir + inputfile_list[i], carbon=carbon)

        sep_ind = np.argmin(np.abs(infile['rn']))
        dn_sep[i] = infile['dn'][sep_ind]
        ki_sep[i] = infile['ki'][sep_ind]
        ke_sep[i] = infile['ke'][sep_ind]
        dn_bdy[i] = infile['dn'][-1]
        ki_bdy[i] = infile['ki'][-1]
        ke_bdy[i] = infile['ke'][-1]

        ax[0].plot(infile['rn'], infile['dn'], '-x', color=cm(i / (float(ninfiles) - 1)),
                   label=inputfile_list[i][13:])
        ax[1].plot(infile['rn'], infile['ki'], '-x', color=cm(i / (float(ninfiles) - 1)))
        ax[2].plot(infile['rn'], infile['ke'], '-x', color=cm(i / (float(ninfiles) - 1)))

    ax[0].set_ylabel('dn')
    ax[1].set_ylabel('ki')
    ax[2].set_ylabel('ke')
    ax[-1].set_xlabel('rn')
    ax[0].legend(loc='best')
    for j in range(len(ax)):
        ax[j].grid('on')

    plt.figure()
    plt.plot(range(ninfiles), dn_sep*Dn_scalar, '-xk', lw=2, label='Dn x' + str(Dn_scalar))
    plt.plot(range(ninfiles), ki_sep, '-ob', lw=2, label='ki')
    plt.plot(range(ninfiles), ke_sep, '-or', lw=2, label='ke')
    plt.legend(loc='best')
    plt.xlabel('Iteration')
    plt.title('Transport coefficient evolution at separatrix')
    plt.grid('on')

    plt.figure()
    plt.plot(range(ninfiles), dn_bdy*Dn_scalar, '-xk', lw=2, label='Dn x' + str(Dn_scalar))
    plt.plot(range(ninfiles), ki_bdy, '-ob', lw=2, label='ki')
    plt.plot(range(ninfiles), ke_bdy, '-or', lw=2, label='ke')
    plt.legend(loc='best')
    plt.xlabel('Iteration')
    plt.title('Transport coefficient evolution at boundary')
    plt.grid('on')

    plt.show(block=False)

    Track the evolution of the b2.transport.inputfile transport
    coefficients through and evolving transport matching job

    Append b2.transport.inputfile filenames with numbers and leave them
    in the same run directory

    Requires everything to be on the same grid with the same species
    
Track the evolution of the b2.transport.inputfile transport
coefficients through and evolving transport matching job

Append b2.transport.inputfile filenames with numbers and leave them
in the same run directory

Requires everything to be on the same grid with the same species
Track the evolution of the b2 . transport . inputfile transport coefficients through and evolving transport matching job Append b2 . transport . inputfile filenames with numbers and leave them in the same run directory Requires everything to be on the same grid with the same species
def track_inputfile_iterations(rundir=None, carbon=True, cmap='viridis', Dn_scalar = 100):
    from SOLPSutils import read_b2_transport_inputfile
    if rundir is None:
        print("No run directory given, selecting cwd:")
        rundir = os.getcwd()
        print(rundir)
    cm = get_cmap(cmap)
    _, _, filenames = next(os.walk(rundir), (None, None, []))
    inputfile_list = [fn for fn in filenames if
                      (fn[:22] == 'b2.transport.inputfile' and fn[-1] != '~')]
    inputfile_list.sort()
    if len(inputfile_list[0]) == 22:  
        inputfile_list = inputfile_list[1:] + [inputfile_list[0]]
    ninfiles = len(inputfile_list)
    if rundir[-1] != '/': rundir += '/'
    dn_sep = np.zeros(ninfiles)
    ki_sep = np.zeros(ninfiles)
    ke_sep = np.zeros(ninfiles)
    dn_bdy = np.zeros(ninfiles)
    ki_bdy = np.zeros(ninfiles)
    ke_bdy = np.zeros(ninfiles)
    f, ax = plt.subplots(3, sharex='all')
    for i in range(ninfiles):
        infile = read_b2_transport_inputfile(rundir + inputfile_list[i], carbon=carbon)
        sep_ind = np.argmin(np.abs(infile['rn']))
        dn_sep[i] = infile['dn'][sep_ind]
        ki_sep[i] = infile['ki'][sep_ind]
        ke_sep[i] = infile['ke'][sep_ind]
        dn_bdy[i] = infile['dn'][-1]
        ki_bdy[i] = infile['ki'][-1]
        ke_bdy[i] = infile['ke'][-1]
        ax[0].plot(infile['rn'], infile['dn'], '-x', color=cm(i / (float(ninfiles) - 1)),
                   label=inputfile_list[i][13:])
        ax[1].plot(infile['rn'], infile['ki'], '-x', color=cm(i / (float(ninfiles) - 1)))
        ax[2].plot(infile['rn'], infile['ke'], '-x', color=cm(i / (float(ninfiles) - 1)))
    ax[0].set_ylabel('dn')
    ax[1].set_ylabel('ki')
    ax[2].set_ylabel('ke')
    ax[-1].set_xlabel('rn')
    ax[0].legend(loc='best')
    for j in range(len(ax)):
        ax[j].grid('on')
    plt.figure()
    plt.plot(range(ninfiles), dn_sep*Dn_scalar, '-xk', lw=2, label='Dn x' + str(Dn_scalar))
    plt.plot(range(ninfiles), ki_sep, '-ob', lw=2, label='ki')
    plt.plot(range(ninfiles), ke_sep, '-or', lw=2, label='ke')
    plt.legend(loc='best')
    plt.xlabel('Iteration')
    plt.title('Transport coefficient evolution at separatrix')
    plt.grid('on')
    plt.figure()
    plt.plot(range(ninfiles), dn_bdy*Dn_scalar, '-xk', lw=2, label='Dn x' + str(Dn_scalar))
    plt.plot(range(ninfiles), ki_bdy, '-ob', lw=2, label='ki')
    plt.plot(range(ninfiles), ke_bdy, '-or', lw=2, label='ke')
    plt.legend(loc='best')
    plt.xlabel('Iteration')
    plt.title('Transport coefficient evolution at boundary')
    plt.grid('on')
    plt.show(block=False)
def track_inputfile_iterations ( rundir = None , carbon = True , cmap = 'viridis' , Dn_scalar = 100 ) : from SOLPSutils import read_b2_transport_inputfile if rundir is None : print ( "No run directory given, selecting cwd:" ) rundir = os . getcwd ( ) print ( rundir ) cm = get_cmap ( cmap ) _ , _ , filenames = next ( os . walk ( rundir ) , ( None , None , [ ] ) ) inputfile_list = [ fn for fn in filenames if ( fn [ : 22 ] == 'b2.transport.inputfile' and fn [ - 1 ] != '~' ) ] inputfile_list . sort ( ) if len ( inputfile_list [ 0 ] ) == 22 : inputfile_list = inputfile_list [ 1 : ] + [ inputfile_list [ 0 ] ] ninfiles = len ( inputfile_list ) if rundir [ - 1 ] != '/' : rundir += '/' dn_sep = np . zeros ( ninfiles ) ki_sep = np . zeros ( ninfiles ) ke_sep = np . zeros ( ninfiles ) dn_bdy = np . zeros ( ninfiles ) ki_bdy = np . zeros ( ninfiles ) ke_bdy = np . zeros ( ninfiles ) f , ax = plt . subplots ( 3 , sharex = 'all' ) for i in range ( ninfiles ) : infile = read_b2_transport_inputfile ( rundir + inputfile_list [ i ] , carbon = carbon ) sep_ind = np . argmin ( np . abs ( infile [ 'rn' ] ) ) dn_sep [ i ] = infile [ 'dn' ] [ sep_ind ] ki_sep [ i ] = infile [ 'ki' ] [ sep_ind ] ke_sep [ i ] = infile [ 'ke' ] [ sep_ind ] dn_bdy [ i ] = infile [ 'dn' ] [ - 1 ] ki_bdy [ i ] = infile [ 'ki' ] [ - 1 ] ke_bdy [ i ] = infile [ 'ke' ] [ - 1 ] ax [ 0 ] . plot ( infile [ 'rn' ] , infile [ 'dn' ] , '-x' , color = cm ( i / ( float ( ninfiles ) - 1 ) ) , label = inputfile_list [ i ] [ 13 : ] ) ax [ 1 ] . plot ( infile [ 'rn' ] , infile [ 'ki' ] , '-x' , color = cm ( i / ( float ( ninfiles ) - 1 ) ) ) ax [ 2 ] . plot ( infile [ 'rn' ] , infile [ 'ke' ] , '-x' , color = cm ( i / ( float ( ninfiles ) - 1 ) ) ) ax [ 0 ] . set_ylabel ( 'dn' ) ax [ 1 ] . set_ylabel ( 'ki' ) ax [ 2 ] . set_ylabel ( 'ke' ) ax [ - 1 ] . set_xlabel ( 'rn' ) ax [ 0 ] . legend ( loc = 'best' ) for j in range ( len ( ax ) ) : ax [ j ] . grid ( 'on' ) plt . figure ( ) plt . plot ( range ( ninfiles ) , dn_sep * Dn_scalar , '-xk' , lw = 2 , label = 'Dn x' + str ( Dn_scalar ) ) plt . plot ( range ( ninfiles ) , ki_sep , '-ob' , lw = 2 , label = 'ki' ) plt . plot ( range ( ninfiles ) , ke_sep , '-or' , lw = 2 , label = 'ke' ) plt . legend ( loc = 'best' ) plt . xlabel ( 'Iteration' ) plt . title ( 'Transport coefficient evolution at separatrix' ) plt . grid ( 'on' ) plt . figure ( ) plt . plot ( range ( ninfiles ) , dn_bdy * Dn_scalar , '-xk' , lw = 2 , label = 'Dn x' + str ( Dn_scalar ) ) plt . plot ( range ( ninfiles ) , ki_bdy , '-ob' , lw = 2 , label = 'ki' ) plt . plot ( range ( ninfiles ) , ke_bdy , '-or' , lw = 2 , label = 'ke' ) plt . legend ( loc = 'best' ) plt . xlabel ( 'Iteration' ) plt . title ( 'Transport coefficient evolution at boundary' ) plt . grid ( 'on' ) plt . show ( block = False )
Track the evolution of the b2.transport.inputfile transport
coefficients through and evolving transport matching job
Track the evolution of the b2 . transport . inputfile transport coefficients through and evolving transport matching job
"""
    Track the evolution of the b2.transport.inputfile transport
    coefficients through and evolving transport matching job

    Append b2.transport.inputfile filenames with numbers and leave them
    in the same run directory

    Requires everything to be on the same grid with the same species
    """ # most recent, unnumbered inputfile should be at the end
rundir
carbon
cmap
Dn_scalar