idxLAA+= 1
            idxLAM+= 1
            idxLBA+= 1
            idxLBM+= 1
            idxLCA+= 1
            idxLCM+= 1
        # return V0 V+ V- 
        return[V0Ang,V0Mag,VpAng,VpMag,VnAng,VnMag,Vn_ubalance_seq,V0_ubalance_seq]
        
        
        
    
opts = { 'input_streams'  : ['upmu/switch_a6/L1ANG','upmu/switch_a6/L1MAG','upmu/switch_a6/L2ANG',
                            'upmu/switch_a6/L2MAG','upmu/switch_a6/L3ANG','upmu/switch_a6/L3MAG','upmu/grizzly_new/L1ANG'], \
         'input_uids'     : ['adf13e17-44b7-4ef6-ae3f-fde8a9152ab7','df64af25-a389-4be9-8061-f87c3616f286',
                             '4f56a8f1-f3ca-4684-930e-1b4d9955f72c','6e6ad513-ddd2-47fb-98c1-16e6477504fc',
                             '2c07ccef-20c5-4971-87cf-2c187ce5f722','bcf38098-0e16-46f2-a9fb-9ce481d7d55b',
                             'b4776088-2f85-4c75-90cd-7472a949a8fa'], \
         'start_date'     : '2014-12-03T00:00:00.000000', \
         'end_date'       : '2014-12-03T23:59:59.000000', \
         'output_streams' : ['VOLTAGE_ZERO_SEQ_ANG','VOLTAGE_ZERO_SEQ_MAG','VOLTAGE_POSITIVE_SEQ_ANG',
                             'VOLTAGE_POSITIVE_SEQ_MAG','VOLTAGE_NEGATIVE_SEQ_ANG','VOLTAGE_NEGATIVE_SEQ_MAG',
                             'VOLTAGE_UNBALANCE_NEG_SEQ','VOLTAGE_UNBALANCE_ZERO_SEQ'], \
         'output_units'   : ['Degree','V','Degree','V','Degree','V','Precent','Precent'], \
         'author'         : 'Refined Switch_a6', \
         'name'           : 'Sequence Components', \
         'version'        : 10, \
         'algorithm'      : compute }        
qdf.register(Distillate(), opts)
qdf.begin()
         # start date for input streams. Format must match: 'yyyy-mm-ddThh:mm:ss.ssssss'
         'start_date'     : '2014-10-06T00:00:00.000000',

         # end date for input streams. Format must match: 'yyyy-mm-ddThh:mm:ss.ssssss'
         'end_date'       : '2014-10-06T02:30:00.000000',

         # string names of output streams.
         'output_streams' : ['out1, out2, out3'],

         # List of units for each output stream
         'output_units'   : ['Unit', 'Unit', 'Unit'],

         # The programmer who wrote this distillate. First level directory name
         'author'         : 'CAB',

         # The name of the type algorithm implemented. Second level directory name
         'name'           : 'New Output Frequency',

         # The version of the code. Increment this to overwrite existing data from an older
         #   version of this code
         'version'        : 6,

         # Plaintext name of the function defined above. This passes a 'function reference'
         #   that can be called in another program
         'algorithm'      : algorithm }

# The following two lines instantiate the distillate class and begin begin the distillation
qdf.register(Distillate(),
             opts)  #instantiates an object with your parameters and algorithm
qdf.begin()  # enters the program and runs the distillation program
            continue
        if VpAng[idxVp].time < CpAng[idxCp].time:
            idxCp += 1
            continue

        # compute Total_dpf_pos_seq
        total = np.cos(np.radians(VpAng[idxVp].value - CpAng[idxCp].value))
        Total_dpf_pos_seq.append((VpAng[idxVp].time, total))

        idxVp += 1
        idxCp += 1
    ''' return Totalp_dpf_seq'''
    return [Total_dpf_pos_seq]




opts = { 'input_streams'  : ['Refined Grizzly/Sequence Components/VOLTAGE_POSITIVE_SEQ_ANG',
                             'Refined Grizzly/Sequence Components/CURRENT_POSITIVE_SEQ_ANG'], \
         'input_uids'     : ['b70fae9d-8275-4956-8fb0-cf42a2474c7c','f5e8010b-147c-4d9b-940c-57703f4d29e7'], \
         'start_date'     : '2014-12-03T00:00:00.000000', \
         'end_date'       : '2014-12-03T11:59:59.000000', \
         'output_streams' : ['TOTAL_DPF_POS_SEQ'], \
         'output_units'   : ['Precent'], \
         'author'         : 'Calculated Grizzly', \
         'name'           : 'Sequence Components', \
         'version'        : 17, \
         'algorithm'      : compute }
