예제 #1
0
def main():
    plots = [
        figure(title='Styles Demo {i}'.format(i=i + 1),
               plot_width=200,
               plot_height=200,
               tools='') for i in range(9)
    ]
    [plot.line(np.arange(10), np.random.random(10)) for plot in plots]

    button_bokeh = Button(label="Custom Style: Bokeh Button",
                          css_classes=['custom_button_bokeh'])
    button_bokeh.name = 'button_text'
    button_bokeh.on_event(ButtonClick, on_button_click_event_callback)
    curdoc().add_root(button_bokeh)
    curdoc().add_root(gridplot(children=[plot for plot in plots], ncols=3))

    cur_doc = curdoc()
    # cur_doc.on_event(DocumentUpdate, on_document_update_event_callback)
    cur_doc.on_event(DocumentPatchedEvent, on_document_patch_event_callback)

    cur_doc.theme = Theme(
        filename=
        "G:\\dt-boot\\dt-data-analysis-visual\\app\\api\\server_visual\\timeseries-multi\\dark-theme.yaml"
    )
    cur_doc.on_session_destroyed(on_session_destroyed)
    # cur_doc.add_periodic_callback(on_periodic_callback, 1000)
    cur_doc.add_next_tick_callback(on_next_tick_callback)
예제 #2
0
    def __init__(self, bokeh_document, results_path, starting_index: int = 0):
        self.bokeh_document = bokeh_document
        self.target_type = Target
        self.pool_executor = ThreadPoolExecutor()
        self.results_data_frame = pd.read_csv(results_path, index_col='Index')
        self.current_target_index = starting_index
        self.number_of_indexes_before_and_after_to_load = 2
        self.number_of_indexes_before_and_after_to_delete = 5
        self.target_future_dictionary: Dict[Future] = {}
        self.target_dictionary: Dict[Future] = {}
        self.previous_button, self.next_button = self.create_target_switching_buttons(
        )
        self.target_title_div = Div()
        self.target_title_div.sizing_mode = 'stretch_width'
        self.light_curve_figure, self.light_curve_data_source = self.create_flux_comparison_light_curve_figure(
        )
        self.known_planet_div = Div(
            text='This target has a known ExoFOP disposition',
            css_classes=[
                'notification', 'is-warning', 'is-hidden', 'is-fullwidth'
            ])

        self.fold_coordinate_data_source = ColumnDataSource({
            'Time (BTJD)': [],
            'Normalized PDCSAP flux': []
        })
        self.event_coordinates = []
        unfolded_light_curve_figure = self.create_unfolded_light_curve_figure(
            self.light_curve_data_source)
        folded_light_curve_figure = self.create_folded_figured_based_on_clicks_in_unfolded_figure(
            unfolded_light_curve_figure, self.light_curve_data_source)
        self.star_radius = None
        self.depth = None
        self.period = None
        self.transit_epoch = None
        self.initial_fit_data_source = ColumnDataSource({
            'Folded time (days)': [],
            'Relative flux': [],
            'Fit': [],
            'Fit time': [],
            'Time (BTJD)': [],
            'Time (days)': []
        })
        self.parameters_table_data_source = ColumnDataSource(pd.DataFrame())
        run_fitting_button = Button(label='Run fitting')
        initial_fit_figure, parameters_table = self.create_mcmc_fit_figures(
            run_fitting_button)
        self.add_to_negatives_button = self.create_add_to_negatives_button()

        self.add_to_negatives_button.name = 'add_to_negatives_button'
        bokeh_document.add_root(self.add_to_negatives_button)
        self.previous_button.name = 'previous_button'
        bokeh_document.add_root(self.previous_button)
        self.next_button.name = 'next_button'
        bokeh_document.add_root(self.next_button)
        self.target_title_div.name = 'target_title_div'
        bokeh_document.add_root(self.target_title_div)
        self.light_curve_figure.name = 'light_curve_figure'
        unfolded_light_curve_figure.name = 'unfolded_light_curve_figure'
        folded_light_curve_figure.name = 'folded_light_curve_figure'
        initial_fit_figure.name = 'initial_fit_figure'
        js_reset = CustomJS(code='''
            Bokeh.documents[0].get_model_by_name("light_curve_figure").reset.emit()
            Bokeh.documents[0].get_model_by_name("unfolded_light_curve_figure").reset.emit()
            Bokeh.documents[0].get_model_by_name("folded_light_curve_figure").reset.emit()
            Bokeh.documents[0].get_model_by_name("initial_fit_figure").reset.emit()
        ''')
        self.light_curve_data_source.js_on_change(
            'data', js_reset
        )  # Hacky workaround until the Bokeh team makes a better solution. https://github.com/bokeh/bokeh/issues/9218
        bokeh_document.add_root(self.light_curve_figure)
        self.known_planet_div.name = 'known_planet_div'
        bokeh_document.add_root(self.known_planet_div)
        bokeh_document.add_root(unfolded_light_curve_figure)
        bokeh_document.add_root(folded_light_curve_figure)
        run_fitting_button.name = 'run_fitting_button'
        parameters_table.name = 'parameters_table'
        bokeh_document.add_root(run_fitting_button)
        bokeh_document.add_root(initial_fit_figure)
        bokeh_document.add_root(parameters_table)