def push_data_std(diode_t, diode, buffer):
        """
        Calculate rolling standard deviation of diode readings. Generate lists
        containing values one standard deviation away from the median (lower and higher)
        and push resulting list into buffer to be graphed.

        """

        timeStuff = list(diode_t)
        times = [
            1000 * time for time in timeStuff
        ]  # Convert time to seconds so bokeh formatter can get correct datetime

        diodeData = pd.Series(diode, index=times)
        zipped = basic_event_builder(diode=diodeData)

        median = zipped.rolling(120, min_periods=1).median()
        std = zipped.rolling(120, min_periods=1).std()
        lowerbound = median - std
        higherbound = median + std
        df = pd.DataFrame({
            'lowerbound': lowerbound['diode'],
            'higherbound': higherbound['diode']
        })
        buffer.send(df[119::2])
    def push_data():
        """
        Push data into stream to be ploted on hextiles plot
        
        """

        nonlocal ipm2_plot, ipm3_plot, ebeam_plot, ipm2TS_plot, ipm3TS_plot, ebeamTS_plot, paused_list

        ipm2_plot = list(ipm2List)[ipm2_index:]
        ipm3_plot = list(ipm3List)[ipm3_index:]
        ebeam_plot = list(ebeamList)[ebeam_index:]
        ipm2TS_plot = list(ipm2TS)[ipm2TS_index:]
        ipm3TS_plot = list(ipm3TS)[ipm3TS_index:]
        ebeamTS_plot = list(ebeamTS)[ebeamTS_index:]

        ipm2Data = pd.Series(ipm2_plot, index=ipm2TS_plot)
        ipm3Data = pd.Series(ipm3_plot, index=ipm3TS_plot)
        ebeamData = pd.Series(ebeam_plot, index=ebeamTS_plot)
        zipped = basic_event_builder(ipm2=ipm2Data,
                                     ipm3=ipm3Data,
                                     ebeam=ebeamData)
        data = zipped[['ebeam', switch_key_hex]]
        paused_list = zipped
        #print(zipped)
        streamHex.event(df=data)
    def scatter_tick():
        """
        Push new scatter points into stream to plot.
        
        """
        nonlocal paused_list

        # Still has the freezing points error, though, it seems to come more frequently.
        # This may be a bigger problem now

        ebeamConverted = list(ebeamList)
        ipm2Converted = list(ipm2List)
        ipm3Converted = list(ipm3List)
        ebeamTimeConverted = list(ebeamTS)
        ipm2TimeConverted = list(ipm2TS)
        ipm3TimeConverted = list(ipm3TS)

        ipm2Data = pd.Series(ipm2Converted[-limit:],
                             index=ipm2TimeConverted[-limit:])
        ipm3Data = pd.Series(ipm3Converted[-limit:],
                             index=ipm3TimeConverted[-limit:])
        ebeamData = pd.Series(ebeamConverted[-limit:],
                              index=ebeamTimeConverted[-limit:])

        zipped = basic_event_builder(ipm2=ipm2Data,
                                     ipm3=ipm3Data,
                                     ebeam=ebeamData)

        scatterList = zipped[-limit:]

        data = scatterList[['ebeam', switch_key_scatter]]
        paused_list = scatterList

        streamScatter.event(df=data)
    def push_data(x_diode, y_diode, x_diode_t, y_diode_t, buffer):
        """
        Push data from x and y diode into buffer to be graphed.

        """

        x_diode_data = pd.Series(x_diode, index=x_diode_t)
        y_diode_data = pd.Series(y_diode, index=y_diode_t)
        zipped = basic_event_builder(x_diode=x_diode_data,
                                     y_diode=y_diode_data)
        buffer.send(zipped)
 def saveFile():
     """
     Save current data plotted to csv file as a pandas.DataFrame
     
     """
     
     ipm2Data = pd.Series(ipm2_plot, index=ipm2TS_plot)
     ipm3Data = pd.Series(ipm3_plot, index=ipm3TS_plot)
     ebeamData = pd.Series(ebeam_plot, index=ebeamTS_plot)
     zipped = basic_event_builder(ipm2=ipm2Data, ipm3=ipm3Data, ebeam=ebeamData)
     zipped.to_csv('data2.csv')
