Esempio n. 1
0
def currents(conn, start, end):
    '''Create specific plot and return plot object
    Parameters
    ----------
    conn : DBobject
        Connection object that represents database
    start : time
        Startlimit for x-axis and query (typ. datetime.now()- 4Months)
    end : time
        Endlimit for x-axis and query (typ. datetime.now())
    Return
    ------
    p : Plot object
        Bokeh plot
    '''

    # create a new plot with a title and axis labels
    p = figure(tools="pan,wheel_zoom,box_zoom,reset,save",
               toolbar_location="above",
               plot_width=1120,
               plot_height=500,
               y_range=[0, 1.1],
               x_axis_type='datetime',
               output_backend="webgl",
               x_axis_label='Date',
               y_axis_label='Current (A)')

    p.grid.visible = True
    p.title.text = "FPE & ICE Currents"
    pf.add_basic_layout(p)

    a = pf.add_to_plot(p,
                       "ICE Current idle",
                       "SE_ZIMIRICEA_IDLE",
                       start,
                       end,
                       conn,
                       color="red")
    b = pf.add_to_plot(p,
                       "ICE Current HV on",
                       "SE_ZIMIRICEA_HV_ON",
                       start,
                       end,
                       conn,
                       color="orange")
    c = pf.add_to_plot(p,
                       "FPE Current",
                       "SE_ZIMIRFPEA",
                       start,
                       end,
                       conn,
                       color="brown")

    pf.add_hover_tool(p, [a, b, c])

    p.legend.location = "bottom_right"
    p.legend.click_policy = "hide"
    p.legend.orientation = "horizontal"

    return p
Esempio n. 2
0
def gw23(conn, start, end):
    '''Create specific plot and return plot object
    Parameters
    ----------
    conn : DBobject
        Connection object that represents database
    start : time
        Startlimit for x-axis and query (typ. datetime.now()- 4Months)
    end : time
        Endlimit for x-axis and query (typ. datetime.now())
    Return
    ------
    p : Plot object
        Bokeh plot
    '''

    # create a new plot with a title and axis labels
    p = figure(tools="pan,wheel_zoom,box_zoom,reset,save",
               toolbar_location="above",
               plot_width=1120,
               plot_height=500,
               y_range=[-2, 2],
               x_axis_type='datetime',
               x_axis_label='Date',
               y_axis_label='ratio (normalized)')

    p.grid.visible = True
    p.title.text = "DGA-B Ratio"
    p.title.align = "left"
    pf.add_basic_layout(p)

    pf.add_to_wplot(p,
                    "SHORT",
                    "IMIR_HK_GW23_POS_RATIO_SHORT",
                    start,
                    end,
                    conn,
                    mn.gw23_nominals['SHORT'],
                    color="green")
    pf.add_to_wplot(p,
                    "MEDIUM",
                    "IMIR_HK_GW23_POS_RATIO_MEDIUM",
                    start,
                    end,
                    conn,
                    mn.gw23_nominals['MEDIUM'],
                    color="red")
    pf.add_to_wplot(p,
                    "LONG",
                    "IMIR_HK_GW23_POS_RATIO_LONG",
                    start,
                    end,
                    conn,
                    mn.gw23_nominals['LONG'],
                    color="blue")

    p.legend.location = "bottom_right"
    p.legend.click_policy = "hide"

    return p
