From 2ec6ee842b4999036612c76b4d6703d03afafb57 Mon Sep 17 00:00:00 2001 From: Valerio Mariani <valerio.mariani@desy.de> Date: Thu, 25 May 2017 17:21:28 +0200 Subject: [PATCH] Code cleanup. Instroduced underscore notation for private functions, methods and attributes --- cfel_cxi.py | 12 ++++++++++-- cfel_fabio.py | 4 ++-- cfel_vtk.py | 4 ++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/cfel_cxi.py b/cfel_cxi.py index ce9d2b1..f128862 100644 --- a/cfel_cxi.py +++ b/cfel_cxi.py @@ -33,6 +33,7 @@ import numpy _CXISimpleEntry = namedtuple('SimpleEntry', ['path', 'data', 'overwrite']) + class _Stack: def __init__(self, path, data, axes): @@ -47,6 +48,13 @@ class _Stack: self._path = path self._axes = axes + def is_there_data_to_write(self): + + if self._data_to_write is not None: + return True + else: + return False + def write_initial_slice(self, file_handle, max_num_slices): file_handle.create_dataset(self._path, shape=(max_num_slices,) + self._data_shape, @@ -337,7 +345,7 @@ class CXIWriter: raise RuntimeError('The file already holds the maximum allowed number of slices, and should be closed') for entry in self._cxi_stacks.values(): - if entry._data_to_write is None: + if entry.is_there_data_to_write is False: raise RuntimeError('The slice is incomplete and will not be written. The following stack is not ' 'present in the current slice:', entry.path) @@ -376,4 +384,4 @@ class CXIWriter: self._fh.close() - self._file_is_open = False \ No newline at end of file + self._file_is_open = False diff --git a/cfel_fabio.py b/cfel_fabio.py index 98c3373..9785064 100644 --- a/cfel_fabio.py +++ b/cfel_fabio.py @@ -64,8 +64,8 @@ def read_cbf_from_stream(stream): if len(cbf_obj.cif[cbf_obj.CIF_BINARY_BLOCK_KEY]) > int( cbf_obj.header["X-Binary-Size"]) + cbf_obj.start_binary + len(cbf_obj.STARTER): cbf_obj.cbs = cbf_obj.cif[cbf_obj.CIF_BINARY_BLOCK_KEY][:int(cbf_obj.header["X-Binary-Size"]) + - cbf_obj.start_binary + - len(cbf_obj.STARTER)] + cbf_obj.start_binary + + len(cbf_obj.STARTER)] else: cbf_obj.cbs = cbf_obj.cif[cbf_obj.CIF_BINARY_BLOCK_KEY] binary_data = cbf_obj.cbs[cbf_obj.start_binary + len(cbf_obj.STARTER):] diff --git a/cfel_vtk.py b/cfel_vtk.py index 47bb0c7..f562d04 100644 --- a/cfel_vtk.py +++ b/cfel_vtk.py @@ -460,8 +460,12 @@ def scatterplot_3d(data, color=None, point_size=None, cmap="jet", point_shape=No color (Optional[numpy.ndimage]): 1D Array of floating points with same length as the data array. These numbers give the color of each point. + point_size (Optional[float]): The size of each points. Behaves differently depending on the point_shape. If shape is spheres the size is relative to the scene and if squares the size is relative to the window. + + cmap (Optional[str]): Color map + point_shape (Optional["spheres" or "squares"]): "spheres" plots each point as a sphere, recommended for small data sets. "squares" plot each point as a square without any 3D structure, recommended for large data sets. -- GitLab