Measurements of effluents reported on the Discharge Monitoring Report
        (DMR). The violations are detected by comparing the measurement values
        against the corresponding effluent limit.

        >>> PCS().dmr_measurement('season_num', 2)
551024
def dmr_measurement(self, column=None, value=None, **kwargs):
        
        return self._resolve_call('PCS_DMR_MEASUREMENT', column, value, **kwargs)
1183628
def _parse_sensor_record(self, sensor_data_rec, sensor_info, rem_values):
        
        val_idx = 0

        # @TODO seems there is only a single field in each of these
        assert len(sensor_data_rec.field) == 1
        sensor_data_array = sensor_data_rec.field[0].content

        # there is probably not going to be a count in the def, it'll be in the data
        count = None
        count_text = sensor_data_array.elementCount.text
        if count_text:
            count = int(count_text.strip())

        if not count:
            count = int(rem_values[val_idx])
            val_idx += 1

        parsed = []

        for recnum in range(count):
            cur = []

            for f in sensor_data_array.elementType.field:
                cur_val = rem_values[val_idx]
                val_idx += 1

                m = Member(name=f.name, standard=f.content.definition)

                if hasattr(f.content, "uom"):
                    m["units"] = f.content.uom

                try:
                    m["value"] = float(cur_val)
                except ValueError:
                    m["value"] = cur_val

                if len(f.quality):
                    m["quality"] = []
                    for qual in f.quality:
                        cur_qual = rem_values[val_idx]
                        val_idx += 1

                        # @TODO check this against constraints
                        m["quality"].append(cur_qual)

                cur.append(m)

            parsed.append(cur)

        return parsed, val_idx
1302781
def report_stats(self):
        """"""
        if not self.previous:
            self.previous = dict()
            for key in self.counters:
                self.previous[key] = 0
        values = {
            'name': self.name,
            'consumer_name': self.consumer_name,
            'counts': dict(self.counters),
            'previous': dict(self.previous)
        }
        self.previous = dict(self.counters)
        return values
518553
def analyze(self, chunkSize, *sinks):
        
        measureSize = False
        if self.measureSize:
            for sink in sinks:
                if sink.isRemote:
                    measureSize = True

        # Use destination (already uploaded) edges first
        sinks = list(sinks)
        sinks.reverse()
        self.dest = sinks[0]

        def currentSize():
            return sum([
                n.diffSize
                for n in self.nodes.values()
                if n.diff is not None and n.diff.sink != self.dest
            ])

        while True:
            self._analyzeDontMeasure(chunkSize, measureSize, *sinks)

            if not measureSize:
                return

            estimatedSize = currentSize()

            # logger.info("Measuring any estimated diffs")

            for node in self.nodes.values():
                edge = node.diff
                if edge is not None and edge.sink != self.dest and edge.sizeIsEstimated:
                    edge.sink.measureSize(edge, chunkSize)

            actualSize = currentSize()

            logger.info(
                "measured size (%s), estimated size (%s)",
                humanize(actualSize), humanize(estimatedSize),
            )

            if actualSize <= 1.2 * estimatedSize:
                return
873601
def _measurements(session_group, metric_name):
  
  for session_index, session in enumerate(session_group.sessions):
    metric_value = _find_metric_value(session, metric_name)
    if not metric_value:
      continue
    yield _Measurement(metric_value, session_index)
647169
def perfcounters(infile):
    
    measurements = []
    with open(infile, 'r') as in_file:
        read_struct(in_file)
        for region_struct in read_structs(in_file):
            region = region_struct["1"][1]
            core_info = region_struct["Region Info"]
            measurements += \
                get_measurements(region, core_info, region_struct)

            for table_struct in read_tables(in_file):
                core_info = None
                if "Event" in table_struct:
                    offset = 1
                    core_info = table_struct["Event"][offset:]
                    measurements += get_measurements(region, core_info,
                                                     table_struct, offset)
                elif "Metric" in table_struct:
                    core_info = table_struct["Metric"]
                    measurements += get_measurements(region, core_info,
                                                     table_struct)
    return measurements
601423
def measure_board_rms(control_board, n_samples=10, sampling_ms=10,
                      delay_between_samples_ms=0):
    '''
    
    '''
    try:
        results = control_board.measure_impedance(n_samples, sampling_ms,
                                                  delay_between_samples_ms,
                                                  True, True, [])
    except RuntimeError:
        # `RuntimeError` may be raised if, for example, current limit was
        # reached during measurement.  In such cases, return an empty frame.
        logger.warning('Error encountered during high-voltage RMS '
                       'measurement.', exc_info=True)
        data = pd.DataFrame(None, columns=['board measured V',
                                           'divider resistor index'])
    else:
        data = pd.DataFrame({'board measured V': results.V_hv})
        data['divider resistor index'] = results.hv_resistor
    return data
579509
def <<(measurement)
      # Make sure the value provided is a datapoint
      datapoint = cast_to_datapoint(measurement)

      # If only_save_changes is true, ignore datapoints whose value is the same as the current value
      if only_save_changes and BigDecimal.new(datapoint.value) == BigDecimal.new(current_value)
        @logger.debug "Ignoring datapoint from #{datapoint.at} because value did not change from #{current_value}"
      else
        @current_value = datapoint.value
        datapoints << datapoint
        @logger.debug "Queuing datapoint from #{datapoint.at} with value #{current_value}"
      end

      # See if the buffer is full
      check_datapoints_buffer
    end
