Skip to content

Commit

Permalink
Add simple copy option
Browse files Browse the repository at this point in the history
Closes #137
  • Loading branch information
mwcraig committed Jul 17, 2016
1 parent 3369cfd commit e0377c4
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
47 changes: 47 additions & 0 deletions reducer/astro_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def __init__(self, *arg, **kwd):
allow_dark = kwd.pop('allow_dark', True)
allow_bias = kwd.pop('allow_bias', True)
allow_cosmic_ray = kwd.pop('allow_cosmic_ray', False)
allow_copy = kwd.pop('allow_copy_only', True)
self.image_collection = kwd.pop('input_image_collection', None)
self._master_source = kwd.pop('master_source', None)
super(Reduction, self).__init__(*arg, **kwd)
Expand All @@ -100,6 +101,13 @@ def __init__(self, *arg, **kwd):
self._bias_calib = BiasSubtract(master_source=self._master_source)
self._dark_calib = DarkSubtract(master_source=self._master_source)
self._flat_calib = FlatCorrect(master_source=self._master_source)

if allow_copy:
self._copy_only = CopyFiles()
self.add_child(self._copy_only)
else:
self._copy_only = None

self.add_child(self._overscan)
self.add_child(self._trim)

Expand All @@ -113,6 +121,12 @@ def __init__(self, *arg, **kwd):
if allow_cosmic_ray:
self.add_child(self._cosmic_ray)

if self._copy_only:
self._copy_only._state_monitor.on_trait_change(
self._disable_all_others(),
str('value')
)

def action(self):
if not self.image_collection:
raise ValueError("No images to reduce")
Expand Down Expand Up @@ -177,6 +191,24 @@ def action(self):
finally:
self.progress_bar.visible = False

def _disable_all_others(self):
if not self._copy_only:
return None

def handler():
all_but_copy = [c for c in self.container.children
if c is not self._copy_only]

if self._copy_only._state_monitor.value:
for child in all_but_copy:
print(child.description)
child.disabled = True
else:
for child in all_but_copy:
child.disabled = False

return handler


class Clipping(gui.ToggleContainer):
"""docstring for Clipping"""
Expand Down Expand Up @@ -701,6 +733,21 @@ def _master_image(self, selector, closest=None):
return self._image_cache[path]


class CopyFiles(gui.ToggleContainer):
"""
Just copy images to destination directory without modifying the file.
Useful, for example, if the bias frames have no overscan and do not need
to be trimmed.
"""
def __init__(self, **kwd):
desc = kwd.pop('description', 'Copy without any other action?')
kwd['description'] = desc
super(CopyFiles, self).__init__(**kwd)

def action(self, ccd):
return ccd


class BiasSubtract(CalibrationStep):
"""
Subtract bias from an image using widget settings.
Expand Down
2 changes: 1 addition & 1 deletion reducer/reducer-template.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# IPython notebook crash course"
"# jupyter notebook crash course"
]
},
{
Expand Down

0 comments on commit e0377c4

Please sign in to comment.