Exemplo n.º 1
0
 def create_datatype_measure(self, analyzed_entity, operation=None, storage_path=None):
     """
     :return: persisted DatatypeMeasure
     """
     if operation is None:
         operation, _, storage_path = self.__create_operation()
     measure = DatatypeMeasure(storage_path=storage_path, metrics=self.DATATYPE_MEASURE_METRIC)
     measure.analyzed_datatype = analyzed_entity
     adapter_instance = StoreAdapter([measure])
     OperationService().initiate_prelaunch(operation, adapter_instance, {})
     return measure
Exemplo n.º 2
0
 def create_datatype_measure(self, analyzed_entity, operation=None, storage_path=None):
     """
     :return: persisted DatatypeMeasure
     """
     if operation is None:
         operation, _, storage_path = self.__create_operation()
     measure = DatatypeMeasure(storage_path=storage_path, metrics=self.DATATYPE_MEASURE_METRIC)
     measure.analyzed_datatype = analyzed_entity
     adapter_instance = StoreAdapter([measure])
     OperationService().initiate_prelaunch(operation, adapter_instance, {})
     return measure
    def launch(self, time_series, algorithms=None):
        """ 
        Launch algorithm and build results.

        :param time_series: the time series on which the algorithms are run
        :param algorithms:  the algorithms to be run for computing measures on the time series
        :type  algorithms:  any subclass of BaseTimeseriesMetricAlgorithm (KuramotoIndex, \
                    GlobalVariance, VarianceNodeVariance)
        :rtype: `DatatypeMeasure`
        """
        if algorithms is None:
            algorithms = self.available_algorithms.keys()
        shape = time_series.read_data_shape()
        log_debug_array(LOG, time_series, "time_series")

        metrics_results = {}
        for algorithm_name in algorithms:
            ##------------- NOTE: Assumes 4D, Simulator timeSeries. --------------##
            node_slice = [
                slice(shape[0]),
                slice(shape[1]),
                slice(shape[2]),
                slice(shape[3])
            ]

            ##---------- Iterate over slices and compose final result ------------##
            unstored_ts = TimeSeries(use_storage=False)

            unstored_ts.data = time_series.read_data_slice(tuple(node_slice))

            ##-------------------- Fill Algorithm for Analysis -------------------##
            algorithm = self.available_algorithms[algorithm_name](
                time_series=unstored_ts)
            ## Validate that current algorithm's filter is valid.
            if (algorithm.accept_filter is not None and not algorithm.
                    accept_filter.get_python_filter_equivalent(time_series)):
                LOG.warning(
                    'Measure algorithm will not be computed because of incompatibility on input. '
                    'Filters failed on algo: ' + str(algorithm_name))
                continue
            else:
                LOG.debug("Applying measure: " + str(algorithm_name))

            unstored_result = algorithm.evaluate()
            ##----------------- Prepare a Float object for result ----------------##
            metrics_results[algorithm_name] = unstored_result

        result = DatatypeMeasure(analyzed_datatype=time_series,
                                 storage_path=self.storage_path,
                                 data_name=self._ui_name,
                                 metrics=metrics_results)
        return result