qcodes/data/gnuplot_format.py
def write(self,  # type: ignore[override]
              data_set: 'DataSet',
              io_manager, location, force_write=False,
              write_metadata=True, only_complete=True,
              filename=None):
        """
        Write updates in this DataSet to storage.

        Will choose append if possible, overwrite if not.

        Args:
            data_set: the data we're storing
            io_manager (io_manager): the base location to write to
            location (str): the file location within io_manager
            only_complete (bool): passed to match_save_range, answers the
                following question: Should we write all available new data,
                or only complete rows? Is used to make sure that everything
                gets written when the DataSet is finalised, even if some
                dataarrays are strange (like, full of nans)
            filename (Optional[str]): Filename to save to. Will override
                the usual naming scheme and possibly overwrite files, so
                use with care. The file will be saved in the normal location.
        """
        arrays = data_set.arrays

        # puts everything with same dimensions together
        groups = self.group_arrays(arrays)
        existing_files = set(io_manager.list(location))
        written_files = set()

        # Every group gets its own datafile
        for group in groups:
            log.debug('Attempting to write the following '
                      'group: {}'.format(group.name))
            # it might be useful to output the whole group as below but it is
            # very verbose
            #log.debug('containing {}'.format(group))

            if filename:
                fn = io_manager.join(location, filename + self.extension)
            else:
                fn = io_manager.join(location, group.name + self.extension)

            written_files.add(fn)

            # fn may or may not be an absolute path depending on the location manager
            # used however, io_manager always returns relative paths so make sure both are
            # relative by calling to_location
            file_exists = io_manager.to_location(fn) in existing_files
            save_range = self.match_save_range(group, file_exists,
                                               only_complete=only_complete)

            if save_range is None:
                log.debug('Cannot match save range, skipping this group.')
                continue

            overwrite = save_range[0] == 0 or force_write
            open_mode = 'w' if overwrite else 'a'
            shape = group.set_arrays[-1].shape

            with io_manager.open(fn, open_mode) as f:
                if overwrite:
                    f.write(self._make_header(group))
                    log.debug('Wrote header to file')

                for i in range(save_range[0], save_range[1] + 1):
                    indices = np.unravel_index(i, shape)

                    # insert a blank line for each loop that reset (to index 0)
                    # note that if *all* indices are zero (the first point)
                    # we won't put any blanks
                    for j, index in enumerate(reversed(indices)):
                        if index != 0:
                            if j:
                                f.write(self.terminator * j)
                            break

                    one_point = self._data_point(group, indices)
                    f.write(self.separator.join(one_point) + self.terminator)
                log.debug('Wrote to file from '
                          '{} to {}'.format(save_range[0], save_range[1]+1))
            # now that we've saved the data, mark it as such in the data.
            # we mark the data arrays and the inner setpoint array. Outer
            # setpoint arrays have different dimension (so would need a
            # different unraveled index) but more importantly could have
            # a different saved range anyway depending on whether there
            # is outer data taken before or after the inner loop. Anyway we
            # never look at the outer setpoint last_saved_index or
            # modified_range, we just assume it's got the values we need.
            for array in group.data + (group.set_arrays[-1],):
                array.mark_saved(save_range[1])

        if write_metadata:
            self.write_metadata(
                data_set, io_manager=io_manager, location=location)

        Write updates in this DataSet to storage.

        Will choose append if possible, overwrite if not.

        Args:
            data_set: the data we're storing
            io_manager (io_manager): the base location to write to
            location (str): the file location within io_manager
            only_complete (bool): passed to match_save_range, answers the
                following question: Should we write all available new data,
                or only complete rows? Is used to make sure that everything
                gets written when the DataSet is finalised, even if some
                dataarrays are strange (like, full of nans)
            filename (Optional[str]): Filename to save to. Will override
                the usual naming scheme and possibly overwrite files, so
                use with care. The file will be saved in the normal location.
        
Write updates in this DataSet to storage.
Will choose append if possible, overwrite if not.
Write updates in this DataSet to storage . Will choose append if possible overwrite if not .
def write(self,  
              data_set: 'DataSet',
              io_manager, location, force_write=False,
              write_metadata=True, only_complete=True,
              filename=None):
        arrays = data_set.arrays
        groups = self.group_arrays(arrays)
        existing_files = set(io_manager.list(location))
        written_files = set()
        for group in groups:
            log.debug('Attempting to write the following '
                      'group: {}'.format(group.name))
            if filename:
                fn = io_manager.join(location, filename + self.extension)
            else:
                fn = io_manager.join(location, group.name + self.extension)
            written_files.add(fn)
            file_exists = io_manager.to_location(fn) in existing_files
            save_range = self.match_save_range(group, file_exists,
                                               only_complete=only_complete)
            if save_range is None:
                log.debug('Cannot match save range, skipping this group.')
                continue
            overwrite = save_range[0] == 0 or force_write
            open_mode = 'w' if overwrite else 'a'
            shape = group.set_arrays[-1].shape
            with io_manager.open(fn, open_mode) as f:
                if overwrite:
                    f.write(self._make_header(group))
                    log.debug('Wrote header to file')
                for i in range(save_range[0], save_range[1] + 1):
                    indices = np.unravel_index(i, shape)
                    for j, index in enumerate(reversed(indices)):
                        if index != 0:
                            if j:
                                f.write(self.terminator * j)
                            break
                    one_point = self._data_point(group, indices)
                    f.write(self.separator.join(one_point) + self.terminator)
                log.debug('Wrote to file from '
                          '{} to {}'.format(save_range[0], save_range[1]+1))
            for array in group.data + (group.set_arrays[-1],):
                array.mark_saved(save_range[1])
        if write_metadata:
            self.write_metadata(
                data_set, io_manager=io_manager, location=location)