Esempio n. 3
0
def det(conn, start, end):
    '''Create specific plot and return plot object
    Parameters
    ----------
    conn : DBobject
        Connection object that represents database
    start : time
        Startlimit for x-axis and query (typ. datetime.now()- 4Months)
    end : time
        Endlimit for x-axis and query (typ. datetime.now())
    Return
    ------
    p : Plot object
        Bokeh plot
    '''

    # create a new plot with a title and axis labels
    p = figure(tools="pan,wheel_zoom,box_zoom,reset,save",
               toolbar_location="above",
               plot_width=1120,
               plot_height=500,
               y_range=[6.395, 6.41],
               x_axis_type='datetime',
               output_backend="webgl",
               x_axis_label='Date',
               y_axis_label='Temperature (K)')

    p.grid.visible = True
    p.title.text = "Detector Temperature"
    pf.add_basic_layout(p)

    a = pf.add_to_plot(p,
                       "Det. Temp. IC",
                       "IGDP_MIR_IC_DET_TEMP",
                       start,
                       end,
                       conn,
                       color="red")
    b = pf.add_to_plot(p,
                       "Det. Temp. LW",
                       "IGDP_MIR_LW_DET_TEMP",
                       start,
                       end,
                       conn,
                       color="green")
    c = pf.add_to_plot(p,
                       "Det. Temp. SW",
                       "IGDP_MIR_SW_DET_TEMP",
                       start,
                       end,
                       conn,
                       color="blue")

    pf.add_hover_tool(p, [a, b, c])

    p.legend.location = "bottom_right"
    p.legend.orientation = "horizontal"
    p.legend.click_policy = "hide"

    return p
Esempio n. 4
0
def vdetcom(conn, start, end):
    '''Create specific plot and return plot object
    Parameters
    ----------
    conn : DBobject
        Connection object that represents database
    start : time
        Startlimit for x-axis and query (typ. datetime.now()- 4Months)
    end : time
        Endlimit for x-axis and query (typ. datetime.now())
    Return
    ------
    p : Plot object
        Bokeh plot
    '''

    # create a new plot with a title and axis labels
    p = figure( tools = "pan,wheel_zoom,box_zoom,reset,save",       \
                toolbar_location = "above",                         \
                plot_width = 560,                                   \
                plot_height = 500,                                  \
                x_axis_type = 'datetime',                           \
                output_backend="webgl",                             \
                x_axis_label = 'Date', y_axis_label='Voltage (V)')

    p.grid.visible = True
    p.title.text = "VDETCOM"
    pf.add_basic_layout(p)

    a = pf.add_to_plot(p,
                       "VDETCOM IC",
                       "IGDP_MIR_IC_V_VDETCOM",
                       start,
                       end,
                       conn,
                       color="red")
    b = pf.add_to_plot(p,
                       "VDETCOM SW",
                       "IGDP_MIR_SW_V_VDETCOM",
                       start,
                       end,
                       conn,
                       color="orange")
    c = pf.add_to_plot(p,
                       "VDETCOM LW",
                       "IGDP_MIR_LW_V_VDETCOM",
                       start,
                       end,
                       conn,
                       color="green")

    pf.add_hover_tool(p, [a, b, c])

    p.legend.location = "bottom_right"
    p.legend.click_policy = "hide"
    p.legend.orientation = "horizontal"

    return p
Esempio n. 5
0
def dig5(conn, start, end):
    '''Create specific plot and return plot object
    Parameters
    ----------
    conn : DBobject
        Connection object that represents database
    start : time
        Startlimit for x-axis and query (typ. datetime.now()- 4Months)
    end : time
        Endlimit for x-axis and query (typ. datetime.now())
    Return
    ------
    p : Plot object
        Bokeh plot
    '''

    # create a new plot with a title and axis labels
    p = figure(tools="pan,wheel_zoom,box_zoom,reset,save",
               toolbar_location="above",
               plot_width=560,
               plot_height=500,
               y_range=[4.9, 5.1],
               x_axis_type='datetime',
               output_backend="webgl",
               x_axis_label='Date',
               y_axis_label='Voltage (V)')

    p.grid.visible = True
    p.title.text = "FPE Dig. 5V"
    pf.add_basic_layout(p)

    p.extra_y_ranges = {"current": Range1d(start=2100, end=2500)}
    a = pf.add_to_plot(p,
                       "FPE Dig. 5V",
                       "IMIR_PDU_V_DIG_5V",
                       start,
                       end,
                       conn,
                       color="red")
    b = pf.add_to_plot(p,
                       "FPE Dig. 5V Current",
                       "IMIR_PDU_I_DIG_5V",
                       start,
                       end,
                       conn,
                       y_axis="current",
                       color="blue")
    p.add_layout(
        LinearAxis(y_range_name="current",
                   axis_label="Current (mA)",
                   axis_label_text_color="blue"), 'right')

    pf.add_hover_tool(p, [a, b])

    p.legend.location = "bottom_right"
    p.legend.click_policy = "hide"

    return p
