Skip to content

Commit

Permalink
Add calib headers.
Browse files Browse the repository at this point in the history
For approximate self-consistency, assembleLsstChannels has been
updated with the ability to add header keywords. Since I don't have
the original lsstSim data, however, I have not tested this
functionality and added the headers by a different route.
  • Loading branch information
kfindeisen committed May 3, 2018
1 parent 3dd7654 commit 0199471
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 82 deletions.
1 change: 0 additions & 1 deletion config/ingestCalibs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Config override for lsst.pipe.tasks.IngestCalibsTask
from lsst.obs.test.ingestCalibs import TestCalibsParseTask

config.parse.retarget(TestCalibsParseTask)
config.parse.translation = {'filter': 'FILTER',
}
config.parse.translators = {'calibDate': 'translate_date',
Expand Down
9 changes: 6 additions & 3 deletions data/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,18 @@ To create the repository database, from the obs_test directory
To make the obs_test bias image, from the obs_test directory:

setup -r .
data/utils/assembleLsstChannels.py <lsstSim data location>/bias/v0/R22/S00
data/utils/assembleLsstChannels.py <lsstSim data location>/bias/v0/R22/S00 \
OBSTYPE=bias DATE-OBS=1999-01-17T05:22:00
mv image.fits bias.fits

To make obs_test flat images, from the obs_test directory:

setup -r .
data/utils/assembleLsstChannels.py <lsstSim data location>/flat/v2-fg/R22/S00
data/utils/assembleLsstChannels.py <lsstSim data location>/flat/v2-fg/R22/S00 \
OBSTYPE=flat DATE-OBS=1999-01-17T05:22:00
mv image.fits flat_fg.fits
data/utils/assembleLsstChannels.py <lsstSim data location>/flat/v2-fr/R22/S00
data/utils/assembleLsstChannels.py <lsstSim data location>/flat/v2-fr/R22/S00 \
OBSTYPE=flat DATE-OBS=1999-01-17T05:22:00
mv image.fits flat_fr.fits

To make obs_test raw images, from the obs_test directory:
Expand Down
Binary file modified data/input/bias/bias.fits.gz
Binary file not shown.
Binary file modified data/input/flat/flat_fg.fits.gz
Binary file not shown.
Binary file modified data/input/flat/flat_fr.fits.gz
Binary file not shown.
35 changes: 31 additions & 4 deletions data/utils/assembleLsstChannels.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#
"""Assemble a set of LSSTSim channel images into one obs_test image
"""
from __future__ import absolute_import, division, print_function
import argparse
import glob
import os.path
Expand Down Expand Up @@ -56,8 +55,31 @@ def openChannelImage(dirPath, x, y):
return exposureClass(inImagePath)


def assembleImage(dirPath):
def updateMetadata(metadata, **kwargs):
"""Fill in missing keywords in an image header.
metadata : `lsst.daf.base.PropertySet`
The header to update.
kwargs : `str` to `str`
The values of the metadata keys to add to ``metadata`` if no previous value exists.
"""
for key, value in kwargs.items():
if not metadata.exists(key):
metadata.set(key, value)


def assembleImage(dirPath, **kwargs):
"""Make one image by combining half of amplifiers C00, C01, C10, C11 of lsstSim data
The new image shall be written to a fixed location on disk.
Parameters
----------
dirpath : `str`
Directory containing the four images to be combined.
kwargs : `str` to `str`
Default values for output header keywords. The keyword(s) provided in
the input image always takes precedence.
"""
inExposure = openChannelImage(dirPath, 0, 0)
fullInDim = inExposure.getDimensions()
Expand All @@ -73,7 +95,9 @@ def assembleImage(dirPath):
if inExposure.hasWcs():
outExposure.setWcs(inExposure.getWcs())
outExposure.setFilter(inExposure.getFilter())
outExposure.setMetadata(inExposure.getMetadata())
metadata = inExposure.getMetadata()
updateMetadata(metadata, **kwargs)
outExposure.setMetadata(metadata)
outMI = outExposure.getMaskedImage()

for x in (0, 1):
Expand All @@ -98,6 +122,7 @@ def assembleImage(dirPath):
outExposure.writeFits(OutFileName)
print("wrote assembled data as %r" % (OutFileName,))


if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="""Assemble a set of LSSTSim channel images into one obs_test image.
Expand All @@ -108,6 +133,8 @@ def assembleImage(dirPath):
parser.add_argument("dir", default=".", nargs="?",
help="directory containing LSSTSim channel images (at least for channels " +
"0,0, 0,1, 1,0 and 1,1); defaults to the current working directory.")
parser.add_argument("keywords", nargs=argparse.REMAINDER)
args = parser.parse_args()
args.keywords = dict(pair.split("=") for pair in args.keywords)

assembleImage(args.dir)
assembleImage(args.dir, **args.keywords)
74 changes: 0 additions & 74 deletions python/lsst/obs/test/ingestCalibs.py

This file was deleted.

0 comments on commit 0199471

Please sign in to comment.