-
Notifications
You must be signed in to change notification settings - Fork 10
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 other snapshot formats #7
Comments
Happy to help if you are :) |
Hi @rieder. Thanks for showing interest in Plonk! I am interested in adding AMUSE HDF5 support. However, I'm not familiar with AMUSE. So I'm happy for you to attempt it (with my guidance, as required). |
A good place to start is by looking at CONTRIBUTING.md. If you have any questions, please don't hesitate to ask. (Although, responses may be slow over the holiday period.) |
Perhaps the easiest way is to not write yet another function for reading files, but to directly populate a Plonk snap object with values from an AMUSE particleset. What would be the right way to manually construct such a snap object? |
@dmentipl any ideas on how this can/should be done? |
Sorry for the delayed response. The Then we will need to add a module The properties of
Now for the actual arrays of data. Plonk loads things lazily. It does this by having So, we also need to set:
Any of the arrays that are in the HDF5 file directly can be read like array_registry['position'] = _get_dataset('xyz', 'particles') In the example above, for Phantom HDF5 data, the particle positions are in the dataset 'particles/xyz'. I.e. using h5py directly, If the array doesn't exist on file, e.g. Phantom snaps don't have the density, it is contructed from the smoothing length and mass, we need to write a small function to do this. See for example def _density(snap: Snap) -> ndarray:
m = _mass(snap)
h = _get_dataset('h', 'particles')(snap)
hfact = snap.properties['smoothing_length_factor']
return m * (hfact / np.abs(h)) ** 3 I hope it's not too confusing. The main point is that the array registry is a dictionary of key/values where the value is a function that is called inside self._array_registry['position'](self) Please let me know if that helps. Or if you need some more assistance. |
I've made some changes to what is described above. See https://github.com/dmentipl/plonk/compare/1d34668..master. The comments at the top of https://github.com/dmentipl/plonk/blob/master/plonk/snap/readers/__init__.py explain some of the details. |
But the fundamentals are unchanged. |
Would it be possible to create a Plonk Snap object from a particle array that is already in memory, without writing to an HDF5 file and then reading that file again? That would probably be much easier (and more general) to write. Perhaps it would help to have a chat about this? |
Hi @rieder, Thanks for the suggestion. That sounds like a good idea. Unfortunately, I don't have time at the moment to work on it as I'm writing up my PhD thesis. Hopefully, I'll have more time in December, or January next year. |
of course, that would be fine. good luck with the writing! |
Would you be interested in adding support for other snapshot formats, e.g. the AMUSE HDF5 format?
The text was updated successfully, but these errors were encountered: