qcodes/data/gnuplot_format.py
def read_one_file(self, data_set, f, ids_read):
        """
        Called by Formatter.read to bring one data file into
        a DataSet. Setpoint data may be duplicated across multiple files,
        but each measured DataArray must only map to one file.

        args:
            data_set: the DataSet we are reading into
            f: a file-like object to read from
            ids_read: a `set` of array_ids that we have already read.
                when you read an array, check that it's not in this set (except
                setpoints, which can be in several files with different inner loop)
                then add it to the set so other files know not to read it again
        """
        if not f.name.endswith(self.extension):
            return

        arrays = data_set.arrays
        ids = self._read_comment_line(f).split()
        labels = self._get_labels(self._read_comment_line(f))
        shape = tuple(map(int, self._read_comment_line(f).split()))
        ndim = len(shape)

        set_arrays = ()
        data_arrays = []
        indexed_ids = list(enumerate(ids))

        for i, array_id in indexed_ids[:ndim]:
            snap = data_set.get_array_metadata(array_id)

            # setpoint arrays
            set_shape = shape[: i + 1]
            if array_id in arrays:
                set_array = arrays[array_id]
                if set_array.shape != set_shape:
                    raise ValueError(
                        'shapes do not match for set array: ' + array_id)
                if array_id not in ids_read:
                    # it's OK for setpoints to be duplicated across
                    # multiple files, but we should only empty the
                    # array out the first time we see it, so subsequent
                    # reads can check for consistency
                    set_array.clear()
            else:
                set_array = DataArray(label=labels[i], array_id=array_id,
                                      set_arrays=set_arrays, shape=set_shape,
                                      is_setpoint=True, snapshot=snap)
                set_array.init_data()
                data_set.add_array(set_array)

            set_arrays = set_arrays + (set_array, )
            ids_read.add(array_id)

        for i, array_id in indexed_ids[ndim:]:
            snap = data_set.get_array_metadata(array_id)

            # data arrays
            if array_id in ids_read:
                raise ValueError('duplicate data id found: ' + array_id)

            if array_id in arrays:
                data_array = arrays[array_id]
                data_array.clear()
            else:
                data_array = DataArray(label=labels[i], array_id=array_id,
                                       set_arrays=set_arrays, shape=shape,
                                       snapshot=snap)
                data_array.init_data()
                data_set.add_array(data_array)
            data_arrays.append(data_array)
            ids_read.add(array_id)

        indices = [0] * ndim
        first_point = True
        resetting = 0
        for line in f:
            if self._is_comment(line):
                continue

            # ignore leading or trailing whitespace (including in blank lines)
            line = line.strip()

            if not line:
                # each consecutive blank line implies one more loop to reset
                # when we read the next data point. Don't depend on the number
                # of setpoints that change, as there could be weird cases, like
                # bidirectional sweeps, or highly diagonal sweeps, where this
                # is incorrect. Anyway this really only matters for >2D sweeps.
                if not first_point:
                    resetting += 1
                continue

            values = tuple(map(float, line.split()))

            if resetting:
                indices[-resetting - 1] += 1
                indices[-resetting:] = [0] * resetting
                resetting = 0

            for value, set_array in zip(values[:ndim], set_arrays):
                nparray = set_array.ndarray
                myindices = tuple(indices[:nparray.ndim])
                stored_value = nparray[myindices]
                if math.isnan(stored_value):
                    nparray[myindices] = value
                elif stored_value != value:
                    raise ValueError('inconsistent setpoint values',
                                     stored_value, value, set_array.name,
                                     myindices, indices)

            for value, data_array in zip(values[ndim:], data_arrays):
                # set .ndarray directly to avoid the overhead of __setitem__
                # which updates modified_range on every call
                data_array.ndarray[tuple(indices)] = value

            indices[-1] += 1
            first_point = False

        # Since we skipped __setitem__, back up to the last read point and
        # mark it as saved that far.
        # Using mark_saved is better than directly setting last_saved_index
        # because it also ensures modified_range is set correctly.
        indices[-1] -= 1
        for array in set_arrays + tuple(data_arrays):
            array.mark_saved(array.flat_index(indices[:array.ndim]))

        Called by Formatter.read to bring one data file into
        a DataSet. Setpoint data may be duplicated across multiple files,
        but each measured DataArray must only map to one file.

        args:
            data_set: the DataSet we are reading into
            f: a file-like object to read from
            ids_read: a `set` of array_ids that we have already read.
                when you read an array, check that it's not in this set (except
                setpoints, which can be in several files with different inner loop)
                then add it to the set so other files know not to read it again
        