385593
def filter_record(self, record):
        
        quality_scores = record.letter_annotations['phred_quality']

        mean_score = mean(quality_scores)
        if mean_score >= self.min_mean_score:
            return record
        else:
            raise FailedFilter(mean_score)
138778
def process_eni_metrics(
        stream_eni, myips, stream,
        start, end, period, sample_size,
        resolver, sink_uri):
    """"""
    stats = Counter()
    period_counters = flow_stream_stats(myips, stream, period)
    client = InfluxDBClient.from_dsn(sink_uri)
    resource = resolver.resolve_resource(stream_eni)
    points = []

    for period in sorted(period_counters):
        pc = period_counters[period]
        pd = datetime.fromtimestamp(period)

        for t in ('inbytes', 'outbytes'):
            tpc = pc[t]
            ips = [ip for ip, _ in tpc.most_common(sample_size)]
            resolved = resolver.resolve(ips, pd - timedelta(900), pd + timedelta(900))
            logical_counter = rollup_logical(tpc, resolved, ('app', 'env'))
            for (app, env), v in logical_counter.items():
                p = {}
#                rinfo = resolved.get(ip, {})
                p['fields'] = {'Bytes': v}
                p['measurement'] = 'traffic_%s' % t
                p['time'] = datetime.fromtimestamp(period)
                p['tags'] = {
                    'Kind': resource['type'],
                    'AccountId': resource['account_id'],
                    'App': resource['app'],
                    'Env': resource['env'],
                    'ForeignApp': app,
                    'ForeignEnv': env}
                points.append(p)

        if len(points) > 2000:
            client.write_points(points)
            stats['Points'] += len(points)
            points = []

    client.write_points(points)
    stats['Points'] += len(points)
    log.info('periods:%d resource:%s points:%d',
             len(period_counters), resource, stats['Points'])
    return stats
440172
Stream<DynatraceCustomMetric> writeMeter(Meter meter) {
        final long wallTime = clock.wallTime();
        return StreamSupport.stream(meter.measure().spliterator(), false)
                .map(Measurement::getValue)
                .filter(Double::isFinite)
                .map(value -> createCustomMetric(meter.getId(), wallTime, value));
    }
331722
def _sweep(self):
        
        while self.running:
            for am in list(self.activeMeasurements):
                now = datetime.datetime.utcnow()
                # devices were allocated and have completed == complete
                recordingDeviceCount = len(am.recordingDevices)
                if recordingDeviceCount > 0:
                    if all(entry['state'] == RecordStatus.COMPLETE.name for entry in am.recordingDevices.values()):
                        logger.info("Detected completedmeasurement " + am.id)
                        self._moveToComplete(am)

                # we have reached the end time and we have either all failed devices or no devices == kill
                if now > (am.endTime + datetime.timedelta(days=0, seconds=1)):
                    allFailed = all(entry['state'] == RecordStatus.FAILED.name
                                    for entry in am.recordingDevices.values())
                    if (recordingDeviceCount > 0 and allFailed) or recordingDeviceCount == 0:
                        logger.warning("Detected failed measurement " + am.id + " with " + str(recordingDeviceCount)
                                       + " devices, allFailed: " + str(allFailed))
                        self._moveToFailed(am)

                # we are well past the end time and we have failed devices or an ongoing recording == kill or deathbed
                if now > (am.endTime + datetime.timedelta(days=0, seconds=self.maxTimeTilDeathbedSeconds)):
                    if any(entry['state'] == RecordStatus.FAILED.name for entry in am.recordingDevices.values()):
                        logger.warning("Detected failed and incomplete measurement " + am.id + ", assumed dead")
                        self._moveToFailed(am)
                    elif all(entry['state'] == RecordStatus.RECORDING.name for entry in am.recordingDevices.values()):
                        self._handleDeathbed(am)
            time.sleep(0.1)
        logger.warning("MeasurementCaretaker is now shutdown")
1347308
def standard_deviation(data, period):
    
    catch_errors.check_for_period_error(data, period)

    stds = [np.std(data[idx+1-period:idx+1], ddof=1) for idx in range(period-1, len(data))]

    stds = fill_for_noncomputable_vals(data, stds)
    return stds
1274301
private void reportMeter(String name, Meter meter) {
        String prefixedName = prefix(name);
        if (!snapshots.hasDescriptor(prefixedName)) {

            MetricItem.Builder builder = MetricItem.Builder.create();

            builder.events("events");

            builder.events("m1_rate", 1, rateUnit);
            builder.events("m5_rate", 5, rateUnit);
            builder.events("m15_rate", 15, rateUnit);
            builder.events("mean_rate", rateUnit);
            snapshots.setDescriptor(prefixedName, builder.build());
        }

        Map<String, Number> values = new HashMap<>();

        addMetered(meter, values, "events");

        snapshots.addSnapshot(prefixedName, getTimestamp(), values);
    }
255855
def dre_dm(self, pars):
        
        """
        self._set_parameters(pars)
        terms = self.num / self.denom
        result = - self.sigmai * terms

        return result
607057
def _len_sec_desc(self):
    ''''''
    return len(self.header) + len(self.owner_sid) + len(self.group_sid) + len(self.sacl) + len(self.dacl)
807430
function() {
		return (
			( (!!this.pulse1.lengthCounter) << 0 ) |
			( (!!this.pulse2.lengthCounter) << 1 ) |
			( (!!this.triangle.lengthCounter) << 2 ) |
			( (!!this.noise.lengthCounter) << 3 ) |
			( (!!this.dmc.sampleBytesLeft) << 4 )
		);
	}