Esempio n. 6
0
def power_fpea(conn, start, end):

    start_str = str(Time(start).mjd)
    end_str = str(Time(end).mjd)

    sql_c = "SELECT * FROM SE_ZIMIRFPEA WHERE start_time BETWEEN "+start_str+" AND "+end_str+" ORDER BY start_time"
    _fpea = pd.read_sql_query(sql_c, conn)

    voltage = 30
    _fpea['average'] *= voltage

    _fpea['start_time'] = pd.to_datetime( Time(_fpea['start_time'], format = "mjd").datetime )

    #set column data source
    fpea = ColumnDataSource(_fpea)

    # create a new plot with a title and axis labels
    p = figure( tools = "pan,wheel_zoom,box_zoom,reset,save",       \
                toolbar_location = "above",                         \
                plot_width = 1120,                                   \
                plot_height = 500,                                  \
                y_range = [28.0, 28.5],                               \
                x_axis_type = 'datetime',                           \
                output_backend = "webgl",                             \
                x_axis_label = 'Date', y_axis_label='Power (W)')

    p.grid.visible = True
    p.title.text = "POWER FPE"
    pf.add_basic_layout(p)

    # add a line renderer with legend and line thickness
    scat1 = p.scatter(x = "start_time", y = "average", color = 'orange', legend = "Power FPEA", source = fpea)
    p.line(x = "start_time", y = "average", color = 'orange', legend = "Power FPEA", source = fpea)

    err_xs = []
    err_ys = []

    for index, item in _fpea.iterrows():
        err_xs.append((item['start_time'], item['start_time']))
        err_ys.append((item['average'] - item['deviation'], item['average'] + item['deviation']))

    # plot them
    p.multi_line(err_xs, err_ys, color='orange', legend='Power FPEA')

    #activate HoverTool for scatter plot
    hover_tool = HoverTool( tooltips =
    [
        ('count', '@data_points'),
        ('mean', '@average'),
        ('deviation', '@deviation'),

    ], renderers = [scat1])
    p.tools.append(hover_tool)

    p.legend.location = "bottom_right"
    p.legend.click_policy = "hide"

    return p
Esempio n. 7
0
def volt4(conn, start, end):
    '''Create specific plot and return plot object
    Parameters
    ----------
    conn : DBobject
        Connection object that represents database
    start : time
        Startlimit for x-axis and query (typ. datetime.now()- 4Months)
    end : time
        Endlimit for x-axis and query (typ. datetime.now())
    Return
    ------
    p : Plot object
        Bokeh plot
    '''

    # create a new plot with a title and axis labels
    p = figure(tools="pan,wheel_zoom,box_zoom,reset,save",
               toolbar_location="above",
               plot_width=560,
               plot_height=500,
               y_range=[4.2, 5],
               x_axis_type='datetime',
               output_backend="webgl",
               x_axis_label='Date',
               y_axis_label='Voltage (V)')

    p.grid.visible = True
    p.title.text = "ICE_SEC_VOLT4"
    pf.add_basic_layout(p)

    # add a line renderer with legend and line thickness

    a = pf.add_to_plot(p,
                       "Volt4 Idle",
                       "IMIR_HK_ICE_SEC_VOLT4_IDLE",
                       start,
                       end,
                       conn,
                       color="orange")
    b = pf.add_to_plot(p,
                       "Volt4 Hv on",
                       "IMIR_HK_ICE_SEC_VOLT4_HV_ON",
                       start,
                       end,
                       conn,
                       color="red")

    pf.add_hover_tool(p, [a, b])

    p.legend.location = "bottom_right"
    p.legend.click_policy = "hide"

    return p
Esempio n. 8
0
def cryo(conn, start, end):
    '''Create specific plot and return plot object
    Parameters
    ----------
    conn : DBobject
        Connection object that represents database
    start : time
        Startlimit for x-axis and query (typ. datetime.now()- 4Months)
    end : time
        Endlimit for x-axis and query (typ. datetime.now())
    Return
    ------
    p : Plot object
        Bokeh plot
    '''

    # create a new plot with a title and axis labels
    p = figure( tools = "pan,wheel_zoom,box_zoom,reset,save",       \
                toolbar_location = "above",                         \
                plot_width = 1120,                                   \
                plot_height = 700,                                  \
                y_range = [5.8,6.4],                                \
                x_axis_type = 'datetime',                           \
                output_backend="webgl",                             \
                x_axis_label = 'Date', y_axis_label = 'Temperature (K)')

    p.grid.visible = True
    p.title.text = "Cryo Temperatures"
    pf.add_basic_layout(p)

    a = pf.add_to_plot(p, "T1P", "IGDP_MIR_ICE_T1P_CRYO", start, end, conn, color = "brown")
    b = pf.add_to_plot(p, "T2R", "IGDP_MIR_ICE_T2R_CRYO", start, end, conn, color = "burlywood")
    c = pf.add_to_plot(p, "T3LW", "IGDP_MIR_ICE_T3LW_CRYO", start, end, conn, color = "cadetblue")
    d = pf.add_to_plot(p, "T4SW", "IGDP_MIR_ICE_T4SW_CRYO", start, end, conn, color = "chartreuse")
    e = pf.add_to_plot(p, "T5IMG", "IGDP_MIR_ICE_T5IMG_CRYO", start, end, conn, color = "chocolate")
    f = pf.add_to_plot(p, "T6DECK", "IGDP_MIR_ICE_T6DECKCRYO", start, end, conn, color = "coral")
    g = pf.add_to_plot(p, "T7IOC", "IGDP_MIR_ICE_T7IOC_CRYO", start, end, conn, color = "darkorange")
    h = pf.add_to_plot(p, "FW", "IGDP_MIR_ICE_FW_CRYO", start, end, conn, color = "crimson")
    i = pf.add_to_plot(p, "CCC", "IGDP_MIR_ICE_CCC_CRYO", start, end, conn, color = "cyan")
    j = pf.add_to_plot(p, "GW14", "IGDP_MIR_ICE_GW14_CRYO", start, end, conn, color = "darkblue")
    k = pf.add_to_plot(p, "GW23", "IGDP_MIR_ICE_GW23_CRYO", start, end, conn, color = "darkgreen")
    l = pf.add_to_plot(p, "POMP", "IGDP_MIR_ICE_POMP_CRYO", start, end, conn, color = "darkmagenta")
    m = pf.add_to_plot(p, "POMR", "IGDP_MIR_ICE_POMR_CRYO", start, end, conn, color = "darkcyan")
    n = pf.add_to_plot(p, "IFU", "IGDP_MIR_ICE_IFU_CRYO", start, end, conn, color = "cornflowerblue")
    o = pf.add_to_plot(p, "IMG", "IGDP_MIR_ICE_IMG_CRYO", start, end, conn, color = "orange")

    pf.add_hover_tool(p,[a,b,c,d,e,f,g,h,i,j,k,l,m,n,o])

    p.legend.location = "bottom_right"
    p.legend.orientation = "horizontal"
    p.legend.click_policy = "hide"

    return p
Esempio n. 9
0
def refdig(conn, start, end):
    '''Create specific plot and return plot object
    Parameters
    ----------
    conn : DBobject
        Connection object that represents database
    start : time
        Startlimit for x-axis and query (typ. datetime.now()- 4Months)
    end : time
        Endlimit for x-axis and query (typ. datetime.now())
    Return
    ------
    p : Plot object
        Bokeh plot
    '''

    # create a new plot with a title and axis labels
    p = figure(tools="pan,wheel_zoom,box_zoom,reset,save",
               toolbar_location="above",
               plot_width=560,
               plot_height=500,
               y_range=[2.45, 2.55],
               x_axis_type='datetime',
               output_backend="webgl",
               x_axis_label='Date',
               y_axis_label='Voltage (V)')

    p.grid.visible = True
    p.title.text = "2.5V Ref and FPE Dig."
    pf.add_basic_layout(p)

    a = pf.add_to_plot(p,
                       "FPE Dig. 2.5V",
                       "IMIR_SPW_V_DIG_2R5V",
                       start,
                       end,
                       conn,
                       color="orange")
    b = pf.add_to_plot(p,
                       "FPE PDU 2.5V REF",
                       "IMIR_PDU_V_REF_2R5V",
                       start,
                       end,
                       conn,
                       color="red")

    pf.add_hover_tool(p, [a, b])

    p.legend.location = "bottom_right"
    p.legend.click_policy = "hide"

    return p
