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

Is diffractometer configuration saved by NXWriter? #985

Open
prjemian opened this issue Jun 24, 2024 · 3 comments
Open

Is diffractometer configuration saved by NXWriter? #985

prjemian opened this issue Jun 24, 2024 · 3 comments
Labels
Milestone

Comments

@prjemian
Copy link
Contributor

prjemian commented Jun 24, 2024

When using a diffractometer and hklpy, is the diffractometer orientation (UB matrix, reflections, sample lattice, ...) saved in the NeXus file?

@prjemian prjemian added this to the 1.6.21 milestone Jun 24, 2024
@prjemian prjemian changed the title Is diffractometer configuration save by NXWriter? Is diffractometer configuration saved by NXWriter? Jun 24, 2024
@prjemian prjemian modified the milestones: 1.7.0, 1.7.1 Aug 21, 2024
@prjemian prjemian modified the milestones: 1.7.1, 1.7.2 Oct 24, 2024
@prjemian prjemian modified the milestones: 1.7.2, 1.7.3 Jan 11, 2025
@prjemian
Copy link
Contributor Author

Answer: The diffractometer configuration is not saved by the NXWriter at this time. While the information is present in the descriptor document when the diffractometer is added to the detector list, the NXWriter does not look for it in that location.

@prjemian prjemian moved this to Todo in apstools 1.7.3 Jan 29, 2025
@prjemian
Copy link
Contributor Author

descriptor["configuration"][name]["data"][f"{name}_{item}"] where name is the diffractometer name (such as sixc) and item is U, UB, lattice, ..., as listed in descriptor["configuration"][name]["data"][f"{name}_orientation_attrs"]

Example:

                     'sixc': {'data': {'sixc_U': array([[-1.22173048e-05, -1.22173048e-05, -1.00000000e+00],
       [ 0.00000000e+00, -1.00000000e+00,  1.22173048e-05],
       [-1.00000000e+00,  1.49262536e-10,  1.22173048e-05]]),
                                       'sixc_UB': array([[-1.41342846e-05, -1.41342846e-05, -1.15690694e+00],
       [ 0.00000000e+00, -1.15690694e+00,  1.41342846e-05],
       [-1.15690694e+00,  1.72682934e-10,  1.41342846e-05]]),
                                       'sixc__constraints': array([[-180.        ,  180.        ,    0.        ,    1.        ],
       [-180.        ,  180.        ,   20.32128858,    1.        ],
       [-180.        ,  180.        ,   24.09484255,    1.        ],
       [-180.        ,  180.        ,    0.        ,    1.        ],
       [-180.        ,  180.        ,    0.        ,    1.        ],
       [-180.        ,  180.        ,   40.64257716,    1.        ]]),
                                       'sixc__hklpy_version': '1.1.1',
                                       'sixc__mode': 'bissector_vertical',
                                       'sixc__pseudos': ('h', 'k', 'l'),
                                       'sixc__reals': ('mu',
                                                       'omega',
                                                       'chi',
                                                       'phi',
                                                       'gamma',
                                                       'delta'),
                                       'sixc_class_name': 'SimulatedE6C',
                                       'sixc_diffractometer_name': 'sixc',
                                       'sixc_energy': 8.050921974025975,
                                       'sixc_energy_offset': 0,
                                       'sixc_energy_units': 'keV',
                                       'sixc_energy_update_calc_flag': True,
                                       'sixc_geometry_name': 'E6C',
                                       'sixc_lattice': array([ 5.43102051,  5.43102051,  5.43102051, 90.        , 90.        ,
       90.        ]),
                                       'sixc_lattice_reciprocal': (1.156906937555034,
                                                                   1.156906937555034,
                                                                   1.156906937555034,
                                                                   90.00000000000001,
                                                                   90.00000000000001,
                                                                   90.00000000000001),
                                       'sixc_orientation_attrs': ['orientation_attrs',
                                                                  'geometry_name',
                                                                  'class_name',
                                                                  'UB',
                                                                  'U',
                                                                  'ux',
                                                                  'uy',
                                                                  'uz',
                                                                  'energy',
                                                                  'energy_units',
                                                                  'energy_offset',
                                                                  'sample_name',
                                                                  'lattice',
                                                                  'lattice_reciprocal',
                                                                  'reflections_details',
                                                                  '_pseudos',
                                                                  '_reals',
                                                                  '_constraints',
                                                                  '_mode',
                                                                  'diffractometer_name',
                                                                  '_hklpy_version'],
                                       'sixc_reflections_details': [{'flag': 1,
                                                                     'orientation_reflection': True,
                                                                     'position': {'chi': 0.0,
                                                                                  'delta': 69.0966,
                                                                                  'gamma': 0.0,
                                                                                  'mu': 0.0,
                                                                                  'omega': -145.451,
                                                                                  'phi': 0.0},
                                                                     'reflection': {'h': 4.0,
                                                                                    'k': 0.0,
                                                                                    'l': 0.0},
                                                                     'wavelength': 1.5399999999999998},
                                                                    {'flag': 1,
                                                                     'orientation_reflection': True,
                                                                     'position': {'chi': 90.0,
                                                                                  'delta': 69.0966,
                                                                                  'gamma': 0.0,
                                                                                  'mu': 0.0,
                                                                                  'omega': -145.451,
                                                                                  'phi': 0.0},
                                                                     'reflection': {'h': 0.0,
                                                                                    'k': 4.0,
                                                                                    'l': 0.0},
                                                                     'wavelength': 1.5399999999999998}],
                                       'sixc_sample_name': 'silicon',
                                       'sixc_ux': -45.0,
                                       'sixc_uy': -89.99901005102187,
                                       'sixc_uz': 135.00000000427607},

@prjemian
Copy link
Contributor Author

This function accepts any document published by RE. If hklpy's diffractometer configuration details are found (only in descriptor documents), it fills the dictionary with the config for each diffractometer described in the document:

def get_hklpy_configurations(doc: dict) -> dict:
    """Diffractometer details (from hklpy) in RE descriptor documents."""
    configurations = {}  # zero, one, or more diffractometers are possible
    for k in doc.get("configuration", {}):
        record = doc["configuration"][k].get("data", {})
        attrs = record.get(f"{k}_orientation_attrs", [])
        if len(attrs) == 0:  # no orientation information?
            continue
        configurations[k] = {a: record[f"{k}_{a}"] for a in attrs}
    return configurations

A good addition for:

def descriptor(self, doc):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

1 participant