Skip to content

Commit

Permalink
Add combination method parameter in flat and image recipes
Browse files Browse the repository at this point in the history
* This allows to use `method: sigmaclip` in yaml obs files
  • Loading branch information
sergiopasra committed Sep 3, 2019
1 parent 034b523 commit 00092eb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
15 changes: 14 additions & 1 deletion megaradrp/recipes/calibration/flat.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ class FiberFlatRecipe(MegaraBaseRecipe):
"""

# Requirements
method = Parameter(
'median',
description='Combination method',
choices=['mean', 'median', 'sigmaclip']
)
method_kwargs = Parameter(
dict(),
description='Arguments for combination method',
optional=True
)
master_bias = reqs.MasterBiasRequirement()
master_dark = reqs.MasterDarkRequirement()
master_bpm = reqs.MasterBPMRequirement()
Expand All @@ -99,7 +109,10 @@ class FiberFlatRecipe(MegaraBaseRecipe):

def process_flat2d(self, rinput):
flow = self.init_filters(rinput, rinput.obresult.configuration)
final_image = basic_processing_with_combination(rinput, flow, method=combine.median)
fmethod = getattr(combine, rinput.method)
final_image = basic_processing_with_combination(
rinput, flow, method=fmethod,method_kwargs=rinput.method_kwargs,
)
hdr = final_image[0].header
self.set_base_headers(hdr)
return final_image
Expand Down
22 changes: 19 additions & 3 deletions megaradrp/recipes/scientific/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2011-2018 Universidad Complutense de Madrid
# Copyright 2011-2019 Universidad Complutense de Madrid
#
# This file is part of Megara DRP
#
Expand Down Expand Up @@ -31,8 +31,18 @@
class ImageRecipe(MegaraBaseRecipe):
"""Base Image."""

# Requirements
# Requirements
obresult = ObservationResultRequirement()
method = Parameter(
'median',
description='Combination method',
choices=['mean', 'median', 'sigmaclip']
)
method_kwargs = Parameter(
dict(),
description='Arguments for combination method',
optional=True
)
master_bias = reqs.MasterBiasRequirement()
master_dark = reqs.MasterDarkRequirement()
master_bpm = reqs.MasterBPMRequirement()
Expand All @@ -51,7 +61,13 @@ def base_run(self, rinput):

# 2D reduction
flow1 = self.init_filters(rinput, rinput.obresult.configuration)
img = basic_processing_with_combination(rinput, flow1, method=combine.median)
fmethod = getattr(combine, rinput.method)

img = basic_processing_with_combination(
rinput, flow1,
method=fmethod,
method_kwargs=rinput.method_kwargs
)
hdr = img[0].header
self.set_base_headers(hdr)

Expand Down

0 comments on commit 00092eb

Please sign in to comment.