Esempio n. 10
0
def ccc(conn, start, end):
    '''Create specific plot and return plot object
    Parameters
    ----------
    conn : DBobject
        Connection object that represents database
    start : time
        Startlimit for x-axis and query (typ. datetime.now()- 4Months)
    end : time
        Endlimit for x-axis and query (typ. datetime.now())
    Return
    ------
    p : Plot object
        Bokeh plot
    '''

    # create a new plot with a title and axis labels
    p = figure( tools = "pan,wheel_zoom,box_zoom,reset,save",       \
                toolbar_location = "above",                         \
                plot_width = 1120,                                   \
                plot_height = 500,                                  \
                y_range = [-2,2],                                   \
                x_axis_type = 'datetime',                           \
                x_axis_label = 'Date', y_axis_label = 'ratio (normalized)')

    p.grid.visible = True
    p.title.text = "CCC Ratio"
    pf.add_basic_layout(p)

    #add_to_wplot(p, "LOCKED", "IMIR_HK_CCC_POS_RATIO_LOCKED", start, end, conn, mn.ccc_nominals['LOCKED'], color = "green")
    pf.add_to_wplot(p,
                    "OPEN",
                    "IMIR_HK_CCC_POS_RATIO_OPEN",
                    start,
                    end,
                    conn,
                    mn.ccc_nominals['OPEN'],
                    color="red")
    pf.add_to_wplot(p,
                    "CLOSED",
                    "IMIR_HK_CCC_POS_RATIO_CLOSED",
                    start,
                    end,
                    conn,
                    mn.ccc_nominals['CLOSED'],
                    color="blue")

    p.legend.location = "bottom_right"
    p.legend.click_policy = "hide"

    return p
