Skip to content

Commit da9de67

Browse files
Merge pull request #75 from dihm/lyse-docs
Initial Pass at Lyse docs
2 parents f7a1427 + 4b614cb commit da9de67

10 files changed

+203
-1
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Analysis Subprocess
2+
=====================
3+
4+
.. automodule:: lyse.analysis_subprocess
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Dataframe Utilities
2+
======================
3+
4+
.. automodule:: lyse.dataframe_utilities
5+
:members:
6+
:undoc-members:
7+
:inherited-members:
8+
:show-inheritance:

docs/source/api/index.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
API Reference
3+
=============
4+
5+
.. toctree::
6+
:maxdepth: 2
7+
8+
lyse_functions
9+
run
10+
sequence
11+
dataframe_utilities
12+
analysis_subprocess

docs/source/api/lyse_functions.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Lyse Helper Functions
2+
========================
3+
4+
.. automodule:: lyse
5+
:members:
6+
:undoc-members:
7+
:exclude-members: Run, Sequence

docs/source/api/run.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Run
2+
==========
3+
4+
.. autoclass:: lyse.Run
5+
:members:
6+
:undoc-members:
7+
:inherited-members:
8+
:show-inheritance:
9+
10+
.. automethod:: lyse.Run.__init__

docs/source/api/sequence.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Sequence
2+
==========
3+
4+
.. autoclass:: lyse.Sequence
5+
:members:
6+
:undoc-members:
7+
:inherited-members:
8+
:show-inheritance:
9+
10+
.. automethod:: lyse.Sequence.__init__

docs/source/examples.rst

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
Examples
2+
==========
3+
4+
An analysis on a single shot
5+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6+
7+
.. code-block:: python
8+
9+
from lyse import *
10+
from pylab import *
11+
12+
# Let's obtain our data for this shot -- globals, image attributes and
13+
# the results of any previously run single-shot routines:
14+
ser = data(path)
15+
16+
# Get a global called x:
17+
x = ser['x']
18+
19+
# Get a result saved by another single-shot analysis routine which has
20+
# already run. The result is called 'y', and the routine was called
21+
# 'some_routine':
22+
y = ser['some_routine','y']
23+
24+
# Image attributes are also stored in this series:
25+
w_x2 = ser['side','absorption','OD','Gaussian_XW']
26+
27+
# If we want actual measurement data, we'll have to instantiate a Run object:
28+
run = Run(path)
29+
30+
# Obtaining a trace:
31+
t, mot_fluorecence = run.get_trace('mot fluorecence')
32+
33+
# Now we might do some analysis on this data. Say we've written a
34+
# linear fit function (or we're calling some other libaries linear
35+
# fit function):
36+
m, c = linear_fit(t, mot_fluorecence)
37+
38+
# We might wish to plot the fit on the trace to show whether the fit is any good:
39+
40+
plot(t,mot_fluorecence,label='data')
41+
plot(t,m*t + x,label='linear fit')
42+
xlabel('time')
43+
ylabel('MOT flourescence')
44+
legend()
45+
46+
# Don't call show() ! lyse will introspect what figures have been made
47+
# and display them once this script has finished running. If you call
48+
# show() it won't find anything. lyse keeps track of figures so that new
49+
# figures replace old ones, rather than you getting new window popping
50+
# up every time your script runs.
51+
52+
# We might wish to save this result so that we can compare it across
53+
# shots in a multishot analysis:
54+
run.save_result('mot loadrate', c)
55+
56+
57+
An analysis on multiple shots
58+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
59+
60+
.. code-block:: python
61+
62+
from lyse import *
63+
from pylab import *
64+
65+
# Let's obtain the dataframe for all of lyse's currently loaded shots:
66+
df = data()
67+
68+
# Now let's see how the MOT load rate varies with, say a global called
69+
# 'detuning', which might be the detuning of the MOT beams:
70+
71+
detunings = df['detuning']
72+
73+
# mot load rate was saved by a routine called calculate_load_rate:
74+
75+
load_rates = df['calculate_load_rate', 'mot loadrate']
76+
77+
# Let's plot them against each other:
78+
79+
plot(detunings, load_rates,'bo',label='data')
80+
81+
# Maybe we expect a linear relationship over the range we've got:
82+
m, c = linear_fit(detunings, load_rates)
83+
# (note, not a function provided by lyse, though I'm sure we'll have
84+
# lots of stock functions like this available for import!)
85+
86+
plot(detunings, m*detunings + c, 'ro', label='linear fit')
87+
legend()
88+
89+
#To save this result to the output hdf5 file, we have to instantiate a
90+
#Sequence object:
91+
seq = Sequence(path, df)
92+
seq.save_result('detuning_loadrate_slope',c)
93+
94+
.. sectionauthor:: Chris Billington

docs/source/img/gui.svg

Lines changed: 1 addition & 0 deletions
Loading

docs/source/index.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66
lyse
77
====
88