Called by Formatter.read to bring one data file into
a DataSet. Setpoint data may be duplicated across multiple files,
but each measured DataArray must only map to one file.

the DataSet we are reading into
f: a file-like object to read from
ids_read: a `set` of array_ids that we have already read.
when you read an array, check that it's not in this set (except
setpoints, which can be in several files with different inner loop)
then add it to the set so other files know not to read it again
Called by Formatter . read to bring one data file into a DataSet . Setpoint data may be duplicated across multiple files but each measured DataArray must only map to one file . the DataSet we are reading into f : a file - like object to read from ids_read : a ` set ` of array_ids that we have already read . when you read an array check that it ' s not in this set ( except setpoints which can be in several files with different inner loop ) then add it to the set so other files know not to read it again
def read_one_file(self, data_set, f, ids_read):
        if not f.name.endswith(self.extension):
            return
        arrays = data_set.arrays
        ids = self._read_comment_line(f).split()
        labels = self._get_labels(self._read_comment_line(f))
        shape = tuple(map(int, self._read_comment_line(f).split()))
        ndim = len(shape)
        set_arrays = ()
        data_arrays = []
        indexed_ids = list(enumerate(ids))
        for i, array_id in indexed_ids[:ndim]:
            snap = data_set.get_array_metadata(array_id)
            set_shape = shape[: i + 1]
            if array_id in arrays:
                set_array = arrays[array_id]
                if set_array.shape != set_shape:
                    raise ValueError(
                        'shapes do not match for set array: ' + array_id)
                if array_id not in ids_read:
                    set_array.clear()
            else:
                set_array = DataArray(label=labels[i], array_id=array_id,
                                      set_arrays=set_arrays, shape=set_shape,
                                      is_setpoint=True, snapshot=snap)
                set_array.init_data()
                data_set.add_array(set_array)
            set_arrays = set_arrays + (set_array, )
            ids_read.add(array_id)
        for i, array_id in indexed_ids[ndim:]:
            snap = data_set.get_array_metadata(array_id)
            if array_id in ids_read:
                raise ValueError('duplicate data id found: ' + array_id)
            if array_id in arrays:
                data_array = arrays[array_id]
                data_array.clear()
            else:
                data_array = DataArray(label=labels[i], array_id=array_id,
                                       set_arrays=set_arrays, shape=shape,
                                       snapshot=snap)
                data_array.init_data()
                data_set.add_array(data_array)
            data_arrays.append(data_array)
            ids_read.add(array_id)
        indices = [0] * ndim
        first_point = True
        resetting = 0
        for line in f:
            if self._is_comment(line):
                continue
            line = line.strip()
            if not line:
                if not first_point:
                    resetting += 1
                continue
            values = tuple(map(float, line.split()))
            if resetting:
                indices[-resetting - 1] += 1
                indices[-resetting:] = [0] * resetting
                resetting = 0
            for value, set_array in zip(values[:ndim], set_arrays):
                nparray = set_array.ndarray
                myindices = tuple(indices[:nparray.ndim])
                stored_value = nparray[myindices]
                if math.isnan(stored_value):
                    nparray[myindices] = value
                elif stored_value != value:
                    raise ValueError('inconsistent setpoint values',
                                     stored_value, value, set_array.name,
                                     myindices, indices)
            for value, data_array in zip(values[ndim:], data_arrays):
                data_array.ndarray[tuple(indices)] = value
            indices[-1] += 1
            first_point = False
        indices[-1] -= 1
        for array in set_arrays + tuple(data_arrays):
            array.mark_saved(array.flat_index(indices[:array.ndim]))
def read_one_file ( self , data_set , f , ids_read ) : if not f . name . endswith ( self . extension ) : return arrays = data_set . arrays ids = self . _read_comment_line ( f ) . split ( ) labels = self . _get_labels ( self . _read_comment_line ( f ) ) shape = tuple ( map ( int , self . _read_comment_line ( f ) . split ( ) ) ) ndim = len ( shape ) set_arrays = ( ) data_arrays = [ ] indexed_ids = list ( enumerate ( ids ) ) for i , array_id in indexed_ids [ : ndim ] : snap = data_set . get_array_metadata ( array_id ) set_shape = shape [ : i + 1 ] if array_id in arrays : set_array = arrays [ array_id ] if set_array . shape != set_shape : raise ValueError ( 'shapes do not match for set array: ' + array_id ) if array_id not in ids_read : set_array . clear ( ) else : set_array = DataArray ( label = labels [ i ] , array_id = array_id , set_arrays = set_arrays , shape = set_shape , is_setpoint = True , snapshot = snap ) set_array . init_data ( ) data_set . add_array ( set_array ) set_arrays = set_arrays + ( set_array , ) ids_read . add ( array_id ) for i , array_id in indexed_ids [ ndim : ] : snap = data_set . get_array_metadata ( array_id ) if array_id in ids_read : raise ValueError ( 'duplicate data id found: ' + array_id ) if array_id in arrays : data_array = arrays [ array_id ] data_array . clear ( ) else : data_array = DataArray ( label = labels [ i ] , array_id = array_id , set_arrays = set_arrays , shape = shape , snapshot = snap ) data_array . init_data ( ) data_set . add_array ( data_array ) data_arrays . append ( data_array ) ids_read . add ( array_id ) indices = [ 0 ] * ndim first_point = True resetting = 0 for line in f : if self . _is_comment ( line ) : continue line = line . strip ( ) if not line : if not first_point : resetting += 1 continue values = tuple ( map ( float , line . split ( ) ) ) if resetting : indices [ - resetting - 1 ] += 1 indices [ - resetting : ] = [ 0 ] * resetting resetting = 0 for value , set_array in zip ( values [ : ndim ] , set_arrays ) : nparray = set_array . ndarray myindices = tuple ( indices [ : nparray . ndim ] ) stored_value = nparray [ myindices ] if math . isnan ( stored_value ) : nparray [ myindices ] = value elif stored_value != value : raise ValueError ( 'inconsistent setpoint values' , stored_value , value , set_array . name , myindices , indices ) for value , data_array in zip ( values [ ndim : ] , data_arrays ) : data_array . ndarray [ tuple ( indices ) ] = value indices [ - 1 ] += 1 first_point = False indices [ - 1 ] -= 1 for array in set_arrays + tuple ( data_arrays ) : array . mark_saved ( array . flat_index ( indices [ : array . ndim ] ) )
Called by Formatter.read to bring one data file into
a DataSet.
Called by Formatter . read to bring one data file into a DataSet .
"""
        Called by Formatter.read to bring one data file into
        a DataSet. Setpoint data may be duplicated across multiple files,
        but each measured DataArray must only map to one file.

        args:
            data_set: the DataSet we are reading into
            f: a file-like object to read from
            ids_read: a `set` of array_ids that we have already read.
                when you read an array, check that it's not in this set (except
                setpoints, which can be in several files with different inner loop)
                then add it to the set so other files know not to read it again
        """ # setpoint arrays # it's OK for setpoints to be duplicated across # multiple files, but we should only empty the # array out the first time we see it, so subsequent # reads can check for consistency # data arrays # ignore leading or trailing whitespace (including in blank lines) # each consecutive blank line implies one more loop to reset # when we read the next data point. Don't depend on the number # of setpoints that change, as there could be weird cases, like # bidirectional sweeps, or highly diagonal sweeps, where this # is incorrect. Anyway this really only matters for >2D sweeps. # set .ndarray directly to avoid the overhead of __setitem__ # which updates modified_range on every call # Since we skipped __setitem__, back up to the last read point and # mark it as saved that far. # Using mark_saved is better than directly setting last_saved_index # because it also ensures modified_range is set correctly.
self
data_set
f
ids_read