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

Allow configuring more statistical options for assembleCoadd #142

Merged
merged 1 commit into from Aug 9, 2017

Conversation

yalsayyad
Copy link
Contributor

Specify main stacking statistic in AssembleCoadd and derived tasks
with config parameter statistic. For backwards compatibility:

  • Setting the deprecated doSigmaClip to True (now False by default)
    ignores statistic and uses MEANCLIP.
  • The default statistic is MEANCLIP imitating the previous default
    of doSigmaClip=True.

"SUM": "sum",
"MEANSQUARE": "mean of square of pixel values",
}
)
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to specify these? There's code in Statistics that takes a string and converts it to a valid enum; why don't we use that in the validate method?

Listing statistics here is what caused this problem in the first place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, writing out the allowed options here really sucks, doesn't it. I liked the idea of the options being exposed in the resulting config files. What I really want is the stats class to give me a dictionary of available statistics for stacking. I talked this over with @pschella, who says the new API will offer that. I ended up specifying them explicitly because:

  1. Not all statistics area available for stacking: NOTHING, ERROR, ORMASK make no sense in a coadd and stackStatistics raises InvalidParameter errors or segfault (in the case of ORMASK)
  2. The only documentation for the options in the Property enum is in code comments. There's no way to retrieve them.

Without exposing the options, I could add to the config's validate:

        UNSTACKABLE_STATS = ['NOTHING', 'ERROR', 'ORMASK']
        if not hasattr(afwMath.Property, self.statistic) or self.statistic in UNSTACKABLE_STATS:
            stackableStats = [str(k) for k in afwMath.Property.__members__.keys() 
                         if str(k) not in UNSTACKABLE_STATS]
            raise ValueError("statistic %s is not allowed. Please choose one of %s."
                             % (self.statistic, stackableStats))

sufficient solution?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It'll print out:

ValueError: statistic ORMASK is not allowed. Please choose one of ['NPOINT', 'ERRORS', 'MIN', 'STDEVCLIP', 'SUM', 'VARIANCECLIP', 'MEDIAN', 'MEANCLIP', 'IQRANGE', 'STDEV', 'VARIANCE', 'MEANSQUARE', 'MAX', 'MEAN'].

Copy link
Member

Choose a reason for hiding this comment

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

That looks fine

\ref assembleSubregion to mean-stack the corresponding subregions from the coaddTempExps (with outlier
rejection if config.doSigmaClip=True). Set the edge bits the the coadd mask based on the weight map.
\ref assembleSubregion to stack the corresponding subregions from the coaddTempExps with the
statistic specified. Set the edge bits the the coadd mask based on the weight map.
Copy link
Contributor

Choose a reason for hiding this comment

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

"the the" - I know it was there before, but it seems like you can fix it also.

# Build the unclipped coadd
coaddMean = AssembleCoaddTask.assemble(self, skyInfo, tempExpRefList, imageScalerList, weightList,
bgModelList, doClip=False)
config.statistic = 'MEAN'
Copy link
Contributor

Choose a reason for hiding this comment

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

Haven't you already forced this to be 'MEAN'? Maybe it is just here for clarity?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was for clarity and safety in case the validation of statistic==MEAN was removed. I'll add a comment.

Question: How do you feel about forcing the third and final iteration of assemble to use a MEAN? I added that to replicate current behavior. Of course MEAN should be the default, but it doesn't technically need to be enforced anymore.

@@ -667,7 +691,7 @@ def assembleSubregion(self, coaddExposure, bbox, tempExpRefList, imageScalerList
matching is enabled, add the background and background variance from each coaddTempExp. Remove mask
planes listed in config.removeMaskPlanes, Finally, mean-stack
the actual exposures using \ref afwMath.statisticsStack "statisticsStack" with outlier rejection if
config.doSigmaClip=True. Assign the stacked subregion back to the coadd.
config.statistics=MEANCLIP. Assign the stacked subregion back to the coadd.
Copy link
Contributor

Choose a reason for hiding this comment

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

Since you have now added more statistics options, I think you need to modify this doc. It assumes you are doing mean or clipping.

@yalsayyad yalsayyad force-pushed the tickets/DM-4158 branch 2 times, most recently from 33d49aa to 6871fc3 Compare August 9, 2017 18:43
Specify main stacking statistic in AssembleCoadd and derived tasks
with config parameter `statistic`. For backwards compatibility:
* Setting the deprecated doSigmaClip to True (now False by default)
  ignores `statistic` and uses MEANCLIP.
* The default statistic is MEANCLIP imitating the previous default
  of doSigmaClip=True.
@yalsayyad yalsayyad merged commit 80f0bf6 into master Aug 9, 2017
@ktlim ktlim deleted the tickets/DM-4158 branch August 25, 2018 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants