From ec7c8d2836f9c9bb0a6b6329416a9a4a65caf7de Mon Sep 17 00:00:00 2001 From: gbal Date: Mon, 15 Jun 2020 16:32:19 -0700 Subject: [PATCH 1/8] Test example foo function --- bapsflib/utils/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bapsflib/utils/__init__.py b/bapsflib/utils/__init__.py index 151562fb..2281185f 100644 --- a/bapsflib/utils/__init__.py +++ b/bapsflib/utils/__init__.py @@ -14,3 +14,7 @@ __all__ = ['decorators', 'errors', 'warnings'] from . import (decorators, errors, warnings) + + +def foo(x): + return x From c8ded4972851b95a666a963b5e3cb01e95070376 Mon Sep 17 00:00:00 2001 From: gbal Date: Tue, 16 Jun 2020 10:22:00 -0700 Subject: [PATCH 2/8] Test example foo function --- bapsflib/utils/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bapsflib/utils/__init__.py b/bapsflib/utils/__init__.py index 2281185f..a3419461 100644 --- a/bapsflib/utils/__init__.py +++ b/bapsflib/utils/__init__.py @@ -16,5 +16,11 @@ from . import (decorators, errors, warnings) -def foo(x): +def NdarrayToXarray(data, name={}): + names = list(data.dtype.names) + names.remove('signal') + i=0 + while i Date: Tue, 30 Jun 2020 13:23:54 -0700 Subject: [PATCH 3/8] This commit includes a working module for converting lapd data array to xarray. Module is called NdaarayToXarray --- bapsflib/utils/__init__.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/bapsflib/utils/__init__.py b/bapsflib/utils/__init__.py index a3419461..de0fde80 100644 --- a/bapsflib/utils/__init__.py +++ b/bapsflib/utils/__init__.py @@ -11,16 +11,24 @@ """ Package of developer utilities. """ -__all__ = ['decorators', 'errors', 'warnings'] +__all__ = ['decorators', 'errors', 'warnings', 'NdarrayToXarray'] from . import (decorators, errors, warnings) -def NdarrayToXarray(data, name={}): +def NdarrayToXarray(data, arr_name={}): + import xarray as xr names = list(data.dtype.names) names.remove('signal') - i=0 - while i Date: Mon, 6 Jul 2020 10:02:01 -0700 Subject: [PATCH 4/8] Update bapsflib/utils/__init__.py change module name Co-authored-by: Erik Everson --- bapsflib/utils/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bapsflib/utils/__init__.py b/bapsflib/utils/__init__.py index de0fde80..2b65a397 100644 --- a/bapsflib/utils/__init__.py +++ b/bapsflib/utils/__init__.py @@ -16,7 +16,7 @@ from . import (decorators, errors, warnings) -def NdarrayToXarray(data, arr_name={}): +def ndarray_to_xarray(data, arr_name={}): import xarray as xr names = list(data.dtype.names) names.remove('signal') From 4fa71fe00b909f9f3a7fb08db70abb6d7a86a24f Mon Sep 17 00:00:00 2001 From: gkbal <41760499+gkbal@users.noreply.github.com> Date: Mon, 6 Jul 2020 10:02:37 -0700 Subject: [PATCH 5/8] Update bapsflib/utils/__init__.py "shot_index" to "shotnum" Co-authored-by: Erik Everson --- bapsflib/utils/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bapsflib/utils/__init__.py b/bapsflib/utils/__init__.py index 2b65a397..6435c82c 100644 --- a/bapsflib/utils/__init__.py +++ b/bapsflib/utils/__init__.py @@ -23,12 +23,12 @@ def ndarray_to_xarray(data, arr_name={}): coords_dict = {} for name in names: if name == 'xyz': - coords_dict["x"] = ("shot_index", data[name][:, 0]) - coords_dict["y"] = ("shot_index", data[name][:, 1]) - coords_dict["z"] = ("shot_index", data[name][:, 2]) + coords_dict["x"] = ("shotnum", data[name][:, 0]) + coords_dict["y"] = ("shotnum", data[name][:, 1]) + coords_dict["z"] = ("shotnum", data[name][:, 2]) else: - coords_dict[name] = ("shot_index", data[name]) + coords_dict[name] = ("shotnum", data[name]) # coords_test={names[0]:("shot_index",data[names[0]]),"x":("shot_index",data[names[1]][:,0]),"y":("shot_index",data[names[1]][:,1]),"z":("shot_index",data[names[1]][:,2]),names[2]:("shot_index",data[names[2]]),names[3]:("shot_index",data[names[3]])} data_array = xr.DataArray(data['signal'], dims=('shot_index', 'time_index'), coords=coords_dict,name=arr_name) From 2b7d16843b47f3de68ec56926aace533a0722c79 Mon Sep 17 00:00:00 2001 From: gkbal <41760499+gkbal@users.noreply.github.com> Date: Mon, 6 Jul 2020 10:03:17 -0700 Subject: [PATCH 6/8] Update bapsflib/utils/__init__.py "shot_index" to "shotnum" 2 Co-authored-by: Erik Everson --- bapsflib/utils/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bapsflib/utils/__init__.py b/bapsflib/utils/__init__.py index 6435c82c..14eabbf5 100644 --- a/bapsflib/utils/__init__.py +++ b/bapsflib/utils/__init__.py @@ -31,4 +31,5 @@ def ndarray_to_xarray(data, arr_name={}): coords_dict[name] = ("shotnum", data[name]) # coords_test={names[0]:("shot_index",data[names[0]]),"x":("shot_index",data[names[1]][:,0]),"y":("shot_index",data[names[1]][:,1]),"z":("shot_index",data[names[1]][:,2]),names[2]:("shot_index",data[names[2]]),names[3]:("shot_index",data[names[3]])} - data_array = xr.DataArray(data['signal'], dims=('shot_index', 'time_index'), coords=coords_dict,name=arr_name) + data_array = xr.DataArray(data['signal'], dims=('shotnum', 'time_index'), coords=coords_dict, name=arr_name) + return data_array From d7a2f86928b5af193f8dafe4cc1a86a02836efb2 Mon Sep 17 00:00:00 2001 From: gbal Date: Mon, 6 Jul 2020 11:40:53 -0700 Subject: [PATCH 7/8] NdarrayToXarray updates --- bapsflib/utils/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bapsflib/utils/__init__.py b/bapsflib/utils/__init__.py index de0fde80..c777755e 100644 --- a/bapsflib/utils/__init__.py +++ b/bapsflib/utils/__init__.py @@ -13,11 +13,12 @@ """ __all__ = ['decorators', 'errors', 'warnings', 'NdarrayToXarray'] +import xarray as xr + from . import (decorators, errors, warnings) def NdarrayToXarray(data, arr_name={}): - import xarray as xr names = list(data.dtype.names) names.remove('signal') coords_dict = {} From 59926953017e568a384a579ae705a3db2f79567c Mon Sep 17 00:00:00 2001 From: gbal Date: Mon, 6 Jul 2020 12:24:21 -0700 Subject: [PATCH 8/8] NdarrayToXarray updates 2 --- bapsflib/utils/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bapsflib/utils/__init__.py b/bapsflib/utils/__init__.py index 1523afa0..772c4b8c 100644 --- a/bapsflib/utils/__init__.py +++ b/bapsflib/utils/__init__.py @@ -11,7 +11,7 @@ """ Package of developer utilities. """ -__all__ = ['decorators', 'errors', 'warnings', 'NdarrayToXarray'] +__all__ = ['decorators', 'errors', 'warnings', 'ndarray_to_xarray'] import xarray as xr @@ -31,6 +31,5 @@ def ndarray_to_xarray(data, arr_name={}): else: coords_dict[name] = ("shotnum", data[name]) - # coords_test={names[0]:("shot_index",data[names[0]]),"x":("shot_index",data[names[1]][:,0]),"y":("shot_index",data[names[1]][:,1]),"z":("shot_index",data[names[1]][:,2]),names[2]:("shot_index",data[names[2]]),names[3]:("shot_index",data[names[3]])} data_array = xr.DataArray(data['signal'], dims=('shotnum', 'time_index'), coords=coords_dict, name=arr_name) return data_array