Skip to content

Commit

Permalink
Merge pull request #87 from lsst/tickets/DM-20566-obs_lsstSim
Browse files Browse the repository at this point in the history
DM-20566: Replace afwGeom with geom
  • Loading branch information
timj committed Jul 24, 2019
2 parents d1bf590 + 4f39343 commit 66a0566
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 53 deletions.
1 change: 0 additions & 1 deletion bin.src/extractPhosimGainSaturation.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
simplest no-background, no-source images, so long as they have a real gain and
saturation threshold.
"""
from __future__ import absolute_import, division, print_function

import os
import glob
Expand Down
2 changes: 0 additions & 2 deletions bin.src/genDefectRegistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division
from __future__ import print_function
import glob
import os
import re
Expand Down
2 changes: 0 additions & 2 deletions bin.src/genInputRegistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division
from __future__ import print_function
import glob
from optparse import OptionParser
import os
Expand Down
1 change: 0 additions & 1 deletion bin.src/makeDefectMaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division
import numpy
import time
from astropy.io import fits
Expand Down
26 changes: 12 additions & 14 deletions bin.src/makeLsstCameraRepository.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
Scons should have automatically run this when building obs_lsstSim. To produce
the same files that scons would have, run with no arguments.
"""
from __future__ import absolute_import, division
from __future__ import print_function
from builtins import range
import argparse
import os
import re
Expand All @@ -39,6 +36,7 @@
import lsst.afw.table as afwTable
from lsst.afw.cameraGeom import DetectorConfig, CameraConfig, \
TransformMapConfig, FIELD_ANGLE, FOCAL_PLANE, PIXELS, NullLinearityType
import lsst.geom as geom
from lsst.obs.lsstSim import LsstSimMapper


Expand Down Expand Up @@ -137,7 +135,7 @@ def makeAmpTables(segmentsFile, gainFile):
saturation = 65535
gain = float(els[7])
readnoise = float(els[11])
bbox = afwGeom.Box2I(afwGeom.Point2I(x0, y0), afwGeom.Point2I(x1, y1))
bbox = geom.Box2I(geom.Point2I(x0, y0), geom.Point2I(x1, y1))

if int(els[5]) == -1:
flipx = False
Expand All @@ -160,14 +158,14 @@ def makeAmpTables(segmentsFile, gainFile):
hoverscan = 0
extended = 4
voverscan = 0
rawBBox = afwGeom.Box2I(afwGeom.Point2I(0, 0),
afwGeom.Extent2I(extended+ndatax+hoverscan, prescan+ndatay+voverscan))
rawDataBBox = afwGeom.Box2I(afwGeom.Point2I(extended, prescan), afwGeom.Extent2I(ndatax, ndatay))
rawHorizontalOverscanBBox = afwGeom.Box2I(afwGeom.Point2I(0, prescan),
afwGeom.Extent2I(extended, ndatay))
rawVerticalOverscanBBox = afwGeom.Box2I(afwGeom.Point2I(extended, prescan+ndatay),
afwGeom.Extent2I(ndatax, voverscan))
rawPrescanBBox = afwGeom.Box2I(afwGeom.Point2I(extended, 0), afwGeom.Extent2I(ndatax, prescan))
rawBBox = geom.Box2I(geom.Point2I(0, 0),
geom.Extent2I(extended+ndatax+hoverscan, prescan+ndatay+voverscan))
rawDataBBox = geom.Box2I(geom.Point2I(extended, prescan), geom.Extent2I(ndatax, ndatay))
rawHorizontalOverscanBBox = geom.Box2I(geom.Point2I(0, prescan),
geom.Extent2I(extended, ndatay))
rawVerticalOverscanBBox = geom.Box2I(geom.Point2I(extended, prescan+ndatay),
geom.Extent2I(ndatax, voverscan))
rawPrescanBBox = geom.Box2I(geom.Point2I(extended, 0), geom.Extent2I(ndatax, prescan))

