Skip to content

Commit

Permalink
dials.export format=shelx: Increase number of decimal places in .ins …
Browse files Browse the repository at this point in the history
…file (#2624)

For `dials.export format=shelx` include one more decimal place in CELL and ZERR instructions, to match XPREP output
  • Loading branch information
huwjenkins committed Apr 16, 2024
1 parent 20c0e11 commit 77cda91
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions newsfragments/2624.bugfix
@@ -0,0 +1 @@
``dials.export`` ``format=shelx``: Increased precision of unit cell parameters and their estimated standard deviations written to ``.ins`` file
4 changes: 2 additions & 2 deletions src/dials/util/export_shelx.py
Expand Up @@ -159,13 +159,13 @@ def _write_ins(experiment_list, best_unit_cell, composition, ins_file):
f"TITL {sg.type().number()} in {sg.type().lookup_symbol().replace(' ','')}\n"
)
f.write(
"CELL {:8.5f} {:8.4f} {:8.4f} {:8.4f} {:8.3f} {:8.3f} {:8.3f}\n".format(
"CELL {:7.5f} {:9.5f} {:9.5f} {:9.5f} {:8.4f} {:8.4f} {:8.4f}\n".format(
wl, *uc.parameters()
)
)
if uc_sd:
f.write(
"ZERR {:8.3f} {:8.4f} {:8.4f} {:8.4f} {:8.3f} {:8.3f} {:8.3f}\n".format(
"ZERR {:7.2f} {:9.5f} {:9.5f} {:9.5f} {:8.4f} {:8.4f} {:8.4f}\n".format(
sg.order_z(), *uc_sd
)
)
Expand Down
6 changes: 3 additions & 3 deletions tests/command_line/test_export.py
Expand Up @@ -538,8 +538,8 @@ def test_shelx_ins(dials_data, tmp_path):
assert (tmp_path / "dials.ins").is_file()

cell_esds = {
"CELL": (5.4815, 8.2158, 12.1457, 90.000, 90.000, 90.000),
"ZERR": (0.0005, 0.0007, 0.0011, 0.003, 0.004, 0.004),
"CELL": (5.48154, 8.21578, 12.14570, 90.0000, 90.0000, 90.0000),
"ZERR": (0.00050, 0.00073, 0.00109, 0.0034, 0.0037, 0.0037),
}

with (tmp_path / "dials.ins").open() as fh:
Expand All @@ -548,7 +548,7 @@ def test_shelx_ins(dials_data, tmp_path):
instruction = tokens[0]
if instruction in cell_esds:
result = tuple(map(float, tokens[2:8]))
assert result == pytest.approx(cell_esds[instruction], abs=0.001)
assert result == pytest.approx(cell_esds[instruction], abs=0.0001)


def test_shelx_ins_best_unit_cell(dials_data, tmp_path):
Expand Down

0 comments on commit 77cda91

Please sign in to comment.