Skip to content

Commit

Permalink
Plumb back in
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeilstenedmands committed Apr 8, 2024
1 parent 7526dc9 commit dc1a03f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
23 changes: 8 additions & 15 deletions src/xia2/Modules/SSX/batch_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,18 @@

import copy
import logging
import random

import numpy as np

from cctbx import sgtbx
from dials.algorithms.scaling.algorithm import ScalingAlgorithm
from dials.algorithms.scaling.scaling_library import determine_best_unit_cell
from dials.algorithms.symmetry.cosym import CosymAnalysis, extract_reference_intensities
from dials.array_family import flex
from dials.command_line.symmetry import (
apply_change_of_basis_ops,
change_of_basis_ops_to_minimum_cell,
eliminate_sys_absent,
)
from dials.util.filter_reflections import filtered_arrays_from_experiments_reflections
from dials.util.observer import Subject
from dxtbx.model import ExperimentList

logger = logging.getLogger("dials")

from dials.util.options import ArgumentParser
from libtbx import Auto, phil
from libtbx import phil


class BatchScale(object):
Expand All @@ -45,6 +35,10 @@ def __init__(self, experiments, reflections, reference):
self.input_reflections = reflections
self._experiments = ExperimentList([])
self._reflections = []
self._output_expt_files = []
self._output_refl_files = []
self._new_table = copy.deepcopy(self.input_reflections)
self._new_expts = copy.deepcopy(self.input_experiments)

# create a single table and expt per batch
all_expts = ExperimentList([])
Expand All @@ -53,9 +47,7 @@ def __init__(self, experiments, reflections, reference):
best_unit_cell = determine_best_unit_cell(all_expts)
# self._experiments = all_expts

for i, (table, expts) in enumerate(
zip(self.input_reflections, self.input_experiments)
):
for i, (table, expts) in enumerate(zip(self._new_table, self._new_expts)):
wavelength = np.mean([expt.beam.get_wavelength() for expt in expts])
expt = copy.deepcopy(expts[0])
expt.beam.set_wavelength(wavelength)
Expand Down Expand Up @@ -110,4 +102,5 @@ def run(self):

refl["miller_index"] = change_of_basis_op.apply(refl["miller_index"])
refl.as_file(f"scalereindex_{i}.refl")
assert 0
self._output_expt_files.append(f"scalereindex_{i}.expt")
self._output_refl_files.append(f"scalereindex_{i}.refl")
11 changes: 9 additions & 2 deletions src/xia2/Modules/SSX/data_reduction_programs.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,10 +843,17 @@ def scale_reindex(

with run_in_directory(working_directory), record_step(
"dials.scale_reindex"
), log_to_file(logfile) as dials_logger:
), log_to_file(logfile):
s = BatchScale(expts, refls, reference)
s.run()
return batches_for_reindex
outfiles = []
for expt, refl in zip(s._output_expt_files, s._output_refl_files):
outbatch = ProcessingBatch()
outbatch.add_filepair(
FilePair(working_directory / expt, working_directory / refl)
)
outfiles.append(outbatch)
return outfiles


def cosym_reindex(
Expand Down

0 comments on commit dc1a03f

Please sign in to comment.