Exemple #1
0
 def find_mean(self, startUTCTimeStr, endUTCTimeStr):
     startTime = btrdb.date(startUTCTimeStr)     # returns nanoseconds since the epoch
     endTime   = btrdb.date(endUTCTimeStr)       # returns nanoseconds since the epoch
     summation = 0
     count = 0
     pw = int(math.ceil(math.log(endTime-startTime, 2)))-11
     overview = self.connection.get_stat(self.uuid, startTime, endTime, pw)
     for x in overview:
         summation += x[2]*x[4]
         count += x[4]
     return summation/count, count
 def find_mean(self, startUTCTimeStr, endUTCTimeStr):
     startTime = btrdb.date(
         startUTCTimeStr)  # returns nanoseconds since the epoch
     endTime = btrdb.date(
         endUTCTimeStr)  # returns nanoseconds since the epoch
     summation = 0
     count = 0
     pw = int(math.ceil(math.log(endTime - startTime, 2))) - 11
     overview = self.connection.get_stat(self.uuid, startTime, endTime, pw)
     for x in overview:
         summation += x[2] * x[4]
         count += x[4]
     return summation / count, count
 def multi_resolution_search(self,
                             startUTCTimeStr,
                             endUTCTimeStr,
                             ylabel,
                             threshold=0.1,
                             plotFlag=False,
                             benchmarkFlag=False):
     startTime = btrdb.date(
         startUTCTimeStr)  # returns nanoseconds since the epoch
     endTime = btrdb.date(
         endUTCTimeStr)  # returns nanoseconds since the epoch
     return self.visitor.traverse(self.uuid,
                                  self.connection,
                                  startTime,
                                  endTime,
                                  threshold,
                                  ylabel,
                                  plotFlag=plotFlag,
                                  benchmarkFlag=benchmarkFlag)
Exemple #4
0
def get_upmu_data(inputdt, upmu_path):
    """ Retrieves instantaneous P, Q, and voltage magnitude for specified datetime.

    Args:
        inputdt (datetime): timezone aware datetime object
        upmu_path (str): e.g., '/LBNL/grizzly_bus1/'
    Returns:
        {'P_A': , 'Q_A': , 'P_B': , 'Q_B': , 'P_C': , 'Q_C': ,
         'units': ('kW', 'kVAR'),
         'VMAG_A': , 'VMAG_B': , 'VMAG_C': }
    """

    bc = btrdb.HTTPConnection("miranda.cs.berkeley.edu")
    ur = btrdb.UUIDResolver("miranda.cs.berkeley.edu", "uuidresolver", "uuidpass", "upmu")

    # convert dt to nanoseconds since epoch
    epochns = btrdb.date(inputdt.strftime('%Y-%m-%dT%H:%M:%S'))

    # retrieve raw data from btrdb
    upmu_data = {}
    streams = ['L1MAG', 'L2MAG', 'L3MAG', 'C1MAG', 'C2MAG', 'C3MAG', 'L1ANG', 'L2ANG', 'L3ANG', 'C1ANG', 'C2ANG', 'C3ANG']
    for s in streams:
        pt = bc.get_stat(ur.resolve(upmu_path + s), epochns, epochns + int(9e6))
        upmu_data[s] = pt[0][2]

    output_dict = {}

    output_dict['P_A'] = (upmu_data['L1MAG']*upmu_data['C1MAG']*np.cos(upmu_data['L1ANG'] - upmu_data['C1ANG']))*1e-3
    output_dict['Q_A'] = (upmu_data['L1MAG']*upmu_data['C1MAG']*np.sin(upmu_data['L1ANG'] - upmu_data['C1ANG']))*1e-3

    output_dict['P_B'] = (upmu_data['L2MAG']*upmu_data['C2MAG']*np.cos(upmu_data['L2ANG'] - upmu_data['C2ANG']))*1e-3
    output_dict['Q_B'] = (upmu_data['L2MAG']*upmu_data['C2MAG']*np.sin(upmu_data['L2ANG'] - upmu_data['C2ANG']))*1e-3

    output_dict['P_C'] = (upmu_data['L3MAG']*upmu_data['C3MAG']*np.cos(upmu_data['L3ANG'] - upmu_data['C3ANG']))*1e-3
    output_dict['Q_C'] = (upmu_data['L3MAG']*upmu_data['C3MAG']*np.sin(upmu_data['L3ANG'] - upmu_data['C3ANG']))*1e-3

    output_dict['units'] = ('kW', 'kVAR', 'V')

    output_dict['VMAG_A'] = upmu_data['L1MAG']
    output_dict['VMAG_B'] = upmu_data['L2MAG']
    output_dict['VMAG_C'] = upmu_data['L3MAG']
    return output_dict
Exemple #5
0
 def multi_resolution_search_fw(self, startUTCTimeStr, endUTCTimeStr, ylabel, threshold=0.1, final_res=26, plotFlag=False, benchmarkFlag=False):
     startTime = btrdb.date(startUTCTimeStr)     # returns nanoseconds since the epoch
     endTime   = btrdb.date(endUTCTimeStr)       # returns nanoseconds since the epoch
     return self.visitor.traverse(self.uuid, self.connection, startTime, endTime, threshold, ylabel, final_res, plotFlag=plotFlag, benchmarkFlag=benchmarkFlag)