Skip to content

Commit a156af7

Browse files
docs(part_mixin): instruct users to use the function ozzy.utils.axis_from_extent to create the axes Dataset required for bin_into_grid
1 parent f0f21a8 commit a156af7

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

src/ozzy/part_mixin.py

+20-5
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,24 @@ def bin_into_grid(
298298
Dataset containing grid axes information.
299299
300300
??? tip
301-
The axis information can be easily obtained from a grid Dataset (for example field data) with
301+
The axis information can be created for example with:
302302
```python
303-
axes_ds = fields_ds.coords
303+
import ozzy as oz
304+
nx = 200
305+
ny = 150
306+
xlims = (0.0, 30.0)
307+
ylims = (-4.0, 4.0)
308+
axes_ds = oz.Dataset(
309+
coords={
310+
"x1": oz.utils.axis_from_extent(nx, xlims),
311+
"x2": oz.utils.axis_from_extent(ny, ylims),
312+
},
313+
pic_data_type = "grid")
314+
```
315+
Or it can be obtained from an existing grid data object with:
316+
```python
317+
# fields may be an existing Dataset or DataArray
318+
axes_ds = fields.coords
304319
```
305320
306321
??? note "Note about axis attributes"
@@ -359,10 +374,10 @@ def bin_into_grid(
359374
# Create axes for binning
360375
axes = oz.Dataset(
361376
coords={
362-
"x1": np.linspace(0, 10, 101),
363-
"x2": np.linspace(0, 5, 51),
377+
"x1": oz.utils.axis_from_extent(100, (0.0, 10.0)),
378+
"x2": oz.utils.axis_from_extent(50, (0.0, 5.0)),
364379
},
365-
attrs={"pic_data_type": "grid"}
380+
pic_data_type = "grid",
366381
)
367382
368383
# Bin particles into grid (Cartesian geometry)

0 commit comments

Comments
 (0)