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

Add option to import/export snapshot as matrix #108

Open
EDCarman opened this issue Aug 14, 2023 · 2 comments
Open

Add option to import/export snapshot as matrix #108

EDCarman opened this issue Aug 14, 2023 · 2 comments
Assignees
Labels
enhancement New features or code improvements

Comments

@EDCarman
Copy link
Collaborator

📝 Description of the feature

Add option to import/export snapshot as matrix

An obstacle to quick adoption of TBROMs in a workflow is the need for the user to create additional functions to convert data in tabular format (generally the most common import/export format from other 3D tools) to snapshot vectors and vice versa.
On the input side, there is the potential error of using column-major, rather than row-major vectorisation, while for outputs, the dimensionality is not directly inferable from the vector and needs to retrieve from the TBROM settings anyway.

e.g. n x 3 matrix must be flattened to 3n vector on input. On output, dimensionality must be retrieved from tbrom.field_output_dim and then used to reshape the vector

x y z
x_1 y_1 z_1
x_2 y_2 z_2
... ... ...
x_n y_n z_n

flattens to

x_1
y_1
...
z_n

Incorporating these functions simplifies user work and abstracts the snapshot format.

💡 Steps for implementing the feature

A possible option is to provide an additional boolean argument to TbRom.generate_snapshot and TbRom.generate_snapshot to export as a matrix e.g. as_matrix.

Input flattening could use ndarray.flatten(order='C') directly, explicitly using the row-major style. Boolean argument is not strictly necessary, since structure can be inferred from input shape. This would also required the ability to pass inputs in memory (see Issue 107).

Output reshaping can use the numpy.reshape(vec, newshape, order='C') function. New shape columns are retrieved from TBROM field_output_dim, rows calculated from len(vec) / dim.

In both cases, reading/writing matrices to disk need not necessarily be supported. The specific formats required may vary with upstream and downstream programs, so writing can be left to the user.

🔗 Useful links and references

Input matrices would require implementation of Issue #107

@EDCarman EDCarman added the enhancement New features or code improvements label Aug 14, 2023
@lboucin
Copy link
Collaborator

lboucin commented Sep 7, 2023

  • Implementation size:

btw S & M (depending on if we refactor the static binary data helpers.)

  • Priority:

btw low to medium, this is a question that is often raised by ROM users (=> maybe we should document our snapshot data format better in the PyTwin doc?)

@lboucin
Copy link
Collaborator

lboucin commented Sep 7, 2023

@lboucin lboucin assigned lboucin and EDCarman and unassigned lboucin Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features or code improvements
Projects
None yet
Development

No branches or pull requests

2 participants