示例#1
0
	def _parseStages(self, filterIndex, line):
		chains = {}
		decimations = line.split(",")
		for decimation in decimations:
			if decimation.find("_") == -1:
				rate = decimation
				stringstages = None
			else:
				(rate, stringstages) = decimation.split("_")
			(num, den) =  parsers._rational(decimal.Decimal(rate))
			stages = []
			if stringstages:
				for stage in stringstages.split("/"):
					if len(stage) and stage[0] == 'A':
						stages.append(str(filterIndex + "_digipaz_" + stage[1:]))
					elif len(stage) and  stage[0] == 'I':
						stages.append(str(filterIndex + "_iirpaz_" + stage[1:]))
					elif len(stage):
						stages.append(str(filterIndex + "_FIR_" + stage))
					else:
						raise Exception("Invalid Elo-In-Chain")
			if (num, den) in chains:
				raise Exception("%s has a duplicate rate chain Numerator=%s Denominator=%s" % (self.id, num, den))
			else:
				chains[(num, den)] = stages
		return chains
示例#2
0
 def _parseStages(self, filterIndex, line):
     chains = {}
     decimations = line.split(",")
     for decimation in decimations:
         if decimation.find("_") == -1:
             rate = decimation
             stringstages = None
         else:
             (rate, stringstages) = decimation.split("_")
         (num, den) = parsers._rational(decimal.Decimal(rate))
         stages = []
         if stringstages:
             for stage in stringstages.split("/"):
                 if len(stage) and stage[0] == 'A':
                     stages.append(
                         str(filterIndex + "_digipaz_" + stage[1:]))
                 elif len(stage) and stage[0] == 'I':
                     stages.append(str(filterIndex + "_iirpaz_" +
                                       stage[1:]))
                 elif len(stage):
                     stages.append(str(filterIndex + "_FIR_" + stage))
                 else:
                     raise Exception("Invalid Elo-In-Chain")
         if (num, den) in chains:
             raise Exception(
                 "%s has a duplicate rate chain Numerator=%s Denominator=%s"
                 % (self.id, num, den))
         else:
             chains[(num, den)] = stages
     return chains
示例#3
0
	def _parseSampling(self, sampling):
		_rx_samp = re.compile(r'(?P<band_code>[A-Z])?(?P<sample_rate>.*)$')
		endPreamble = sampling.find('_')
		if endPreamble > 0:
			for x in sampling[:endPreamble].split('/'):
				if x[0] == 'F':
					self.compression = x[1:]
				elif x[0] == 'L':
					self.location = x[1:]
				elif x[0] == 'T':
					self.gainCode = x[1:]
				else:
					raise Exception("unknown Preemble code %s in %s" % (x[0], sampling))
			
		for x in sampling[endPreamble+1:].split('/'):
			m = _rx_samp.match(x)
			if not m:
				raise Exception("error parsing sampling %s at %s" % (sampling, x))
				
			try:
				sample_rate = decimal.Decimal(m.group('sample_rate'))
			except decimal.InvalidOperation:
				raise Exception("error parsing sampling %s at %s" % (sampling, x))
			
			band_code = m.group('band_code')
			
			if not band_code:
				if sample_rate >= 80:
					band_code = 'H'
				elif sample_rate >= 40:
					band_code = 'S'
				elif sample_rate > 1:
					band_code = 'B'
				elif sample_rate == 1:
					band_code = 'L'
				elif sample_rate == decimal.Decimal("0.1"):
					band_code = 'V'
				elif sample_rate == decimal.Decimal("0.01"):
					band_code = 'U'
				else:
					raise Exception("could not determine band code for %s in %s" (x, sampling))
			
			for orientation in self.orientations:
				code = band_code + self.gainCode + orientation
				if code in self.channels:
					raise Exception("channel code %s aready exists for rate %s " % (band_code, sample_rate))
				try:
					(numerator, denominator) = parsers._rational(sample_rate)
				except Exception,e:
					raise Exception("Error converting sample_rate (%s)" % e)
				self.channels[code] = { 'SampleRateNumerator': numerator,
										'SampleRateDenominator': denominator }
				self.channels[code].update(self.orientations[orientation])
示例#4
0
    def _parseSampling(self, sampling):
        _rx_samp = re.compile(r'(?P<band_code>[A-Z])?(?P<sample_rate>.*)$')
        endPreamble = sampling.find('_')
        if endPreamble > 0:
            for x in sampling[:endPreamble].split('/'):
                if x[0] == 'F':
                    self.compression = x[1:]
                elif x[0] == 'L':
                    self.location = x[1:]
                elif x[0] == 'T':
                    self.gainCode = x[1:]
                else:
                    raise Exception("unknown Preemble code %s in %s" %
                                    (x[0], sampling))

        for x in sampling[endPreamble + 1:].split('/'):
            m = _rx_samp.match(x)
            if not m:
                raise Exception("error parsing sampling %s at %s" %
                                (sampling, x))

            try:
                sample_rate = decimal.Decimal(m.group('sample_rate'))
            except decimal.InvalidOperation:
                raise Exception("error parsing sampling %s at %s" %
                                (sampling, x))

            band_code = m.group('band_code')

            if not band_code:
                if sample_rate >= 80:
                    band_code = 'H'
                elif sample_rate >= 40:
                    band_code = 'S'
                elif sample_rate > 1:
                    band_code = 'B'
                elif sample_rate == 1:
                    band_code = 'L'
                elif sample_rate == decimal.Decimal("0.1"):
                    band_code = 'V'
                elif sample_rate == decimal.Decimal("0.01"):
                    band_code = 'U'
                else:
                    raise Exception(
                        "could not determine band code for %s in %s" (
                            x, sampling))

            for orientation in self.orientations:
                code = band_code + self.gainCode + orientation
                if code in self.channels:
                    raise Exception(
                        "channel code %s aready exists for rate %s " %
                        (band_code, sample_rate))
                try:
                    (numerator, denominator) = parsers._rational(sample_rate)
                except Exception as e:
                    raise Exception("Error converting sample_rate (%s)" % e)
                self.channels[code] = {
                    'SampleRateNumerator': numerator,
                    'SampleRateDenominator': denominator
                }
                self.channels[code].update(self.orientations[orientation])