-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #417 from ufo-kit/add-progressbar
Add progressbar
- Loading branch information
Showing
8 changed files
with
155 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
"""Dummy experiments.""" | ||
|
||
import os | ||
from concert.experiments.base import Acquisition, Experiment | ||
from concert.devices.cameras.dummy import FileCamera | ||
from concert.progressbar import wrap_iterable | ||
|
||
|
||
class ImagingFileExperiment(Experiment): | ||
|
||
""" | ||
A typical imaging experiment which consists of acquiring dark, flat and radiographic images, in | ||
this case located on a disk. | ||
.. py:attribute:: directory | ||
Top directory with subdirectories containing the individual images | ||
.. py:attribute:: num_darks | ||
Number of dark images (no beam, just dark current) | ||
.. py:attribute:: num_flats | ||
Number of flat images (beam present, sample not) | ||
.. py:attribute:: num_radios | ||
Number of radiographic images | ||
.. py:attribute:: darks_dir | ||
Subdirectory name with dark images | ||
.. py:attribute:: flats_dir | ||
Subdirectory name with flat images | ||
.. py:attribute:: radio_dir | ||
Subdirectory name with radiographic images | ||
""" | ||
|
||
def __init__(self, directory, num_darks, num_flats, num_radios, darks_dir='darks', | ||
flats_dir='flats', radios_dir='projections', walker=None, separate_scans=True, | ||
name_fmt='scan_{:>04}'): | ||
self.directory = directory | ||
self.num_darks = num_darks | ||
self.num_flats = num_flats | ||
self.num_radios = num_radios | ||
self.darks_dir = darks_dir | ||
self.flats_dir = flats_dir | ||
self.radios_dir = radios_dir | ||
darks = Acquisition('darks', self.take_darks) | ||
flats = Acquisition('flats', self.take_flats) | ||
radios = Acquisition('radios', self.take_radios) | ||
super(ImagingFileExperiment, self).__init__([darks, flats, radios], walker=walker) | ||
|
||
def _produce_images(self, subdirectory, num): | ||
camera = FileCamera(os.path.join(self.directory, subdirectory)) | ||
for i in wrap_iterable(range(num)): | ||
yield camera.grab() | ||
|
||
def take_darks(self): | ||
return self._produce_images(self.darks_dir, self.num_darks) | ||
|
||
def take_flats(self): | ||
return self._produce_images(self.flats_dir, self.num_flats) | ||
|
||
def take_radios(self): | ||
return self._produce_images(self.radios_dir, self.num_radios) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"""Progress bar allows you to see the progress of long-term operations.""" | ||
|
||
import concert.config as cfg | ||
|
||
|
||
try: | ||
import tqdm | ||
except: | ||
cfg.PROGRESS_BAR = False | ||
|
||
|
||
def wrap_iterable(iterable, **kwargs): | ||
"""Wrap *iterable* so that a progress bar will be shown on iteration.""" | ||
if cfg.PROGRESS_BAR: | ||
iterable = tqdm.tqdm(iterable, **kwargs) | ||
|
||
return iterable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters