Conversation
RastislavTuranyi
left a comment
There was a problem hiding this comment.
Some comments, mostly to do with the most recent changes from #39, but there are two major things that stick out:
- No docstrings for
get_kernelandget_peak - No unit tests
Could you add these? That said, tho, not sure how viable unit tests are in this case, ig they'll just have to be reference values to test for regression.
src/resins/models/lookuptables.py
Outdated
| assert len(omega_q.shape) == 2 and omega_q.shape[1] == 1 | ||
| energy = omega_q |
There was a problem hiding this comment.
| assert len(omega_q.shape) == 2 and omega_q.shape[1] == 1 | |
| energy = omega_q | |
| assert points.ndim == 2 and points.shape[1] == 1 | |
| energy = points |
First, related to the discussion #39, is this check necessary? Secondly, are you sure you want to keep it as a 2D array?
There was a problem hiding this comment.
The check seems a good idea for now, this should maybe become something more systematic once we really start using Q as well.
The 2-D array leads to scale factors with the right dimensionality later... Arguably "for the wrong reason"? The 2-D gets expanded to 3-D in the meshgrid step.
It might indeed be a bit clearer to reduce to 1 and than expand dimensions where needed.
There was a problem hiding this comment.
I vaguely remember we discussed both of these things elsewhere and decided to do checks and to use Nx1 2D arrays as inputs? If that's the case, I think this can be ignored
src/resins/models/lookuptables.py
Outdated
| omega_q: Float[np.ndarray, 'sample dimension=1'], | ||
| mesh: Float[np.ndarray, 'mesh'], | ||
| ) -> Float[np.ndarray, 'sample mesh']: | ||
| shifted_meshes = [mesh - energy for energy in omega_q[:, 0]] |
There was a problem hiding this comment.
| shifted_meshes = [mesh - energy for energy in omega_q[:, 0]] | |
| try: | |
| points = points[:, 0] | |
| except IndexError as e: | |
| raise InvalidPointsError( | |
| f'The provided array of points (shape={points.shape}) is not valid. The points ' | |
| f'array must be a Nx1 2D array where N is the number of energy transfers.' | |
| ) from e | |
| shifted_meshes = [mesh - energy for energy in points] |
This is an interpolated lookup approach to the TOSCA resolution function, using McStas data from Adrien Perrichon

This scheme is a "scaled" lookup table:
The table is quite compact but still a bit chunky to include in the .yaml files. Instead we store all the model parameters in a .npz file and point to this from the .yaml.
Some pre-processing was performed on the original data: