Esempio n. 1
0
    def _read_data_array( self ):
        ''' Read the experiment data. 
        '''
        if exists( self.data_file ):

            print 'READ FILE'
            # change the file name dat with asc  
            file_split = self.data_file.split( '.' )

            file_name = file_split[0] + '.csv'
            if not os.path.exists( file_name ):

                file_name = file_split[0] + '.ASC'
                if not os.path.exists( file_name ):
                    raise IOException, 'file %s does not exist' % file_name

            print 'file_name', file_name

            # try to use loadtxt to read data file
            try:
                _data_array = loadtxt( file_name,
                                       delimiter = ';' )

            # loadtxt returns an error if the data file contains
            # 'NOVALUE' entries. In this case use the special 
            # method 'loadtxt_novalue'
            except ValueError:
                _data_array = loadtxt_novalue( file_name )

            self.data_array = _data_array
Esempio n. 2
0
    def _read_data_array(self):
        ''' Read the experiment data.
        '''
        if os.path.exists(self.data_file):

            print 'READ FILE'
            # change the file name dat with asc
            file_split = self.data_file.split('.')
            file_name = file_split[0] + '.csv'

            # for data exported into a single csv-file
            if os.path.exists(file_name):
                print 'check csv-file'
                file_ = open(file_name, 'r')
                header_line_1 = file_.readline().split()

                if header_line_1[0].split(';')[0] == 'Datum/Uhrzeit':
                    print 'read csv-file'
                    # for data exported into down sampled data array
                    try:
                        _data_array = np.loadtxt(file_name,
                                                 delimiter=';',
                                                 skiprows=2)
                        # reset time[sec] in order to start at 0.
                        _data_array[:0] -= _data_array[0:0]
                    except ValueError:
                        # for first column use converter method 'time2sec';
                        converters = {0: time2sec}
                        # for all other columns use converter method
                        # 'comma2dot'
                        for i in range(len(header_line_1[0].split(';')) - 1):
                            converters[i + 1] = comma2dot
                        _data_array = np.loadtxt(
                            file_name, delimiter=";", skiprows=2, converters=converters)

                        # reset time[sec] in order to start at 0.
                        _data_array[:0] -= _data_array[0:0]

                else:
                    # for data exported into DAT and ASC-files
                    # try to use loadtxt to read data file
                    try:
                        _data_array = np.loadtxt(file_name,
                                                 delimiter=';')

                    # loadtxt returns an error if the data file contains
                    # 'NOVALUE' entries. In this case use the special
                    # method 'loadtxt_novalue'
                    except ValueError:
                        _data_array = loadtxt_novalue(file_name)

            if not os.path.exists(file_name):
                file_name = file_split[0] + '.ASC'
                if not os.path.exists(file_name):
                    raise IOError, 'file %s does not exist' % file_name

                # for data exported into DAT and ASC-files
                # try to use loadtxt to read data file
                try:
                    _data_array = np.loadtxt(file_name,
                                             delimiter=';')

                # loadtxt returns an error if the data file contains
                # 'NOVALUE' entries. In this case use the special
                # method 'loadtxt_novalue'
                except ValueError:
                    _data_array = loadtxt_novalue(file_name)

            self.data_array = _data_array
Esempio n. 3
0
    def _read_data_array(self):
        ''' Read the experiment data.
        '''
        if os.path.exists(self.data_file):

            print 'READ FILE'
            # change the file name dat with asc
            file_split = self.data_file.split('.')
            file_name = file_split[0] + '.csv'

            # for data exported into a single csv-file
            if os.path.exists(file_name):
                print 'check csv-file'
                file_ = open(file_name, 'r')
                header_line_1 = file_.readline().split()

                if header_line_1[0].split(';')[0] == 'Datum/Uhrzeit':
                    print 'read csv-file'
                    # for data exported into down sampled data array
                    try:
                        _data_array = np.loadtxt(file_name,
                                                 delimiter=';',
                                                 skiprows=2)
                        # reset time[sec] in order to start at 0.
                        _data_array[:0] -= _data_array[0:0]
                    except ValueError:
                        # for first column use converter method 'time2sec';
                        converters = {0: time2sec}
                        # for all other columns use converter method
                        # 'comma2dot'
                        for i in range(len(header_line_1[0].split(';')) - 1):
                            converters[i + 1] = comma2dot
                        _data_array = np.loadtxt(
                            file_name, delimiter=";", skiprows=2, converters=converters)

                        # reset time[sec] in order to start at 0.
                        _data_array[:0] -= _data_array[0:0]

                else:
                    # for data exported into DAT and ASC-files
                    # try to use loadtxt to read data file
                    try:
                        _data_array = np.loadtxt(file_name,
                                                 delimiter=';')

                    # loadtxt returns an error if the data file contains
                    # 'NOVALUE' entries. In this case use the special
                    # method 'loadtxt_novalue'
                    except ValueError:
                        _data_array = loadtxt_novalue(file_name)

            if not os.path.exists(file_name):
                file_name = file_split[0] + '.ASC'
                if not os.path.exists(file_name):
                    raise IOError, 'file %s does not exist' % file_name

                # for data exported into DAT and ASC-files
                # try to use loadtxt to read data file
                try:
                    _data_array = np.loadtxt(file_name,
                                             delimiter=';')

                # loadtxt returns an error if the data file contains
                # 'NOVALUE' entries. In this case use the special
                # method 'loadtxt_novalue'
                except ValueError:
                    _data_array = loadtxt_novalue(file_name)

            self.data_array = _data_array