From abceb3e262dff4c11437c49f38ddd6768db46c53 Mon Sep 17 00:00:00 2001 From: Akio Taniguchi Date: Sat, 13 Jul 2024 20:00:51 +0000 Subject: [PATCH] #168 Fix assign.scan not updating in-place --- decode/assign.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/decode/assign.py b/decode/assign.py index 07d8b05..b7e9121 100644 --- a/decode/assign.py +++ b/decode/assign.py @@ -32,10 +32,6 @@ def scan( DEMS DataArray to which the scan label are assigned. """ - if not inplace: - # deepcopy except for data - dems = dems.copy(data=dems.data) - is_div = xr.zeros_like(dems.scan, dtype=bool) ref = dems.coords[by].data @@ -45,4 +41,9 @@ def scan( is_div[1:] |= np.diff(dems.time) >= dt new_scan = is_div.cumsum().astype(dems.scan.dtype) - return dems.assign_coords(scan=new_scan) + + if inplace: + dems.coords["scan"][:] = new_scan + return dems + else: + return dems.assign_coords(scan=new_scan)