qdf.register(Distillate(), opts)
qdf.begin()
        values_1hz = []
        values_2hz = []
        while timestamp < target_end_date:
            #Round down to the second to prevent cumulative error
            timestamp /= 1000000000
            timestamp *= 1000000000
            for i in xrange(120):
                delta = 8333333 #This corresponds with the one used by the uPMUs
                values_1hz.append((timestamp + delta*i, np.sin( 2*np.pi   * i*delta/1E9)))
                values_2hz.append((timestamp + delta*i, np.sin( 2*2*np.pi * i*delta/1E9)))

            if len(values_1hz) >= qdf.OPTIMAL_BATCH_SIZE:
                yield self.stream_insert_multiple("1hz", values_1hz)
                yield self.stream_insert_multiple("2hz", values_2hz)
                values_1hz = []
                values_2hz = []

            timestamp += 1000000000 #Next second

        #Make sure that we write out the values we generated
        yield self.stream_insert_multiple("1hz", values_1hz)
        yield self.stream_insert_multiple("2hz", values_2hz)

        #Now that we are done, save the time we finished at
        self.persist("end_timestamp", timestamp)


qdf.register(Example1HZ())
qdf.begin()
Example #5
0
                window_end = current + 15 * qdf.MINUTE
                if window_end > end:
                    window_end = end
                _, hz1_values = yield self.stream_get("1hz", current, window_end)
                _, hz2_values = yield self.stream_get("2hz", current, window_end)

                delta_values = []

                idx1 = 0
                idx2 = 0
                while idx1 < len(hz1_values) and idx2 < len(hz2_values):
                    if hz1_values[idx1].time < hz2_values[idx2].time:
                        idx1 += 1
                        continue
                    if hz1_values[idx1].time > hz2_values[idx2].time:
                        idx2 += 1
                        continue
                    delta = hz1_values[idx1].value - hz2_values[idx2].value
                    delta_values.append((hz1_values[idx1].time, delta))
                    idx1 += 1
                    idx2 += 1

                yield self.stream_insert_multiple("delta", delta_values)

                current += 15 * qdf.MINUTE

        # we don't need to use any persistence, because the latest versions we used are stored in the metadata

qdf.register(DistillateDriver())
qdf.begin()
        #This is the final level. You can have multiple of these
        self.use_stream("del", "589f0dbe-8855-49f2-b30e-3c64440673de")

        #If this is incremented, it is assumed that the whole distillate is invalidated, and it
        #will be deleted and discarded. In addition all 'persist' data will be removed
        self.set_version(4)

    @defer.inlineCallbacks
    def compute(self):
        """
        This is called to compute your algorithm.

        This example generates the difference between two streams
        """

        if self.unpersist("done",False):
            print "Already done"
            return

        start_date = self.date("2014-10-01T00:00:00.000000")
        end_date = self.date("2014-10-01T00:01:00.000000")

        yield self.stream_delete_range("dev", start_date, end_date)

        #Now that we are done, save the time we finished at
        self.persist("done", True)


qdf.register(DeleteStream())
qdf.begin()
        hz1_version, hz1_values = yield self.stream_get("1hz", start_date, end_date)
        hz2_version, hz2_values = yield self.stream_get("2hz", start_date, end_date)
        delta_values = []

        idx1 = 0
        idx2 = 0
        while idx1 < len(hz1_values) and idx2 < len(hz2_values):
            if hz1_values[idx1].time < hz2_values[idx2].time:
                idx1 += 1
                continue
            if hz1_values[idx1].time > hz2_values[idx2].time:
                idx2 += 1
                continue
            delta = hz1_values[idx1].value - hz2_values[idx2].value
            delta_values.append((hz1_values[idx1].time, delta))
            if len(delta_values) >= qdf.OPTIMAL_BATCH_SIZE:
                yield self.stream_insert_multiple("delta", delta_values)
                delta_values = []
            idx1 += 1
            idx2 += 1

        yield self.stream_insert_multiple("delta", delta_values)

        #Now that we are done, save the time we finished at
        self.persist("done", True)


qdf.register(ExampleDelta())
qdf.begin()
Example #8
0
                    idx1 = 0
                    idx2 = 0
                    while idx1 < len(vals_a) and idx2 < len(vals_b):
                        if vals_a[idx1].time < vals_b[idx2].time:
                            idx1 += 1
                            continue
                        if vals_a[idx1].time > vals_b[idx2].time:
                            idx2 += 1
                            continue
                        delta = vals_a[idx1].value - vals_b[idx2].value + pair[
                            0][2] + pair[1][2]
                        if delta < -180:
                            delta += 360
                        elif delta >= 180:
                            delta -= 360

                        delta_values.append((vals_a[idx1].time, delta))
                        idx1 += 1
                        idx2 += 1

                    print "Inserting values: ", len(delta_values)
                    yield self.stream_insert_multiple(streamname, delta_values)

                    current += 15 * qdf.MINUTE

        # we don't need to use any persistence, because the latest versions we used are stored in the metadata


