helper to plot prior parameter histograms implied by
    parameter bounds. Saves a multipage pdf named <case>.prior.pdf

    Parameters
    ----------
    pst : pyemu.Pst
    logger : pyemu.Logger
    filename : str
        PDF filename to save plots to. If None, return figs without saving.  Default is None.
    kwargs : dict
        accepts 'grouper' as dict to group parameters on to a single axis (use
        parameter groups if not passed),
        'unqiue_only' to only show unique mean-stdev combinations within a
        given group

    Returns
    -------
    None

    TODO
    ----
    external parcov, unique mean-std pairs

def pst_prior(pst,logger=None, filename=None, **kwargs):
    """ helper to plot prior parameter histograms implied by
    parameter bounds. Saves a multipage pdf named <case>.prior.pdf

    Parameters
    ----------
    pst : pyemu.Pst
    logger : pyemu.Logger
    filename : str
        PDF filename to save plots to. If None, return figs without saving.  Default is None.
    kwargs : dict
        accepts 'grouper' as dict to group parameters on to a single axis (use
        parameter groups if not passed),
        'unqiue_only' to only show unique mean-stdev combinations within a
        given group

    Returns
    -------
    None

    TODO
    ----
    external parcov, unique mean-std pairs

    """
    if logger is None:
        logger=Logger('Default_Loggger.log',echo=False)
    logger.log("plot pst_prior")
    par = pst.parameter_data

    if "parcov_filename" in pst.pestpp_options:
        logger.warn("ignoring parcov_filename, using parameter bounds for prior cov")
    logger.log("loading cov from parameter data")
    cov = pyemu.Cov.from_parameter_data(pst)
    logger.log("loading cov from parameter data")

    logger.log("building mean parameter values")
    li = par.partrans.loc[cov.names] == "log"
    mean = par.parval1.loc[cov.names]
    info = par.loc[cov.names,:].copy()
    info.loc[:,"mean"] = mean
    info.loc[li,"mean"] = mean[li].apply(np.log10)
    logger.log("building mean parameter values")

    logger.log("building stdev parameter values")
    if cov.isdiagonal:
        std = cov.x.flatten()
    else:
        std = np.diag(cov.x)
    std = np.sqrt(std)
    info.loc[:,"prior_std"] = std

    logger.log("building stdev parameter values")

    if std.shape != mean.shape:
        logger.lraise("mean.shape {0} != std.shape {1}".
                      format(mean.shape,std.shape))

    if "grouper" in kwargs:
        raise NotImplementedError()
        #check for consistency here

    else:
        par_adj = par.loc[par.partrans.apply(lambda x: x in ["log","none"]),:]
        grouper = par_adj.groupby(par_adj.pargp).groups
        #grouper = par.groupby(par.pargp).groups

    if len(grouper) == 0:
        raise Exception("no adustable parameters to plot")

    fig = plt.figure(figsize=figsize)
    if "fig_title" in kwargs:
        plt.figtext(0.5,0.5,kwargs["fig_title"])
    else:
        plt.figtext(0.5,0.5,"pyemu.Pst.plot(kind='prior')\nfrom pest control file '{0}'\n at {1}"
                 .format(pst.filename,str(datetime.now())),ha="center")
    figs = []
    ax_count = 0
    grps_names = list(grouper.keys())
    grps_names.sort()
    for g in grps_names:
        names = grouper[g]
        logger.log("plotting priors for {0}".
                   format(','.join(list(names))))
        if ax_count % (nr * nc) == 0:
            plt.tight_layout()
            #pdf.savefig()
            #plt.close(fig)
            figs.append(fig)
            fig  = plt.figure(figsize=figsize)
            axes = get_page_axes()
            ax_count = 0

        islog = False
        vc = info.partrans.value_counts()
        if vc.shape[0] > 1:
            logger.warn("mixed partrans for group {0}".format(g))
        elif "log" in vc.index:
            islog = True
        ax = axes[ax_count]
        if "unique_only" in kwargs and kwargs["unique_only"]:


            ms = info.loc[names,:].apply(lambda x: (x["mean"],x["prior_std"]),axis=1).unique()
            for (m,s) in ms:
                x, y = gaussian_distribution(m, s)
                ax.fill_between(x, 0, y, facecolor='0.5', alpha=0.5,
                                edgecolor="none")


        else:
            for m,s in zip(info.loc[names,'mean'],info.loc[names,'prior_std']):
                x,y = gaussian_distribution(m,s)
                ax.fill_between(x,0,y,facecolor='0.5',alpha=0.5,
                                            edgecolor="none")
        ax.set_title("{0}) group:{1}, {2} parameters".
                                 format(abet[ax_count],g,names.shape[0]),loc="left")

        ax.set_yticks([])
        if islog:
            ax.set_xlabel("$log_{10}$ parameter value",labelpad=0.1)
        else:
            ax.set_xlabel("parameter value", labelpad=0.1)
        logger.log("plotting priors for {0}".
                   format(','.join(list(names))))

        ax_count += 1

    for a in range(ax_count,nr*nc):
        axes[a].set_axis_off()
        axes[a].set_yticks([])
        axes[a].set_xticks([])

    plt.tight_layout()
    #pdf.savefig()
    #plt.close(fig)
    figs.append(fig)
    if filename is not None:
        with PdfPages(filename) as pdf:
            plt.tight_layout()
            pdf.savefig(fig)
            plt.close(fig)
        logger.log("plot pst_prior")
    else:
        logger.log("plot pst_prior")
        return figs