def write ( self , data_set : 'DataSet' , io_manager , location , force_write = False , write_metadata = True , only_complete = True , filename = None ) : arrays = data_set . arrays groups = self . group_arrays ( arrays ) existing_files = set ( io_manager . list ( location ) ) written_files = set ( ) for group in groups : log . debug ( 'Attempting to write the following ' 'group: {}' . format ( group . name ) ) if filename : fn = io_manager . join ( location , filename + self . extension ) else : fn = io_manager . join ( location , group . name + self . extension ) written_files . add ( fn ) file_exists = io_manager . to_location ( fn ) in existing_files save_range = self . match_save_range ( group , file_exists , only_complete = only_complete ) if save_range is None : log . debug ( 'Cannot match save range, skipping this group.' ) continue overwrite = save_range [ 0 ] == 0 or force_write open_mode = 'w' if overwrite else 'a' shape = group . set_arrays [ - 1 ] . shape with io_manager . open ( fn , open_mode ) as f : if overwrite : f . write ( self . _make_header ( group ) ) log . debug ( 'Wrote header to file' ) for i in range ( save_range [ 0 ] , save_range [ 1 ] + 1 ) : indices = np . unravel_index ( i , shape ) for j , index in enumerate ( reversed ( indices ) ) : if index != 0 : if j : f . write ( self . terminator * j ) break one_point = self . _data_point ( group , indices ) f . write ( self . separator . join ( one_point ) + self . terminator ) log . debug ( 'Wrote to file from ' '{} to {}' . format ( save_range [ 0 ] , save_range [ 1 ] + 1 ) ) for array in group . data + ( group . set_arrays [ - 1 ] , ) : array . mark_saved ( save_range [ 1 ] ) if write_metadata : self . write_metadata ( data_set , io_manager = io_manager , location = location )
Write updates in this DataSet to storage.
Write updates in this DataSet to storage .
# type: ignore[override] """
        Write updates in this DataSet to storage.

        Will choose append if possible, overwrite if not.

        Args:
            data_set: the data we're storing
            io_manager (io_manager): the base location to write to
            location (str): the file location within io_manager
            only_complete (bool): passed to match_save_range, answers the
                following question: Should we write all available new data,
                or only complete rows? Is used to make sure that everything
                gets written when the DataSet is finalised, even if some
                dataarrays are strange (like, full of nans)
            filename (Optional[str]): Filename to save to. Will override
                the usual naming scheme and possibly overwrite files, so
                use with care. The file will be saved in the normal location.
        """ # puts everything with same dimensions together # Every group gets its own datafile # it might be useful to output the whole group as below but it is # very verbose #log.debug('containing {}'.format(group)) # fn may or may not be an absolute path depending on the location manager # used however, io_manager always returns relative paths so make sure both are # relative by calling to_location # insert a blank line for each loop that reset (to index 0) # note that if *all* indices are zero (the first point) # we won't put any blanks # now that we've saved the data, mark it as such in the data. # we mark the data arrays and the inner setpoint array. Outer # setpoint arrays have different dimension (so would need a # different unraveled index) but more importantly could have # a different saved range anyway depending on whether there # is outer data taken before or after the inner loop. Anyway we # never look at the outer setpoint last_saved_index or # modified_range, we just assume it's got the values we need.
self
data_set
'DataSet'
the data we're storing
the data we ' re storing
io_manager
the base location to write to
the base location to write to
location
the file location within io_manager
the file location within io_manager
force_write
write_metadata
only_complete
passed to match_save_range, answers the
following question: Should we write all available new data,
or only complete rows. Is used to make sure that everything
gets written when the DataSet is finalised, even if some
dataarrays are strange (like, full of nans)
passed to match_save_range answers the following question : Should we write all available new data or only complete rows . Is used to make sure that everything gets written when the DataSet is finalised even if some dataarrays are strange ( like full of nans )
filename
Filename to save to. Will override
the usual naming scheme and possibly overwrite files, so
use with care. The file will be saved in the normal location.
Filename to save to . Will override the usual naming scheme and possibly overwrite files so use with care . The file will be saved in the normal location .