qdf.register(DistillateDriver())
qdf.begin()
        #This is the final level. You can have multiple of these
        self.use_stream("del", "589f0dbe-8855-49f2-b30e-3c64440673de")

        #If this is incremented, it is assumed that the whole distillate is invalidated, and it
        #will be deleted and discarded. In addition all 'persist' data will be removed
        self.set_version(4)

    @defer.inlineCallbacks
    def compute(self):
        """
        This is called to compute your algorithm.

        This example generates the difference between two streams
        """

        if self.unpersist("done", False):
            print "Already done"
            return

        start_date = self.date("2014-10-01T00:00:00.000000")
        end_date = self.date("2014-10-01T00:01:00.000000")

        yield self.stream_delete_range("dev", start_date, end_date)

        #Now that we are done, save the time we finished at
        self.persist("done", True)


qdf.register(DeleteStream())
qdf.begin()
            "1hz", start_date, end_date)
        hz2_version, hz2_values = yield self.stream_get(
            "2hz", start_date, end_date)
        delta_values = []

        idx1 = 0
        idx2 = 0
        while idx1 < len(hz1_values) and idx2 < len(hz2_values):
            if hz1_values[idx1].time < hz2_values[idx2].time:
                idx1 += 1
                continue
            if hz1_values[idx1].time > hz2_values[idx2].time:
                idx2 += 1
                continue
            delta = hz1_values[idx1].value - hz2_values[idx2].value
            delta_values.append((hz1_values[idx1].time, delta))
            if len(delta_values) >= qdf.OPTIMAL_BATCH_SIZE:
                yield self.stream_insert_multiple("delta", delta_values)
                delta_values = []
            idx1 += 1
            idx2 += 1

        yield self.stream_insert_multiple("delta", delta_values)

        #Now that we are done, save the time we finished at
        self.persist("done", True)


qdf.register(ExampleDelta())
qdf.begin()
Example #11
0
        values_2hz = []
        while timestamp < target_end_date:
            #Round down to the second to prevent cumulative error
            timestamp /= 1000000000
            timestamp *= 1000000000
            for i in xrange(120):
                delta = 8333333  #This corresponds with the one used by the uPMUs
                values_1hz.append((timestamp + delta * i,
                                   np.sin(2 * np.pi * i * delta / 1E9)))
                values_2hz.append((timestamp + delta * i,
                                   np.sin(2 * 2 * np.pi * i * delta / 1E9)))

            if len(values_1hz) >= qdf.OPTIMAL_BATCH_SIZE:
                yield self.stream_insert_multiple("1hz", values_1hz)
                yield self.stream_insert_multiple("2hz", values_2hz)
                values_1hz = []
                values_2hz = []

            timestamp += 1000000000  #Next second

        #Make sure that we write out the values we generated
        yield self.stream_insert_multiple("1hz", values_1hz)
        yield self.stream_insert_multiple("2hz", values_2hz)

        #Now that we are done, save the time we finished at
        self.persist("end_timestamp", timestamp)


qdf.register(Example1HZ())
qdf.begin()
         # start date for input streams. Format must match: 'yyyy-mm-ddThh:mm:ss.ssssss'
         'start_date'     : '2014-10-06T00:00:00.000000',

         # end date for input streams. Format must match: 'yyyy-mm-ddThh:mm:ss.ssssss'
         'end_date'       : '2014-10-06T02:30:00.000000',

         # string names of output streams.
         'output_streams' : ['out1, out2, out3'],

         # List of units for each output stream
         'output_units'   : ['Unit', 'Unit', 'Unit'],

         # The programmer who wrote this distillate. First level directory name
         'author'         : 'CAB',

         # The name of the type algorithm implemented. Second level directory name
         'name'           : 'New Output Frequency',

         # The version of the code. Increment this to overwrite existing data from an older 
         #   version of this code
         'version'        : 6,

         # Plaintext name of the function defined above. This passes a 'function reference'
         #   that can be called in another program
         'algorithm'      : algorithm }

# The following two lines instantiate the distillate class and begin begin the distillation
qdf.register(Distillate(), opts) #instantiates an object with your parameters and algorithm
qdf.begin() # enters the program and runs the distillation program