-
Notifications
You must be signed in to change notification settings - Fork 7
Incorporate det into sca #30
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
Open
arunkannawadi
wants to merge
26
commits into
main
Choose a base branch
from
incorporate_det_into_sca
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
3e34f7b
rearrange functions in detector_physics.py to sca.py and detector_eff…
yuedong0607 48b3560
fix clip calls in add_persistence
yuedong0607 4540ad0
remove some commented codes in sca.py
yuedong0607 9aef8d2
Start refactoring the detector_effects class:
yuedong0607 2532065
Start refactoring the detector effects in a subfolder
yuedong0607 1f291cd
remove debugging code
yuedong0607 23305b1
Add cross_refer method to roman_effects for internal cross-referencin…
yuedong0607 c560726
add some logging to bfe and recip_failure
yuedong0607 56e4962
add dead_pix, interpix_cap, read_noise, vtpe
yuedong0607 52d3cd7
add gain and bias model to effects
yuedong0607 b0a8713
add setup_sky class for generating sky as well as sky subtracted images
yuedong0607 cc56da0
modify config and sca.py for generating sky subtracted images
yuedong0607 12b1c1e
rearrange functions in detector_physics.py to sca.py and detector_eff…
yuedong0607 c3b6474
add .gitignore file
yuedong0607 bab7272
rearrange functions in detector_physics.py to sca.py and detector_eff…
yuedong0607 212c0bf
rearrange functions in detector_physics.py to sca.py and detector_eff…
yuedong0607 98ff4c3
reformat to meet pep8
yuedong0607 bb9168a
black reformated
yuedong0607 f727aac
black reformated
yuedong0607 7255582
black formatted
yuedong0607 a765773
* renaming the classes using CamelCase
yuedong0607 7c6bf21
move model validity checking into base (RomanEffects) class
yuedong0607 24a84ed
renamed the files for effects
yuedong0607 fe411a8
fix the import in sca.py
yuedong0607 0346889
bug fix in read_noise.py: missed assignment for simple model
yuedong0607 1ff7ee3
* remove duplicates in detector_physics.py
yuedong0607 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 hidden or 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,3 @@ | ||
| /build/* | ||
| /dist/* | ||
| /roman_imsim.egg-info/* |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,15 @@ | ||
| from .roman_effects import RomanEffects, setup_sky | ||
| from .brighter_fatter import BrighterFatter | ||
| from .nonlinearity import Nonlinearity | ||
| from .background import Background | ||
| from .quantum_efficiency import QuantumEfficiency | ||
| from .persistence import Persistence | ||
| from .reciprocity_failure import ReciprocityFailure | ||
| from .dark_current import DarkCurrent | ||
| from .saturation import Saturation | ||
| from .ipc import IPC | ||
| from .dead_pixel import DeadPixel | ||
| from .vtpe import VTPE | ||
| from .read_noise import ReadNoise | ||
| from .gain import Gain | ||
| from .bias import Bias |
This file contains hidden or 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,54 @@ | ||
| import os | ||
| import galsim | ||
| from . import RomanEffects | ||
| import galsim.roman as roman | ||
|
|
||
|
|
||
| class Background(RomanEffects): | ||
| def __init__(self, params, base, logger, rng, rng_iter=None): | ||
| super().__init__(params, base, logger, rng, rng_iter) | ||
| self.thermal_background = ( | ||
| self.params["thermal_background"] if "thermal_background" in self.params else False | ||
| ) | ||
| self.stray_light = self.params["stray_light"] if "stray_light" in self.params else False | ||
|
|
||
| self.is_model_valid() | ||
|
|
||
| def simple_model(self, image): | ||
| if self.save_diff: | ||
| orig = image.copy() | ||
|
|
||
| self.logger.warning("Simple model will be applied for background.") | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should these be warning-level logs? I get why we want to emit a warning if we use simple model when a model is not specified. But if the user specifically asked for it, then we should apply it without a warning. |
||
| pointing = self.pointing | ||
| # Build current specification sky level if sky level not given | ||
| if self.force_cvz: | ||
| radec = self.translate_cvz(pointing.radec) | ||
| else: | ||
| radec = pointing.radec | ||
| sky_level = roman.getSkyLevel(pointing.bpass, world_pos=radec, date=pointing.date) | ||
| self.logger.debug("Adding sky_level = %s", sky_level) | ||
|
|
||
| if self.stray_light: | ||
| self.logger.debug("Stray light fraction = %s", roman.stray_light_fraction) | ||
| sky_level *= 1.0 + roman.stray_light_fraction | ||
| # Create sky image | ||
| self.sky = galsim.Image(bounds=image.bounds, wcs=pointing.WCS) | ||
| pointing.WCS.makeSkyImage(self.sky, sky_level) | ||
| if self.thermal_background: | ||
| tb = roman.thermal_backgrounds[pointing.filter] * pointing.exptime | ||
| self.logger.debug("Adding thermal background: %s", tb) | ||
| self.sky += tb | ||
| self.sky.addNoise(self.noise) | ||
|
|
||
| # [TODO] Not entirely sure about this block, since the 'auto' option is meant to | ||
| # let the software choose which drawing method to use based on the total flux. | ||
| if self.base["image"]["draw_method"] not in ["phot", "auto"]: | ||
| image.addNoise(self.noise) | ||
|
|
||
| # Adding sky level to the image. | ||
| image += self.sky[self.sky.bounds & image.bounds] | ||
| if self.save_diff: | ||
| prev = image.copy() | ||
| diff = prev - orig | ||
| diff.write(os.path.join(self.diff_dir, "sky_a.fits")) | ||
| return image | ||
This file contains hidden or 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,27 @@ | ||
| import os | ||
| import fitsio as fio | ||
| from . import RomanEffects | ||
| from .utils import sca_number_to_file | ||
|
|
||
|
|
||
| class Bias(RomanEffects): | ||
| def __init__(self, params, base, logger, rng, rng_iter=None): | ||
| super().__init__(params, base, logger, rng, rng_iter) | ||
|
|
||
| self.is_model_valid() | ||
|
|
||
| def simple_model(self, image): | ||
| self.logger.warning("No bias will be applied.") | ||
| return image | ||
|
|
||
| def lab_model(self, image): | ||
| if self.sca_filepath is None: | ||
| self.logger.warning("No bias data provided; no bias will be applied.") | ||
| return image | ||
| self.df = fio.FITS(os.path.join(self.sca_filepath, sca_number_to_file[self.sca])) | ||
|
|
||
| self.logger.warning("Lab measured model will be applied for bias.") | ||
| bias = self.df["BIAS"][:, :] # 4096x4096 img | ||
|
|
||
| image.array[:, :] += bias | ||
| return image |
Oops, something went wrong.
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.
This would read cleaner as
and similarly others.