diff --git a/.gitignore b/.gitignore index 633ae29..185254f 100644 --- a/.gitignore +++ b/.gitignore @@ -283,3 +283,6 @@ modules.order Module.symvers Mkfile.old dkms.conf + +# Generated version file +src/sdf_xarray/_version.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 9119d88..bae788f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,9 @@ cmake_minimum_required(VERSION 3.15...3.27) -project(${SKBUILD_PROJECT_NAME} LANGUAGES C) + +project(${SKBUILD_PROJECT_NAME} + LANGUAGES C + VERSION ${SKBUILD_PROJECT_VERSION} +) add_subdirectory(SDF/C) diff --git a/LICENCE b/LICENCE new file mode 100644 index 0000000..ec7839f --- /dev/null +++ b/LICENCE @@ -0,0 +1,28 @@ +Copyright 2024, Peter Hill + +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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..3690ea0 --- /dev/null +++ b/README.md @@ -0,0 +1,41 @@ +# sdf-xarray + +`sdf-xarray` provides a backend for [xarray](https://xarray.dev) to +read SDF files as created by the [EPOCH](https://epochpic.github.io) +plasma PIC code. + +## Installation + +Until this is on PyPI, please install directly from this repo: + +``` +pip install git+https://github.com/PlasmaFAIR/sdf-xarray.git@main +``` + +or from a local checkout: + +``` +git clone https://github.com/PlasmaFAIR/sdf-xarray.git +cd sdf-xarray +pip install . +``` + +## Usage + +`sdf-xarray` is a backend for xarray, and so is usable directly from +xarray: + +```python +import xarray as xr + +df = xr.open_dataset("0010.sdf") + +print(df["Electric Field/Ex"]) + +# Size: 128B +# [16 values with dtype=float64] +# Coordinates: +# * X_x_px_deltaf/electron_beam (X_x_px_deltaf/electron_beam) float64 128B 1... +# Attributes: +# units: V/m +``` diff --git a/pyproject.toml b/pyproject.toml index 38a4aba..93cb89d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,19 @@ [build-system] requires = [ - "scikit-build-core", + "scikit-build-core>=0.3", + "setuptools_scm", "numpy>=2.0.0", ] build-backend = "scikit_build_core.build" [project] name = "sdf-xarray" -version = "0.0.1" +dynamic = ["version"] +license = {file = "LICENCE"} +readme = "README.md" +authors = [ + {name = "Peter Hill", email = "peter.hill@york.ac.uk"} +] requires-python = ">=3.9" dependencies = [ "numpy>=2.0.0", @@ -29,3 +35,10 @@ lint = ["ruff"] [project.entry-points."xarray.backends"] sdf_engine = "sdf_xarray:SDFEntrypoint" + +[tool.scikit-build] +metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" +sdist.include = ["src/sdf_xarray/_version.py"] + +[tool.setuptools_scm] +write_to = "src/sdf_xarray/_version.py"