9+
**lyse** is a component of the labscript suite. It is a combination API and GUI interface that leverages the API to run user provided analysis scripts of experiment shots. This documentation provides a brief outline of the use of lyse.
10+
911
.. toctree::
1012
:maxdepth: 2
1113
:hidden:
1214
:caption: DOCUMENTATION
1315

14-
16+
introduction
17+
examples
18+
api/index
1519

1620
.. toctree::
1721
:maxdepth: 2

docs/source/introduction.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
Introduction
2+
==============
3+
4+
**Lyse** is a data analysis system which gets *your code* running on experimental data as it is acquired. It is fundamenally based around the ideas of experimental *shots* and analysis *routines*. A shot is one trial of an experiment, and a routine is a ``Python`` script, written by you, that does something with the measurement data from one or more shots.
5+
6+
Analysis routines can be either *single-shot* or *multi-shot*. This determines what data and functions are available to your code when it runs. A single-shot routine has access to the data from only one shot, and functions available for saving results only to the hdf5 file for that shot. A a multi-shot routine has access to the entire dataset from all the runs that are currently loaded into **lyse**, and has functions available for saving results to an hdf5 file which does not belong to any of the shots---it's a file that exists only to save the "meta results".
7+
8+
Actually things are far less magical than that. The only enforced difference between a single shot routine and a multi-shot routine is a single variable provided to your code when **lyse** runs it. Your code runs in a perfectly clean ``Python`` environment with this one exception: a variable in the global namespace called ``path``, which is a path to an hdf5 file. If you have told **lyse** that your routine is a singleshot one, then this path will point to the hdf5 file for the current shot being analysed. On the other hand, if you've told **lyse** that your routine is a multishot one, then it will be the path to an h5 file that has been selected in **lyse** for saving results to.
9+
10+
The other differences listed above are conventions only (though **lyse**'s design is based around the assumption that you'll follow these conventions most of the time), and pertain to how you use the API that **lyse** provides, which will be different depending on what sort of analysis you're doing.
11+
12+
The **lyse** API
13+
~~~~~~~~~~~~~~~~~
14+
15+
So grea, you've got a single filepath. What data analysis could you possibly do with that? It might seem like you have to still do the same amount of work that you would without an analysis system! Whilst that's not quite true, it's intentionally been designed that way so that you can run your code outside **lyse** with very little modification. Another motivating factor is to minimise the amount of magic black box behaviour, such that an analysis routine is actually just an ordinary ``Python`` script which makes use of an API designed for our purposes. **lyse** is both a program which executes your code, and an API that your code can call on.
16+
17+
To use the API in an analysis routine, begine your code with:
18+
19+
.. code-block:: python
20+
21+
from lyse import *
22+
23+
The details of the API are found in the :doc:`API reference<api/index>`.
24+
25+
**lyse** GUI
26+
~~~~~~~~~~~~~~~
27+
28+
The **lyse** GUI uses the API to apply single and multi-shot routines to collections of shot files, added either manually by the user or automatically by BLACS after shot completion.
29+
30+
Here's a screenshot of **lyse**:
31+
32+
.. image:: /img/gui.svg
33+
:alt: Lyse Screenshot
34+
35+
1. Here's where single shot routines can be added and removed, with the plus and minus buttons. They will be executed in order on each shot (more on how that works shortly). They can be reordered, or enabled/disabled with the checkboxes on the left. The checkboxes to the right, underneath the plot icons don't currently do anything, but they are intended to provide control over how plots generated by the analysis routines are displayed and updated.
36+
37+
2. Here is where multi-shot routines can be added or removed. The file selection button at the top allows you to select what hdf5 file multi-shot routines will get given (to which they will save their results).
38+
39+
3. Allows pausing of analysis. **lyse** by default will run all single-shot routines on a shot when it arrives (either via the HTTP server or having been manually added). After all the shots have been processed, only then will the multi-shot routines be executed. So if you load ten shots in quickly, the multi-shot routines won't run until they've all been processed by the single-shot routines. However most of the time there will be sufficient delay in between shots arriving that multi-shot routines will be executed pretty much every time a new shot arrives.
40+
41+
4. If you want to re-run single-shot analyses on some shots, select them and click this button. They'll then be processed in order.
42+
43+
5. This will rerun all the multi-shot analyses.
44+
45+
6. Here is where shots appear, either having arrived over HTTP of having been added manually via the file browser (by clicking the plus button). Many columns will populate this part of the screen, one for each global and each of the results (as saved by single-shot routines) present in the shots. A high-priority planned feature is to be able to choose exactly which globals and results are displayed. Otherwise this display is overwhelming to the point of uselessness. The data displayed here represents the entirety of what is available to multi-shot routines via the API provided by **lyse**.
46+
47+
7. This is where the output of routines is displayed, errors in red. If you're putting ``print`` statements in your analysis code, here is where to look to see them. Likewise if there's an exception and analysis stops, look here to see why.
48+
49+
.. sectionauthor:: Chris Billington

0 commit comments

Comments
 (0)