Exemple #1
0
    def OnSaveMaskParams(self, event):
        from dials.util.masking import phil_scope

        file_name = self.params.output.mask_params
        with open(file_name, "w") as f:
            print("Saving parameters to %s" % file_name)
            phil_scope.fetch_diff(phil_scope.format(self.params.masking)).show(f)
Exemple #2
0
        def run(self):
            import os
            from xia2.Handlers.Streams import Debug

            Debug.write("Running dials.generate_mask")

            self.clear_command_line()

            assert self._params is not None
            from dials.util.masking import phil_scope

            working_phil = phil_scope.format(self._params)
            diff_phil = phil_scope.fetch_diff(source=working_phil)
            phil_filename = os.path.join(
                self.get_working_directory(), "%s_mask.phil" % self.get_xpid()
            )
            with open(phil_filename, "wb") as f:
                f.write(diff_phil.as_str())
                f.write(
                    os.linesep
                )  # temporarily required for https://github.com/dials/dials/issues/522

            self.add_command_line(
                'input.experiments="%s"' % self._input_experiments_filename
            )
            if self._output_mask_filename is None:
                self._output_mask_filename = os.path.join(
                    self.get_working_directory(), "%s_pixels.mask" % self.get_xpid()
                )
            if self._output_experiments_filename is None:
                self._output_experiments_filename = os.path.join(
                    self.get_working_directory(), "%s_masked.expt" % self.get_xpid()
                )
            self.add_command_line('output.mask="%s"' % self._output_mask_filename)
            self.add_command_line(
                'output.experiments="%s"' % self._output_experiments_filename
            )
            self.add_command_line(phil_filename)
            self.start()
            self.close_wait()
            self.check_for_errors()
            assert os.path.exists(
                self._output_mask_filename
            ), self._output_mask_filename
            assert os.path.exists(
                self._output_experiments_filename
            ), self._output_experiments_filename
            return self._output_experiments_filename, self._output_mask_filename