1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

from __future__ import absolute_import, print_function 

 

from pyrocko.guts import Object, Timestamp 

 

 

class Constraint(Object): 

 

tmin = Timestamp.T(optional=True) 

tmax = Timestamp.T(optional=True) 

 

def contains(self, constraint): 

''' 

Check if the constraint completely includes a more restrictive one. 

''' 

 

if self.tmin is not None and constraint.tmin is not None: 

b1 = self.tmin <= constraint.tmin 

elif self.tmin is None: 

b1 = True 

else: 

b1 = False 

 

if self.tmax is not None and constraint.tmax is not None: 

b2 = constraint.tmax <= self.tmax 

elif self.tmax is None: 

b2 = True 

else: 

b2 = False 

 

return b1 and b2 

 

def expand(self, constraint): 

''' 

Widen constraint to include another given constraint. 

''' 

 

if constraint.tmin is None or self.tmin is None: 

self.tmin = None 

else: 

self.tmin = min(constraint.tmin, self.tmin) 

 

if constraint.tmax is None or self.tmax is None: 

self.tmax = None 

else: 

self.tmax = max(constraint.tmax, self.tmax) 

 

 

class Source(Object): 

 

def update_channel_inventory(self, squirrel, constraint): 

''' 

Let local inventory be up-to-date with remote for a given constraint. 

''' 

 

pass 

 

def update_event_inventory(self, squirrel, contraint): 

''' 

Let local inventory be up-to-date with remote for a given constraint. 

''' 

 

pass 

 

def update_waveform_inventory(self, squirrel, contraint): 

''' 

Let local inventory be up-to-date with remote for a given constraint. 

''' 

 

pass