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

Tickets/dm 8686 #102

Merged
merged 2 commits into from
Mar 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 19 additions & 15 deletions python/lsst/pipe/tasks/mocks/simpleMapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ class PersistenceType(object):
suffixes = ()

@classmethod
def makeButlerLocation(cls, path, dataId, mapper, suffix=None):
def makeButlerLocation(cls, path, dataId, mapper, suffix=None, storage=None):
"""Method called by SimpleMapping to implement a map_ method."""
return lsst.daf.persistence.ButlerLocation(cls.python, cls.cpp, cls.storage, [path], dataId,
mapper=mapper)
mapper=mapper,
storage=storage)

def canStandardize(self, datasetType):
return False
Expand All @@ -77,10 +78,10 @@ class BypassPersistenceType(PersistenceType):
python = "lsst.daf.base.PropertySet" # something to import even when we don't need to

@classmethod
def makeButlerLocation(cls, path, dataId, mapper, suffix=None):
def makeButlerLocation(cls, path, dataId, mapper, suffix=None, storage=None):
"""Method called by SimpleMapping to implement a map_ method; overridden to not use the path."""
return lsst.daf.persistence.ButlerLocation(cls.python, cls.cpp, cls.storage, [], dataId,
mapper=mapper)
mapper=mapper, storage=storage)


class ExposurePersistenceType(PersistenceType):
Expand All @@ -94,14 +95,16 @@ class ExposurePersistenceType(PersistenceType):
suffixes = ("_sub",)

@classmethod
def makeButlerLocation(cls, path, dataId, mapper, suffix=None):
def makeButlerLocation(cls, path, dataId, mapper, suffix=None, storage=None):
"""Method called by SimpleMapping to implement a map_ method; overridden to support subimages."""
if suffix is None:
loc = super(ExposurePersistenceType, cls).makeButlerLocation(path, dataId, mapper, suffix=None)
loc = super(ExposurePersistenceType, cls).makeButlerLocation(path, dataId, mapper, suffix=None,
storage=storage)
elif suffix == "_sub":
subId = dataId.copy()
bbox = subId.pop('bbox')
loc = super(ExposurePersistenceType, cls).makeButlerLocation(path, subId, mapper, suffix=None)
loc = super(ExposurePersistenceType, cls).makeButlerLocation(path, subId, mapper, suffix=None,
storage=storage)
loc.additionalData.set('llcX', bbox.getMinX())
loc.additionalData.set('llcY', bbox.getMinY())
loc.additionalData.set('width', bbox.getWidth())
Expand Down Expand Up @@ -159,13 +162,13 @@ def __init__(self, persistence, template=None, keys=None):
if keys is not None:
self.keys = keys

def map(self, dataset, root, dataId, mapper, suffix=None):
def map(self, dataset, root, dataId, mapper, suffix=None, storage=None):
if self.template is not None:
path = os.path.join(root, self.template.format(dataset=dataset, ext=self.persistence.ext,
**dataId))
path = self.template.format(dataset=dataset, ext=self.persistence.ext, **dataId)
else:
path = None
return self.persistence.makeButlerLocation(path, dataId, suffix=suffix, mapper=mapper)
return self.persistence.makeButlerLocation(path, dataId, suffix=suffix, mapper=mapper,
storage=storage)


class RawMapping(SimpleMapping):
Expand Down Expand Up @@ -209,7 +212,7 @@ class MapperMeta(type):
@staticmethod
def _makeMapClosure(dataset, mapping, suffix=None):
def mapClosure(self, dataId, write=False):
return mapping.map(dataset, self.root, dataId, self, suffix=suffix)
return mapping.map(dataset, self.root, dataId, self, suffix=suffix, storage=self.storage)
return mapClosure

@staticmethod
Expand Down Expand Up @@ -297,8 +300,9 @@ class SimpleMapper(with_metaclass(MapperMeta, lsst.daf.persistence.Mapper)):
ccd=[],
)

def __init__(self, root):
super(SimpleMapper, self).__init__()
def __init__(self, root, **kwargs):
self.storage = lsst.daf.persistence.Storage.makeFromURI(root)
super(SimpleMapper, self).__init__(**kwargs)
self.root = root
self.camera = makeSimpleCamera(nX=1, nY=2, sizeX=400, sizeY=200, gapX=2, gapY=2)
afwImageUtils.defineFilter('r', 619.42)
Expand Down Expand Up @@ -344,7 +348,7 @@ def bypass_camera(self, datasetType, pythonType, location, dataId):

def map_camera(self, dataId, write=False):
return lsst.daf.persistence.ButlerLocation(
"lsst.afw.cameraGeom.Camera", "Camera", None, [], dataId, mapper=self
"lsst.afw.cameraGeom.Camera", "Camera", None, [], dataId, mapper=self, storage=self.storage
)

def std_calexp(self, item, dataId):
Expand Down
2 changes: 1 addition & 1 deletion tests/testMakeDiscreteSkyMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def tearDown(self):
def testBasics(self):
"""Test construction of a discrete sky map
"""
butler = Butler(root=self.inPath, outputRoot=self.outPath)
butler = Butler(inputs=self.inPath, outputs={'root': self.outPath, 'mode': 'rw'})
coordList = [] # list of sky coords of all corners of all calexp
for dataId in (
dict(visit=1, filter="g"),
Expand Down