From 10cc9f5bc2412febbc5cd40f7d04d08e16db3b0e Mon Sep 17 00:00:00 2001 From: Rafael Gort <rafael.gort@xfel.eu> Date: Sun, 3 May 2020 19:50:50 +0200 Subject: [PATCH] Altered logging in dssc module. Started doc --- doc/index.rst | 38 +++++++++++++++++++++ index.rst | 18 +++++++++- src/toolbox_scs/detectors/dssc.py | 6 ++-- src/toolbox_scs/misc/data_handling.py | 8 +++++ src/toolbox_scs/test/test_detectors_dssc.py | 19 +++++------ 5 files changed, 75 insertions(+), 14 deletions(-) create mode 100644 src/toolbox_scs/misc/data_handling.py diff --git a/doc/index.rst b/doc/index.rst index 50b3c80..8b99ebf 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -1,10 +1,48 @@ ``Getting started`` ~~~~~~~~~~~~~~~~~~~ +Installation +------------ +The ToolBox may be installed in any environment. However, it depends on the extra_data and the euxfel_bunch_pattern package, which are no official third party python modules. Within environments where the latter are not present, they need to be installed by hand. + +Furthermore, as long as the ToolBox is not yet added to one of our custom environments, it needs to be installed locally. Activate your preferred environment and check installation of scs_toolbox by typing: + +.. code:: bash + + pip show toolbox_scs + +If the toolbox has been installed in your home directory previously, everything is set up. Otherwise it needs to be installed (only once). In that case enter following command from the the ToolBox top-level directory: + +.. code:: bash + + pip install --user . + +Alternatively, use the -e flag for installation to install the package in development mode. + +.. code:: bash + + pip install --user -e . + ``How to`` ~~~~~~~~~~ +Top level +--------- + +.. code:: python3 + + import toolbox_scs as tb + +misc +---- + +detectors:dssc + ``Contribute`` ~~~~~~~~~~~~~~ + +Code structuring, pep8 + +https://www.python.org/dev/peps/pep-0008/#a-foolish-consistency-is-the-hobgoblin-of-little-minds diff --git a/index.rst b/index.rst index 0f838a4..46e3b92 100644 --- a/index.rst +++ b/index.rst @@ -10,4 +10,20 @@ The SCS Toolbox Module index ============ -*to be done* +*to to* (automatized doc generation) + +**toolbox_scs**: Top-level entry point + +**detectors**: detector specific routines + +**plot**: Collected plotting routines + +**routines**: Automatized evaluations involving several instruments + +**misc**: Various sub-routines and helper functions + +**test**: Test environment + +**util**: Package related routines + + diff --git a/src/toolbox_scs/detectors/dssc.py b/src/toolbox_scs/detectors/dssc.py index 1bb38f1..31b32fc 100644 --- a/src/toolbox_scs/detectors/dssc.py +++ b/src/toolbox_scs/detectors/dssc.py @@ -317,7 +317,6 @@ def process_dssc_module(job): """ - log.info(f"processing dssc module {module}: start") proposal = job['proposal'] run_nr = job['run_nr'] module = job['module'] @@ -331,8 +330,9 @@ def process_dssc_module(job): include=f'*DSSC{module:02d}*') ntrains = len(collection.train_ids) - # read preprocessed scan variable from file - selection and (possibly) - # rounding already done. + log.info(f"Processing dssc module {module}: start") + + # read preprocessed scan variable from file scan = xr.open_dataarray(scanfile, 'data', engine='h5netcdf') # read binary pulse/train mask - e.g. from XGM thresholding diff --git a/src/toolbox_scs/misc/data_handling.py b/src/toolbox_scs/misc/data_handling.py new file mode 100644 index 0000000..caaef8d --- /dev/null +++ b/src/toolbox_scs/misc/data_handling.py @@ -0,0 +1,8 @@ +def dssc_safe_processed(): + pass + +def dssc_safe_dark(): + pass + +def dssc_load_mask(): + pass \ No newline at end of file diff --git a/src/toolbox_scs/test/test_detectors_dssc.py b/src/toolbox_scs/test/test_detectors_dssc.py index eb54fac..ce3757b 100644 --- a/src/toolbox_scs/test/test_detectors_dssc.py +++ b/src/toolbox_scs/test/test_detectors_dssc.py @@ -43,7 +43,6 @@ suites = {"no-processing": ( "test_prepareempty", "test_loadchunkdata", "test_splitframes", - "test_mergechunks", ), "full": ( "test_info", @@ -52,7 +51,6 @@ suites = {"no-processing": ( "test_prepareempty", "test_loadchunkdata", "test_splitframes", - "test_mergechunks", "test_processmodule", ) } @@ -88,6 +86,7 @@ class TestDSSC(unittest.TestCase): log_root.info("Finished global setup, start tests") + @classmethod def tearDownClass(cls): log_root.info("Clean up test environment....") @@ -159,12 +158,12 @@ class TestDSSC(unittest.TestCase): log_root.debug(f"Loaded {ntrains} trains for {sourcename}") + @unittest.skipIf(is_dark == True, "No xgm data") def test_splitframes(self): - pass - - - def test_mergechunks(self): - pass + cls = self.__class__ + pulses_no_dark = [p for p in framepattern if 'dark' not in p] + data = tbdet.split_frames(cls._xgm, pulses_no_dark, prefix='xgm_') + self.assertIsNotNone(data) def test_processmodule(self): @@ -175,7 +174,7 @@ class TestDSSC(unittest.TestCase): print('processing', chunksize, 'trains per chunk') jobs = [] - for m in range(16): + for m in range(2): jobs.append(dict( proposal=proposal, run_nr=run_nr, @@ -188,11 +187,11 @@ class TestDSSC(unittest.TestCase): print(f'start processing modules:', strftime('%X')) - with multiprocessing.Pool(16) as pool: + with multiprocessing.Pool(2) as pool: module_data = pool.map(tbdet.process_dssc_module, jobs) print('finished processing modules:', strftime('%X')) - + def list_suites(): print("""\nPossible test suites:\n-------------------------""") -- GitLab