SOLPSutils.py
def read_pfile(pfile_loc):
    """
    Read in the kinetic profiles from a p file to be used as inputs (successfully tested 2018/1/3)

    Returns a dictionary with a non-intuitive set of keys (units are included)
    
    ** Note: pfiles don't go into the SOL **
    """
    with open(pfile_loc, mode='r') as pfile:
        lines = pfile.readlines()

    profiles = {}
    nprofs = 0  # counter for total number of profiles so far
    linestart = 0  # counter for which line to start at for each profile
    nlines_tot = len(lines)

    while True:
        # Read the header line for each profile first
        lin1 = lines[linestart].split()
        npts_prof = int(lin1[0])

        xname = lin1[1]
        yname = lin1[2]
        dyname = ''.join(lin1[3:])[:-1]

        # Generate and populate the profile arrays
        x = np.zeros(npts_prof)
        y = np.zeros(npts_prof)
        dy = np.zeros(npts_prof)
        for i in range(npts_prof):
            split_line = lines[linestart + i + 1].split()
            x[i] = float(split_line[0])
            y[i] = float(split_line[1])
            dy[i] = float(split_line[2][:-1])

        # profiles[xname + '_' + yname] = x  # psinorm
        profiles[xname] = x
        profiles[yname] = y
        profiles[dyname] = dy

        nprofs += 1
        linestart += 1 + npts_prof

        if linestart >= nlines_tot:
            break

    # Check if all psinorms are the same, consolidate if so (they are, don't bother separating)

    # condense = True
    # psinorm = None
    # for k in profiles.keys():
    #     if k is None or k=='':
    #         continue
    #
    #     if k[:4] == 'psin':
    #         if psinorm is None:
    #             psinorm = profiles[k]
    #
    #         if max(abs(profiles[k] - psinorm)) > 1e-5:
    #             condense = False
    #             break

    # if condense:
    #     profiles = {key: value for key, value in profiles.items()
    #                 if key[:4] != 'psin' or key is None or key==''}
    #     profiles['psinorm'] = psinorm

    return profiles

    Read in the kinetic profiles from a p file to be used as inputs (successfully tested 2018/1/3)

    Returns a dictionary with a non-intuitive set of keys (units are included)
    
    ** Note: pfiles don't go into the SOL **
    
Read in the kinetic profiles from a p file to be used as inputs (successfully tested 2018/1/3)
Returns a dictionary with a non-intuitive set of keys (units are included)

pfiles don't go into the SOL
Read in the kinetic profiles from a p file to be used as inputs ( successfully tested 2018 / 1 / 3 ) Returns a dictionary with a non - intuitive set of keys ( units are included ) pfiles don ' t go into the SOL
def read_pfile(pfile_loc):
    with open(pfile_loc, mode='r') as pfile:
        lines = pfile.readlines()
    profiles = {}
    nprofs = 0  
    linestart = 0  
    nlines_tot = len(lines)
    while True:
        lin1 = lines[linestart].split()
        npts_prof = int(lin1[0])
        xname = lin1[1]
        yname = lin1[2]
        dyname = ''.join(lin1[3:])[:-1]
        x = np.zeros(npts_prof)
        y = np.zeros(npts_prof)
        dy = np.zeros(npts_prof)
        for i in range(npts_prof):
            split_line = lines[linestart + i + 1].split()
            x[i] = float(split_line[0])
            y[i] = float(split_line[1])
            dy[i] = float(split_line[2][:-1])
        profiles[xname] = x
        profiles[yname] = y
        profiles[dyname] = dy
        nprofs += 1
        linestart += 1 + npts_prof
        if linestart >= nlines_tot:
            break
         if k[:4] == 'psin':
             if psinorm is None:
                 psinorm = profiles[k]
             if max(abs(profiles[k] - psinorm)) > 1e-5:
                 condense = False
                 break
     if condense:
         profiles = {key: value for key, value in profiles.items()
                     if key[:4] != 'psin' or key is None or key==''}
         profiles['psinorm'] = psinorm
    return profiles
def read_pfile ( pfile_loc ) : with open ( pfile_loc , mode = 'r' ) as pfile : lines = pfile . readlines ( ) profiles = { } nprofs = 0 linestart = 0 nlines_tot = len ( lines ) while True : lin1 = lines [ linestart ] . split ( ) npts_prof = int ( lin1 [ 0 ] ) xname = lin1 [ 1 ] yname = lin1 [ 2 ] dyname = '' . join ( lin1 [ 3 : ] ) [ : - 1 ] x = np . zeros ( npts_prof ) y = np . zeros ( npts_prof ) dy = np . zeros ( npts_prof ) for i in range ( npts_prof ) : split_line = lines [ linestart + i + 1 ] . split ( ) x [ i ] = float ( split_line [ 0 ] ) y [ i ] = float ( split_line [ 1 ] ) dy [ i ] = float ( split_line [ 2 ] [ : - 1 ] ) profiles [ xname ] = x profiles [ yname ] = y profiles [ dyname ] = dy nprofs += 1 linestart += 1 + npts_prof if linestart >= nlines_tot : break return profiles
Read in the kinetic profiles from a p file to be used as inputs (successfully tested 2018/1/3)
Returns a dictionary with a non-intuitive set of keys (units are included)
Read in the kinetic profiles from a p file to be used as inputs ( successfully tested 2018 / 1 / 3 ) Returns a dictionary with a non - intuitive set of keys ( units are included )
"""
    Read in the kinetic profiles from a p file to be used as inputs (successfully tested 2018/1/3)

    Returns a dictionary with a non-intuitive set of keys (units are included)
    
    ** Note: pfiles don't go into the SOL **
    """ # counter for total number of profiles so far # counter for which line to start at for each profile # Read the header line for each profile first # Generate and populate the profile arrays # profiles[xname + '_' + yname] = x  # psinorm # Check if all psinorms are the same, consolidate if so (they are, don't bother separating) # condense = True # psinorm = None # for k in profiles.keys(): #     if k is None or k=='': #         continue # #     if k[:4] == 'psin': #         if psinorm is None: #             psinorm = profiles[k] # #         if max(abs(profiles[k] - psinorm)) > 1e-5: #             condense = False #             break # if condense: #     profiles = {key: value for key, value in profiles.items() #                 if key[:4] != 'psin' or key is None or key==''} #     profiles['psinorm'] = psinorm
pfile_loc