Code Duplication    Length = 40-40 lines in 2 locations

rsudp/c_plot.py 1 location

@@ 82-121 (lines=40) @@
79
	:param queue.Queue q: queue of data and messages sent by :class:`rsudp.c_consumer.Consumer`
80
	:raise ImportError: if the module cannot import either of the Matplotlib Qt5 or TkAgg backends
81
	'''
82
	def _set_channels(self, cha):
83
		'''
84
		This function sets the channels available for plotting. Allowed units are as follows:
85
86
		- ``["SHZ", "EHZ", "EHN", "EHE"]`` - velocity channels
87
		- ``["ENZ", "ENN", "ENE"]`` - acceleration channels
88
		- ``["HDF"]`` - pressure transducer channel
89
		- ``["all"]`` - all available channels
90
91
		So for example, if you wanted to display the two vertical channels of a Shake 4D,
92
		(geophone and vertical accelerometer) you could specify:
93
94
		``["EHZ", "ENZ"]``
95
96
		You can also specify partial channel names.
97
		So for example, the following will display at least one channel from any
98
		Raspberry Shake instrument:
99
100
		``["HZ", "HDF"]``
101
102
		Or if you wanted to display only vertical channels from a RS4D,
103
		you could specify
104
105
		``["Z"]``
106
107
		which would match both ``"EHZ"`` and ``"ENZ"``.
108
109
		:param cha: the channel or list of channels to plot
110
		:type cha: list or str
111
		'''
112
		cha = rs.chns if ('all' in cha) else cha
113
		cha = list(cha) if isinstance(cha, str) else cha
114
		for c in rs.chns:
115
			n = 0
116
			for uch in cha:
117
				if (uch.upper() in c) and (c not in str(self.chans)):
118
					self.chans.append(c)
119
				n += 1
120
		if len(self.chans) < 1:
121
			self.chans = rs.chns
122
123
124
	def _set_deconv(self, deconv):

rsudp/c_write.py 1 location

@@ 19-58 (lines=40) @@
16
	:param queue.Queue q: queue of data and messages sent by :class:`rsudp.c_consumer.Consumer`
17
	:param bool debug: whether or not to display messages when writing data to disk.
18
	"""
19
	def _set_channels(self, cha):
20
		'''
21
		This function sets the channels available for plotting. Allowed units are as follows:
22
23
		- ``["SHZ", "EHZ", "EHN", "EHE"]`` - velocity channels
24
		- ``["ENZ", "ENN", "ENE"]`` - acceleration channels
25
		- ``["HDF"]`` - pressure transducer channel
26
		- ``["all"]`` - all available channels
27
28
		So for example, if you wanted to display the two vertical channels of a Shake 4D,
29
		(geophone and vertical accelerometer) you could specify:
30
31
		``["EHZ", "ENZ"]``
32
33
		You can also specify partial channel names.
34
		So for example, the following will display at least one channel from any
35
		Raspberry Shake instrument:
36
37
		``["HZ", "HDF"]``
38
39
		Or if you wanted to display only vertical channels from a RS4D,
40
		you could specify
41
42
		``["Z"]``
43
44
		which would match both ``"EHZ"`` and ``"ENZ"``.
45
46
		:param cha: the channel or list of channels to plot
47
		:type cha: list or str
48
		'''
49
		cha = rs.chns if ('all' in cha) else cha
50
		cha = list(cha) if isinstance(cha, str) else cha
51
		for c in rs.chns:
52
			n = 0
53
			for uch in cha:
54
				if (uch.upper() in c) and (c not in str(self.chans)):
55
					self.chans.append(c)
56
				n += 1
57
		if len(self.chans) < 1:
58
			self.chans = rs.chns
59
60
61
	def __init__(self, q, debug=False, cha='all'):