Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overall interval_width_degrees #2268

Merged
merged 5 commits into from
Nov 9, 2022
Merged

Conversation

dagewa
Copy link
Member

@dagewa dagewa commented Nov 4, 2022

Set an overall interval_width_degrees to adjust the defaults for all models.

$ dials.refine indexed.expt indexed.refl interval_width_degrees=60
Warning: Ambiguous parameter definition: interval_width_degrees = 60
Best matches:
  refinement.parameterisation.interval_width_degrees
  refinement.parameterisation.beam.smoother.interval_width_degrees
  refinement.parameterisation.crystal.unit_cell.smoother.interval_width_degrees
  refinement.parameterisation.crystal.orientation.smoother.interval_width_degrees
  refinement.parameterisation.detector.smoother.interval_width_degrees
  refinement.parameterisation.goniometer.smoother.interval_width_degrees
Assuming refinement.parameterisation.interval_width_degrees was intended.

Fix for #2262.

By the way, you can also try interval_width_degrees=Auto. No guarantee this gives sensible results in all cases, but it is most likely to work well for wide scans (full or multi-turn).

@graeme-winter
Copy link
Contributor

@dagewa thank you; noted; will review

@graeme-winter
Copy link
Contributor

Warning: Ambiguous parameter definition: interval_width_degrees = 18
Best matches:
  refinement.parameterisation.interval_width_degrees
  refinement.parameterisation.beam.smoother.interval_width_degrees
  refinement.parameterisation.crystal.unit_cell.smoother.interval_width_degrees
  refinement.parameterisation.crystal.orientation.smoother.interval_width_degrees
  refinement.parameterisation.detector.smoother.interval_width_degrees
  refinement.parameterisation.goniometer.smoother.interval_width_degrees
Assuming refinement.parameterisation.interval_width_degrees was intended.

verbose but accurate 🙂

I wonder though whether that would worry people?

@dagewa
Copy link
Member Author

dagewa commented Nov 4, 2022

That comes from cctbx. Not sure I can easily hide it as it is all in the option parser stuff

@dagewa
Copy link
Member Author

dagewa commented Nov 4, 2022

Alternative would be to have a different named parameter and then not use the PHIL disambiguation mechanism, but overall I thought that seemed like a worse interface.

Copy link
Contributor

@graeme-winter graeme-winter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first glance this does exactly what I had expected, so thank you. On more thorough investigation I think this does probably more than we would want? By default I would only expect the crystal parameters to vary, as the others (I had understood) were assumed to be static however... maybe I had that wrong?

Grey-Area screen19-2 :) $ dials.refine -c -e2 | grep interval_width
    interval_width_degrees = None
        interval_width_degrees = 36.0
          interval_width_degrees = 36.0
          interval_width_degrees = 36.0
        interval_width_degrees = 36.0
        interval_width_degrees = 36.0

This looks a lot like they are all scan varying? Since we cannot save scan varying detector positions etc. this confuses me some.

Anyway: requested change is to ensure that this default only applies to the crystal parameters... very happy to discuss this though.

@@ -0,0 +1 @@
``dials.refine``: use an overall ``interval_width_degrees`` parameter to set defaults for all models simultaneously.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this set it for all models?

For example I would not expect

refinement.parameterisation.detector.smoother.interval_width_degrees

to be affected?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in: I had expected that this would affect all crystal models

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With an additional sentence explaining the default behaviour here as discussed in the conversation for the PR looks great, thank you.

.help = "Overall default value of the width of scan between checkpoints"
"in degrees for scan-varying refinement. If set to None, each"
"model will use its own specified value."
.type = float(value_min=0.)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we want to set a maximum value? 90° or something? Or is that an exercise for the user?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes it is worth making a very low frequency scan-varying model, i.e. two checkpoints at the start and end. Then you capture essentially linear change in parameters. However, this is better done via the absolute_num_intervals parameters.

@@ -790,6 +796,22 @@ def build_prediction_parameterisation(
A prediction equation parameterisation object
"""

# Set overall default interval_width_degrees values, if requested
if options.interval_width_degrees:
options.beam.smoother.interval_width_degrees = options.interval_width_degrees
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As comment above: I had anticiated this only applying to the crystal parameters. I would further mention right here that we cannot (IIUC) serialise scan varying beam, goniometer and detector parameters -> it is probably not correct to sweep them up in this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can serialise scan-varying models other than crystals, but dials.integrate does not use them properly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, I might have fixed that at least for scan-varying beams. IIRC it is still problematic because things like the mosaicity model ignore the scan-varying parameters. So, while prediction in integration is scan-varying, the overall model remains global

@dagewa
Copy link
Member Author

dagewa commented Nov 4, 2022

What the new parameter does is to override the default values for all the smoothers, which are otherwise set to 36.0. The choice of whether to allow scan-varying parameterisation still remains with the models where each has a force_static parameter. For crystals these are default False, for other models they are True.

This all interacts with scan_varying=(False/True/Auto) which actually controls whether scan-varying refinement is done.

@dagewa
Copy link
Member Author

dagewa commented Nov 4, 2022

For small molecule data with P1 cell I sometimes do this:

dials.refine indexed.expt indexed.refl detector.fix=distance crystal.unit_cell.force_static=true

That way you get the usual static then scan-varying macrocycles, but the cell remains fixed to its static value and only the orientation refines scan-varying. This is because I found that the P1 scan-varying parameters often looked unreasonable (too much freedom) and I would not expect the cell to change anyway. Admittedly this is with ED data with narrow wedges and high centroid errors and would be less of an issue with good quality X-ray data

@graeme-winter
Copy link
Contributor

What the new parameter does is to override the default values for all the smoothers, which are otherwise set to 36.0. The choice of whether to allow scan-varying parameterisation still remains with the models where each has a force_static parameter. For crystals these are default False, for other models they are True.

This all interacts with scan_varying=(False/True/Auto) which actually controls whether scan-varying refinement is done.

Ah, in which case the effective behaviour is precisely what I would have expected thank you. Would then simply ask if this could be explicit in the news fragment.

@graeme-winter graeme-winter self-requested a review November 4, 2022 12:14
Copy link
Contributor

@graeme-winter graeme-winter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With additional comment in news -> 👍 looks good thank you

@@ -0,0 +1 @@
``dials.refine``: use an overall ``interval_width_degrees`` parameter to set defaults for all models simultaneously.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With an additional sentence explaining the default behaviour here as discussed in the conversation for the PR looks great, thank you.

@codecov
Copy link

codecov bot commented Nov 4, 2022

Codecov Report

Merging #2268 (80c52a2) into main (05eca55) will increase coverage by 0.02%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main    #2268      +/-   ##
==========================================
+ Coverage   80.48%   80.51%   +0.02%     
==========================================
  Files         586      586              
  Lines       66899    66905       +6     
  Branches     8899     8900       +1     
==========================================
+ Hits        53846    53868      +22     
+ Misses      10992    10974      -18     
- Partials     2061     2063       +2     

@ndevenish ndevenish enabled auto-merge (squash) November 9, 2022 12:48
@ndevenish ndevenish merged commit b0f0dc3 into main Nov 9, 2022
@ndevenish ndevenish deleted the overall-interval_width_degrees branch November 9, 2022 15:27
dagewa added a commit that referenced this pull request Dec 5, 2022
Overall interval_width_degrees changes the defaults for each model.

Fixes #2262
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants