SOLPSutils.py
def read_b2_transport_inputfile(infileloc, carbon=True):
    """
    Reads b2.transport.inputfile, outputs basic quantities as a dictionary
    
    All carbon species are assumed to have the same transport coefficients
    (this could be fixed easily if you want)
    
    !!!WARNING!!!
      This was only written to read inputfiles written using SOLPSxport.py,
      and therefore may not work properly if your file is formatted differently.
    """
    with open(infileloc, 'r') as f:
        lines = f.readlines()

    ndata = int(
        lines[1].strip().split()[5])  # This is the same for every array in our write routine

    rn = np.zeros(ndata)
    dn = np.zeros(ndata)
    ke = np.zeros(ndata)
    ki = np.zeros(ndata)
    if carbon:
        vrc = np.zeros(ndata)
        dc = np.zeros(ndata)

    for line_full in lines[2:]:
        line = line_full.strip().split()
        if len(line) < 4: continue

        if line[2][0] == '1' and line[3][0] == '1':
            rn[int(line[1][:-1]) - 1] = np.float(line[5])
            dn[int(line[1][:-1]) - 1] = np.float(line[-2])

        elif line[2][0] == '3' and line[3][0] == '1':
            ki[int(line[1][:-1]) - 1] = np.float(line[-2])

        elif line[2][0] == '4' and line[3][0] == '1':
            ke[int(line[1][:-1]) - 1] = np.float(line[-2])

        elif carbon:

            if line[2][0] == '1' and line[3][0] == '4':
                dc[int(line[1][:-1]) - 1] = np.float(line[-2])

            elif line[2][0] == '6' and line[3][0] == '3':
                vrc[int(line[1][:-1]) - 1] = np.float(line[-2])

    if carbon:
        return {'rn': rn, 'dn': dn, 'ki': ki, 'ke': ke, 'dc': dc, 'vrc': vrc}
    else:
        return {'rn': rn, 'dn': dn, 'ki': ki, 'ke': ke}

    Reads b2.transport.inputfile, outputs basic quantities as a dictionary
    
    All carbon species are assumed to have the same transport coefficients
    (this could be fixed easily if you want)
    
    !!!WARNING!!!
      This was only written to read inputfiles written using SOLPSxport.py,
      and therefore may not work properly if your file is formatted differently.
    
Reads b2.transport.inputfile, outputs basic quantities as a dictionary
All carbon species are assumed to have the same transport coefficients
(this could be fixed easily if you want)

WARNING
This was only written to read inputfiles written using SOLPSxport.py,
and therefore may not work properly if your file is formatted differently.
Reads b2 . transport . inputfile outputs basic quantities as a dictionary All carbon species are assumed to have the same transport coefficients ( this could be fixed easily if you want ) WARNING This was only written to read inputfiles written using SOLPSxport . py and therefore may not work properly if your file is formatted differently .
def read_b2_transport_inputfile(infileloc, carbon=True):
    with open(infileloc, 'r') as f:
        lines = f.readlines()
    ndata = int(
        lines[1].strip().split()[5])  
    rn = np.zeros(ndata)
    dn = np.zeros(ndata)
    ke = np.zeros(ndata)
    ki = np.zeros(ndata)
    if carbon:
        vrc = np.zeros(ndata)
        dc = np.zeros(ndata)
    for line_full in lines[2:]:
        line = line_full.strip().split()
        if len(line) < 4: continue
        if line[2][0] == '1' and line[3][0] == '1':
            rn[int(line[1][:-1]) - 1] = np.float(line[5])
            dn[int(line[1][:-1]) - 1] = np.float(line[-2])
        elif line[2][0] == '3' and line[3][0] == '1':
            ki[int(line[1][:-1]) - 1] = np.float(line[-2])
        elif line[2][0] == '4' and line[3][0] == '1':
            ke[int(line[1][:-1]) - 1] = np.float(line[-2])
        elif carbon:
            if line[2][0] == '1' and line[3][0] == '4':
                dc[int(line[1][:-1]) - 1] = np.float(line[-2])
            elif line[2][0] == '6' and line[3][0] == '3':
                vrc[int(line[1][:-1]) - 1] = np.float(line[-2])
    if carbon:
        return {'rn': rn, 'dn': dn, 'ki': ki, 'ke': ke, 'dc': dc, 'vrc': vrc}
    else:
        return {'rn': rn, 'dn': dn, 'ki': ki, 'ke': ke}
def read_b2_transport_inputfile ( infileloc , carbon = True ) : with open ( infileloc , 'r' ) as f : lines = f . readlines ( ) ndata = int ( lines [ 1 ] . strip ( ) . split ( ) [ 5 ] ) rn = np . zeros ( ndata ) dn = np . zeros ( ndata ) ke = np . zeros ( ndata ) ki = np . zeros ( ndata ) if carbon : vrc = np . zeros ( ndata ) dc = np . zeros ( ndata ) for line_full in lines [ 2 : ] : line = line_full . strip ( ) . split ( ) if len ( line ) < 4 : continue if line [ 2 ] [ 0 ] == '1' and line [ 3 ] [ 0 ] == '1' : rn [ int ( line [ 1 ] [ : - 1 ] ) - 1 ] = np . float ( line [ 5 ] ) dn [ int ( line [ 1 ] [ : - 1 ] ) - 1 ] = np . float ( line [ - 2 ] ) elif line [ 2 ] [ 0 ] == '3' and line [ 3 ] [ 0 ] == '1' : ki [ int ( line [ 1 ] [ : - 1 ] ) - 1 ] = np . float ( line [ - 2 ] ) elif line [ 2 ] [ 0 ] == '4' and line [ 3 ] [ 0 ] == '1' : ke [ int ( line [ 1 ] [ : - 1 ] ) - 1 ] = np . float ( line [ - 2 ] ) elif carbon : if line [ 2 ] [ 0 ] == '1' and line [ 3 ] [ 0 ] == '4' : dc [ int ( line [ 1 ] [ : - 1 ] ) - 1 ] = np . float ( line [ - 2 ] ) elif line [ 2 ] [ 0 ] == '6' and line [ 3 ] [ 0 ] == '3' : vrc [ int ( line [ 1 ] [ : - 1 ] ) - 1 ] = np . float ( line [ - 2 ] ) if carbon : return { 'rn' : rn , 'dn' : dn , 'ki' : ki , 'ke' : ke , 'dc' : dc , 'vrc' : vrc } else : return { 'rn' : rn , 'dn' : dn , 'ki' : ki , 'ke' : ke }
Reads b2.transport.inputfile, outputs basic quantities as a dictionary
All carbon species are assumed to have the same transport coefficients
(this could be fixed easily if you want)
Reads b2 . transport . inputfile outputs basic quantities as a dictionary All carbon species are assumed to have the same transport coefficients ( this could be fixed easily if you want )
"""
    Reads b2.transport.inputfile, outputs basic quantities as a dictionary
    
    All carbon species are assumed to have the same transport coefficients
    (this could be fixed easily if you want)
    
    !!!WARNING!!!
      This was only written to read inputfiles written using SOLPSxport.py,
      and therefore may not work properly if your file is formatted differently.
    """ # This is the same for every array in our write routine
infileloc
carbon