Open Tissot11 opened 4 months ago
thanks for the feedback. this is very much a work-in-progress package.
yes, the best way is to simply install it in a virtual environment:
# create virtual environment in the .venv directory
python3 -m venv .venv
# activate the virtual environment
source .venv/bin/activate
# check to ensure you are using the `pip` from that virtual environment
which pip # should print `.../.venv/bin/pip`
# install the package
pip install graph-et
if you use the python kernels from the same virtual environment -- it should directly recognize the package.
as long as the data is accessible from the place python instance is running, you can pass the absolute path to the data:
path = "/path/to/scratch/directory/simulation_dir/"
data_output_dir = f"{path}output/"
cfg_file = f"{path}input.cfg"
d = Data( TristanV2, # plugin steps=range(150), # steps to load metadata for path=data_output_dir", # path to the data cfg_fname=cfg_file, # configuration file )
if a functionality is missing (or is different from what you need -- you can always override the plugin with your own (inheriting from the `TristanV2` one):
```python
class MyOwnTristanV2(TristanV2):
def readField(self, field: str, step: int) -> h5py.Dataset:
... # here you can define your own `readField`
# rest of the functions will remain the same as in `TristanV2`
xarray
and dask
libraries, which load the metadata, and stack them properly. and you access the raw xarray
metadata via, for instance, data.fields
. then in principle you can do any sort of data manipulation including plotting etc:
d = Data(...) # load the metadata
tot_EM_energy = 0.5 * (d.fields.Ex2 + d.fields.Ey2 + d.fields.Ez2 + d.fields.Bx2 + d.fields.By2 + d.fields.Bz2).sum(("x", "y", "z"))
tot_EM_energy.plot()
plt.plot(tot_EM_energy.t, tot_EM_energy)
slice_dens = (d.fields.dens1 + d.fields.dens2).sel(z=0, t=10, method="nearest")
slice_dens.plot()
plt.pcolormesh(slice_dens.x, slice_dens.y, slice_dens)
Thanks for your answer and the example. I could now use the plugin and plot the data for the test simulation.
By basic functionality I meant what you indeed provide for in this plugin e.g. being able to read simulation data file along with attributes (defined in the input and user files) and able to extract data between time-steps and physical domains like you showed in the example above. Since I am new to Tristan, I still can get occasionally confused by few things and I still wanted to ask few questions related to this Plugin for TristanV2
cfg_fname=cfg_file
in your Plugin?u, v, w, ind, proc and wei
. I suppose these are three component of velocities, indices of particles, processors IDs, and weight,
respectively? I didn't save or used these in the test simulation but rather they were asserted in the testTristan routine of your plugin. So do they appear always in all simulations? As mentioned above, I essentially would only be expecting to get the info and extract the attributes and parameters of a given simulation using your plugin.Thanks again!
Thanks for sharing the link on Tristan website. I did try it but somehow I noticed few problems. I need to understand few things
Data()
routine? Also the path string needs be changed at least at one place in the package?https://github.com/PrincetonUniversity/tristan-mp-pu/wiki/Writing-your-own-python-scripts
Thanks for the help!