コード例 #1
0
def exportPlot_SingleLC_ToHTML(data, fullPath):
    TOOLTIPS = [("index", "$index"), ("(x,y)", "@x{0,0.000000}, $y"),
                ("UTC", "@UTC")]

    plot = figure(tooltips=TOOLTIPS,
                  title="Result",
                  x_axis_label='time',
                  y_axis_label='Flux',
                  sizing_mode="stretch_both")

    instances = [float(i) for i in data["instances"]]
    timestamp = [float(i) for i in data["timestamps"]]
    UTC = ut_astro.convertList_MJDtoUTC(timestamp)
    fileName = data["fileName"]
    source = ColumnDataSource(data=dict(x=timestamp, y=instances, UTC=UTC))
    plot.line('x',
              'y',
              source=source,
              line_alpha=1,
              color="blue",
              line_width=2,
              legend_label=fileName)
    plot.circle('x', 'y', source=source, color="blue", legend_label=fileName)

    plot.legend.border_line_width = 3
    plot.legend.click_policy = "hide"
    plot.legend.border_line_color = "navy"
    plot.legend.border_line_alpha = 0.
    plot.xaxis.axis_label_text_font_size = "16pt"
    plot.xaxis.major_label_text_font_size = "13pt"
    plot.yaxis.axis_label_text_font_size = "16pt"
    plot.yaxis.major_label_text_font_size = "13pt"
    save(plot, filename=fullPath)
    return True
コード例 #2
0
def export_JsDiv_rawdy(data):
    list_ini_bin = [3, 5, 7, 10]
    TOOLTIPS = [("index", "$index"), ("(x,y)", "@x{0,0.000000}, $y"),
                ("UTC", "@UTC")]
    instances = [float(i) for i in data["instances"]]
    timestamp = [float(i) for i in data["timestamps"]]
    UTC = ut_astro.convertList_MJDtoUTC(timestamp)
    fileName = data["fileName"]

    plot = figure(tooltips=TOOLTIPS,
                  title="Result : {}".format(fileName),
                  x_axis_label='time',
                  y_axis_label='Flux',
                  sizing_mode="stretch_both")
    source = ColumnDataSource(data=dict(x=timestamp, y=instances, UTC=UTC))
    plot.line('x',
              'y',
              source=source,
              line_alpha=1,
              color="black",
              line_width=2,
              legend_label="Raw data")
    plot.circle('x',
                'y',
                source=source,
                color="black",
                legend_label="Raw data")

    windowSize = int(data["windowSize"])

    corePlot = sketchDyBinService(windowSize=windowSize,
                                  initialBin=5,
                                  isOnline=False)
    sketchInstances = corePlot.sketchMode(instances=instances)

    source = ColumnDataSource(data=dict(x=timestamp, y=sketchInstances))
    plot.line('x',
              'y',
              source=source,
              line_alpha=1,
              color="red",
              line_width=2,
              legend_label="DyBin")

    plot.legend.border_line_width = 3
    plot.legend.click_policy = "hide"
    plot.legend.border_line_color = "navy"
    plot.legend.border_line_alpha = 0.
    plot.xaxis.axis_label_text_font_size = "16pt"
    plot.xaxis.major_label_text_font_size = "13pt"
    plot.yaxis.axis_label_text_font_size = "16pt"
    plot.yaxis.major_label_text_font_size = "13pt"
    js, div = components(plot)
    return js, div
コード例 #3
0
def export_JsDiv_RawRRCF(data, rrcf_resultList, isUTC):
    instances = [float(i) for i in data["instances"]]
    timestamp = [float(i) for i in data["timestamp"]]
    colorRaw = 'black'
    colorMp = 'red'
    if isUTC:
        TOOLTIPS = [("index", "$index"), ("(x,y)", "@x{0,0.000000}, $y"),
                    ("UTC", "@UTC")]
        UTC = ut_astro.convertList_MJDtoUTC(timestamp)
        rawSource = ColumnDataSource(
            data=dict(x=timestamp, y=instances, UTC=UTC))
        mpSource = ColumnDataSource(
            data=dict(x=timestamp[0:len(rrcf_resultList)],
                      y=rrcf_resultList,
                      UTC=UTC[0:len(rrcf_resultList)]))
    else:
        TOOLTIPS = [("index", "$index"), ("(x,y)", "@x{0,0.000000}, $y")]
        rawSource = ColumnDataSource(data=dict(x=timestamp, y=instances))
        mpSource = ColumnDataSource(
            data=dict(x=timestamp[0:len(rrcf_resultList)], y=rrcf_resultList))

    plot = figure(tooltips=TOOLTIPS,
                  title="Result",
                  x_axis_label='time',
                  y_axis_label='Flux',
                  sizing_mode="stretch_both")

    plot.line('x',
              'y',
              source=rawSource,
              line_alpha=1,
              color=colorRaw,
              line_width=2,
              legend_label="RAW")
    plot.circle('x', 'y', source=rawSource, color=colorRaw, legend_label="RAW")

    plot.line('x',
              'y',
              source=mpSource,
              line_alpha=1,
              color=colorMp,
              line_width=2,
              legend_label="RRCF")

    plot.legend.border_line_width = 3
    plot.legend.click_policy = "hide"
    plot.legend.border_line_color = "navy"
    plot.legend.border_line_alpha = 0.
    plot.xaxis.axis_label_text_font_size = "16pt"
    plot.xaxis.major_label_text_font_size = "13pt"
    plot.yaxis.axis_label_text_font_size = "16pt"
    plot.yaxis.major_label_text_font_size = "13pt"
    js, div = components(plot)
    return js, div
コード例 #4
0
def export_JsDiv_martixprofile(listData):
    TOOLTIPS = [("index", "$index"), ("(x,y)", "@x{0,0.000000}, $y"),
                ("UTC", "@UTC")]
    plot = figure(tooltips=TOOLTIPS,
                  title="Matrix profile",
                  x_axis_label='time',
                  y_axis_label='Distance',
                  sizing_mode="stretch_both")
    for data, color in zip(listData, Spectral10):
        instances = [float(i) for i in data["instances"]]
        timestamp = [float(i) for i in data["timestamp"]]
        UTC = ut_astro.convertList_MJDtoUTC(timestamp)
        fileName = data["fileName"]
        mp_list = ut_gen.genMartixProfile(
            instances=instances,
            timestamp=timestamp,
            subsequence_length=data["subsequence_length"])

        source = ColumnDataSource(data=dict(x=timestamp, y=mp_list))
        plot.line('x',
                  'y',
                  source=source,
                  line_alpha=1,
                  color=color,
                  line_width=2,
                  legend_label=fileName)
        plot.circle('x',
                    'y',
                    source=source,
                    color=color,
                    legend_label=fileName)

    plot.legend.border_line_width = 3
    plot.legend.click_policy = "hide"
    plot.legend.border_line_color = "navy"
    plot.legend.border_line_alpha = 0.
    plot.xaxis.axis_label_text_font_size = "16pt"
    plot.xaxis.major_label_text_font_size = "13pt"
    plot.yaxis.axis_label_text_font_size = "16pt"
    plot.yaxis.major_label_text_font_size = "13pt"
    js, div = components(plot)
    return js, div
コード例 #5
0
def export_Simultaneous(listData, isJSDIV=True):
    TOOLTIPS = [("index", "$index"), ("(x,y)", "@x{0,0.000000}, $y"),
                ("UTC", "@UTC")]
    plot = figure(tooltips=TOOLTIPS,
                  title="Result",
                  x_axis_label='time',
                  y_axis_label='Flux',
                  sizing_mode="stretch_both")
    for data, color in zip(listData, Spectral10):
        instances = [float(i) for i in data["instances"]]
        timestamp = [float(i) for i in data["timestamp"]]
        UTC = ut_astro.convertList_MJDtoUTC(timestamp)
        fileName = data["fileName"]
        source = ColumnDataSource(data=dict(x=timestamp, y=instances, UTC=UTC))
        plot.line('x',
                  'y',
                  source=source,
                  line_alpha=1,
                  color=color,
                  line_width=2,
                  legend_label=fileName)
        plot.circle('x',
                    'y',
                    source=source,
                    color=color,
                    legend_label=fileName)

    plot.legend.border_line_width = 3
    plot.legend.click_policy = "hide"
    plot.legend.border_line_color = "navy"
    plot.legend.border_line_alpha = 0.
    plot.xaxis.axis_label_text_font_size = "16pt"
    plot.xaxis.major_label_text_font_size = "13pt"
    plot.yaxis.axis_label_text_font_size = "16pt"
    plot.yaxis.major_label_text_font_size = "13pt"
    if isJSDIV:
        js, div = components(plot)
        return js, div
    else:
        return plot
コード例 #6
0
import utility.utility_db as ut_db
import utility.utility_webservice as ut_service
import utility.utility_genData as ut_gen
import utility.utility_astronomy as ut_astro
import utility.utility_exportBokeh as ut_bokeh

inis_bin = [3, 5]
windows_size = [10, 20]

if __name__ == '__main__':

    list_files = ut_db.getAnswerMDF_toDB()
    for index, row in enumerate(list_files):
        file_name = row['file_name']
        FdataMDF, FtimestampMDF = ut_service.getMDFData(file_name)
        UTC = ut_astro.convertList_MJDtoUTC(FtimestampMDF)
        raw = {"timestamp": FtimestampMDF, 'instances': FdataMDF, 'UTC': UTC}
        rows_data = []
        for ini_bin in inis_bin:
            for window_size in windows_size:
                FdataMDF_dy = ut_gen.genListDyBin(instances=FdataMDF,
                                                  timestamp=FtimestampMDF,
                                                  windowSize=window_size,
                                                  isOnline=False,
                                                  initialBin=ini_bin)
                rows_data.append({
                    "timestamp":
                    FtimestampMDF,
                    'instances':
                    FdataMDF_dy['sketchInstances'],
                    'UTC':
コード例 #7
0
                    float(item)
                    for item in ut.txt_to_list(path_lc_timestamp_path)
                ]
                save_mjd = "{}{}\\{}\\".format(main_save_path, "timestamp_MJD",
                                               fileDate)
                ut.checkFolderandCreate(save_mjd)
                save_mjd_fileName = "{}{}.txt".format(save_mjd, fileName)
                ut.list_to_txt(rows=mjd_list,
                               csv_name=save_mjd_fileName,
                               is_sort=False)

                # Save LC to Common UTC
                save_UTC = "{}{}\\{}\\".format(main_save_path, "timestamp_UTC",
                                               fileDate)
                ut.checkFolderandCreate(save_UTC)
                UTC_list = ut_astro.convertList_MJDtoUTC(listMJD=mjd_list)
                save_utc_fileName = "{}{}.txt".format(save_UTC, fileName)
                ut.list_to_txt(rows=UTC_list,
                               csv_name=save_utc_fileName,
                               is_sort=False)

                # Save LC to Common HTML
                save_HTML = "{}{}\\{}\\".format(main_save_path, "HTML",
                                                fileDate)
                ut.checkFolderandCreate(save_HTML)
                save_HTML_fileName = "{}{}.html".format(save_HTML, fileName)
                data = {
                    "instances": FdataMDF,
                    "timestamps": mjd_list,
                    "UTCs": UTC_list,
                    "fileName": fileName
コード例 #8
0
def export_JsDiv_saxcompare(data, add_on=[]):
    TOOLTIPS = [("index", "$index"), ("(x,y)", "@x{0,0.000000}, $y"),
                ("UTC", "@UTC")]
    instances = [float(i) for i in data["instances"]]
    timestamp = [float(i) for i in data["timestamp"]]
    instances_nor = TimeSeriesScalerMeanVariance(mu=0., std=1.).fit_transform(
        [instances])
    UTC = ut_astro.convertList_MJDtoUTC(timestamp)
    fileName = data["fileName"]
    windowSize = int(data["windowSize"])

    plot = figure(tooltips=TOOLTIPS,
                  title="Result : {}".format(fileName),
                  x_axis_label='time',
                  y_axis_label='Flux',
                  sizing_mode="stretch_both")
    source = ColumnDataSource(
        data=dict(x=timestamp, y=list(instances_nor[0].ravel()), UTC=UTC))
    plot.line('x',
              'y',
              source=source,
              line_alpha=0.5,
              color="black",
              line_width=2,
              legend_label="Raw data")
    plot.circle('x',
                'y',
                source=source,
                alpha=0.7,
                color="black",
                legend_label="Raw data")

    # Dybin
    corePlot = sketchDyBinService(windowSize=windowSize,
                                  initialBin=5,
                                  isOnline=False)
    sketchInstances = corePlot.sketchMode(
        instances=list(instances_nor[0].ravel()))
    sourceDy = ColumnDataSource(data=dict(x=timestamp, y=sketchInstances))
    plot.line('x',
              'y',
              source=sourceDy,
              line_alpha=1,
              color=Bokeh5[0],
              line_width=3,
              legend_label="DyBin")

    # Hoedd
    #
    # Hoeffding_dy = ut_gen.genListHoeffdingBin(instances=list(instances_nor[0].ravel()), timestamp=timestamp,
    #                            windowSize=windowSize, initialBin=5)
    # sourceHoeffding = ColumnDataSource(data=dict(x=timestamp, y=Hoeffding_dy["sketchInstances"]))
    # plot.line('x', 'y', source=sourceHoeffding, line_alpha=1, color=Bokeh5[1], line_width=3,
    #           legend_label="Hoeffding")

    # PAA
    data_PAA = ut_gen.genListPAA(instances_nor=instances_nor,
                                 timestamp=timestamp,
                                 windowSize=windowSize)
    sourcePAA = ColumnDataSource(
        data=dict(x=data_PAA['timestamp'], y=data_PAA['sketchInstances']))
    plot.line('x',
              'y',
              source=sourcePAA,
              line_alpha=1,
              color=Bokeh5[2],
              line_width=3,
              legend_label="PAA")

    # SAX
    data_SAX = ut_gen.genListSAX(instances_nor=instances_nor,
                                 timestamp=timestamp,
                                 windowSize=windowSize,
                                 n_sax_symbols=25)
    sourceSAX = ColumnDataSource(
        data=dict(x=data_SAX['timestamp'], y=data_SAX['sketchInstances']))
    plot.line('x',
              'y',
              source=sourceSAX,
              line_alpha=1,
              color=Bokeh5[3],
              line_width=3,
              legend_label="SAX")

    # 1D-SAX
    data_1DSAX = ut_gen.genList1D_SAX(instances_nor=instances_nor,
                                      timestamp=timestamp,
                                      windowSize=windowSize)
    source1DSAX = ColumnDataSource(
        data=dict(x=data_1DSAX['timestamp'], y=data_1DSAX['sketchInstances']))
    plot.line('x',
              'y',
              source=source1DSAX,
              line_alpha=1,
              color=Bokeh5[4],
              line_width=3,
              legend_label="1D-SAX")

    if add_on:
        for row in add_on:
            if row["type"] == "anwser":
                start_point = timestamp[row["start"]]
                end_point = timestamp[row["end"]]
                plot = ut_bok.plotAnswerBox(plot=plot,
                                            start_point=start_point,
                                            end_point=end_point)

    plot.legend.border_line_width = 3
    plot.legend.click_policy = "hide"
    plot.legend.border_line_color = "navy"
    plot.legend.border_line_alpha = 0.
    plot.xaxis.axis_label_text_font_size = "16pt"
    plot.xaxis.major_label_text_font_size = "13pt"
    plot.yaxis.axis_label_text_font_size = "16pt"
    plot.yaxis.major_label_text_font_size = "13pt"
    js, div = components(plot)
    return js, div
コード例 #9
0
import utility.utility_mdf as ut_mdf
import utility.utility_astronomy as ut_astro
from datetime import datetime,timedelta

main_file = ut_mdf.getDataFromFile(fileName='light_curve_Gaia-DR2_49407521363733632_date20191129')
start_index = 765
end_index = 2570 - 1
second = 10

#second
# def genTimePeriod(mdf_date,period = 10):
#     main_file['UTC'] = ut_astro.convertList_MJDtoUTC(main_file['timestamp'])
#     start_UTC =
#
#     end_time = start_time + timedelta(seconds=3)
#     while
#     print("a")


if __name__ == '__main__':
    main_file['UTC'] = ut_astro.convertList_MJDtoUTC(main_file['timestamp'])

    print(main_file['UTC'][start_index])
    date_time_obj = datetime.strptime(main_file['UTC'][start_index], '%Y-%m-%d %H:%M:%S.%f')
    genTimePeriod(start_time=date_time_obj,end_time=date_time_obj)
    print("a")