Esempio n. 11
0
def fw(conn, start, end):
    '''Create specific plot and return plot object
    Parameters
    ----------
    conn : DBobject
        Connection object that represents database
    start : time
        Startlimit for x-axis and query (typ. datetime.now()- 4Months)
    end : time
        Endlimit for x-axis and query (typ. datetime.now())
    Return
    ------
    p : Plot object
        Bokeh plot
    '''

    # create a new plot with a title and axis labels
    p = figure(tools="pan,wheel_zoom,box_zoom,reset,save",
               toolbar_location="above",
               plot_width=1120,
               plot_height=500,
               y_range=[-6, 4],
               x_axis_type='datetime',
               x_axis_label='Date',
               y_axis_label='ratio (normalized)')

    p.grid.visible = True
    p.title.text = "Filterwheel Ratio"
    pf.add_basic_layout(p)

    pf.add_to_wplot(p,
                    "FND",
                    "IMIR_HK_FW_POS_RATIO_FND",
                    start,
                    end,
                    conn,
                    mn.fw_nominals['FND'],
                    color="green")
    pf.add_to_wplot(p,
                    "OPAQUE",
                    "IMIR_HK_FW_POS_RATIO_OPAQUE",
                    start,
                    end,
                    conn,
                    mn.fw_nominals['OPAQUE'],
                    color="red")
    pf.add_to_wplot(p,
                    "F1000W",
                    "IMIR_HK_FW_POS_RATIO_F1000W",
                    start,
                    end,
                    conn,
                    mn.fw_nominals['F1000W'],
                    color="blue")
    pf.add_to_wplot(p,
                    "F1130W",
                    "IMIR_HK_FW_POS_RATIO_F1130W",
                    start,
                    end,
                    conn,
                    mn.fw_nominals['F1130W'],
                    color="orange")
    pf.add_to_wplot(p,
                    "F1280W",
                    "IMIR_HK_FW_POS_RATIO_F1280W",
                    start,
                    end,
                    conn,
                    mn.fw_nominals['F1280W'],
                    color="firebrick")
    pf.add_to_wplot(p,
                    "P750L",
                    "IMIR_HK_FW_POS_RATIO_P750L",
                    start,
                    end,
                    conn,
                    mn.fw_nominals['P750L'],
                    color="cyan")
    pf.add_to_wplot(p,
                    "F1500W",
                    "IMIR_HK_FW_POS_RATIO_F1500W",
                    start,
                    end,
                    conn,
                    mn.fw_nominals['F1500W'],
                    color="magenta")
    pf.add_to_wplot(p,
                    "F1800W",
                    "IMIR_HK_FW_POS_RATIO_F1800W",
                    start,
                    end,
                    conn,
                    mn.fw_nominals['F1800W'],
                    color="burlywood")
    pf.add_to_wplot(p,
                    "F2100W",
                    "IMIR_HK_FW_POS_RATIO_F2100W",
                    start,
                    end,
                    conn,
                    mn.fw_nominals['F2100W'],
                    color="cadetblue")
    pf.add_to_wplot(p,
                    "F560W",
                    "IMIR_HK_FW_POS_RATIO_F560W",
                    start,
                    end,
                    conn,
                    mn.fw_nominals['F560W'],
                    color="chartreuse")
    pf.add_to_wplot(p,
                    "FLENS",
                    "IMIR_HK_FW_POS_RATIO_FLENS",
                    start,
                    end,
                    conn,
                    mn.fw_nominals['FLENS'],
                    color="brown")
    pf.add_to_wplot(p,
                    "F2300C",
                    "IMIR_HK_FW_POS_RATIO_F2300C",
                    start,
                    end,
                    conn,
                    mn.fw_nominals['F2300C'],
                    color="chocolate")
    pf.add_to_wplot(p,
                    "F770W",
                    "IMIR_HK_FW_POS_RATIO_F770W",
                    start,
                    end,
                    conn,
                    mn.fw_nominals['F770W'],
                    color="darkorange")
    pf.add_to_wplot(p,
                    "F1550C",
                    "IMIR_HK_FW_POS_RATIO_F1550C",
                    start,
                    end,
                    conn,
                    mn.fw_nominals['F1550C'],
                    color="darkgreen")
    pf.add_to_wplot(p,
                    "F2550W",
                    "IMIR_HK_FW_POS_RATIO_F2550W",
                    start,
                    end,
                    conn,
                    mn.fw_nominals['F2550W'],
                    color="darkcyan")
    pf.add_to_wplot(p,
                    "F1140C",
                    "IMIR_HK_FW_POS_RATIO_F1140C",
                    start,
                    end,
                    conn,
                    mn.fw_nominals['F1140C'],
                    color="darkmagenta")
    pf.add_to_wplot(p,
                    "F2550WR",
                    "IMIR_HK_FW_POS_RATIO_F2550WR",
                    start,
                    end,
                    conn,
                    mn.fw_nominals['F2550WR'],
                    color="crimson")
    pf.add_to_wplot(p,
                    "F1065C",
                    "IMIR_HK_FW_POS_RATIO_F1065C",
                    start,
                    end,
                    conn,
                    mn.fw_nominals['F1065C'],
                    color="cornflowerblue")

    p.legend.location = "bottom_right"
    p.legend.click_policy = "hide"

    return p
Esempio n. 12
0
def pos_volt(conn, start, end):
    '''Create specific plot and return plot object
    Parameters
    ----------
    conn : DBobject
        Connection object that represents database
    start : time
        Startlimit for x-axis and query (typ. datetime.now()- 4Months)
    end : time
        Endlimit for x-axis and query (typ. datetime.now())
    Return
    ------
    p : Plot object
        Bokeh plot
    '''

    # create a new plot with a title and axis labels
    p = figure(tools="pan,wheel_zoom,box_zoom,reset,save",
               toolbar_location="above",
               plot_width=560,
               plot_height=500,
               y_range=[280, 300],
               x_axis_type='datetime',
               output_backend="webgl",
               x_axis_label='Date',
               y_axis_label='Voltage (mV)')

    p.grid.visible = True
    p.title.text = "Wheel Sensor Supply"
    pf.add_basic_layout(p)

    a = pf.add_to_plot(p,
                       "FW",
                       "IMIR_HK_FW_POS_VOLT",
                       start,
                       end,
                       conn,
                       color="red")
    b = pf.add_to_plot(p,
                       "GW14",
                       "IMIR_HK_GW14_POS_VOLT",
                       start,
                       end,
                       conn,
                       color="purple")
    c = pf.add_to_plot(p,
                       "GW23",
                       "IMIR_HK_GW23_POS_VOLT",
                       start,
                       end,
                       conn,
                       color="orange")
    d = pf.add_to_plot(p,
                       "CCC",
                       "IMIR_HK_CCC_POS_VOLT",
                       start,
                       end,
                       conn,
                       color="firebrick")

    pf.add_hover_tool(p, [a, b, c, d])

    p.legend.location = "bottom_right"
    p.legend.click_policy = "hide"

    return p
Esempio n. 13
0
def power_ice(conn, start, end):
    #query data from database
    start_str = str(Time(start).mjd)
    end_str = str(Time(end).mjd)

    sql_c = "SELECT * FROM SE_ZIMIRICEA_IDLE WHERE start_time BETWEEN " + start_str + " AND " + end_str + " ORDER BY start_time"
    _idle = pd.read_sql_query(sql_c, conn)
    sql_c = "SELECT * FROM SE_ZIMIRICEA_HV_ON WHERE start_time BETWEEN " + start_str + " AND " + end_str + " ORDER BY start_time"
    _hv = pd.read_sql_query(sql_c, conn)

    voltage = 30
    _idle['average'] *= voltage
    _hv['average'] *= voltage

    _idle['start_time'] = pd.to_datetime(
        Time(_idle['start_time'], format="mjd").datetime)
    _hv['start_time'] = pd.to_datetime(
        Time(_hv['start_time'], format="mjd").datetime)

    #set column data source
    idle = ColumnDataSource(_idle)
    hv = ColumnDataSource(_hv)

    # create a new plot with a title and axis labels
    p = figure( tools = "pan,wheel_zoom,box_zoom,reset,save",       \
                toolbar_location = "above",                         \
                plot_width = 1120,                                  \
                plot_height = 500,                                  \
                y_range = [5,14],                                   \
                x_axis_type = 'datetime',                           \
                output_backend = "webgl",                           \
                x_axis_label = 'Date', y_axis_label='Power (W)')

    p.grid.visible = True
    p.title.text = "POWER ICE"
    pf.add_basic_layout(p)
    pf.add_limit_box(p, 6, 8, alpha=0.1, color="green")

    # add a line renderer with legend and line thickness
    scat1 = p.scatter(x="start_time",
                      y="average",
                      color='orange',
                      legend="Power idle",
                      source=idle)
    scat2 = p.scatter(x="start_time",
                      y="average",
                      color='red',
                      legend="Power hv on",
                      source=hv)
    p.line(x="start_time",
           y="average",
           color='orange',
           legend="Power idle",
           source=idle)
    p.line(x="start_time",
           y="average",
           color='red',
           legend="Power hv on",
           source=hv)

    #generate error bars
    err_xs_hv = []
    err_ys_hv = []
    err_xs_idle = []
    err_ys_idle = []

    for index, item in _hv.iterrows():
        err_xs_hv.append((item['start_time'], item['start_time']))
        err_ys_hv.append((item['average'] - item['deviation'],
                          item['average'] + item['deviation']))

    for index, item in _idle.iterrows():
        err_xs_idle.append((item['start_time'], item['start_time']))
        err_ys_idle.append((item['average'] - item['deviation'],
                            item['average'] + item['deviation']))
    # plot them
    p.multi_line(err_xs_hv, err_ys_hv, color='red', legend='Power hv on')
    p.multi_line(err_xs_idle, err_ys_idle, color='orange', legend='Power idle')

    #activate HoverTool for scatter plot
    hover_tool = HoverTool(tooltips=[
        ('count', '@data_points'),
        ('mean', '@average'),
        ('deviation', '@deviation'),
    ],
                           mode='mouse',
                           renderers=[scat1, scat2])

    p.tools.append(hover_tool)

    p.legend.location = "bottom_right"
    p.legend.click_policy = "hide"

    return p
