Beispiel #1
0
'''
Created on 24 kwi 2013

@author: jurek
'''
from hra_math.utils.utils import print_import_error
try:
    import numpy as np
    from hra_core.units import get_time_unit
    from hra_math.model.data_vector import DataVector
    from hra_math.utils.array_utils import \
        get_max_index_for_cumulative_sum_greater_then_value
    from hra_math.utils.array_utils import \
        get_max_index_for_cumulative_sum_of_means_greater_then_value
except ImportError as error:
    print_import_error(__name__, error)


class SegmenterManager(object):
    @staticmethod
    def getDataVectorSegmenter(data,
                               window_size_value,
                               window_size_unit=None,
                               sample_step=None,
                               shift=1,
                               stepper_size=None,
                               stepper_unit=None,
                               mark_last_segment=False):

        if window_size_value == None:
            return __OneRunSegmenter__(data, shift, mark_last_segment)
from hra_math.utils.utils import print_import_error
try:
    import collections
    import pylab as pl
    from hra_core.collections_utils import nvl
    from hra_core.misc import Params
    from hra_core.misc import is_positive
    from hra_math.model.data_vector import DataVector
    from hra_math.model.utils import get_unique_annotations
    from hra_math.utils.array_utils \
            import get_datetimes_array_as_miliseconds_intervals
    from hra_math.model.numerical_file_data_source \
            import NumericalFileDataSource
    from hra_math.model.text_file_data_source import TextFileDataSource
except ImportError as error:
    print_import_error(__name__, error)

__Entities__ = collections.namedtuple('__Entities__',
                                      ['signal', 'annotation', 'time'])


class DataVectorFileDataSource(object):
    """
    class to load numerical data file into data vector
    """

    def __init__(self, **params):
        self.params = Params(**params)
        self.__indexes__ = __Entities__(nvl(self.params.signal_index, -1),
                                       nvl(self.params.annotation_index, -1),
                                       nvl(self.params.time_index, -1))