Skip to content

[Bug] Error thrown in Bragg2DPtycho if surface_normal and scattering_mode are None and no orientation specified in the dataset #65

@yoshikisd

Description

@yoshikisd

The changes made in #63 will now cause the following error to get thrown if Bragg2DPtycho is used, but surface_normal and scattering_mode are both none and no orientation is specified in the dataset. The simplest way to reproduce the error is to run examples/fancy_ptycho.py but replace the cdtools.models.FancyPtycho.from_dataset with cdtools.models.Bragg2DPtycho.from_dataset.

Traceback (most recent call last):
  File ".../cdtools/examples/fancy_ptycho.py", line 8, in <module>
    model = cdtools.models.Bragg2DPtycho.from_dataset(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../cdtools/src/cdtools/models/bragg_2d_ptycho.py", line 292, in from_dataset
    elif scattering_mode.strip().lower() in {'t', 'transmission'}:
         ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'strip'

The intended default behavior for the surface normal defining logic is to make surface_normal = np.array([0., 0., 1.]). The logic for defining the surface normal in Bragg2DPtycho needs to be rejiggered a bit to guard the string-stripping operation against cases where surface_normal and scattering_mode are both none.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions