Skip to content
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

DM-10299: Apply crosstalk correction in decam #77

Merged
merged 7 commits into from Mar 26, 2018
Merged

Conversation

mrawls
Copy link
Contributor

@mrawls mrawls commented Mar 13, 2018

No description provided.

Copy link
Contributor

@SimonKrughoff SimonKrughoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's doable to keep from passing around the dataref. Have a look at my suggestion and we can iterate.

# The xtalk file has image areas like 'ccd01A'; preserve only '01A'
sources[elem[0][3:]].append(elem[1][3:])
# The linear crosstalk coefficients
coeffs[(elem[0][3:], elem[1][3:])] = float(elem[2])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I reading this that you are not applying the non-linear terms of the crosstalk? I know this caused problems with the edges of saturated areas sneaking through.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct, I'm only applying the linear terms. That's what both the DES and THELI pipelines do, and I didn't see any edge problems by eye (doesn't mean they aren't there!). Do you think higher order coefficients are important to include?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really can't say how important they are. I was just echoing what I had read in docs from the DECam team. If they don't apply them, I don't see any reason we should.

from .isr import DecamIsrTask
decamisr = DecamIsrTask()
decamisr.overscanCorrection(exposure, amp)
victim = ccdnum_str + amp.getName()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has already happened on line 152, right?

@@ -47,13 +50,23 @@ class DecamIsrConfig(IsrTask.ConfigClass):
doc="Number of edge pixels to be flagged as untrustworthy.",
default=35,
)
doCrosstalk = pexConfig.Field(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doCrosstalk and crosstalk should be in a config. We have the config mechanism to avoid just this sort of thing. In the config file you can retarget the crosstalk sub-task and set the value of doCrosstalk.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to follow the convention used by other decam ISR config things by putting these here. Would it be clearer to have a new config/isr.py that has all of the DecamIsrConfig stuff in it? The IsrTask is already retargeted to DecamIsrTask in config/processCcd.py (and config/processCcdCpIsr.py).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use the config override mechanism where possible rather than adding code. Then only DECam specific configs go in new code.

_DefaultName = 'decamCrosstalk'

@pipeBase.timeMethod
def run(self, exposure, dataRef):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with Paul that this should be refactored to have a signature like: def run(self, exposure, source_dict) where source_dict is a dict possibly keyed by the source id string containing a tuple (or dict) of source exposure and coefficient.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is an (untested) gist showing what I'm talking about: https://gist.github.com/SimonKrughoff/12b8bbb2e17a6cfe1b8cc4397d293410

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this just has a prepCrosstalk method that you call in IsrTask.runDataRef.

for source in sources[victim]:
source_ccdnum = int(source[:2])
try:
source_exposure = butler.get('raw', dataId={'visit': visit, 'ccdnum': source_ccdnum})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have all the information you need to do this outside this method. I think you could have a runDataRef method that assembles the data necessary for each victim as it comes along. It may have to grab all the sources for a full exposure, but then passes that structure on to run.

At that point, you may be able to just collapse this into the run method since all the data wrangling will be done in runDataRef.

config.isr.retarget(DecamIsrTask)
config.isr.crosstalk.retarget(DecamCrosstalkTask)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't have to retarget in both places. I think it might be better to not have a separate isr.py and just put those overrides here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm is this because you have two different processCcd-ish configs? If that's the case, I would like to see the dups removed and just use isr.py for everything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, it's because there are configs for both processCcd and processCcdCpIsr. Both contain more than just ISR-related config settings, however. The workflow for processing outlined in the obs_decam README uses them. I added the ISR config so the test I wrote which runs ISR only will work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, got it. Didn't realize one could load configs from configs... or as Colin put it, import pexInception 😆

"""
isrData = super().readIsrData(dataRef, exposure)
if self.config.doCrosstalk:
crosstalkSources = self.crosstalk.prepCrosstalk(dataRef)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see this in the base class IsrTask so that other instruments can use this mechanism without reinventing wheels.

There are two main functionalities: 1. part of the ISR workflow
(primary) and 2. standalone crosstalk removal of a raw DECam FITS file
Update docstrings, clarify columns in decam xtalk coefficient file,
make CrosstalkTask a Task rather than a CommandLineTask.
Also remove unnecessary "extensions" config dict
This makes a custom readIsrData unnecessary for DecamCpIsrTask,
because ip_isr's readIsrData now uses these instead of hardwired
'bias' and 'flat' for all cases.
This new method returns crosstalkSources, which contain source image
data and the corresponding crosstalk coefficient.

The processCcd and processCcdCpIsr configs now retarget to
DecamCrosstalkTask, and a new plain isr config does the same.
Copy link
Contributor

@SimonKrughoff SimonKrughoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great.

@mrawls mrawls merged commit fd4b988 into master Mar 26, 2018
@ktlim ktlim deleted the tickets/DM-10299 branch August 25, 2018 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants