Skip to content

Commit

Permalink
finished Mtz::ensure_asu() - but not tested much
Browse files Browse the repository at this point in the history
  • Loading branch information
wojdyr committed Jan 26, 2022
1 parent 06316ce commit 8c4c8ba
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
19 changes: 17 additions & 2 deletions include/gemmi/mtz.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ struct Mtz {
if (no_special_columns)
continue;
int isym = result.second;
if (!phase_columns.empty()) {
if (!phase_columns.empty() || !abcd_columns.empty()) {
const Op& op = gops.sym_ops[(isym - 1) / 2];
double shift = op.phase_shift(hkl);
if (shift != 0) {
Expand All @@ -836,6 +836,22 @@ struct Mtz {
double shift_deg = deg(shift);
for (int col : phase_columns)
data[n + col] = float(data[n + col] + shift_deg);
for (auto i = abcd_columns.begin(); i+3 < abcd_columns.end(); i += 4) {
double sinx = std::sin(shift);
double cosx = std::cos(shift);
double sin2x = 2 * sinx * cosx;
double cos2x = sq(cosx)- sq(sinx);
double a = data[n + *(i+0)];
double b = data[n + *(i+1)];
double c = data[n + *(i+2)];
double d = data[n + *(i+3)];
// a sin(x+y) + b cos(x+y) = a sin(x) cos(y) - b sin(x) sin(y)
// + a cos(x) sin(y) + b cos(x) cos(y)
data[n + *(i+0)] = float(a * cosx - b * sinx);
data[n + *(i+1)] = float(a * sinx + b * cosx);
data[n + *(i+2)] = float(c * cos2x - d * sin2x);
data[n + *(i+3)] = float(c * sin2x + d * cos2x);
}
}
}
if (isym % 2 == 0 && !centric) {
Expand All @@ -844,7 +860,6 @@ struct Mtz {
for (int col : dano_columns)
data[n + col] = -data[n + col];
}
// TODO handle abcd_columns
}
}

Expand Down
1 change: 1 addition & 0 deletions python/mtz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ void add_mtz(py::module& m) {
}, py::arg("array"))
.def("update_reso", &Mtz::update_reso)
.def("sort", &Mtz::sort)
.def("ensure_asu", &Mtz::ensure_asu)
.def("switch_to_original_hkl", &Mtz::switch_to_original_hkl)
.def("switch_to_asu_hkl", &Mtz::switch_to_asu_hkl)
.def("write_to_file", &Mtz::write_to_file, py::arg("path"))
Expand Down

0 comments on commit 8c4c8ba

Please sign in to comment.