Skip to content

Commit 65e3560

Browse files
authored
Merge pull request #315 from boutproject/final-time
Add helper accessor to return final time slice
2 parents cb87f23 + 1053212 commit 65e3560

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

xbout/boutdataarray.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,3 +1169,12 @@ def as_cherab_emitter(
11691169
cylinder_rmax=cyliner_rmax,
11701170
step=step,
11711171
)
1172+
1173+
def final_time(self):
1174+
"""
1175+
Returns the final time in the Dataset whether
1176+
it contains a time dimension or not.
1177+
"""
1178+
if "t" in self.data.sizes:
1179+
return self.data.isel(t=-1)
1180+
return self.data

xbout/boutdataset.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,15 @@ def with_cherab_grid(self):
13561356

13571357
return grid.ds_with_cherab_grid(self.data)
13581358

1359+
def final_time(self):
1360+
"""
1361+
Returns the final time in the Dataset whether
1362+
it contains a time dimension or not.
1363+
"""
1364+
if "t" in self.data.sizes:
1365+
return self.data.isel(t=-1)
1366+
return self.data
1367+
13591368

13601369
def _find_major_vars(data):
13611370
"""

xbout/xarraybackend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""License:
2-
Distributed under the OSI-approved Apache License, Version 2.0. See
3-
accompanying file Copyright.txt for details.
2+
Distributed under the OSI-approved Apache License, Version 2.0. See
3+
accompanying file Copyright.txt for details.
44
"""
55

66
from __future__ import annotations

0 commit comments

Comments
 (0)