def load_kinsim(filename, sample_period, duration):
    time, factin_d, pi_d, atp_d = io.data.load_data(filename)
    factin = time, factin_d
    pi = time, pi_d
    atp = time, atp_d

    sample_times = numpy.arange(0, duration + float(sample_period)/2,
                                sample_period)

    sampled_factin = interpolation.resample_measurement(factin, sample_times)
    sampled_pi     = interpolation.resample_measurement(pi, sample_times)
    sampled_atp    = interpolation.resample_measurement(atp, sample_times)

    return sampled_factin, sampled_pi, sampled_atp
Exemple #2
0
def load_kinsim(filename, sample_period, duration):
    time, factin_d, pi_d, atp_d = io.data.load_data(filename)
    factin = time, factin_d
    pi = time, pi_d
    atp = time, atp_d

    sample_times = numpy.arange(0, duration + float(sample_period) / 2,
                                sample_period)

    sampled_factin = interpolation.resample_measurement(factin, sample_times)
    sampled_pi = interpolation.resample_measurement(pi, sample_times)
    sampled_atp = interpolation.resample_measurement(atp, sample_times)

    return sampled_factin, sampled_pi, sampled_atp
Exemple #3
0
    def perform(self, run, target):
        log.debug('Performing SimpleDataFit of %s.', self.measurement_name)
        sim_result = run.analyses[self.measurement_name]
        data = run.experiment.objectives[self.label].measurement
        sim_result = _measurements.skip_beginning(sim_result,
                                                  self.skip_beginning)
        sim_result = _measurements.scale(sim_result, self.scale_simulation_by)

        if self.interpolate_simulation:
            interp = _interpolation.resample_measurement(sim_result, data[0])

            #            log.debug('interp times: %s', interp[0])
            log.debug('Sim  values: %s', interp[1])
            log.debug('Data values: %s', data[1])

            target.value = self.residual_function(interp, data)
        else:
            target.value = self.residual_function(sim_result, data)

            log.debug('Sim  values: %s', sim_result[1])
            log.debug('Data values: %s', data[1])
        log.debug('Objective value: %s.', target.value)

        if target.value <= 0:
            log.warn('Negative or zero residual found %s.', target.value)
    def perform(self, simulation_results, result_factory):
        value_collection = []
#        sample_period = None
        sample_times = numpy.arange(self.start_time,
                self.stop_time + self.sample_period/2, self.sample_period)
        for simulation in simulation_results:
            times, values = simulation['filaments'][0]['measurements'
                    ][self.measurement_name]
            stimes, sampled_values = interpolation.resample_measurement(
                    (times, values), sample_times, method='previous_value')

#            if not sample_period and len(times) > 1:
#                sample_period = float(times[1] - times[0])
            value_collection.append(sampled_values)

        # calculate velocities collection
        velocity_collection = [numpy.diff(v) / self.sample_period
                for v in value_collection]

        # collection get mean/std -> threshold
        mean, std = correlation.collection_stats(velocity_collection)
        threshold = mean + self.std_devs * std

        # do autocorrelation
        if 'above' == self.side.lower():
            matched_collection = [numpy.array(velocities > threshold, dtype=int)
                    for velocities in velocity_collection]
        else:
            matched_collection = [numpy.array(velocities < threshold, dtype=int)
                    for velocities in velocity_collection]

        measurement = correlation.aggregate_autocorrelation(self.sample_period,
                matched_collection)

        return result_factory(measurement, label=self.label)
    def perform(self, run, target):
        log.debug('Performing SimpleDataFit of %s.', self.measurement_name)
        sim_result = run.analyses[self.measurement_name]
        data = run.experiment.objectives[self.label].measurement
        sim_result = _measurements.skip_beginning(sim_result,
                self.skip_beginning)
        sim_result = _measurements.scale(sim_result, self.scale_simulation_by)

        if self.interpolate_simulation:
            interp = _interpolation.resample_measurement(sim_result, data[0])

#            log.debug('interp times: %s', interp[0])
            log.debug('Sim  values: %s', interp[1])
            log.debug('Data values: %s', data[1])

            target.value = self.residual_function(interp, data)
        else:
            target.value = self.residual_function(sim_result, data)

            log.debug('Sim  values: %s', sim_result[1])
            log.debug('Data values: %s', data[1])
        log.debug('Objective value: %s.', target.value)

        if target.value <= 0:
            log.warn('Negative or zero residual found %s.', target.value)
 def get_sampled_measurements(self, simulation_results):
     raw_measurements = utils.get_measurement(simulation_results,
                                              self.measurement_name,
                                              self.measurement_type)
     sample_times = workalike.arange(self.start_time, self.stop_time,
                                     self.sample_period)
     if not sample_times:
         _log.error('Sample time length is 0.  ' +
                    'Measurement name: %s, stop_time: %s, period %s.',
                    self.measurement_name, self.stop_time,
                    self.sample_period)
     return [interpolation.resample_measurement(
        rm, sample_times, method=self.interpolation_method)
            for rm in raw_measurements]
def _get_timecourse(run, resample_times, poly_duration):
    # Grab the analysis
    times, values, errors = run.analyses['length']

    times = numpy.array(times)
    values = numpy.array(values)

    times -= poly_duration

    # resample
    sampled_values = numpy.array(_interpolation.resample_measurement(
        (times, values), resample_times)[1])

    numpy.putmask(sampled_values, sampled_values < 50, float('nan'))

    return sampled_values
 def get_sampled_measurements(self, simulation_results):
     raw_measurements = utils.get_measurement(simulation_results,
                                              self.measurement_name,
                                              self.measurement_type)
     sample_times = workalike.arange(self.start_time, self.stop_time,
                                     self.sample_period)
     if not sample_times:
         _log.error(
             'Sample time length is 0.  ' +
             'Measurement name: %s, stop_time: %s, period %s.',
             self.measurement_name, self.stop_time, self.sample_period)
     return [
         interpolation.resample_measurement(
             rm, sample_times, method=self.interpolation_method)
         for rm in raw_measurements
     ]
def _get_timecourse(run, resample_times, poly_duration):
    # Grab the analysis
    times, values, errors = run.analyses['length']

    times = numpy.array(times)
    values = numpy.array(values)

    times -= poly_duration

    # resample
    sampled_values = numpy.array(
        _interpolation.resample_measurement((times, values),
                                            resample_times)[1])

    numpy.putmask(sampled_values, sampled_values < 50, float('nan'))

    return sampled_values
    def run(self):
        full_filename = _ospath.join(self.base_directory, self.filename)
        f = _comments.CommentFilter.from_filename(full_filename)
        reader = _csv.reader(f, dialect=_DatDialect)

        results = []
        for row in reader:
            new_row = map(float, row)
            results.append(new_row)

        raw_results = zip(*results)
        if not self.interpolate_data:
            return raw_results

        sample_times = _workalike.arange(self.xmin, self.xmax,
                                         self.sample_period)
        return _interpolation.resample_measurement(raw_results, sample_times)
    def perform(self, simulation_results, result_factory):
        value_collection = []
        sample_times = numpy.arange(self.start_time,
                self.stop_time + self.sample_period/2, self.sample_period)
        for simulation in simulation_results:
            times, values = simulation['filaments'][0]['measurements'
                    ][self.measurement_name]
            stimes, sampled_values = interpolation.resample_measurement(
                    (times, values), sample_times, method='previous_value')

            values = numpy.array(sampled_values)
            matches = numpy.array(values == self.state, dtype=int)
            value_collection.append(matches)

        measurement = correlation.aggregate_autocorrelation(self.sample_period,
                value_collection)

        return result_factory(measurement, label=self.label)
    def perform(self, simulation_results, result_factory):
        value_collection = []
        sample_times = numpy.arange(self.start_time,
                                    self.stop_time + self.sample_period / 2,
                                    self.sample_period)
        for simulation in simulation_results:
            times, values = simulation['filaments'][0]['measurements'][
                self.measurement_name]
            stimes, sampled_values = interpolation.resample_measurement(
                (times, values), sample_times, method='previous_value')

            values = numpy.array(sampled_values)
            matches = numpy.array(values == self.state, dtype=int)
            value_collection.append(matches)

        measurement = correlation.aggregate_autocorrelation(
            self.sample_period, value_collection)

        return result_factory(measurement, label=self.label)
    def _get_pyrene_measurements(self, simulation):
        # Loop over each weight,
        times = numpy.arange(0, self.stop_time, self.sample_period)
        total = []
        for name, weight in self.weights.iteritems():
            raw = [f['measurements'][name] for f in simulation['filaments']]
            interpolated = []
            for rm in raw:
                junk_times, values = interpolation.resample_measurement(rm, times,
                        method='previous_value')
                values = numpy.array(values)
                if 0 == len(interpolated):
                    interpolated = values
                else:
                    interpolated += values
            interpolated *= weight
            if 0 == len(total):
                total = interpolated
            else:
                total += interpolated

        return times, total
Exemple #14
0
    def _get_pyrene_measurements(self, simulation):
        # Loop over each weight,
        times = numpy.arange(0, self.stop_time, self.sample_period)
        total = []
        for name, weight in self.weights.iteritems():
            raw = [f['measurements'][name] for f in simulation['filaments']]
            interpolated = []
            for rm in raw:
                junk_times, values = interpolation.resample_measurement(
                    rm, times, method='previous_value')
                values = numpy.array(values)
                if 0 == len(interpolated):
                    interpolated = values
                else:
                    interpolated += values
            interpolated *= weight
            if 0 == len(total):
                total = interpolated
            else:
                total += interpolated

        return times, total