Skip to content

Commit

Permalink
Merge branch 'main' of github.com:rs-station/laue-dials
Browse files Browse the repository at this point in the history
  • Loading branch information
PrinceWalnut committed Sep 8, 2023
2 parents 0e5e019 + acda0c2 commit 5671640
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/laue_dials/command_line/optimize_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import time
from itertools import repeat
from multiprocessing import Pool
import numpy as np

import libtbx.phil
import numpy as np
from dials.array_family.flex import reflection_table
from dials.util import show_mail_handle_errors
from dials.util.options import (ArgumentParser,
Expand Down Expand Up @@ -252,7 +252,7 @@ def run(args=None, *, phil=working_phil):
ids = list(np.unique(reflections["id"]).astype(np.int32))
expts_arr = []
refls_arr = []
for i in ids: # Split DIALS objects into lists
for i in ids: # Split DIALS objects into lists
expts_arr.append(ExperimentList([experiments[i]]))
refls_arr.append(reflections.select(reflections["id"] == i))
inputs = list(zip(repeat(params), refls_arr, expts_arr))
Expand Down
9 changes: 6 additions & 3 deletions src/laue_dials/command_line/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def predict_spots(params, refls, expts):
A function for predicting spots given a geometry
"""
from laue_dials.algorithms.laue import LauePredictor

img_num = refls["id"][0]

# Remove outliers
Expand Down Expand Up @@ -174,8 +175,10 @@ def predict_spots(params, refls, expts):
preds = preds.select(flex.bool(sel))
new_lams = new_lams[sel]
except:
logger.warning(f"WARNING: Could not predict reflections for experiment {img_num}. Image skipped.")
return reflection_table() # Return empty on failure
logger.warning(
f"WARNING: Could not predict reflections for experiment {img_num}. Image skipped."
)
return reflection_table() # Return empty on failure

# Append image predictions to dataset
final_preds.extend(preds)
Expand Down Expand Up @@ -256,7 +259,7 @@ def run(args=None, *, phil=working_phil):
ids = list(np.unique(reflections["id"]).astype(np.int32))
expts_arr = []
refls_arr = []
for i in range(len(ids)): # Split DIALS objects into lists
for i in range(len(ids)): # Split DIALS objects into lists
expts_arr.append(ExperimentList([experiments[i]]))
refls_arr.append(reflections.select(reflections["id"] == ids[i]))
inputs = list(zip(repeat(params), refls_arr, expts_arr))
Expand Down
10 changes: 6 additions & 4 deletions src/laue_dials/command_line/refine.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import logging
import sys
import time
import numpy as np
from itertools import repeat
from multiprocessing import Pool

import libtbx.phil
import numpy as np
from dials.array_family import flex
from dials.array_family.flex import reflection_table
from dials.command_line.refine import run_dials_refine
Expand Down Expand Up @@ -109,6 +109,7 @@

working_phil = main_phil.fetch(sources=[refiner_phil])


def refine_image(params, expts, refls):
img_num = refls["id"][0]
original_ids = refls["id"]
Expand All @@ -123,8 +124,10 @@ def refine_image(params, expts, refls):
multi_expts, multi_refls, params
)
except:
logger.warning(f"WARNING: Experiment {img_num} could not be refined. Skipping image.")
return ExperimentList(), reflection_table() # Return empty
logger.warning(
f"WARNING: Experiment {img_num} could not be refined. Skipping image."
)
return ExperimentList(), reflection_table() # Return empty

crystals = refined_expts.crystals()

Expand All @@ -140,7 +143,6 @@ def refine_image(params, expts, refls):
return refined_expts, refined_refls



@show_mail_handle_errors()
def run(args=None, *, phil=working_phil):
# Parse arguments
Expand Down

0 comments on commit 5671640

Please sign in to comment.