 Timestamp:
 10/25/12 10:42:13 (8 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

SHX/trunk/SeismicHandler/modules/filters.py
r796 r798 22 22 """ 23 23 def __init__(self, filter_type=None, filename=None, pos=None, 24 input_coeff=[], output_coeff=[]):24 poles=[], zeros=[], input_coeff=[], output_coeff=[]): 25 25 """ 26 26 Initialize filter object from filter file. … … 32 32 self.input_coeff = input_coeff 33 33 self.output_coeff = output_coeff 34 self.zeros = zeros 35 self.poles = poles 36 37 def complexify(self): 38 """ 39 Parse string content of "poles" and "zeros" into complex numbers. 40 """ 41 self.input_coeff = [] 42 for _i in self.zeros: 43 self.input_coeff.append(complexifyString(_i)) 44 self.output_coeff = [] 45 for _i in self.poles: 46 self.output_coeff.append(complexifyString(_i)) 34 47 35 48 def inverse(self): … … 69 82 # set doc string from comment 70 83 while True: 71 line = lines.pop(0) 72 line.strip() 84 line = lines.pop(0).strip() 73 85 # add comment to doc string 74 86 if line.startswith('!'): 75 87 self.__doc__ += line[1:] 76 88 continue 77 import pdb; pdb.set_trace()78 89 # test for "magic" number 1357913578 79 90 if not line.startswith("1357913578"): … … 94 105 filter_type = int(lines.pop(0)) 95 106 filter = Filter(filter_type, self.filename, pos) 96 filter. input_coeff= []97 filter. output_coeff= []107 filter.poles = [] 108 filter.zeros = [] 98 109 99 110 if filter_type == 1: … … 103 114 nol = int(lines.pop(0)) 104 115 for _ in xrange(nol): 105 temp = complexifyString(lines.pop(0)) 106 filter.input_coeff.append(temp) 116 filter.zeros.append(lines.pop(0)) 107 117 # read output coefficient 108 118 nol = int(lines.pop(0)) 109 119 for _ in xrange(nol): 110 temp = complexifyString(lines.pop(0))111 filter.output_coeff.append(temp)120 filter.poles.append(lines.pop(0)) 121 filter.complexify() 112 122 elif filter_type == 2: 113 123 # FLT  digital filter … … 115 125 # read coefficients 116 126 for _ in xrange(nol): 117 temp = [float(_i) for _i in lines.pop(0).split()] 118 filter.input_coeff.append(temp) 127 temp = [_i for _i in lines.pop(0).split()] 128 filter.poles.append(temp) 129 filter.input_coeff.append(map(float, temp)) 119 130 elif filter_type == 3: 120 131 # FLR files  Finite Impulse Response (FIR) … … 128 139 nol = int(lines.pop(0)) 129 140 for _ in xrange(nol): 130 filter.output_coeff.append(float(lines.pop(0))) 141 temp = lines.pop(0) 142 filter.poles.append(lines.pop(0)) 143 filter.output_coeff.append(float(temp)) 131 144 else: 132 145 raise
Note: See TracChangeset
for help on using the changeset viewer.