Skip to content

Commit

Permalink
add tests for LsstComCamSim
Browse files Browse the repository at this point in the history
  • Loading branch information
jchiang87 committed Feb 12, 2024
1 parent f6aaa3e commit 613d15d
Show file tree
Hide file tree
Showing 12 changed files with 86,179 additions and 6 deletions.

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions data/input/comCamSim/butler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
datastore:
cls: lsst.daf.butler.datastores.fileDatastore.FileDatastore
records:
table: file_datastore_records
root: <butlerRoot>
registry:
db: sqlite:///<butlerRoot>/gen3.sqlite3
managers:
attributes: lsst.daf.butler.registry.attributes.DefaultButlerAttributeManager
collections: lsst.daf.butler.registry.collections.synthIntKey.SynthIntKeyCollectionManager
datasets: lsst.daf.butler.registry.datasets.byDimensions.ByDimensionsDatasetRecordStorageManagerUUID
datastores: lsst.daf.butler.registry.bridge.monolithic.MonolithicDatastoreRegistryBridgeManager
dimensions: lsst.daf.butler.registry.dimensions.static.StaticDimensionRecordStorageManager
opaque: lsst.daf.butler.registry.opaque.ByNameOpaqueTableStorageManager
Binary file added data/input/comCamSim/gen3.sqlite3
Binary file not shown.

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions python/lsst/obs/lsst/translators/comCamSim.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
__all__ = ("LsstComCamSimTranslator", )

import logging
from numbers import Number

from astropy.time import Time
from .lsstCam import LsstCamTranslator
from .lsst import SIMONYI_TELESCOPE