extraRawX = extended + hoverscan
extraRawY = prescan + voverscan
Expand All @@ -187,7 +185,7 @@ def makeAmpTables(segmentsFile, gainFile):
record.setRawFlipX(flipx)
record.setRawFlipY(flipy)
record.setRawBBox(rawBBox)
record.setRawXYOffset(afwGeom.Extent2I(rawx0, rawy0))
record.setRawXYOffset(geom.Extent2I(rawx0, rawy0))
record.setRawDataBBox(rawDataBBox)
record.setRawHorizontalOverscanBBox(rawHorizontalOverscanBBox)
record.setRawVerticalOverscanBBox(rawVerticalOverscanBBox)
Expand Down Expand Up @@ -319,7 +317,7 @@ def getPhosimVersion(defaultDataDir):
camConfig.detectorList = dict([(i, detectorConfigList[i]) for i in range(len(detectorConfigList))])
camConfig.name = 'LSST'
camConfig.plateScale = 20.0
pScaleRad = afwGeom.arcsecToRad(camConfig.plateScale)
pScaleRad = geom.arcsecToRad(camConfig.plateScale)
pincushion = 0.925
# Don't have this yet ticket/3155
# camConfig.boresiteOffset_x = 0.
Expand Down
1 change: 0 additions & 1 deletion bin.src/processCalibLsstSim.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division
import sys
import traceback

Expand Down
1 change: 0 additions & 1 deletion config/sourceAssoc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import print_function
config.inputLevel = "sensor"
config.inputSourceDataset = "src"
config.inputCalexpMetadataDataset = "calexp_md"
Expand Down
1 change: 0 additions & 1 deletion python/lsst/obs/lsstSim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

"""lsst.obs.lsstSim
"""
from __future__ import absolute_import
from .version import *
from .lsstSimMapper import *
from .lsstSimIsrTask import *
Expand Down
12 changes: 5 additions & 7 deletions python/lsst/obs/lsstSim/lsstSimMapper.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from builtins import map
from past.builtins import basestring
#
# LSST Data Management System
# Copyright 2008, 2009, 2010, 2011, 2012, 2013 LSST Corporation.
Expand Down Expand Up @@ -28,9 +26,9 @@
import re
from astropy.io import fits

import lsst.afw.geom as afwGeom
import lsst.daf.base as dafBase
import lsst.afw.image.utils as afwImageUtils
import lsst.geom as geom
import lsst.daf.persistence as dafPersist
from lsst.meas.algorithms import Defects
from .makeLsstSimRawVisitInfo import MakeLsstSimRawVisitInfo
Expand Down Expand Up @@ -143,7 +141,7 @@ def validate(self, dataId):
if component not in dataId:
continue
val = dataId[component]
if not isinstance(val, basestring):
if not isinstance(val, str):
raise RuntimeError(
"%s identifier should be type str, not %s: %r" % (component.title(), type(val), val))
if component == "sensor":
Expand Down Expand Up @@ -319,9 +317,9 @@ def bypass_defects(self, datasetType, pythonType, butlerLocation, dataId):

defectList = Defects()
for data in hdu.data:
bbox = afwGeom.Box2I(
afwGeom.Point2I(int(data['x0']), int(data['y0'])),
afwGeom.Extent2I(int(data['width']), int(data['height'])),
bbox = geom.Box2I(
geom.Point2I(int(data['x0']), int(data['y0'])),
geom.Extent2I(int(data['width']), int(data['height'])),
)
defectList.append(bbox)
return defectList
Expand Down
6 changes: 1 addition & 5 deletions python/lsst/obs/lsstSim/makeLsstSimRawVisitInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,12 @@
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import astropy.units

from lsst.afw.image import VisitInfo, RotType
from lsst.afw.geom import degrees, SpherePoint
from lsst.afw.coord import Observatory, Weather
from lsst.afw.coord.refraction import defaultWeather
from lsst.geom import degrees, SpherePoint
from lsst.obs.base import MakeRawVisitInfo

__all__ = ["MakeLsstSimRawVisitInfo"]
Expand Down
8 changes: 3 additions & 5 deletions python/lsst/obs/lsstSim/processCalibLsstSim.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function
from builtins import zip
#
# LSST Data Management System
# Copyright 2008, 2009, 2010, 2011, 2012, 2013 LSST Corporation.
Expand All @@ -23,7 +21,7 @@
#
import lsst.afw.image as afwImage
import lsst.afw.math as afwMath
import lsst.afw.geom as afwGeom
import lsst.geom as geom
import lsst.meas.algorithms as measAlg
import lsst.pex.config as pexConfig
import lsst.pipe.base as pipeBase
Expand Down Expand Up @@ -180,8 +178,8 @@ def transposeDefectList(self, defectList, checkBbox=None):
retDefectList = measAlg.DefectListT()
for defect in defectList:
bbox = defect.getBBox()
nbbox = afwGeom.Box2I(afwGeom.Point2I(bbox.getMinY(), bbox.getMinX()),
afwGeom.Extent2I(bbox.getDimensions()[1], bbox.getDimensions()[0]))
nbbox = geom.Box2I(geom.Point2I(bbox.getMinY(), bbox.getMinX()),
geom.Extent2I(bbox.getDimensions()[1], bbox.getDimensions()[0]))
if checkBbox:

if checkBbox.overlaps(bbox):
Expand Down
1 change: 0 additions & 1 deletion tests/test_getBias.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function
import os.path
import sys
import unittest
Expand Down
1 change: 0 additions & 1 deletion tests/test_getCamera.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function
import os.path
import sys
import unittest
Expand Down
13 changes: 6 additions & 7 deletions tests/test_getEimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

"""Test ability to get an eimage from the butler.
**Note that this is an lsstSim specific test and
Expand All @@ -31,7 +30,7 @@
import numpy as np

import lsst.utils
import lsst.afw.geom as afwGeom
import lsst.geom as geom
from lsst.afw.image import RotType
import lsst.utils.tests
import lsst.daf.persistence as dafPersistence
Expand Down Expand Up @@ -70,16 +69,16 @@ def test_getBoresightAirmass(self):
self.assertEqual(1.00015190967402, self.visit_info.getBoresightAirmass())

def test_getBoresightAzAlt(self):
coord = afwGeom.SpherePoint(0.0, 89.0, afwGeom.degrees)
coord = geom.SpherePoint(0.0, 89.0, geom.degrees)
self.assertEqual(coord, self.visit_info.getBoresightAzAlt())

def test_getBoresightRaDec(self):
coord = afwGeom.SpherePoint(53.0091385, -27.4389488, afwGeom.degrees)
coord = geom.SpherePoint(53.0091385, -27.4389488, geom.degrees)
self.assertEqual(coord, self.visit_info.getBoresightRaDec())

def test_getBoresightRotAngle(self):
# Note test eimage header has ROTANG=236.983652. boresightRotAngle is -ROTANG.
angle = afwGeom.Angle(-236.983652, afwGeom.degrees)
angle = geom.Angle(-236.983652, geom.degrees)
self.assertAnglesAlmostEqual(angle, self.visit_info.getBoresightRotAngle())

def test_getDarkTime(self):
Expand All @@ -100,8 +99,8 @@ def test_getExposureTime(self):
self.assertEqual(30.0, self.visit_info.getExposureTime())

def test_getObservatory(self):
observatory = Observatory(afwGeom.Angle(-70.749417, afwGeom.degrees),
afwGeom.Angle(-30.244633, afwGeom.degrees), 2663)
observatory = Observatory(geom.Angle(-70.749417, geom.degrees),
geom.Angle(-30.244633, geom.degrees), 2663)
self.assertEqual(observatory, self.visit_info.getObservatory())

def test_getRotType(self):
Expand Down
3 changes: 1 addition & 2 deletions tests/test_getRaw.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function
import math
import os.path
import sys
Expand All @@ -30,7 +29,7 @@
from lsst.obs.base import MakeRawVisitInfo
import lsst.utils.tests
from lsst.afw.image import RotType
from lsst.afw.geom import degrees, SpherePoint
from lsst.geom import degrees, SpherePoint


class GetRawTestCase(lsst.utils.tests.TestCase):
Expand Down
1 change: 0 additions & 1 deletion tests/test_lsstSimIsrTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function
import os
import sys
import unittest
Expand Down
1 change: 0 additions & 1 deletion tests/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function
import os.path
import sys
import unittest
Expand Down

0 comments on commit 66a0566

Please sign in to comment.