Ejemplo n.º 1
0
    def update_file_paths(self, update_h5=False):
        """
        """
        try:
            # set the filename and path
            base_path = self.settings.child(('base_path')).value()
            base_name = self.settings.child(('base_name')).value()
            current_scan = self.settings.child(('current_scan_name')).value()
            scan_type = self.settings.child(('save_type')).value() == 'scan'

            if current_scan == '' or update_h5:
                next_scan_index = 0
                update_h5 = True  #just started the main program so one should create a new h5
            else:
                next_scan_index = self.get_scan_index()

            scan_path, current_filename, dataset_path = utils.set_current_scan_path(
                base_path,
                base_name,
                update_h5,
                next_scan_index,
                create_dataset_folder=scan_type)
            self.settings.child(('current_scan_path')).setValue(str(scan_path))

            return scan_path, current_filename, dataset_path

        except Exception as e:
            print(e)
Ejemplo n.º 2
0
    def update_file_paths(self, update_h5=False):
        """Apply the template depending on the 'save_type' settings child

        Parameters
        ----------
        update_h5: bool
                   if True, will increment the file name and eventually the current scan index
                   if False, get the current scan index in the h5 file

        Returns
        -------
        scan_path: Path
        current_filename: str
        dataset_path: Path

        See Also
        --------
        :py:meth:`pymodaq.daq_utils.daq_utils.set_current_scan_path`

        """

        try:
            # set the filename and path
            base_path = self.settings.child(('base_path')).value()
            base_name = self.settings.child(('base_name')).value()
            current_scan = self.settings.child(('current_scan_name')).value()
            scan_type = self.settings.child(('save_type')).value() == 'scan'

            if current_scan == '' or update_h5:
                next_scan_index = 0
                update_h5 = True  #just started the main program so one should create a new h5
            else:
                next_scan_index = self.get_scan_index()

            scan_path, current_filename, dataset_path = utils.set_current_scan_path(
                base_path,
                base_name,
                update_h5,
                next_scan_index,
                create_dataset_folder=scan_type)
            self.settings.child(('current_scan_path')).setValue(str(scan_path))

            return scan_path, current_filename, dataset_path

        except Exception as e:
            print(e)
Ejemplo n.º 3
0
    def show_image(self, data):
        """

        Parameters
        ----------
        data: (dict) with keys 'names', 'data', 'x_axis', 'y_axis', 'pixmap2D'
        """

        if self.h5file is None:
            scan_path, current_filename, dataset_path = utils.set_current_scan_path(
                navigator_path,
                base_name='Scan',
                update_h5=True,
                next_scan_index=self.next_scan_index,
                create_scan_folder=False)
            self.h5file = tables.open_file(
                str(dataset_path.joinpath(dataset_path.name + ".h5")), 'w')
            h5group = self.h5file.root
            data2D_group = self.h5file.create_group(h5group, 'Data2D')
            data2D_group._v_attrs.type = 'data2D'
        else:
            scan_path, current_filename, dataset_path = utils.set_current_scan_path(
                navigator_path,
                base_name='Scan',
                update_h5=False,
                next_scan_index=self.next_scan_index,
                create_scan_folder=False)
            if not self.h5file.isopen:
                self.h5file = tables.open_file(
                    str(dataset_path.joinpath(dataset_path.name + ".h5")), 'a')
        self.next_scan_index += 1
        curr_group = self.h5file.create_group('/Data2D', current_filename)
        curr_group._v_attrs['pixmap2D'] = data['pixmap2D']

        xarray = self.h5file.create_array(curr_group,
                                          "scan_x_axis_unique",
                                          obj=data['x_axis'],
                                          title=current_filename)
        xarray.attrs['shape'] = xarray.shape
        xarray.attrs['type'] = 'signal_axis'
        xarray.attrs['data_type'] = '1D'

        yarray = self.h5file.create_array(curr_group,
                                          "scan_y_axis_unique",
                                          obj=data['y_axis'],
                                          title=current_filename)
        yarray.attrs['shape'] = yarray.shape
        yarray.attrs['type'] = 'signal_axis'
        yarray.attrs['data_type'] = '1D'

        for ind_channel, name in enumerate(data['names']):
            try:
                channel_group = self.h5file.create_group(curr_group, name)
                channel_group._v_attrs.Channel_name = name
                array = self.h5file.create_carray(
                    channel_group,
                    current_filename + '_' + name,
                    obj=data['data'][ind_channel],
                    title='data',
                    filters=self.filters)
                array.attrs['type'] = 'data'
                array.attrs['data_type'] = '0D'
                array.attrs['data_name'] = name
                array.attrs['shape'] = data['data'][ind_channel].shape
                array.attrs['scan_type'] = 'Scan2D'
            except Exception as e:
                self.update_status(utils.getLineInfo() + str(e),
                                   status_time=self.status_time,
                                   log_type='log')

        self.update_2Dscans()