From 0ca77fba1df7d522b889f4a7b8e80ac58fe956df Mon Sep 17 00:00:00 2001 From: JoelLucaAdams Date: Fri, 9 Aug 2024 13:38:03 +0100 Subject: [PATCH] Update readme --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index 3690ea0..2dce88c 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ pip install . `sdf-xarray` is a backend for xarray, and so is usable directly from xarray: +### Single file loading ```python import xarray as xr @@ -39,3 +40,25 @@ print(df["Electric Field/Ex"]) # Attributes: # units: V/m ``` + +### Multi file loading +```python +ds = xr.open_mfdataset( + "*.sdf", + concat_dim="time", + combine="nested", + data_vars='minimal', + coords='minimal', + compat='override', + preprocess=lambda ds: ds.expand_dims(time=[ds.attrs["time"]]) +) + +print(ds) + +# Dimensions: +# time: 301, X_Grid_mid: 128, Y_Grid_mid: 128, Px_px_py/Photon: 200, Py_px_py/Photon: 200, X_Grid: 129, Y_Grid: 129, Px_px_py/Photon_mid: 199, Py_px_py/Photon_mid: 199 +# Coordinates: (9) +# Data variables: (18) +# Indexes: (9) +# Attributes: (22) +```