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

Rename daf_butlerUtils to obs_base Tickets/dm 7915 #1

Merged
merged 5 commits into from
Oct 10, 2016
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
7 changes: 6 additions & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Description
===========

This package provides base classes for the obs camera packages, to provide a unified framework for building new cameras and testing their functionality.

Calibrations
============
------------

Calibrations, like all datasets, are identified by a set of data ids. These
are typically only used internally, so they do not need to be as user-friendly
Expand Down
2 changes: 1 addition & 1 deletion SConstruct
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# -*- python -*-
from lsst.sconsUtils import scripts
scripts.BasicSConstruct("daf_butlerUtils")
scripts.BasicSConstruct("obs_base")
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import shutil
import weakref
import lsst.daf.persistence as dafPersist
from lsst.daf.butlerUtils import ImageMapping, ExposureMapping, CalibrationMapping, DatasetMapping
from . import ImageMapping, ExposureMapping, CalibrationMapping, DatasetMapping
import lsst.daf.base as dafBase
import lsst.afw.geom as afwGeom
import lsst.afw.image as afwImage
Expand Down Expand Up @@ -184,7 +184,7 @@ def __init__(self, policy, repositoryDir,
if repoPolicy is not None:
policy.update(repoPolicy)

defaultPolicyFile = dafPersist.Policy.defaultPolicyFile("daf_butlerUtils",
defaultPolicyFile = dafPersist.Policy.defaultPolicyFile("obs_base",
"MapperDictionary.paf",
"policy")
dictPolicy = dafPersist.Policy(defaultPolicyFile)
Expand Down Expand Up @@ -262,13 +262,13 @@ def __init__(self, policy, repositoryDir,

# Sub-dictionaries (for exposure/calibration/dataset types)
imgMappingPolicy = dafPersist.Policy(dafPersist.Policy.defaultPolicyFile(
"daf_butlerUtils", "ImageMappingDictionary.paf", "policy"))
"obs_base", "ImageMappingDictionary.paf", "policy"))
expMappingPolicy = dafPersist.Policy(dafPersist.Policy.defaultPolicyFile(
"daf_butlerUtils", "ExposureMappingDictionary.paf", "policy"))
"obs_base", "ExposureMappingDictionary.paf", "policy"))
calMappingPolicy = dafPersist.Policy(dafPersist.Policy.defaultPolicyFile(
"daf_butlerUtils", "CalibrationMappingDictionary.paf", "policy"))
"obs_base", "CalibrationMappingDictionary.paf", "policy"))
dsMappingPolicy = dafPersist.Policy(dafPersist.Policy.defaultPolicyFile(
"daf_butlerUtils", "DatasetMappingDictionary.paf", "policy"))
"obs_base", "DatasetMappingDictionary.paf", "policy"))

