ufo-kit/concert — pull request #111 by sensej (2013-10-27 08:38:24+00:00)
Title: [WIP] Experiments upgrade

I tried to use an experiment by the pure generator-coroutine (GC further on) approach, but it turned out to be unusable because of the need to have control over when which images are acquired and read out. That is for some cases very hard to do by the GC approach. Moreover, an imaging experiment is too complex to be contained in one [function](https://github.com/ufo-kit/concert/blob/master/concert/experiments/imaging.py#L117-119) with plenty of parameters.

The GC approach would need to have some mechanism for telling it when to start (we discussed that in #63 already). It is not so straightforward to add an attribute to a created generator, and even if we would want to do it, there must be a reason for it not being so easy.

I think this could be a good compromise, there is still the base `Experiment` class where you can to do whatever you want, on the other hand there is a _template_ `Radiography` and as a user you specify how to generate the data and how to consume them, all the boilerplate, file output and logging are taken care of behind the scenes.

Example: an experiment which takes only the radiographs and outputs them to files.

```python
class SimpleRadiography(Radiography):

def __init__(self, root_folder, camera, num_radios):
super(SimpleRadiography, self).__init__(root_folder)
self.camera = camera
self.num_radios = num_radios

def acquire_radios(self):
return (frame for frame in self.camera.acquire(self.num_radios))
```

One could argue that a new class needs to be created, but I think it is better then tons of global variables. Anyway, I will use it next week and in the meantime we can think about it some more.