Example #1
0
def cumulative_df(df, full_cum=False):
    """Index by band, """
    bands = df.index
    assert all(bands == ["Z", "Y", "J", "H", "K"]), bands
    if full_cum:
        cum_bands = [
            "Z", "ZY", "ZYJ", "ZYJH", "ZYJHK", "YJHK", "JHK", "HK", "K"
        ]

        cum_dict = {
            "Band": cum_bands,
            "Cond. 1": rv_cumulative_full(df["Cond. 1"]),
            "Cond. 2": rv_cumulative_full(df["Cond. 2"]),
            "Cond. 3": rv_cumulative_full(df["Cond. 3"]),
        }
    else:
        cum_bands = ["Z", "ZY", "ZYJ", "ZYJH", "ZYJHK"]
        cum_dict = {
            "Band": cum_bands,
            "Cond. 1": rv_cumulative(df["Cond. 1"], single=True),
            "Cond. 2": rv_cumulative(df["Cond. 2"], single=True),
            "Cond. 3": rv_cumulative(df["Cond. 3"], single=True),
        }
    cum_df = pd.DataFrame(cum_dict)
    cum_df = cum_df.set_index("Band")
    cum_df = cum_df.reindex(cum_bands)
    return cum_df
Example #2
0
def test_rv_cumulative(input_, flag):
    """Test it works on well formed input."""
    result = rv_cumulative(input_, single=flag)
    assert result[-2] == weighted_error(input_[:-1])
    assert result[-1] == weighted_error(input_)
    if flag:
        assert result[0] == input_[0]
def cumulative_df(df, full_cum=False):
    """Calculated cumulative RV precision across bands.
    The precision of "Z", "ZY", "ZYJ", "ZYJH", "ZYJHK" bands.

    Parameters
    ----------
    df: pandas.DataFrame
       DataFrame.
    full_cum: bool
       Include "YJHK", "JHK", "HK", "K" grouping also. Default is False.

    """
    bands = df.index
    assert all(bands == ["Z", "Y", "J", "H", "K"]), bands
    if full_cum:
        cum_bands = [
            "Z", "ZY", "ZYJ", "ZYJH", "ZYJHK", "YJHK", "JHK", "HK", "K"
        ]

        cum_dict = {
            "Band": cum_bands,
            "Cond. 1": rv_cumulative_full(df["Cond. 1"]),
            "Cond. 2": rv_cumulative_full(df["Cond. 2"]),
            "Cond. 3": rv_cumulative_full(df["Cond. 3"]),
        }
    else:
        cum_bands = ["Z", "ZY", "ZYJ", "ZYJH", "ZYJHK"]
        cum_dict = {
            "Band": cum_bands,
            "Cond. 1": rv_cumulative(df["Cond. 1"], single=True),
            "Cond. 2": rv_cumulative(df["Cond. 2"], single=True),
            "Cond. 3": rv_cumulative(df["Cond. 3"], single=True),
        }
    cum_df = pd.DataFrame(cum_dict)
    cum_df = cum_df.set_index("Band")
    cum_df = cum_df.reindex(cum_bands)
    return cum_df