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-8467: Wrap lsst_distrib with pybind11 #36

Merged
merged 1 commit into from
Mar 7, 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
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ config.log
*.dylib
*.cfgc
*.pyc
*_wrap.cc
*Lib.py
doc/html
doc/*.tag
doc/*.inc
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/obs/lsstSim/SConscript
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# -*- python -*-
from lsst.sconsUtils import scripts
scripts.BasicSConscript.python(['sensorLib'])
scripts.BasicSConscript.pybind11(['edgeRolloffFunctor'])
10 changes: 7 additions & 3 deletions python/lsst/obs/lsstSim/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#
# LSST Data Management System
# Copyright 2008, 2009, 2010, 2011, 2012, 2013 LSST Corporation.
#
# This product includes software developed by the
# LSST Project (http://www.lsst.org/).
# See the COPYRIGHT file
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -17,11 +17,15 @@
#
# You should have received a copy of the LSST License Statement and
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
# see <https://www.lsstcorp.org/LegalNotices/>.
#

"""lsst.obs.lsstSim
"""
from __future__ import absolute_import
from .version import *
from .lsstSimMapper import *
from .lsstSimIsrTask import *
from .utils import *
from .sensorLib import *
from ._edgeRolloffFunctor import *
from .makeLsstSimRawVisitInfo import *
Original file line number Diff line number Diff line change
@@ -1,46 +1,44 @@
// -*- c++ -*-

/*
/*
* LSST Data Management System
* Copyright 2015 LSST Corporation.
*
*
* This product includes software developed by the
* LSST Project (http://www.lsst.org/).
* See the COPYRIGHT file
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the LSST License Statement and
* the GNU General Public License along with this program. If not,
* see <http://www.lsstcorp.org/LegalNotices/>.
*
* You should have received a copy of the LSST License Statement and
* the GNU General Public License along with this program. If not,
* see <https://www.lsstcorp.org/LegalNotices/>.
*/


%define sensorLib_DOCSTRING
"
Python interface to lsst::obs::lsstSim::sensorLib
"
%enddef
#include <pybind11/pybind11.h>

%feature("autodoc", "1");
%module(package="lsst.obs.lsstSim", docstring=sensorLib_DOCSTRING) sensorLib
#include "lsst/obs/lsstSim/EdgeRolloffFunctor.h"

%{
#include "lsst/afw/geom.h"
#include "lsst/obs/lsstSim/sensor.h"
%}
namespace py = pybind11;
using namespace pybind11::literals;

%include "lsst/pex/exceptions/handler.i"
namespace lsst {
namespace obs {
namespace lsstSim {

%import "lsst/afw/geom/geomLib.i"
PYBIND11_PLUGIN(_edgeRolloffFunctor) {
py::module mod("_edgeRolloffFunctor");

%shared_ptr(lsst::obs::lsstSim::EdgeRolloffFunctor);
py::class_<EdgeRolloffFunctor, std::shared_ptr<EdgeRolloffFunctor>, afw::geom::Functor> cls(mod, "EdgeRolloffFunctor");
cls.def(py::init<double, double, double>(), "amplitude"_a, "scale"_a, "width"_a);
// operator()(double)->double and derivative(double)->double declared by Functor

%include "lsst/obs/lsstSim/EdgeRolloffFunctor.h"
return mod.ptr();
}
}
}
} // lsst::obs::lsstSim
4 changes: 2 additions & 2 deletions python/lsst/obs/lsstSim/makeLsstSimRawVisitInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from __future__ import division
from __future__ import print_function

