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

it_coordinate_system_code fix #153

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

it_coordinate_system_code fix #153

wants to merge 4 commits into from

Conversation

rozyczko
Copy link
Member

@rozyczko rozyczko commented Nov 15, 2024

This adds proper handling of CIF-read it_coordinate_system_code value.

Setting the code in the script also works, using space_group_IT_coordinate_system_code

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This pull request does not contain a valid label. Please add one of the following labels: ['chore', 'fix', 'bugfix', 'bug', 'enhancement', 'feature', 'dependencies', 'documentation']

@rozyczko rozyczko added the bug Something isn't working label Nov 15, 2024
@rozyczko rozyczko marked this pull request as ready for review November 18, 2024 05:33
@rozyczko rozyczko added feature and removed bug Something isn't working labels Nov 18, 2024
Copy link
Member

@AndrewSazonov AndrewSazonov left a comment

Choose a reason for hiding this comment

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

The code is tested on one example (Fitting_PD-NEUT-TOF_Si-SEPD.ipynb). It now generates the correct pattern in the case of both possible it_codes for "F d -3 m". The only thing I noticed is that

  • when specifying it_code in a CIF file via dot notation (_space_group.IT_coordinate_system_code 2) and reading it via the Job interface, everything seems to work, but the cif output in this case still shows _space_group_IT_coordinate_system_code 1.
  • when using the underscore notation in CIF (_space_group_IT_coordinate_system_code 2), on the contrary, it shows the correct value of _space_group_IT_coordinate_system_code 2 in the cif output.

easydiffraction/calculators/cryspy.py Outdated Show resolved Hide resolved
easydiffraction/calculators/cryspy.py Outdated Show resolved Hide resolved
@AndrewSazonov
Copy link
Member

Fixes #129

@AndrewSazonov
Copy link
Member

I noticed another small issue. If you load a CIF file without the _space_group.IT_coordinate_system_code parameter, its default value is assigned after the space group has been processed by Cryspy. This results in a warning from Cryspy, which itself sets a default value for _space_group.IT_coordinate_system_code. And this default value is sometimes different from the one assigned by easydiffraction.

For example, running this:

job = ed.Job()
job.add_phase_from_file('data/si.cif')
phase = job.phases['si']
print(phase.space_group.it_coordinate_system_code)

leads to (from Cryspy):

Several values of it_coordinate_system_code have been defined:
2, 1
The default value has been choosen:'2'.

and to (from easydiffraction):

<Descriptor 'coordinate-code': 1>

Similarly, when assigning a space group manually via phase.space_group.name_hm_alt = "P n m a", its phase.IT_coordinate_system_code remains None, and when adding this phase to a job object, Cryspy complains that it_code is missing.

@rozyczko
Copy link
Member Author

Hmm I just chose the first element of the settings list for a given spacegroup as returned by gemmi. If there is a way to find out the default setting, I'll be happy to implement it.

@rozyczko
Copy link
Member Author

Now we get the settings value based on cryspy choses to be the default. It's the cryspy calculator after all, so importing a method from cryspy makes sense.

@AndrewSazonov AndrewSazonov added enhancement New feature or request and removed feature labels Nov 22, 2024
@AndrewSazonov
Copy link
Member

I am still experiencing undesirable behaviour as indicated in my comment above. That is, it seems that when the job.add_phase_from_file method is called with a CIF file with no _space_group.IT_coordinate_system_code parameter, the default value is not used when passing this data to Cryspy. As a result, Cryspy assumes that the system code is not defined and displays a warning.

@rozyczko
Copy link
Member Author

Yes but this is a superfluous message coming from the initial setup of the calculator.
Later thr correct object is generated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants