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-9313: obs_decam should not call stripWcsKeywords #44

Merged
merged 2 commits into from
Feb 8, 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: 1 addition & 1 deletion python/lsst/obs/decam/decamCpIsr.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import absolute_import, division, print_function
#
# LSST Data Management System
#
Expand All @@ -21,6 +20,7 @@
# the GNU General Public License along with this program. If not,
# see <https://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

from lsst.ip.isr import biasCorrection, flatCorrection
from lsst.meas.algorithms.detection import SourceDetectionTask
Expand Down
31 changes: 17 additions & 14 deletions python/lsst/obs/decam/decamMapper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from builtins import map
#
# LSST Data Management System
# Copyright 2012-2016 LSST Corporation.
Expand All @@ -20,9 +19,12 @@
# 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 re

import numpy as np

from lsst.utils import getPackageDir
import lsst.afw.image as afwImage
import lsst.afw.image.utils as afwImageUtils
Expand All @@ -40,14 +42,15 @@ class DecamMapper(CameraMapper):

MakeRawVisitInfoClass = MakeDecamRawVisitInfo

detectorNames = {1: 'S29', 2: 'S30', 3: 'S31', 4: 'S25', 5: 'S26', 6: 'S27', 7: 'S28', 8: 'S20', 9: 'S21',
10: 'S22', 11: 'S23', 12: 'S24', 13: 'S14', 14: 'S15', 15: 'S16', 16: 'S17', 17: 'S18',
18: 'S19', 19: 'S8', 20: 'S9', 21: 'S10', 22: 'S11', 23: 'S12', 24: 'S13', 25: 'S1', 26: 'S2',
27: 'S3', 28: 'S4', 29: 'S5', 30: 'S6', 31: 'S7', 32: 'N1', 33: 'N2', 34: 'N3', 35: 'N4',
36: 'N5', 37: 'N6', 38: 'N7', 39: 'N8', 40: 'N9', 41: 'N10', 42: 'N11', 43: 'N12', 44: 'N13',
45: 'N14', 46: 'N15', 47: 'N16', 48: 'N17', 49: 'N18', 50: 'N19', 51: 'N20', 52: 'N21',
53: 'N22', 54: 'N23', 55: 'N24', 56: 'N25', 57: 'N26', 58: 'N27', 59: 'N28', 60: 'N29',
62: 'N31'}
detectorNames = {
1: 'S29', 2: 'S30', 3: 'S31', 4: 'S25', 5: 'S26', 6: 'S27', 7: 'S28', 8: 'S20', 9: 'S21',
10: 'S22', 11: 'S23', 12: 'S24', 13: 'S14', 14: 'S15', 15: 'S16', 16: 'S17', 17: 'S18',
18: 'S19', 19: 'S8', 20: 'S9', 21: 'S10', 22: 'S11', 23: 'S12', 24: 'S13', 25: 'S1', 26: 'S2',
27: 'S3', 28: 'S4', 29: 'S5', 30: 'S6', 31: 'S7', 32: 'N1', 33: 'N2', 34: 'N3', 35: 'N4',
36: 'N5', 37: 'N6', 38: 'N7', 39: 'N8', 40: 'N9', 41: 'N10', 42: 'N11', 43: 'N12', 44: 'N13',
45: 'N14', 46: 'N15', 47: 'N16', 48: 'N17', 49: 'N18', 50: 'N19', 51: 'N20', 52: 'N21',
53: 'N22', 54: 'N23', 55: 'N24', 56: 'N25', 57: 'N26', 58: 'N27', 59: 'N28', 60: 'N29',
62: 'N31'}

def __init__(self, inputPolicy=None, **kwargs):
policyFile = pexPolicy.DefaultPolicyFile(self.packageName, "DecamMapper.paf", "policy")
Expand Down Expand Up @@ -165,7 +168,7 @@ def translate_dqmask(self, dqmask):
def translate_wtmap(self, wtmap):
wtmArr = wtmap.getArray()
idxUndefWeight = np.where(wtmArr <= 0)
#Reassign weights to be finite but small:
# Reassign weights to be finite but small:
wtmArr[idxUndefWeight] = min(1e-14, np.min(wtmArr[np.where(wtmArr > 0)]))
var = 1.0 / wtmArr
varim = afwImage.ImageF(var)
Expand All @@ -188,7 +191,7 @@ def bypass_instcal(self, datasetType, pythonType, butlerLocation, dataId):

mi = afwImage.MaskedImageF(afwImage.ImageF(instcal.getImage()), mask, variance)
md = instcal.getMetadata()
wcs = afwImage.makeWcs(md)
wcs = afwImage.makeWcs(md, True)
exp = afwImage.ExposureF(mi, wcs)

# Set the calib by hand; need to grab the zeroth extension
Expand All @@ -201,8 +204,6 @@ def bypass_instcal(self, datasetType, pythonType, butlerLocation, dataId):
visitInfo = self.makeRawVisitInfo(md=md0, exposureId=exposureId)
exp.getInfo().setVisitInfo(visitInfo)

afwImage.stripWcsKeywords(md, wcs)

for kw in ('LTV1', 'LTV2'):
md.remove(kw)

Expand Down Expand Up @@ -242,12 +243,14 @@ def std_raw(self, item, dataId):
# from the metadata. Once TPV is supported, the following keyword
# removal may not be necessary here and would probably be done at
Copy link
Author

Choose a reason for hiding this comment

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

May you please correct these comments too? These comments were there partially because of the line you removed. My understanding is the previous behavior of afw.image.makeWcs would not modify the input metadata at all if it's PTV. And the behavior has changed now with DM-9298. Now it removes some wcs cards but not PV cards. Is that correct?

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed. Unfortunately the code is still required because although makeWcs strips those PVn_n keywords internally, it does so on a deep copy. I updated the comment accordingly.

# makeWcs() when the raw image is converted to an Exposure.
afwImage.stripWcsKeywords(md, exp.getWcs())
for kw in ('LTV1', 'LTV2'):
md.remove(kw)

# Currently the existence of some PV cards in the metadata combined
# with a CTYPE of TAN is interpreted as TPV (DM-2883).
# However, `lsst.afw.image.makeWcs` (which is called by `exposureFromImage`,
# and strips most WCS keywords from the metadata) does not strip the PVn_n keywords
# (except on an internal deep copy), so do that here.
for kw in md.paramNames():
if re.match(r'PV\d_\d', kw):
md.remove(kw)
Expand Down
2 changes: 2 additions & 0 deletions python/lsst/obs/decam/decamNullIsr.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
# the GNU General Public License along with this program. If not,
# see <https://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

import lsst.pipe.base as pipeBase
import lsst.pex.config as pexConfig

Expand Down
14 changes: 10 additions & 4 deletions python/lsst/obs/decam/ingest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from builtins import zip
#
# LSST Data Management System
# Copyright 2012,2015 LSST Corporation.
Expand All @@ -20,8 +19,12 @@
# 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 re

from builtins import zip

import lsst.afw.image as afwImage
from lsst.pipe.tasks.ingest import ParseTask, IngestTask, IngestArgumentParser

Expand Down Expand Up @@ -56,11 +59,14 @@ def run(self, args):
fileInfo, hduInfoList = self.parse.getInfo(infile, args.filetype)
if len(hduInfoList) > 0:
outfileInstcal = os.path.join(root, self.parse.getDestination(args.butler,
hduInfoList[0], infile, "instcal"))
hduInfoList[0],
infile, "instcal"))
outfileDqmask = os.path.join(root, self.parse.getDestination(args.butler,
hduInfoList[0], infile, "dqmask"))
hduInfoList[0], infile,
"dqmask"))
outfileWtmap = os.path.join(root, self.parse.getDestination(args.butler,
hduInfoList[0], infile, "wtmap"))
hduInfoList[0], infile,
"wtmap"))

ingestedInstcal = self.ingest(fileInfo["instcal"], outfileInstcal,
mode=args.mode, dryrun=args.dryrun)
Expand Down
3 changes: 3 additions & 0 deletions python/lsst/obs/decam/ingestCalibs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from __future__ import absolute_import, division, print_function

import collections
import re

from lsst.pipe.tasks.ingestCalibs import CalibsParseTask


Expand Down
1 change: 1 addition & 0 deletions python/lsst/obs/decam/isr.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# 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 lsst.afw.geom as afwGeom
import lsst.afw.table as afwTable
Expand Down
3 changes: 3 additions & 0 deletions python/lsst/obs/decam/makeCamera.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from __future__ import absolute_import, division, print_function

from builtins import range

import lsst.afw.geom as afwGeom
import lsst.afw.cameraGeom as cameraGeom

Expand Down
6 changes: 3 additions & 3 deletions python/lsst/obs/decam/selectDecamImages.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import print_function
from __future__ import absolute_import, division, print_function
from builtins import range
import MySQLdb
import os
Expand Down Expand Up @@ -163,7 +163,7 @@ def run(self, coordList, filter):
if not columnNames:
raise RuntimeError("Bug: no column names")
queryStr = "select %s " % (", ".join(columnNames),)
dataTuple = () # tuple(columnNames)
dataTuple = () # tuple(columnNames)

if coordList is not None:
# look for exposures that overlap the specified region
Expand All @@ -174,7 +174,7 @@ def run(self, coordList, filter):
coordStr = ", ".join(coordStrList)
coordCmd = "call scisql.scisql_s2CPolyRegion(scisql_s2CPolyToBin(%s), 10)" % (coordStr,)
cursor.execute(coordCmd)
cursor.nextset() # ignore one-line result of coordCmd
cursor.nextset() # ignore one-line result of coordCmd

queryStr += """
from %s as ccdExp,
Expand Down
3 changes: 2 additions & 1 deletion tests/testButler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import print_function
#
# LSST Data Management System
# Copyright 2016 LSST Corporation.
Expand All @@ -20,10 +19,12 @@
# 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 unittest
import warnings

import lsst.daf.persistence as dafPersist
import lsst.pex.exceptions as pexExcept
import lsst.utils.tests
Expand Down
3 changes: 2 additions & 1 deletion tests/testGetId.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
# the GNU General Public License along with this program. If not,
# see <https://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

import unittest
import lsst.utils.tests

import lsst.utils.tests
import lsst.daf.persistence as dafPersist
from lsst.obs.decam import DecamMapper

Expand Down
2 changes: 1 addition & 1 deletion tests/testGetInstcal.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import print_function
#
# LSST Data Management System
# Copyright 2016 LSST Corporation.
Expand All @@ -20,6 +19,7 @@
# 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
Expand Down
1 change: 1 addition & 0 deletions tests/testGetRaw.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# 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
Expand Down
2 changes: 1 addition & 1 deletion tests/testProcessCcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# the GNU General Public License along with this program. If not,
# see <https://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import print_function
from __future__ import absolute_import, division, print_function

import os
import shutil
Expand Down
1 change: 1 addition & 0 deletions tests/testWcsCards.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# the GNU General Public License along with this program. If not,
# see <https://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

import os
import unittest
Expand Down