Metadata-Version: 2.3
Name: graph-et
Version: 0.1.3
Summary: library for efficient loading of particle-in-cell simulation data produced by a variety of different codes
Project-URL: Repository, https://github.com/haykh/graph-et
Author-email: Hayk <haykh.astro@gmail.com>
Maintainer-email: Hayk <haykh.astro@gmail.com>
License: BSD 3-Clause License
        
        Copyright (c) 2024, @haykh
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
License-File: LICENSE
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.8
Requires-Dist: dask>=2024.1.1
Requires-Dist: h5pickle>=0.4.2
Requires-Dist: h5py>=3.10.0
Requires-Dist: numpy>=1.26.4
Requires-Dist: pandas>=2.2.0
Requires-Dist: pyarrow>=15.0.0
Requires-Dist: xarray>=2024.1.1
Description-Content-Type: text/markdown

# `graph-et` [grɑːf iː.tiː.]

`dask` and `xarray` based library for loading particle-in-cell simulation data produced by a variety of different codes. The support for arbitrary codes is provided through the so-called plugins. Currently supported (and planned) codes include:

- [ ] Tristan v1
- [x] Tristan v2

### Usage example

```python
from graphet import Data
from graphet.plugins import TristanV2

# load the metadata using the TristanV2 plugin
d = Data(
    TristanV2,              # plugin
    steps=range(150),       # steps to load metadata for
    path=f"output/",        # path to the data
    cfg_fname=f"input.cfg", # configuration file
    params=True,            # read configuration file
    coord_transform={       # time/coordinate transformation
        "t": lambda t, prm: t * prm["output:interval"] * prm["algorithm:c"] / prm["grid:my0"],
        "x": lambda x, prm: (x - x.mean()) / prm["grid:my0"],
        "z": lambda z, prm: (z - z.mean()) / prm["grid:my0"],
        "y": lambda y, prm: (y - y.mean()) / prm["grid:my0"],
    },
    swapaxes=[(0, 1), (2, 1)],  # axes swapping "zyx" -> "yxz"
)
# main containers are
d.fields      # <- fields
d.particles   # <- particles
d.spectra     # <- spectra

## Examples of doing useful stuff

# plot averaged spectra of species #2 between 1.5 < t < 2.2
d.spectra.n2.sel(t=slice(1.5, 2.2)).mean("t").plot()

# plot the density of species #1 and #2 at time t = 2.5 and y = 0.1
(d.fields.dens1 + d.fields.dens2).sel(y=0.1, t=2.5, method="nearest").plot(cmap="turbo")

# compute the distribution function from the particle data for species #3 at 1.5 < t < 2.2
cnt, _ = np.histogram(
    (np.sqrt(1 + d.particles[3].u ** 2 + d.particles[3].v ** 2 + d.particles[3].w ** 2) - 1)
    .sel(t=slice(1.5, 2.2)).mean("t"),
    bins=np.logspace(-1, 3, 100),
)
```

### Todo

- [ ] Add support for `TristanV1` plugin
- [x] Coordinate transformations for particles
- [x] Support for coordinate swapping in field names
- [ ] Support for custom defined fields