Пример #6
0
    def push_data_scatter(timetool_d, timetool_t, buffer):

        timeStuff = list(timetool_t)
        # Convert time to seconds so bokeh formatter can get correct datetime
        times = [1000 * time for time in timeStuff]

        edgePos = []
        for array in timetool_d:
            edgePos.append(array[1])

        edgePos_data = pd.Series(edgePos, index=times)
        zipped = basic_event_builder(timetool_data=edgePos_data)
        buffer.send(zipped)
    def push_data_median(diode_t, diode, buffer):
        """
        Push rolling median of diode readings and push resulting list into buffer
        to be graphed.

        """

        timeStuff = list(diode_t)
        # Convert time to seconds so bokeh formatter can get correct datetime
        times = [1000 * time for time in timeStuff]

        diodeData = pd.Series(diode, index=times)

        zipped = basic_event_builder(diode=diodeData)
        median = zipped.rolling(120, min_periods=1).median()
        # Exclude first 119 points because of binning issues and sparsing the data (Doesn't seem to really work though)
        buffer.send(median[119::2])
        zipped.to_csv('testData2.csv')
    def push_data(stream):

        if switch_key == 'ipm2':
            ipm_plot = list(ipm2List)
            timestamp_plot = list(ipm2TS)
        elif switch_key == 'ipm3':
            ipm_plot = list(ipm3List)
            timestamp_plot = list(ipm3TS)

        times = [1000 * time for time in timestamp_plot]
        ipmData = pd.Series(ipm_plot, index=times)

        zipped = basic_event_builder(ipm=ipmData)
        median = zipped.rolling(120, min_periods=1).median()

        #This might be making it take a long time to switch
        if type(stream) == hv.streams.Buffer:
            if len(median) > 1000:
                counter = 0
                pos = 0
                send = pd.DataFrame({'ipm': []})

                while counter < 1000:

                    divide = len(median) / 1000.
                    test = int(pos)
                    send = send.append(median.iloc[[test]])
                    #print(send)
                    #print(type(median.iloc[[test]]))
                    pos += divide
                    counter += 1

                #print(len(send))
                #print(len(stream.data))
                stream.send(send)
                #print(stream.data[-10:])
                print("Done")

            else:
                stream.send(median)
            #stream.send(median)
        elif len(median) > 100:
            stream.event(df=median)
Пример #9
0
        def saveFile():
            """
            Save current data plotted to csv file as a pandas.DataFrame

            """

            ipm2Data = pd.Series(self.ipm2_plot[self.ipm2_index:],
                                 index=self.ipm2TS_plot[self.ipm2TS_index:])

            ipm3Data = pd.Series(self.ipm3_plot[self.ipm3_index:],
                                 index=self.ipm3TS_plot[self.ipm3TS_index:])

            ebeamData = pd.Series(self.ebeam_plot[self.ebeam_index:],
                                  index=self.ebeamTS_plot[self.ebeamTS_index:])

            zipped = basic_event_builder(ipm2=ipm2Data,
                                         ipm3=ipm3Data,
                                         ebeam=ebeamData)
            zipped.to_csv('data_class.csv')
    def push_data(ipm, timestamp, stream):
        """
        Push data into stream to be ploted on hextiles plot
        
        """

        ipm_plot = list(ipm)
        timestamp_plot = list(timestamp)

        times = [1000 * time for time in timestamp_plot]
        ipmData = pd.Series(ipm_plot, index=times)

        zipped = basic_event_builder(ipm=ipmData)
        median = zipped.rolling(120, min_periods=1).median()

        if type(stream) == hv.streams.Buffer:
            if len(median) > 1000:
                counter = 0
                pos = 0
                send = pd.DataFrame({'ipm': []})

                while counter < 1000:

                    divide = len(median) / 1000.
                    test = int(pos)
                    send = send.append(median.iloc[[test]])
                    #print(send)
                    #print(type(median.iloc[[test]]))
                    pos += divide
                    counter += 1

                #print(len(send))
                #print(len(stream.data))
                stream.send(send)
                #print(stream.data[-10:])
                print("Done")

            else:
                stream.send(median)
            #stream.send(median)
        elif len(median) > 100:
            stream.event(df=median)
Пример #11
0
    def push_std(stream):
        if switch_key == 'ipm2':
            ipm_plot = list(ipm2List)
            timestamp_plot = list(ipm2TS)
        elif switch_key == 'ipm3':
            ipm_plot = list(ipm3List)
            timestamp_plot = list(ipm3TS)

        times = [1000 * time for time in timestamp_plot]
        ipmData = pd.Series(ipm_plot, index=times)

        zipped = basic_event_builder(ipm=ipmData)
        median = zipped.rolling(120, min_periods=1).median()
        std = zipped.rolling(120, min_periods=1).std()
        lowerbound = median - std
        higherbound = median + std
        df = pd.DataFrame({
            'lowerbound': lowerbound['ipm'],
            'higherbound': higherbound['ipm']
        })

        if len(df) > 1000:
            counter = 0
            pos = 0
            send = pd.DataFrame({
                'lowerbound': lowerbound['ipm'],
                'higherbound': higherbound['ipm']
            })

            while counter < 1000:

                divide = len(df) / 1000.
                test = int(pos)
                send = send.append(df.iloc[[test]])
                pos += divide
                counter += 1
                #print(divide)

            stream.send(send)

        else:
            stream.send(df)
Пример #12
0
    def push_data(stream):

        TS_key = switch_key + '_TS'
        data = list(peak[switch_key])
        timestamp = list(peakTS[TS_key])

        times = [1000 * time for time in timestamp]
        dataSeries = pd.Series(data, index=times)

        zipped = basic_event_builder(peak=dataSeries)
        median = zipped.rolling(120, min_periods=1).median()
        std = zipped.rolling(120, min_periods=1).std()
        lowerbound = median - std
        higherbound = median + std
        df = pd.DataFrame({
            'peak': median['peak'],
            'lowerbound': lowerbound['peak'],
            'higherbound': higherbound['peak']
        })

        stream.send(df)
Пример #13
0
        def push_data():
            """
            Push data into stream to be ploted on hextiles plot

            """
            
            # Doesn't seem to get the most recent data :(

            socket.send_string("Hello")
            print("Oof")
            
            #if socket.poll(timeout=0):
                
            data_dict = socket.recv_pyobj()
            peakDict = data_dict['peakDict']
            peakTSDict = data_dict['peakTSDict']

            self.ipm2_plot = list(peakDict['peak_8'])
            self.ipm3_plot = list(peakDict['peak_9'])
            self.ebeam_plot = list(peakDict['peak_10'])
            self.ipm2TS_plot = list(peakTSDict['peak_8_TS'])
            self.ipm3TS_plot = list(peakTSDict['peak_9_TS'])
            self.ebeamTS_plot = list(peakTSDict['peak_10_TS'])

            ipm2Data = pd.Series(
                self.ipm2_plot[self.ipm2_index:], 
                index=self.ipm2TS_plot[self.ipm2TS_index:])

            ipm3Data = pd.Series(
                self.ipm3_plot[self.ipm3_index:], 
                index=self.ipm3TS_plot[self.ipm3TS_index:])

            ebeamData = pd.Series(
                self.ebeam_plot[self.ebeam_index:], 
                index=self.ebeamTS_plot[self.ebeamTS_index:])

            zipped = basic_event_builder(ipm2=ipm2Data, ipm3=ipm3Data, ebeam=ebeamData)
            data = zipped[['ebeam', self.switch_key]]
            self.paused_list = zipped
            self.streamHex.event(df=data)
    def push_std(stream):
        if switch_key == 'ipm2':
            ipm_plot = list(ipm2List)
            timestamp_plot = list(ipm2TS)
        elif switch_key == 'ipm3':
            ipm_plot = list(ipm3List)
            timestamp_plot = list(ipm3TS)

        times = [1000 * time for time in timestamp_plot]
        ipmData = pd.Series(ipm_plot, index=times)

        zipped = basic_event_builder(ipm=ipmData)
        median = zipped.rolling(120, min_periods=1).median()
        std = zipped.rolling(120, min_periods=1).std()
        lowerbound = median - std
        higherbound = median + std
        df = pd.DataFrame({
            'lowerbound': lowerbound['ipm'],
            'higherbound': higherbound['ipm']
        })

        stream.send(df)
        def push_data(stream):
            """
            Push data to timetool time history graph
            
            """

            median = pd.DataFrame({'peak': []})
            lowerbound = pd.DataFrame({'peak': []})
            higherbound = pd.DataFrame({'peak': []})

            # Request
            socket.send_string("Hello")
            print("Oof")

            data_dict = socket.recv_pyobj()
            peakDict = data_dict['peakDict']
            peakTSDict = data_dict['peakTSDict']

            TS_key = self.switch_key + '_TS'
            data = list(peakDict[self.switch_key])
            timestamp = list(peakTSDict[TS_key])

            times = [1000 * time for time in timestamp]
            dataSeries = pd.Series(data, index=times)

            zipped = basic_event_builder(peak=dataSeries)
            median = zipped.rolling(120, min_periods=1).median()
            std = zipped.rolling(120, min_periods=1).std()
            lowerbound = median - std
            higherbound = median + std

            df = pd.DataFrame({
                'peak': median['peak'],
                'lowerbound': lowerbound['peak'],
                'higherbound': higherbound['peak']
            })

            stream.send(df)
        def scatter_tick():
            """
            Push new scatter points into stream to plot.

            """
            # Still has the freezing points error, though, it seems to come more frequently.
            # This may be a bigger problem now

            if socket.poll(timeout=0):

                data_dict = socket.recv_pyobj()
                peakDict = data_dict['peakDict']
                peakTSDict = data_dict['peakTSDict']

                self.ipm2_plot = list(peakDict['peak_8'])
                self.ipm3_plot = list(peakDict['peak_9'])
                self.ebeam_plot = list(peakDict['peak_10'])
                self.ipm2TS_plot = list(peakTSDict['peak_8_TS'])
                self.ipm3TS_plot = list(peakTSDict['peak_9_TS'])
                self.ebeamTS_plot = list(peakTSDict['peak_10_TS'])

                ipm2Data = pd.Series(self.ipm2_plot[-self.limit:],
                                     index=self.ipm2TS_plot[-self.limit:])
                ipm3Data = pd.Series(self.ipm3_plot[-self.limit:],
                                     index=self.ipm3TS_plot[-self.limit:])
                ebeamData = pd.Series(self.ebeam_plot[-self.limit:],
                                      index=self.ebeamTS_plot[-self.limit:])

                zipped = basic_event_builder(ipm2=ipm2Data,
                                             ipm3=ipm3Data,
                                             ebeam=ebeamData)

                scatterList = zipped

                data = scatterList[['ebeam', self.switch_key]]
                self.paused_list = scatterList

                self.streamScatter.event(df=data)
        def push_data(stream):
            """
            Push data to timetool time history graph
            
            """

            median = pd.DataFrame({'peak': []})
            lowerbound = pd.DataFrame({'peak': []})
            higherbound = pd.DataFrame({'peak': []})

            # Maybe fix this for stopping no data coming in? And switching issue? (Right now it's a feature)
            if socket.poll(timeout=0):
                data_dict = socket.recv_pyobj()
                peakDict = data_dict['peakDict']
                peakTSDict = data_dict['peakTSDict']

                TS_key = self.switch_key + '_TS'
                data = list(peakDict[self.switch_key])
                timestamp = list(peakTSDict[TS_key])

                times = [1000 * time for time in timestamp]
                dataSeries = pd.Series(data, index=times)

                zipped = basic_event_builder(peak=dataSeries)
                median = zipped.rolling(120, min_periods=1).median()
                std = zipped.rolling(120, min_periods=1).std()
                lowerbound = median - std
                higherbound = median + std

            df = pd.DataFrame({
                'peak': median['peak'],
                'lowerbound': lowerbound['peak'],
                'higherbound': higherbound['peak']
            })

            stream.send(df)