def speciessorter(df, timepoints=False):
    """
    Divides PFLOTRAN outputs in to useful groups.

    This function splits outputs from PFLOTRAN, with the .tec file read in as
    a dataframe (**df**) into logical groupings. This is useful for plotting as
    well as data management.

    **Inputs:**

    **df:** Dataframe containing the relevant columns

    **Timepoints:** Identify if the files being sorted are for distinct time
    points (no time column for individual timepoint files)

    **Outputs:**

    **Nspecies:** (Aqueous) nitrogen species involved in nitrogen cycling

    **Cspecies:** (Aqueous) carbon sources

    **Pspecies:** (Aqueous) phosphate-based phosphorous sources

    **Sspecies:** (Aqueous) sulfate-based sulfur species (just SO4 at the
    moment, but wanted to maintain flexibility)

    **ions:** aqueous ions (mostly metals)

    **solids:** Solid-phase compounds (e.g. CRF fertilizer)

    **physical:** Physical parameters included in the model (not grouped for
    plotting, just for reference)

    **biomass:** Biomass species
    """
    # Filter out fields that aren't useful to sort, depending on file type
    if not timepoints:
        newdf = df.drop(columns=['Time_[d]', 'pH', 'H+_[M]', 'O2(aq)_[M]'])
    else:
        newdf = df.drop(columns=['pH', 'H+_[M]', 'O2(aq)_[M]', 'X_[m]',
                                 'Y_[m]', 'Z_[m]'])
    # Now split out key categories as cleanly as possible. May need work.
    physical = [col for col in newdf.columns if ('Pressure' in col or
                                                 'Saturation' in col or
                                                 'Density' in col or
                                                 'X_g^l' in col or
                                                 'X_l^l' in col or
                                                 'X_g^g' in col or
                                                 'X_l^g' in col or
                                                 'Energy' in col or
                                                 'Temperature' in col or
                                                 'State' in col or
                                                 'Material' in col)]
    solids = [col for col in newdf.columns if '(s)' in col]
    biomass = [col for col in newdf.columns if ('(aq)' not in col and
                                                '-' not in col and
                                                '+' not in col and
                                                '(s)' not in col and
                                                '[M]' not in col and
                                                col not in physical)]
    nitrogen_species = [col for col in newdf.columns if ('N2' in col
                                                         or 'NO2-' in col
                                                         or 'NO3-' in col or
                                                         'NH4+' in col and
                                                         col not in solids)]
    phosphorus_species = [col for col in newdf.columns if ('PO4' in col and
                                                           col not in solids)]
    ions = [col for col in newdf.columns if ('H+' not in col and
                                             'ate' not in col and
                                             'ine' not in col and
                                             'ol' not in col and
                                             'O' not in col and
                                             '(aq)' not in col and
                                             '(s)' not in col and
                                             col not in nitrogen_species and
                                             col not in biomass and
                                             col not in physical and
                                             ('+' in col or '-' in col))]
    sulfur_species = [col for col in newdf.columns if ('SO4' in col and
                                                       col not in solids)]
    carbon_species = [col for col in newdf.columns if (col not in phosphorus_species and
                                                       col not in sulfur_species and
                                                       col not in solids and
                                                       col not in ions and
                                                       col not in nitrogen_species and
                                                       col not in biomass and
                                                       col not in physical)]

    return (nitrogen_species, carbon_species, phosphorus_species,
            sulfur_species, ions, solids, physical, biomass)