Пример #1
0
  def Print(self, I):

    if CU.IsType(I, 's'):
      I = self.GetIndex(I)

    if I != []:
      E = self.Events[I]

      print('Event Id: {0}'.format(E['Id']))
      print('Location:')
      for n, L in enumerate(E['Location']):
        print('[{0}] -'.format(n), end='')
        print('Year: {0}'.format(L['Year']), end='')
        print('Month: {0}'.format(L['Month']), end='')
        print('Day: {0}'.format(L['Day']), end='')
        print('Hour: {0}'.format(L['Hour']), end='')
        print('Minute: {0}'.format(L['Minute']), end='')
        print('Second: {0}'.format(L['Second']), end='')
        print('Latitude: {0}'.format(L['Latitude']), end='')
        print('Longitude: {0}'.format(L['Longitude']), end='')
        print('Depth: {0}'.format(L['Depth']), end='')
        print('Agency: {0}'.format(L['LocCode']), end='')
        print('Prime: {0}'.format(L['Prime']))
      print('Magnitude:')
      for m, M in enumerate(E['Magnitude']):
        print('[{0}] -'.format(m), end='')
        print('Type: {0}'.format(M['MagType']), end='')
        print('Size: {0}'.format(M['MagSize']), end='')
        print('Error: {0}'.format(M['MagError']), end='')
        print('Agency: {0}'.format(M['MagCode']))
      print('Log:')
      print('{0}'.format(E['Log']))

    else:
      print('Warning: Event not found')
Пример #2
0
  def DelEvent(self, I):

    if CU.IsType(I, 's'):
      I = self.GetIndex(I)
    else:
      I = int(I)

    if I != []:
      del self.Events[I]
    else:
      print('Warning: Event not found')
Пример #3
0
  def Filter(self,Key, Value, Opr='=',
                              Best=False,
                              All=False,
                              Owrite=True):

    def Search(Event, Value, Str0, Str1, Opr, Best):

      NewE = {}
      NewE[Str1] = []
      NewE[Str0] = []
      Klist = []

      """
      for V in Value:
        for E in Event[Str0]:
          if (Opr == '=') and (E[Key] == V):
              NewE[Str0].append(E)
          if (Opr == '!=') and (E[Key] != V):
              NewE[Str0].append(E)
          if (Opr == '>') and (E[Key] > V):
              NewE[Str0].append(E)
          if (Opr == '<') and (E[Key] < V):
              NewE[Str0].append(E)
          if (Opr == '>=') and (E[Key] >= V):
              NewE[Str0].append(E)
          if (Opr == '<=') and (E[Key] <= V):
              NewE[Str0].append(E)
      """

      for E in Event[Str0]:
        if (Opr == '=') and any([V==E[Key] for V in Value]):
            NewE[Str0].append(E)
        if (Opr == '!=') and not any([V==E[Key] for V in Value]):
            NewE[Str0].append(E)
        if (Opr == '>') and any([V<E[Key] for V in Value]):
            NewE[Str0].append(E)
        if (Opr == '<') and any([V>E[Key] for V in Value]):
            NewE[Str0].append(E)
        if (Opr == '>=') and any([V<=E[Key] for V in Value]):
            NewE[Str0].append(E)
        if (Opr == '<=') and any([V>=E[Key] for V in Value]):
            NewE[Str0].append(E)

      Klist = [k[Key] for k in NewE[Str0]]

      if NewE[Str0]:
        NewE['Id'] = Event['Id']
        NewE['Log'] = Event['Log']
        NewE[Str1] = Event[Str1]
        if Best:
          NewE[Str0] = [NewE[Str0][0]]

      return NewE, Klist

    Out = Database()
    Out.Header = cp.deepcopy(self.Header)

    if not CU.IsType(Value, 'l'):
      Value = [Value]

    Group = CU.KeyGroup(Key)

    for E in self.Events:
      if Group == 'Location':
        E, Klist = Search(E, Value, 'Location', 'Magnitude', Opr, Best)
      if Group == 'Magnitude':
        E, Klist = Search(E, Value, 'Magnitude', 'Location', Opr, Best)
      if E['Location'] or E['Magnitude']:
        if All:
          if sorted(Value) == sorted(set(Klist)):
            Out.Events.append(cp.deepcopy(E))
        else:
          Out.Events.append(cp.deepcopy(E))

    if Owrite:
      self.Events = Out.Events
    else:
      return Out