Skip to content

Commit

Permalink
DensityCalculator::set_refmac_compatible_blur(): add option allow_neg…
Browse files Browse the repository at this point in the history
…ative

with this option set to true, blur is compatible with servalcat
  • Loading branch information
wojdyr committed May 25, 2024
1 parent f3c57ea commit afd2f48
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions include/gemmi/dencalc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,14 @@ struct DensityCalculator {

double requested_grid_spacing() const { return d_min / (2 * rate); }

void set_refmac_compatible_blur(const Model& model) {
void set_refmac_compatible_blur(const Model& model, bool allow_negative=false) {
double spacing = requested_grid_spacing();
if (spacing <= 0)
spacing = std::min(std::min(grid.spacing[0], grid.spacing[1]), grid.spacing[2]);
double b_min = calculate_b_aniso_range(model).first;
blur = std::max(u_to_b() / 1.1 * sq(spacing) - b_min, 0.);
blur = u_to_b() / 1.1 * sq(spacing) - b_min;
if (!allow_negative && blur < 0)
blur = 0.;
}

// pre: check if Table::has(atom.element)
Expand Down
3 changes: 2 additions & 1 deletion python/sf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ void add_dencalc(py::module& m, const char* name) {
.def_readwrite("blur", &DenCalc::blur)
.def_readwrite("cutoff", &DenCalc::cutoff)
.def_readwrite("addends", &DenCalc::addends)
.def("set_refmac_compatible_blur", &DenCalc::set_refmac_compatible_blur)
.def("set_refmac_compatible_blur", &DenCalc::set_refmac_compatible_blur,
py::arg("allow_negative")=false)
.def("put_model_density_on_grid", &DenCalc::put_model_density_on_grid)
.def("initialize_grid", &DenCalc::initialize_grid)
.def("add_model_density_to_grid", &DenCalc::add_model_density_to_grid)
Expand Down

0 comments on commit afd2f48

Please sign in to comment.