diff --git a/xbout/boutdataarray.py b/xbout/boutdataarray.py index 3e54f402..a8bf533f 100644 --- a/xbout/boutdataarray.py +++ b/xbout/boutdataarray.py @@ -1169,3 +1169,13 @@ def as_cherab_emitter( cylinder_rmax=cyliner_rmax, step=step, ) + + def final_time(self): + """ + Returns the final time in the Dataset whether + it contains a time dimension or not. + """ + if "t" in self.data.sizes: + return self.data.isel(t=-1) + else: + return self.data diff --git a/xbout/boutdataset.py b/xbout/boutdataset.py index 94987b4b..fe31bd12 100644 --- a/xbout/boutdataset.py +++ b/xbout/boutdataset.py @@ -1356,6 +1356,16 @@ def with_cherab_grid(self): return grid.ds_with_cherab_grid(self.data) + def final_time(self): + """ + Returns the final time in the Dataset whether + it contains a time dimension or not. + """ + if "t" in self.data.sizes: + return self.data.isel(t=-1) + else: + return self.data + def _find_major_vars(data): """ diff --git a/xbout/xarraybackend.py b/xbout/xarraybackend.py index 38f4d65c..6a9644c5 100644 --- a/xbout/xarraybackend.py +++ b/xbout/xarraybackend.py @@ -1,6 +1,6 @@ """License: - Distributed under the OSI-approved Apache License, Version 2.0. See - accompanying file Copyright.txt for details. +Distributed under the OSI-approved Apache License, Version 2.0. See +accompanying file Copyright.txt for details. """ from __future__ import annotations