Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelLucaAdams committed Aug 9, 2024
1 parent 2645ee7 commit 0ca77fb
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
```

0 comments on commit 0ca77fb

Please sign in to comment.