def rprof(rproffile, colnames):
    """Extract radial profiles data

    If :data:`colnames` is too long, it will be truncated. If it is too short,
    additional numeric column names from 0 to N-1 will be attributed to the N
    extra columns present in :data:`timefile`.

    Args:
        rproffile (:class:`pathlib.Path`): path of the rprof.dat file.
        colnames (list of names): names of the variables expected in
            :data:`rproffile` (may be modified).

    Returns:
        tuple of :class:`pandas.DataFrame`: (profs, times)
            :data:`profs` are the radial profiles, with the variables in
            columns and rows double-indexed with the time step and the radial
            index of numerical cells.

            :data:`times` is the dimensionless time indexed by time steps.
    """
    if not rproffile.is_file():
        return None, None
    data = pd.read_csv(rproffile, delim_whitespace=True, dtype=str,
                       header=None, comment='*', skiprows=1,
                       engine='c', memory_map=True,
                       error_bad_lines=False, warn_bad_lines=False)
    data = data.apply(pd.to_numeric, raw=True, errors='coerce')

    isteps, rows_to_del = _extract_rsnap_isteps(rproffile)
    if rows_to_del:
        rows_to_keep = set(range(len(data))) - rows_to_del
        data = data.take(list(rows_to_keep), convert=False)

    id_arr = [[], []]
    for istep, _, n_z in isteps:
        id_arr[0].extend(repeat(istep, n_z))
        id_arr[1].extend(range(n_z))

    data.index = id_arr

    ncols = data.shape[1]
    _tidy_names(colnames, ncols)
    data.columns = colnames

    df_times = pd.DataFrame(list(map(itemgetter(1), isteps)),
                            index=map(itemgetter(0), isteps))
    return data, df_times
def rprof ( rproffile , colnames ) : if not rproffile . is_file ( ) : return None , None data = pd . read_csv ( rproffile , delim_whitespace = True , dtype = str , header = None , comment = '*' , skiprows = 1 , engine = 'c' , memory_map = True , error_bad_lines = False , warn_bad_lines = False ) data = data . apply ( pd . to_numeric , raw = True , errors = 'coerce' ) isteps , rows_to_del = _extract_rsnap_isteps ( rproffile ) if rows_to_del : rows_to_keep = set ( range ( len ( data ) ) ) - rows_to_del data = data . take ( list ( rows_to_keep ) , convert = False ) id_arr = [ [ ] , [ ] ] for istep , _ , n_z in isteps : id_arr [ 0 ] . extend ( repeat ( istep , n_z ) ) id_arr [ 1 ] . extend ( range ( n_z ) ) data . index = id_arr ncols = data . shape [ 1 ] _tidy_names ( colnames , ncols ) data . columns = colnames df_times = pd . DataFrame ( list ( map ( itemgetter ( 1 ) , isteps ) ) , index = map ( itemgetter ( 0 ) , isteps ) ) return data , df_times
Extract radial profiles data

    If :data:`colnames` is too long, it will be truncated. If it is too short,
    additional numeric column names from 0 to N-1 will be attributed to the N
    extra columns present in :data:`timefile`.

    Args:
        rproffile (:class:`pathlib.Path`): path of the rprof.dat file.
        colnames (list of names): names of the variables expected in
            :data:`rproffile` (may be modified).

    Returns:
        tuple of :class:`pandas.DataFrame`: (profs, times)
            :data:`profs` are the radial profiles, with the variables in
            columns and rows double-indexed with the time step and the radial
            index of numerical cells.

            :data:`times` is the dimensionless time indexed by time steps.