Esempio n. 14
0
def temp(conn, start, end):
    '''Create specific plot and return plot object
    Parameters
    ----------
    conn : DBobject
        Connection object that represents database
    start : time
        Startlimit for x-axis and query (typ. datetime.now()- 4Months)
    end : time
        Endlimit for x-axis and query (typ. datetime.now())
    Return
    ------
    p : Plot object
        Bokeh plot
    '''

    start_str = str(Time(start).mjd)
    end_str = str(Time(end).mjd)

    sql_c = "SELECT * FROM IGDP_MIR_ICE_INTER_TEMP WHERE start_time BETWEEN " + start_str + " AND " + end_str + " ORDER BY start_time"
    temp = pd.read_sql_query(sql_c, conn)

    temp['average'] += 273.15
    reg = pd.DataFrame(
        {'reg': pf.pol_regression(temp['start_time'], temp['average'], 3)})
    temp = pd.concat([temp, reg], axis=1)

    temp['start_time'] = pd.to_datetime(
        Time(temp['start_time'], format="mjd").datetime)
    plot_data = ColumnDataSource(temp)

    # create a new plot with a title and axis labels
    p = figure( tools = "pan,wheel_zoom,box_zoom,reset,save",       \
                toolbar_location = "above",                         \
                plot_width = 1120,                                   \
                plot_height = 700,                                  \
                y_range = [275,295],                             \
                x_axis_type = 'datetime',                           \
                output_backend="webgl",                             \
                x_axis_label = 'Date', y_axis_label = 'Temperature (K)')

    p.grid.visible = True
    p.title.text = "IEC Temperatures"
    pf.add_basic_layout(p)

    p.line(x="start_time",
           y="average",
           color="brown",
           legend="Internal Temp.",
           source=plot_data)
    p.scatter(x="start_time",
              y="average",
              color="brown",
              legend="Internal Temp.",
              source=plot_data)

    a = pf.add_to_plot(p,
                       "ICE IEC A",
                       "ST_ZTC1MIRIA",
                       start,
                       end,
                       conn,
                       color="burlywood")
    b = pf.add_to_plot(p,
                       "FPE IEC A",
                       "ST_ZTC2MIRIA",
                       start,
                       end,
                       conn,
                       color="cadetblue")
    j = pf.add_to_plot(p,
                       "ICE IEC B",
                       "ST_ZTC1MIRIB",
                       start,
                       end,
                       conn,
                       color="blue")
    k = pf.add_to_plot(p,
                       "FPE IEC B.",
                       "ST_ZTC2MIRIB",
                       start,
                       end,
                       conn,
                       color="brown")
    c = pf.add_to_plot(p,
                       "FPE PDU",
                       "IMIR_PDU_TEMP",
                       start,
                       end,
                       conn,
                       color="chartreuse")
    d = pf.add_to_plot(p,
                       "ANA IC",
                       "IMIR_IC_SCE_ANA_TEMP1",
                       start,
                       end,
                       conn,
                       color="chocolate")
    e = pf.add_to_plot(p,
                       "ANA SW",
                       "IMIR_SW_SCE_ANA_TEMP1",
                       start,
                       end,
                       conn,
                       color="coral")
    f = pf.add_to_plot(p,
                       "ANA LW",
                       "IMIR_LW_SCE_ANA_TEMP1",
                       start,
                       end,
                       conn,
                       color="darkorange")
    g = pf.add_to_plot(p,
                       "DIG IC",
                       "IMIR_IC_SCE_DIG_TEMP",
                       start,
                       end,
                       conn,
                       color="crimson")
    h = pf.add_to_plot(p,
                       "DIG SW",
                       "IMIR_SW_SCE_DIG_TEMP",
                       start,
                       end,
                       conn,
                       color="cyan")
    i = pf.add_to_plot(p,
                       "DIG LW",
                       "IMIR_LW_SCE_DIG_TEMP",
                       start,
                       end,
                       conn,
                       color="darkblue")

    pf.add_hover_tool(p, [a, b, c, d, e, f, g, h, i, j, k])

    p.legend.location = "bottom_right"
    p.legend.orientation = "horizontal"
    p.legend.click_policy = "hide"

    return p