write a template file for an hfb using multipliers per zone (double yuck!)

    Parameters
    ----------
        m : flopy.modflow.Modflow instance with an HFB file

    Returns
    -------
        (hfb_mults, tpl_filename) : (dict, str)
            a dictionary with original unique HFB conductivity values and their corresponding parameter names
            and the name of the template file

def write_hfb_zone_multipliers_template(m):
    """write a template file for an hfb using multipliers per zone (double yuck!)

    Parameters
    ----------
        m : flopy.modflow.Modflow instance with an HFB file

    Returns
    -------
        (hfb_mults, tpl_filename) : (dict, str)
            a dictionary with original unique HFB conductivity values and their corresponding parameter names
            and the name of the template file

    """
    assert m.hfb6 is not None
    # find the model file
    hfb_file = os.path.join(m.model_ws, m.hfb6.file_name[0])

    # this will use multipliers, so need to copy down the original
    if not os.path.exists(os.path.join(m.model_ws, 'hfb6_org')):
        os.mkdir(os.path.join(m.model_ws, 'hfb6_org'))
    # copy down the original file
    shutil.copy2(os.path.join(m.model_ws, m.hfb6.file_name[0]), os.path.join(m.model_ws,'hfb6_org', m.hfb6.file_name[0]))

    if not os.path.exists(os.path.join(m.model_ws, 'hfb6_mlt')):
        os.mkdir(os.path.join(m.model_ws, 'hfb6_mlt'))

    # read in the model file
    hfb_file_contents = open(hfb_file, 'r').readlines()

    # navigate the header
    skiprows = sum([1 if i.strip().startswith('#') else 0 for i in hfb_file_contents]) + 1
    header = hfb_file_contents[:skiprows]

    # read in the data
    names = ['lay', 'irow1','icol1','irow2','icol2', 'hydchr']
    hfb_in = pd.read_csv(hfb_file, skiprows=skiprows, delim_whitespace=True, names=names).dropna()
    for cn in names[:-1]:
        hfb_in[cn] = hfb_in[cn].astype(np.int)

    # set up a multiplier for each unique conductivity value
    unique_cond = hfb_in.hydchr.unique()
    hfb_mults = dict(zip(unique_cond, ['hbz_{0:04d}'.format(i) for i in range(len(unique_cond))]))
    # set up the TPL line for each parameter and assign
    hfb_in['tpl'] = 'blank'
    for cn, cg in hfb_in.groupby('hydchr'):
        hfb_in.loc[hfb_in.hydchr == cn, 'tpl'] = '~{0:^10s}~'.format(hfb_mults[cn])

    assert 'blank' not in hfb_in.tpl

    # write out the TPL file
    tpl_file = os.path.join(m.model_ws, "hfb6.mlt.tpl")
    with open(tpl_file, 'w') as ofp:
        ofp.write('ptf ~\n')
        [ofp.write('{0}\n'.format(line.strip())) for line in header]
        ofp.flush()
        hfb_in[['lay', 'irow1','icol1','irow2','icol2', 'tpl']].to_csv(ofp, sep=' ', quotechar=' ',
                header=None, index=None, mode='a')

    # make a lookup for lining up the necessary files to perform multiplication with the
    # helpers.apply_hfb_pars() function which must be added to the forward run script
    with open(os.path.join(m.model_ws, 'hfb6_pars.csv'), 'w') as ofp:
        ofp.write('org_file,mlt_file,model_file\n')
        ofp.write('{0},{1},{2}\n'.format(os.path.join(m.model_ws, 'hfb6_org', m.hfb6.file_name[0]),
                                         os.path.join(m.model_ws, 'hfb6_mlt', os.path.basename(tpl_file).replace('.tpl','')),
                                         hfb_file))

    return hfb_mults, tpl_file