Skip to content

Commit

Permalink
Merge pull request #23 from lsst/tickets/DM-34687
Browse files Browse the repository at this point in the history
DM-34687: Add generation of HiPS-compatible exposures
  • Loading branch information
erykoff authored May 26, 2022
2 parents 698d287 + f6aebcf commit 1d37475
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
33 changes: 33 additions & 0 deletions bin.src/ci_imsim_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
QGRAPH_FILE = "DRP.qgraph"
INPUTCOL = f"{INSTRUMENT_NAME}/defaults"
COLLECTION = f"{INSTRUMENT_NAME}/runs/ci_imsim"
HIPS_QGRAPH_FILE = "hips.qgraph"
HIPS_COLLECTION = f"{INSTRUMENT_NAME}/runs/ci_imsim_hips"

index_command = 0

Expand Down Expand Up @@ -119,6 +121,37 @@ def run(self, currentState: BuildState):
subprocess.run(pipetask, check=True)


@ciRunner.register("hips_qgraph", index_command := index_command + 1)
class HipsQgraphCommand(BaseCommand):
def run(self, currentState: BuildState):
args = (
"build",
"-b", self.runner.RunDir,
"-p", "$CI_IMSIM_DIR/resources/highres_hips.yaml",
"-i", COLLECTION,
"--pixels", str(33),
"-q", os.path.join(self.runner.RunDir, HIPS_QGRAPH_FILE)
)
builder = self.runner.getExecutableCmd("PIPE_TASKS_DIR", "build-high-resolution-hips-qg", args)
subprocess.run(builder, check=True)


@ciRunner.register("hips_process", index_command := index_command + 1)
class HipsProcessCommand(BaseCommand):
def run(self, currentState: BuildState):
args = (
"--long-log",
"run",
"-j", str(self.arguments.num_cores),
"-b", self.runner.RunDir,
"--output", HIPS_COLLECTION,
"--register-dataset-types",
"-g", HIPS_QGRAPH_FILE
)
pipetask = self.runner.getExecutableCmd("CTRL_MPEXEC_DIR", "pipetask", args)
subprocess.run(pipetask, check=True)


ciRunner.register("test", index_command := index_command + 1)(TestRunner)

ciRunner.run()
5 changes: 5 additions & 0 deletions resources/highres_hips.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
description: Run HighResolutionHipsTask
instrument: lsst.obs.lsst.LsstCamImSim
tasks:
highResolutionHips9:
class: lsst.pipe.tasks.hips.HighResolutionHipsTask
55 changes: 55 additions & 0 deletions tests/test_hips_outputs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# This file is part of ci_imsim.
#
# Developed for the LSST Data Management System.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# 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 GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import unittest
import os

from lsst.daf.butler import Butler
from lsst.utils import getPackageDir


class TestHipsOutputs(unittest.TestCase):
"""Check that HIPS outputs are as expected."""
def setUp(self):
self.butler = Butler(os.path.join(getPackageDir("ci_imsim"), "DATA"),
instrument="LSSTCam-imSim", skymap="discrete/ci_imsim/4k",
writeable=False, collections=["LSSTCam-imSim/runs/ci_imsim_hips"])
self._bands = ['u', 'g', 'r', 'i', 'z', 'y']

def test_hips_exist(self):
"""Test that the HIPS images exist and are readable."""
for band in self._bands:
datasets = set(self.butler.registry.queryDatasets("deepCoadd_hpx", band=band))

# There are 90 HiPS images for each band.
self.assertEqual(len(datasets), 90)

for dataset in datasets:
self.assertTrue(self.butler.datastore.exists(dataset), msg="File exists for deepCoadd_hpx")

exp = self.butler.getDirect(list(datasets)[0])

self.assertEqual(exp.wcs.getFitsMetadata()["CTYPE1"], "RA---HPX")
self.assertEqual(exp.wcs.getFitsMetadata()["CTYPE2"], "DEC--HPX")


if __name__ == "__main__":
unittest.main()

0 comments on commit 1d37475

Please sign in to comment.