moved some more npy utils into general utils folder
This commit is contained in:
@@ -2,6 +2,8 @@ from time import sleep
|
||||
import numpy as np
|
||||
from epics import PV
|
||||
|
||||
from slic.utils import get_dtype, get_shape
|
||||
|
||||
from .acquisition import Acquisition
|
||||
|
||||
|
||||
@@ -75,22 +77,6 @@ def make_arrays(pvs, n_pulses):
|
||||
return arrays
|
||||
|
||||
|
||||
def get_dtype(v):
|
||||
if is_array(v):
|
||||
return v.dtype
|
||||
else:
|
||||
return type(v)
|
||||
|
||||
def get_shape(v):
|
||||
if is_array(v):
|
||||
return v.shape
|
||||
else:
|
||||
return tuple()
|
||||
|
||||
def is_array(v):
|
||||
return isinstance(v, np.ndarray)
|
||||
|
||||
|
||||
def write_to_h5(filename, channels, arrays):
|
||||
if filename == "/dev/null":
|
||||
return
|
||||
|
||||
@@ -6,7 +6,7 @@ from .elog import Elog
|
||||
from .fs_tools import can_create_file, glob_files, make_dir
|
||||
from .ipy_tools import devices
|
||||
from .json_tools import json_dump
|
||||
from .npy_tools import fraction_to_percentage, within, within_fraction
|
||||
from .npy_tools import fraction_to_percentage, within, within_fraction, get_dtype, get_shape, is_array
|
||||
from .screenshot import Screenshot
|
||||
|
||||
|
||||
|
||||
@@ -25,4 +25,20 @@ def fraction_to_percentage(fraction, ndigits=1):
|
||||
return percentage
|
||||
|
||||
|
||||
def get_dtype(v):
|
||||
if is_array(v):
|
||||
return v.dtype
|
||||
else:
|
||||
return type(v)
|
||||
|
||||
def get_shape(v):
|
||||
if is_array(v):
|
||||
return v.shape
|
||||
else:
|
||||
return tuple()
|
||||
|
||||
def is_array(v):
|
||||
return isinstance(v, np.ndarray)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user