Esempio n. 1
0
def prepare_tpf_datasource(tpf):
    """Prepare a bokeh DataSource object for selection glyphs

    Parameters
    ----------
    tpf : TargetPixelFile
        TPF to be shown.

    Returns
    -------
    tpf_source : bokeh.plotting.ColumnDataSource
        Bokeh object to be shown.
    """
    n_pixels = tpf.flux[0, :, :].size
    pixel_index_array = np.arange(0, n_pixels, 1,
                                  dtype=int).reshape(tpf.flux[0, :, :].shape)
    xx = tpf.column + np.arange(tpf.shape[2])
    yy = tpf.row + np.arange(tpf.shape[1])
    xa, ya = np.meshgrid(xx, yy)
    preselection = Selection()
    preselection.indices = pixel_index_array[tpf.pipeline_mask].reshape(
        -1).tolist()
    tpf_source = ColumnDataSource(data=dict(xx=xa + 0.5, yy=ya + 0.5),
                                  selected=preselection)
    return tpf_source
Esempio n. 2
0
def prepare_tpf_datasource(tpf, aperture_mask):
    """Prepare a bokeh DataSource object for selection glyphs

    Parameters
    ----------
    tpf : TargetPixelFile
        TPF to be shown.
    aperture_mask : boolean numpy array
        The Aperture mask applied at the startup of interact

    Returns
    -------
    tpf_source : bokeh.plotting.ColumnDataSource
        Bokeh object to be shown.
    """
    npix = tpf.flux[0, :, :].size
    pixel_index_array = np.arange(0, npix, 1).reshape(tpf.flux[0].shape)
    xx = tpf.column + np.arange(tpf.shape[2])
    yy = tpf.row + np.arange(tpf.shape[1])
    xa, ya = np.meshgrid(xx, yy)
    preselected = Selection()
    preselected.indices = pixel_index_array[aperture_mask].reshape(-1).tolist()
    tpf_source = ColumnDataSource(data=dict(xx=xa + 0.5, yy=ya + 0.5),
                                  selected=preselected)
    return tpf_source
Esempio n. 3
0
def prepare_bls_datasource(result, loc):
    """Prepare a bls result for bokeh plotting

    Parameters
    ----------
    result : BLS.model result
        The BLS model result to use
    loc : int
        Index of the "best" period. (Usually the max power)

    Returns
    -------
    bls_source : Bokeh.plotting.ColumnDataSource
        Bokeh style source for plotting
    """
    preselected = Selection()
    preselected.indices = [loc]
    bls_source = ColumnDataSource(data=dict(
        period=result['period'],
        power=result['power'],
        depth=result['depth'],
        duration=result['duration'],
        transit_time=result['transit_time']),
                                  selected=preselected)
    return bls_source