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-29279: Add healsparse input map generation to AssembleCoaddTask #494

Merged
merged 9 commits into from Apr 15, 2021

Conversation

erykoff
Copy link
Contributor

@erykoff erykoff commented Apr 5, 2021

No description provided.

@@ -99,6 +100,12 @@ class AssembleCoaddConnections(pipeBase.PipelineTaskConnections,
storageClass="ImageU",
dimensions=("tract", "patch", "skymap", "band"),
)
inputMap = pipeBase.connectionTypes.Output(
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh man, I'm going to have to get used to inputMap being an Output

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you think this should have another name, now is the time to yelp!

dtype=int,
default=32768,
)
nside_coverage = 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.

Oh man, I'm not ready for a mix of snake and camel case configs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Re: snake case for configs, may I quote @TallJimbo in response to the question "Are config variable names similarly supposed to be snake in new tasks going forward?": "Config names aren't covered explicitly in the guidelines, but I'd say yes."

class HealSparseInputMapConfig(pexConfig.Config):
"""Configuration parameters for HealSparseInputMapTask"""
nside = pexConfig.Field(
doc="Mapping healpix nside. Must be power of 2.",
Copy link
Contributor

Choose a reason for hiding this comment

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

There are ways to require that its power of 2. Either here with check kwarg or in a validate method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And now I found a new trick of checking that an integer is a power of two. Today is a good day! https://stackoverflow.com/questions/57025836/how-to-check-if-a-given-number-is-a-power-of-two

default=256,
)
bad_mask_min_coverage = pexConfig.Field(
doc=("Minimum area fraction of a map healpixel pixel that must be "
Copy link
Contributor

Choose a reason for hiding this comment

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

Parentheses unnecessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But they do make the auto-indentation work correctly so I use them...

self._bits_per_visit_ccd = {}
self._bits_per_visit = defaultdict(list)
for bit, ccd in enumerate(ccds):
metadata[f'B{bit:04d}CCD'] = ccd['ccd']
Copy link
Contributor

Choose a reason for hiding this comment

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

double check that we're guaranteed to have a column called 'ccd'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is defined here:

self.ccdCcdKey = self.ccdSchema.addField("ccd", type=numpy.int32, doc="cameraGeom CCD serial number")
and I know that I've mentioned this on slack. Right now it's hard-coded to be called "ccd" and if it isn't a whole bunch of code is going to break (including this code!). I don't know of any plans to update this to "detectorId" (it can't be "detector" because that's reserved for the ExposureCatalog).

@@ -199,6 +198,32 @@ def __init__(self, *args, **kwargs):
DcrAssembleCoaddTask.__init__(self, *args, **kwargs)


# class MockInputMapAssembleCoaddConfig(MockSafeClipAssembleCoaddConfig):
Copy link
Contributor

Choose a reason for hiding this comment

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

Left these in by accident

# class MockInputMapAssembleCoaddTask(MockSafeClipAssembleCoaddTask):
# class MockInputMapAssembleCoaddTask(MockAssembleCoaddTask, SafeClipAssembleCoaddTask):
class MockInputMapAssembleCoaddTask(MockCompareWarpAssembleCoaddTask):
"""Lightly modified version of `SafeClipAssembleCoaddTask`
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this docstring true?

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 is now after I fixed it! 😄

_DefaultName = "inputMapAssembleCoadd"

def __init__(self, *args, **kwargs):
# SafeClipAssembleCoaddTask.__init__(self, *args, **kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

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

coding remnants

validPix, raPix, decPix = inputMap.valid_pixels_pos(return_pixels=True)

# Confirm that all the map pixels are in the bounding box
xPix, yPix = exposures[100].getWcs().skyToPixelArray(raPix, decPix, degrees=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

anything special about expId=100?

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's the first one, and they all have the same WCS in the tests. I've added a comment to that effect.

@@ -262,6 +287,56 @@ def testDcrGen2Gen3Compatibility(self):
assembleTask = MockDcrAssembleCoaddTask(config=config)
self.checkGen2Gen3Compatibility(assembleTask)

def testInputMapGen3(self):
import numpy as np
Copy link
Contributor

Choose a reason for hiding this comment

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

You mean to move this up top?

@erykoff erykoff merged commit ffa7890 into master Apr 15, 2021
@erykoff erykoff deleted the tickets/DM-29279 branch April 15, 2021 22:06
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

2 participants