from lsst.afw.image import makeVisitInfo, RotType_SKY
from lsst.afw.image import makeVisitInfo, RotType
from lsst.afw.geom import degrees
from lsst.afw.coord import Coord, IcrsCoord, Observatory, Weather
from lsst.obs.base import MakeRawVisitInfo
Expand Down Expand Up @@ -60,7 +60,7 @@ def setArgDict(self, md, argDict):
)
argDict["boresightAirmass"] = self.popFloat(md, "AIRMASS")
argDict["boresightRotAngle"] = 90*degrees - self.popAngle(md, "ROTANG")
argDict["rotType"] = RotType_SKY
argDict["rotType"] = RotType.SKY
argDict["observatory"] = self.observatory
argDict["weather"] = Weather(
self.popFloat(md, "TEMPERA"),
Expand Down
9 changes: 4 additions & 5 deletions python/lsst/obs/lsstSim/processCalibLsstSim.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#
import lsst.afw.cameraGeom as cameraGeom
import lsst.afw.image as afwImage
import lsst.afw.math as afwMath
import lsst.afw.geom as afwGeom
Expand Down Expand Up @@ -81,10 +80,10 @@ def run(self, sensorRefList, calibType):
self.log.info("Amp: Processing %s", amp.dataId)
print("dataid %s" % (amp.dataId))
butler = amp.butlerSubset.butler
ampMIList = afwImage.vectorMaskedImageF()
ampMIList = []
for sRef in sensorRefList:
self.log.info("Sensor: Processing %s", sRef.dataId)
ampSnapMIList = afwImage.vectorMaskedImageF()
ampSnapMIList = []
dataId = eval(amp.dataId.__repr__())
dataId['visit'] = sRef.dataId['visit']
for snap in (0, 1):
Expand All @@ -94,7 +93,7 @@ def run(self, sensorRefList, calibType):
expmeta = ampExposure.getMetadata()
expfilter = ampExposure.getFilter()
expcalib = ampExposure.getCalib()
ampDetector = cameraGeom.cast_Amp(ampExposure.getDetector())
ampDetector = ampExposure.getDetector()

ampExposure = self.convertIntToFloat(ampExposure)
ampExpDataView = ampExposure.Factory(ampExposure, ampDetector.getDiskDataSec())
Expand Down Expand Up @@ -163,7 +162,7 @@ def fixDefectsAndSat(self, masterFrame, detector):
x = dataBbox.getMinY()
height = dataBbox.getDimensions()[0]
# When at detector level, there will not be the need to go through the step of getting the parent
defectList = cameraGeom.cast_Ccd(detector.getParent()).getDefects()
defectList = detector.getParent().getDefects()
dl = self.transposeDefectList(defectList, dataBbox)
for d in dl:
d.shift(-x, -y)
Expand Down
4 changes: 2 additions & 2 deletions tests/getRaw.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import lsst.daf.persistence as dafPersist
from lsst.obs.base import MakeRawVisitInfo
import lsst.utils.tests
from lsst.afw.image import RotType_SKY
from lsst.afw.image import RotType
from lsst.afw.coord import IcrsCoord, Coord
from lsst.afw.geom import degrees

Expand All @@ -48,7 +48,7 @@ def setUp(self):
self.boresightAzAlt = Coord(127.158246182602*degrees, (90 - 40.6736117075876)*degrees)
self.boresightAirmass = 1.31849492005496
self.boresightRotAngle = (90 - 3.43228)*degrees
self.rotType = RotType_SKY
self.rotType = RotType.SKY
self.obs_longitude = -70.749417*degrees
self.obs_latitude = -30.244633*degrees
self.obs_elevation = 2663.0
Expand Down
3 changes: 2 additions & 1 deletion tests/testGetEimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import lsst.utils
import lsst.afw.geom as afwGeom
from lsst.afw.image import RotType
import lsst.utils.tests
import lsst.daf.persistence as dafPersistence
from lsst.afw.coord import Coord, IcrsCoord, Observatory, Weather
Expand Down Expand Up @@ -103,7 +104,7 @@ def test_getObservatory(self):
self.assertEqual(observatory, self.visit_info.getObservatory())

def test_getRotType(self):
self.assertEqual(1, self.visit_info.getRotType())
self.assertEqual(RotType.SKY, self.visit_info.getRotType())

def test_getWeather(self):
def test_weather(w1, w2):
Expand Down
4 changes: 2 additions & 2 deletions ups/obs_lsstSim.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import lsst.sconsUtils

dependencies = {
"required" : ["afw"],
"buildRequired" : ["boost_test", "swig"],
"buildRequired" : ["boost_test", "pybind11"],
}

config = lsst.sconsUtils.Configuration(
__file__,
headers=["lsst/obs_lsstSim/sensor.h"],
hasDoxygenInclude=False,
hasSwigFiles=True,
hasSwigFiles=False,
)
1 change: 1 addition & 0 deletions ups/obs_lsstSim.table
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ setupRequired(obs_base)
setupRequired(meas_algorithms)
setupRequired(ip_isr)
setupRequired(pipe_tasks)
setupRequired(pybind11)
setupRequired(python_mysqlclient)
setupRequired(utils)

Expand Down