# Dict of valid keys and their value types
self.keyDict = dict()
Expand All @@ -286,7 +286,7 @@ def __init__(self, policy, repositoryDir,
datasets = policy[name]

# Centrally-defined datasets
defaultsPath = os.path.join(getPackageDir("daf_butlerUtils"), "policy", name + ".yaml")
defaultsPath = os.path.join(getPackageDir("obs_base"), "policy", name + ".yaml")
if os.path.exists(defaultsPath):
datasets.merge(dafPersist.Policy(defaultsPath))

Expand Down Expand Up @@ -664,7 +664,7 @@ def bypass_defects(self, datasetType, pythonType, butlerLocation, dataId):

def map_expIdInfo(self, dataId, write=False):
return dafPersist.ButlerLocation(
pythonType="lsst.daf.butlerUtils.ExposureIdInfo",
pythonType="lsst.obs.base.ExposureIdInfo",
cppType=None,
storageName="Internal",
locationList="ignored",
Expand All @@ -673,7 +673,7 @@ def map_expIdInfo(self, dataId, write=False):
)

def bypass_expIdInfo(self, datasetType, pythonType, location, dataId):
"""Hook to retrieve an lsst.daf.butlerUtils.ExposureIdInfo for an exposure"""
"""Hook to retrieve an lsst.obs.base.ExposureIdInfo for an exposure"""
expId = self.bypass_ccdExposureId(datasetType, pythonType, location, dataId)
expBits = self.bypass_ccdExposureId_bits(datasetType, pythonType, location, dataId)
return ExposureIdInfo(expId=expId, expBits=expBits)
Expand Down Expand Up @@ -855,7 +855,7 @@ def _setFilter(self, mapping, item, dataId):
"""Set the filter object in an Exposure. If the Exposure had a FILTER
keyword, this was already processed during load. But if it didn't,
use the filter from the registry.
@param mapping (lsst.daf.butlerUtils.Mapping)
@param mapping (lsst.obs.base.Mapping)
@param[in,out] item (lsst.afw.image.Exposure)
@param dataId (dict) Dataset identifier"""

Expand All @@ -878,7 +878,7 @@ def _standardizeExposure(self, mapping, item, dataId, filter=True,
and optionally set the Fiter. In both cases this saves
having to persist some data in each exposure (or image).

@param mapping (lsst.daf.butlerUtils.Mapping)
@param mapping (lsst.obs.base.Mapping)
@param[in,out] item image-like object; any of lsst.afw.image.Exposure,
lsst.afw.image.DecoratedImage, lsst.afw.image.Image
or lsst.afw.image.MaskedImage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __init__(self, datasetType, policy, registry, root, provided=None):
@param datasetType (string)
@param policy (daf_persistence.Policy, or pexPolicy.Policy (only for backward compatibility))
Mapping Policy
@param registry (lsst.daf.butlerUtils.Registry) Registry for metadata lookups
@param registry (lsst.obs.base.Registry) Registry for metadata lookups
@param root (string) Path of root directory
@param provided (list of strings) Keys provided by the mapper
"""
Expand Down Expand Up @@ -236,7 +236,7 @@ def __init__(self, datasetType, policy, registry, root, **kwargs):
@param datasetType (string)
@param policy (daf_persistence.Policy, or pexPolicy.Policy (only for backward compatibility))
Mapping Policy
@param registry (lsst.daf.butlerUtils.Registry) Registry for metadata lookups
@param registry (lsst.obs.base.Registry) Registry for metadata lookups
@param root (string) Path of root directory"""
if isinstance(policy, pexPolicy.Policy):
policy = Policy(policy)
Expand All @@ -252,7 +252,7 @@ def __init__(self, datasetType, policy, registry, root, **kwargs):
@param datasetType (string)
@param policy (daf_persistence.Policy, or pexPolicy.Policy (only for backward compatibility))
Mapping Policy
@param registry (lsst.daf.butlerUtils.Registry) Registry for metadata lookups
@param registry (lsst.obs.base.Registry) Registry for metadata lookups
@param root (string) Path of root directory"""
if isinstance(policy, pexPolicy.Policy):
policy = Policy(policy)
Expand Down Expand Up @@ -300,8 +300,8 @@ def __init__(self, datasetType, policy, registry, calibRegistry, calibRoot, **kw
@param datasetType (string)
@param policy (daf_persistence.Policy, or pexPolicy.Policy (only for backward compatibility))
Mapping Policy
@param registry (lsst.daf.butlerUtils.Registry) Registry for metadata lookups
@param calibRegistry (lsst.daf.butlerUtils.Registry) Registry for calibration metadata lookups
@param registry (lsst.obs.base.Registry) Registry for metadata lookups
@param calibRegistry (lsst.obs.base.Registry) Registry for calibration metadata lookups
@param calibRoot (string) Path of calibration root directory"""
if isinstance(policy, pexPolicy.Policy):
policy = Policy(policy)
Expand Down Expand Up @@ -383,7 +383,7 @@ def __init__(self, datasetType, policy, registry, root, **kwargs):
@param policy (daf_persistence.Policy, or pexPolicy.Policy (only for backward compatibility))
Mapping Policy
@param datasetType (string)
@param registry (lsst.daf.butlerUtils.Registry) Registry for metadata lookups
@param registry (lsst.obs.base.Registry) Registry for metadata lookups
@param root (string) Path of root directory"""
if isinstance(policy, pexPolicy.Policy):
policy = Policy(policy)
Expand Down
26 changes: 14 additions & 12 deletions tests/testCameraMapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,32 @@
import lsst.utils.tests
import lsst.afw.geom as afwGeom
import lsst.daf.persistence as dafPersist
import lsst.daf.butlerUtils as butlerUtils
import lsst.obs.base
from lsst.utils import getPackageDir


testDir = os.path.relpath(os.path.join(getPackageDir('daf_butlerUtils'), 'tests'))
testDir = os.path.relpath(os.path.join(getPackageDir('obs_base'), 'tests'))


def setup_module(module):
lsst.utils.tests.init()

class BaseMapper(butlerUtils.CameraMapper):

class BaseMapper(lsst.obs.base.CameraMapper):
packageName = 'base'

def __init__(self):
policy = dafPersist.Policy(os.path.join(testDir, "BaseMapper.paf"))
butlerUtils.CameraMapper.__init__(self, policy=policy, repositoryDir=testDir, root=testDir)
lsst.obs.base.CameraMapper.__init__(self, policy=policy, repositoryDir=testDir, root=testDir)
return

class MinMapper1(butlerUtils.CameraMapper):

class MinMapper1(lsst.obs.base.CameraMapper):
packageName = 'larry'

def __init__(self):
policy = dafPersist.Policy(os.path.join(testDir, "MinMapper1.paf"))
butlerUtils.CameraMapper.__init__(self, policy=policy, repositoryDir=testDir, root=testDir)
lsst.obs.base.CameraMapper.__init__(self, policy=policy, repositoryDir=testDir, root=testDir)
return

def std_x(self, item, dataId):
Expand All @@ -65,15 +67,15 @@ def getCameraName(cls):
return "min"


class MinMapper2(butlerUtils.CameraMapper):
class MinMapper2(lsst.obs.base.CameraMapper):
packageName = 'moe'

# CalibRoot in policy
# needCalibRegistry
def __init__(self):
policy = dafPersist.Policy(os.path.join(testDir, "MinMapper2.paf"))
butlerUtils.CameraMapper.__init__(self, policy=policy, repositoryDir=testDir, root=testDir,
registry=os.path.join(testDir, "cfhtls.sqlite3"))
lsst.obs.base.CameraMapper.__init__(self, policy=policy, repositoryDir=testDir, root=testDir,
registry=os.path.join(testDir, "cfhtls.sqlite3"))
return

def _transformId(self, dataId):
Expand All @@ -92,11 +94,11 @@ def getCameraName(cls):


# does not assign packageName
class MinMapper3(butlerUtils.CameraMapper):
class MinMapper3(lsst.obs.base.CameraMapper):

def __init__(self):
policy = dafPersist.Policy(os.path.join(testDir, "MinMapper1.paf"))
butlerUtils.CameraMapper.__init__(self, policy=policy, repositoryDir=testDir, root=testDir)
lsst.obs.base.CameraMapper.__init__(self, policy=policy, repositoryDir=testDir, root=testDir)
return


Expand Down Expand Up @@ -262,7 +264,7 @@ def testGetRepoPolicy(self):

for data in testData:
path = os.path.join(testDir, 'testGetRepoPolicy', data.folder)
policy = butlerUtils.CameraMapper.getRepoPolicy(os.environ['DAF_BUTLERUTILS_DIR'], path)
policy = lsst.obs.base.CameraMapper.getRepoPolicy(getPackageDir('obs_base'), path)
self.assertIsNotNone(policy)
self.assertEqual(policy[data.key], data.value)

Expand Down
16 changes: 8 additions & 8 deletions tests/testDM-329.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,25 @@

import lsst.afw.image
import lsst.daf.persistence as dafPersist
import lsst.daf.butlerUtils as butlerUtils
import lsst.obs.base
import lsst.pex.policy as pexPolicy
from lsst.utils import getPackageDir

import os

testDir = os.path.relpath(os.path.join(getPackageDir('daf_butlerUtils'), 'tests'))
testDir = os.path.relpath(os.path.join(getPackageDir('obs_base'), 'tests'))


class MinMapper2(butlerUtils.CameraMapper):
class MinMapper2(lsst.obs.base.CameraMapper):
packageName = 'larry'

def __init__(self):
policy = pexPolicy.Policy.createPolicy(os.path.join(testDir, 'MinMapper2.paf'))
butlerUtils.CameraMapper.__init__(self,
policy=policy,
repositoryDir=testDir,
root=testDir,
registry=os.path.join(testDir, 'cfhtls.sqlite3'))
lsst.obs.base.CameraMapper.__init__(self,
policy=policy,
repositoryDir=testDir,
root=testDir,
registry=os.path.join(testDir, 'cfhtls.sqlite3'))
return

def _transformId(self, dataId):
Expand Down
2 changes: 1 addition & 1 deletion tests/testExposureFromImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import lsst.utils.tests
from lsst.daf.base import PropertyList
from lsst.daf.butlerUtils import exposureFromImage
from lsst.obs.base import exposureFromImage
import lsst.afw.image as afwImage


Expand Down
2 changes: 1 addition & 1 deletion tests/testMakeRawVisitInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import lsst.utils.tests
import lsst.pex.exceptions
from lsst.daf.base import DateTime, PropertySet
from lsst.daf.butlerUtils import MakeRawVisitInfo
from lsst.obs.base import MakeRawVisitInfo
from lsst.afw.geom import degrees


Expand Down
11 changes: 5 additions & 6 deletions tests/testOutputRoot.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@
import pickle
import os
import subprocess
import pickle
import lsst.afw.geom as afwGeom
import lsst.pex.policy as pexPolicy
import lsst.daf.persistence as dafPersist
import lsst.daf.butlerUtils as butlerUtils
import lsst.obs.base

# Define paths used for testing
testPath = os.path.abspath(os.path.dirname(__file__))
Expand All @@ -49,14 +48,14 @@ def setup_module(module):
lsst.utils.tests.init()


class MinMapper1(butlerUtils.CameraMapper):
class MinMapper1(lsst.obs.base.CameraMapper):
packageName = 'larry'

def __init__(self, root=testPath, outputRoot=None):
policy = pexPolicy.Policy.createPolicy(os.path.join(testPath, "MinMapper1.paf"))
butlerUtils.CameraMapper.__init__(self,
policy=policy, repositoryDir=testPath, root=root,
outputRoot=outputRoot)
lsst.obs.base.CameraMapper.__init__(self,
policy=policy, repositoryDir=testPath, root=root,
outputRoot=outputRoot)
return

def std_x(self, item, dataId):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.