Exemple #1
0
    def save(self, projectfile):
        """
        Save workspace to Hidra project file
        """
        projectfile = os.path.abspath(
            projectfile)  # confirm absolute path to make logs more readable
        checkdatatypes.check_file_name(
            projectfile,
            check_exist=False,
            check_writable=True,
            is_dir=False,
            description='Converted Hidra project file')

        # remove file if it already exists
        if os.path.exists(projectfile):
            self._log.information(
                'Projectfile "{}" exists, removing previous version'.format(
                    projectfile))
            os.remove(projectfile)

        # save
        hydra_file = HidraProjectFile(projectfile,
                                      HidraProjectFileMode.OVERWRITE)

        # Set geometry
        hydra_file.write_instrument_geometry(
            HidraSetup(self._hidra_workspace.get_instrument_setup()))
        # save experimental data/detector counts
        self._hidra_workspace.save_experimental_data(hydra_file)
Exemple #2
0
def test_rw_raw():
    """Test read a project to workspace and write in the scope of raw data

    Returns
    -------

    """
    raw_project_name = os.path.join(os.getcwd(), 'data/HZB_Raw_Project.h5')

    # Read to workspace
    source_project = HidraProjectFile(raw_project_name, 'r')

    # To the workspace
    source_workspace = workspaces.HidraWorkspace('Source HZB')
    source_workspace.load_hidra_project(source_project,
                                        load_raw_counts=True,
                                        load_reduced_diffraction=False)

    # Export
    target_project = HidraProjectFile('HZB_HiDra_Test.h5', 'w')
    # Experiment data
    source_workspace.save_experimental_data(target_project,
                                            sub_runs=range(1, 41))

    # Instrument
    detector_setup = source_workspace.get_instrument_setup()
    instrument_setup = HidraSetup(detector_setup=detector_setup)
    target_project.write_instrument_geometry(instrument_setup)

    # Save
    target_project.save(True)

    return