Expand All @@ -39,7 +37,7 @@ def can_translate(cls, header, filename=None):
"""Indicate whether this translation class can translate the
supplied header.
Looks for "COMCAM" instrument in case-insensitive manner but
Looks for "COMCAMSIM" instrument in case-insensitive manner but
must be on LSST telescope. This avoids confusion with other
telescopes using commissioning cameras.
Expand Down
122 changes: 122 additions & 0 deletions tests/headers/comCamSim-IM_P_20240117_000000_R22_S00.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
SIMPLE: true
EXTEND: true
RUNNUM: 3000000
OBSID: IM_P_20240117_000000
MJD: 60326.0
DATE: '2024-01-17T00:00:00.000'
DAYOBS: '20240117'
SEQNUM: 0
CONTRLLR: P
EXPTIME: 0.0
DARKTIME: 0.0
TIMESYS: TAI
LSST_NUM: ITL-3800C-229
IMGTYPE: bias
OBSTYPE: bias
REASON: calibration
MONOWL: -1
ROTANGLE: 69.38276508708303
FILTER: r_03
TELESCOP: Simonyi Survey Telescope
INSTRUME: ComCamSim
RAFTBAY: R22
CCDSLOT: S00
RA: 199.68134610137426
DEC: -34.544668655603914
ROTCOORD: sky
ROTPA: 69.38276508708303
MJD-OBS: 60326.0
HASTART: -154.50897532930324
HAEND: -154.50897532930324
DATE-OBS: '2024-01-17T00:00:00.000'
DATE-END: '2024-01-17T00:00:00.000'
AMSTART: 1.3680456183164553
AMEND: 1.3680456183164553
IMSIMVER: '2.0'
PKG00000: throughputs
VER00000: '1.4'
CHIPID: R22_S00
FOCUSZ: 0.0
TESTTYPE: bias
PROGRAM: calibration
OUTFILE: bias_03000000-0-r-R22_S00-det000.fits.fz
XTENSION: BINTABLE
BITPIX: 8
NAXIS: 2
NAXIS1: 8
NAXIS2: 2048
PCOUNT: 798582
GCOUNT: 1
TFIELDS: 1
TTYPE1: COMPRESSED_DATA
TFORM1: 1PB(404)
ZIMAGE: true
ZTENSION: IMAGE
ZBITPIX: 32
ZNAXIS: 2
ZNAXIS1: 576
ZNAXIS2: 2048
ZPCOUNT: 0
ZGCOUNT: 1
ZTILE1: 576
ZTILE2: 1
ZCMPTYPE: RICE_1
ZNAME1: BLOCKSIZE
ZVAL1: 32
ZNAME2: BYTEPIX
ZVAL2: 4
EXTNAME: Segment10
GS_XMIN: 1
GS_YMIN: 1
GS_WCS: GSFitsWCS
CTYPE1: RA---TAN-SIP
CTYPE2: DEC--TAN-SIP
CRPIX1: -1526.5106898451024
CRPIX2: 2000.4893552509109
CD1_1: 1.95923524902693e-05
CD1_2: -5.1966735293673e-05
CD2_1: -5.1990207577865e-05
CD2_2: -1.9647180296879e-05
CUNIT1: deg
CUNIT2: deg
CRVAL1: 199.52340844684164
CRVAL2: -34.831788378670616
A_ORDER: 3
A_0_2: 4.73746786976863e-09
A_0_3: -1.6726695113156e-15
A_1_1: 1.04269719838779e-08
A_1_2: -8.5163091900977e-13
A_2_0: 1.40591999584633e-08
A_2_1: -4.9629216414744e-15
A_3_0: -8.5167839844527e-13
B_ORDER: 3
B_0_2: 1.40368079796922e-08
B_0_3: -8.5163562363519e-13
B_1_1: 1.03242218545778e-08
B_1_2: -4.9663686256606e-15
B_2_0: 4.74109857951207e-09
B_2_1: -8.5163350345288e-13
B_3_0: -1.6727980314197e-15
AP_ORDER: 3
AP_0_1: -2.7986814355711e-13
AP_0_2: -4.7375607927692e-09
AP_0_3: 1.85515396398912e-15
AP_1_0: -5.4348747724475e-11
AP_1_1: -1.042735909399e-08
AP_1_2: 8.52141372380089e-13
AP_2_0: -1.40596494307e-08
AP_2_1: 5.55557717892048e-15
AP_3_0: 8.52147489547319e-13
BP_ORDER: 3
BP_0_1: -5.4372395474899e-11
BP_0_2: -1.4037256914799e-08
BP_0_3: 8.52102937272653e-13
BP_1_0: -3.1948496283012e-13
BP_1_1: -1.0324606449967e-08
BP_1_2: 5.55399830380869e-15
BP_2_0: -4.7411917639159e-09
BP_2_1: 8.52141549526488e-13
BP_3_0: 1.85515988155434e-15
DATASEC: '[4:512,1:2000]'
DETSEC: '[509:1,4000:2001]'

Check failure on line 122 in tests/headers/comCamSim-IM_P_20240117_000000_R22_S00.yaml

View workflow job for this annotation

GitHub Actions / call-workflow / yamllint

122:1 [empty-lines] too many blank lines (1 > 0)
4 changes: 4 additions & 0 deletions tests/test_butlerCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ class TestButlerCmdLsstComCam(ButlerCmdTestBase, lsst.utils.tests.TestCase):
instrumentClassName = "lsst.obs.lsst.LsstComCam"


class TestButlerCmdLsstComCamSim(ButlerCmdTestBase, lsst.utils.tests.TestCase):
instrumentClassName = "lsst.obs.lsst.LsstComCamSim"


class TestButlerCmdLsstCamImSim(ButlerCmdTestBase, lsst.utils.tests.TestCase):
instrumentClassName = "lsst.obs.lsst.LsstCamImSim"

Expand Down
105 changes: 105 additions & 0 deletions tests/test_comCamSim.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# This file is part of obs_lsst.
#
# Developed for the LSST Data Management System.
# This product includes software developed by the LSST Project
# (http://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 <http://www.gnu.org/licenses/>.
#
import sys
import unittest

import lsst.utils.tests
from lsst.geom import arcseconds, Extent2I
import lsst.afw.image

from lsst.obs.lsst.testHelper import ObsLsstButlerTests, ObsLsstObsBaseOverrides
from lsst.obs.lsst import LsstComCamSim


class TestLsstCam(ObsLsstObsBaseOverrides, ObsLsstButlerTests):
instrumentDir = "comCamSim"

@classmethod
def getInstrument(cls):
return LsstComCamSim()

def setUp(self):
dataIds = {'raw': {'exposure': 5024032100720, 'name_in_raft': 'S11', 'raft': 'R22'},
'bias': unittest.SkipTest,
'flat': unittest.SkipTest,
'dark': unittest.SkipTest,
}
self.setUp_tests(self._butler, dataIds)

ccdExposureId_bits = 52
exposureIds = {'raw': 5024032100720000,
}
filters = {'raw': 'r_03',
}
exptimes = {'raw': 30.0,
}
detectorIds = {'raw': 4,
}
detector_names = {'raw': 'R22_S11',
}
# This name comes from the camera and not from the butler
detector_serials = {'raw': 'ITL-3800C-283',
}
dimensions = {'raw': Extent2I(4608, 4096),
}
sky_origin = unittest.SkipTest
raw_subsets = (({}, 1),
({'physical_filter': 'r_03'}, 1),
({'physical_filter': 'foo'}, 0),
({'exposure': 5024032100720}, 1),
)
linearizer_type = unittest.SkipTest
self.setUp_butler_get(ccdExposureId_bits=ccdExposureId_bits,
exposureIds=exposureIds,
filters=filters,
exptimes=exptimes,
detectorIds=detectorIds,
detector_names=detector_names,
detector_serials=detector_serials,
dimensions=dimensions,
sky_origin=sky_origin,
raw_subsets=raw_subsets,
linearizer_type=linearizer_type
)

self.raw_filename = '5024032100720-R22-S11-det004.fits.fz'

self.setUp_camera(camera_name='LSSTComCamSim',
n_detectors=9,
first_detector_name='R22_S00',
plate_scale=20.0 * arcseconds,
)

super().setUp()


class MemoryTester(lsst.utils.tests.MemoryTestCase):
pass


def setup_module(module):
lsst.utils.tests.init()


if __name__ == '__main__':
setup_module(sys.modules[__name__])
unittest.main()
7 changes: 6 additions & 1 deletion tests/test_gen3.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@

from astro_metadata_translator import ObservationInfo
from lsst.obs.lsst import (LsstCam, LsstComCam, LsstCamImSim, LsstCamPhoSim,
LsstTS8, LsstTS3, LsstUCDCam, Latiss, readRawFitsHeader)
LsstTS8, LsstTS3, LsstUCDCam, Latiss, LsstComCamSim,
readRawFitsHeader)

from lsst.daf.butler import (
Butler,
Expand Down Expand Up @@ -141,6 +142,10 @@ def testComCam(self):
testFpath = "comCam/raw/2019-05-30/3019053000001/3019053000001-R22-S00-det000.fits"
self.checkInstrumentWithRegistry(LsstComCam, testFpath)

def testComCamSim(self):
testFpath = "comCamSim/raw/2024-03-21/5024032100720/5024032100720-R22-S11-det004.fits.fz"
self.checkInstrumentWithRegistry(LsstComCamSim, testFpath)

def testImSim(self):
self.checkInstrumentWithRegistry(LsstCamImSim,
"imsim/raw/204595/R11/00204595-R11-S20-det042.fits")
Expand Down
30 changes: 29 additions & 1 deletion tests/test_ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

from lsst.afw.math import flipImage
from lsst.afw.cameraGeom import AmplifierGeometryComparison
from lsst.daf.butler import Butler
from lsst.daf.butler import Butler, DataCoordinate
from lsst.daf.butler.cli.butler import cli as butlerCli
from lsst.daf.butler.cli.utils import LogCliRunner
from lsst.obs.base.ingest_tests import IngestTestBase
Expand Down Expand Up @@ -120,6 +120,34 @@ class ComCamIngestTestCase(IngestTestBase, lsst.utils.tests.TestCase):
filterLabel = lsst.afw.image.FilterLabel(physical="unknown", band="unknown")


class ComCamSimIngestTestCase(IngestTestBase, lsst.utils.tests.TestCase):

curatedCalibrationDatasetTypes = ("camera",)
instrumentClassName = "lsst.obs.lsst.LsstComCamSim"
ingestDir = TESTDIR
file = os.path.join(DATAROOT, "comCamSim", "raw", "2024-03-21",
"5024032100720", "5024032100720-R22-S11-det004.fits.fz")
dataIds = [dict(instrument="LSSTComCamSim", exposure=5024032100720, detector=4)]
filterLabel = lsst.afw.image.FilterLabel(physical="r_03", band="r")

@property
def visits(self):
butler = Butler(self.root, collections=[self.outputRun])
return {
DataCoordinate.standardize(
instrument="LSSTComCamSim",
visit=5024032100720,
universe=butler.dimensions
): [
DataCoordinate.standardize(
instrument="LSSTComCamSim",
exposure=5024032100720,
universe=butler.dimensions
)
]
}


class LSSTCamIngestTestCase(IngestTestBase, lsst.utils.tests.TestCase):

curatedCalibrationDatasetTypes = ("camera",)
Expand Down
20 changes: 19 additions & 1 deletion tests/test_packer.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
LsstCamImSim,
LsstCamPhoSim,
LsstComCam,
LsstComCamSim,
LsstTS3,
LsstTS8,
LsstUCDCam,
Expand Down Expand Up @@ -56,7 +57,8 @@ def setUp(self) -> None:
registry_config = RegistryConfig()
registry_config["db"] = "sqlite://"
self.registry = SqlRegistry.createFromConfig(registry_config)
self.rubin_packer_instruments = [LsstCam, LsstComCam, Latiss]
self.rubin_packer_instruments = [LsstCam, LsstComCam, LsstComCamSim,
Latiss]
self.old_packer_instruments = [
LsstCamImSim,
LsstCamPhoSim,
Expand Down Expand Up @@ -246,6 +248,22 @@ def test_comCam(self):
detector=5,
)

def test_comCamSim(self):
instrument = LsstComCamSim()
instrument.register(self.registry)
# Input values obtained from:
# $ butler query-dimension-records data/input/comCamSim exposure \
# --where "instrument='LSSTComCamSim'" --limit 1
self.check_rubin_dimension_packer(
instrument,
is_exposure=False,
exposure_id=5024032100720,
day_obs=20240321,
seq_num=720,
detector=4,
controller="P"
)

def test_imsim(self):
instrument = LsstCamImSim()
instrument.register(self.registry)
Expand Down
Loading

0 comments on commit 613d15d

Please sign in to comment.