-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cy/issue 0033 #88
Merged
Merged
Cy/issue 0033 #88
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
e31831d
Work for background recipe
chyan26 e949c6b
Allowing SKY target
chyan26 b3d053d
Update README
chyan26 853557b
Update program
chyan26 3ec4870
EDPS works with background
chyan26 febf578
Update the readme
chyan26 437a96c
Working with standard process
chyan26 0508431
Works with metis_lm_img_std_process
chyan26 65e56a3
Adding to metis_recipes.py
chyan26 dfc7eb6
Adding distorion recipe
chyan26 88f56a0
Fixing typo
chyan26 7b11a49
Works with metis_lm_img_cal_distortion
chyan26 78a6416
Working with metis_lm_img_calibrate
chyan26 b1c7a82
Full functional version
chyan26 1493aef
Update metis_recipes.py
chyan26 f78dd51
Update metisp/pymetis/src/pymetis/inputs/multiple.py
chyan26 4470896
Update review suggestion
chyan26 12c53aa
Fix bug
chyan26 273eb08
Fix bug for running EDPS
chyan26 0a2321a
Run edps test
chyan26 bafce7b
No store __init__.py
chyan26 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# Skip __init__.py setting | ||
__init__.py | ||
|
||
# Skip vscode setting | ||
.vscode | ||
|
||
|
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
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
125 changes: 125 additions & 0 deletions
125
metisp/pymetis/src/pymetis/recipes/img/metis_lm_img_cal_distortion.py
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,125 @@ | ||
""" | ||
This file is part of the METIS Pipeline. | ||
Copyright (C) 2024 European Southern Observatory | ||
|
||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
|
||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
""" | ||
|
||
import re | ||
|
||
import cpl | ||
from cpl.core import Msg | ||
from typing import Dict | ||
|
||
from pymetis.inputs.common import RawInput, LinearityInput, BadpixMapInput, PersistenceMapInput, GainMapInput | ||
from pymetis.base.recipe import MetisRecipe | ||
from pymetis.base.product import PipelineProduct | ||
from pymetis.inputs import RawInput, SinglePipelineInput | ||
from pymetis.prefab.rawimage import RawImageProcessor | ||
|
||
|
||
class MetisLmImgCalDistortionImpl(RawImageProcessor): | ||
class InputSet(RawImageProcessor.InputSet): | ||
class RawInput(RawInput): | ||
_tags = re.compile(r"LM_WCU_OFF_RAW") | ||
|
||
class DistortionInput(SinglePipelineInput): | ||
_tags = re.compile(r"LM_DISTORTION_RAW") | ||
_title = "Distortion map" | ||
_group: cpl.ui.Frame.FrameGroup = cpl.ui.Frame.FrameGroup.CALIB | ||
|
||
class PinholeTableInput(SinglePipelineInput): | ||
_tags = re.compile(r"PINHOLE_TABLE") | ||
_title = "pinhole table" | ||
_group: cpl.ui.Frame.FrameGroup = cpl.ui.Frame.FrameGroup.CALIB | ||
|
||
def __init__(self, frameset: cpl.ui.FrameSet): | ||
super().__init__(frameset) | ||
self.pinhole_table = SinglePipelineInput(frameset, | ||
tags=re.compile(r"PINHOLE_TABLE"), | ||
title="pinhole table", | ||
group=cpl.ui.Frame.FrameGroup.CALIB) | ||
|
||
self.distortion = self.DistortionInput(frameset, required=False) | ||
self.linearity = LinearityInput(frameset, required=False) # But should be | ||
self.badpix_map = BadpixMapInput(frameset, required=False) | ||
self.persistence_map = PersistenceMapInput(frameset, required=False) # But should be | ||
self.gain_map = GainMapInput(frameset, required=False) # But should be | ||
|
||
self.inputs |= {self.pinhole_table, self.linearity, self.distortion, | ||
self.badpix_map, self.persistence_map, self.gain_map} | ||
|
||
|
||
class ProductLmDistortionTable(PipelineProduct): | ||
category = rf"ILM_DISTORTION_TABLE" | ||
tag = category | ||
level = cpl.ui.Frame.FrameLevel.FINAL | ||
frame_type = cpl.ui.Frame.FrameType.TABLE | ||
|
||
class ProductLmDistortionMap(PipelineProduct): | ||
category = rf"LM_DIST_MAP" | ||
tag = category | ||
level = cpl.ui.Frame.FrameLevel.FINAL | ||
frame_type = cpl.ui.Frame.FrameType.IMAGE | ||
|
||
class ProductLmDistortionReduced(PipelineProduct): | ||
category = rf"LM_DIST_REDUCED" | ||
tag = category | ||
level = cpl.ui.Frame.FrameLevel.FINAL | ||
frame_type = cpl.ui.Frame.FrameType.IMAGE | ||
|
||
def process_images(self) -> Dict[str, PipelineProduct]: | ||
raw_images = cpl.core.ImageList() | ||
|
||
for idx, frame in enumerate(self.inputset.raw.frameset): | ||
Msg.info(self.name, f"Loading raw image {frame.file}") | ||
|
||
if idx == 0: | ||
self.header = cpl.core.PropertyList.load(frame.file, 0) | ||
|
||
raw_image = cpl.core.Image.load(frame.file, extension=1) | ||
raw_images.append(raw_image) | ||
|
||
combined_image = self.combine_images(raw_images, "average") | ||
|
||
self.products = { | ||
product.category: product(self, self.header, combined_image) | ||
for product in [self.ProductLmDistortionTable, self.ProductLmDistortionMap, | ||
self.ProductLmDistortionReduced] | ||
} | ||
return self.products | ||
|
||
|
||
class MetisLmImgCalDistortion(MetisRecipe): | ||
_name = "metis_lm_img_cal_distortion" | ||
_version = "0.1" | ||
_author = "Chi-Hung Yan" | ||
_email = "[email protected]" | ||
_synopsis = "Determine optical distortion coefficients for the LM imager." | ||
_description = ( | ||
"Currently just a skeleton prototype." | ||
) | ||
|
||
parameters = cpl.ui.ParameterList([ | ||
cpl.ui.ParameterEnum( | ||
name="metis_lm_img_cal_distortion.stacking.method", | ||
context="metis_lm_img_cal_distortion", | ||
description="Name of the method used to combine the input images", | ||
default="average", | ||
alternatives=("add", "average", "median", "sigclip"), | ||
), | ||
]) | ||
|
||
implementation_class = MetisLmImgCalDistortionImpl |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__init__.py
should not be in.gitignore
, since it should generally not be ignored. Could you please remove this again? I believe this was added only after I reviewed the PR so I couldn't remark on it before.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding
__init__.py
to.gitignore
is indeed leading to problems, because__init__.py
is missing from #113 because it was ignored by git.