Skip to content

Commit

Permalink
Added the integration tests and unit tests for lsstcam_calibrations.
Browse files Browse the repository at this point in the history
  • Loading branch information
rbovill committed Dec 14, 2023
1 parent 08045a7 commit 8d0903f
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 0 deletions.
1 change: 1 addition & 0 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ build:
- gencam_disabled_enabled = lsst.ts.IntegrationTests.gencam_disabled_enabled:run_gencam_disabled_enabled
- gencam_standby_disabled = lsst.ts.IntegrationTests.gencam_standby_disabled:run_gencam_standby_disabled
- enabled_offline = lsst.ts.IntegrationTests.enabled_offline:run_enabled_offline
- lsstcam_calibrations = lsst.ts.IntegrationTests.lsstcam_calibrations:run_lsstcam_calibrations
- lsstcam_image_taking = lsst.ts.IntegrationTests.image_taking_verification:run_lsstcam_image_taking
- lsstcam_offline_standby = lsst.ts.IntegrationTests.maintel_offline_standby:run_maintel_offline_standby
- maintel_disabled_enabled = lsst.ts.IntegrationTests.maintel_disabled_enabled:run_maintel_disabled_enabled
Expand Down
1 change: 1 addition & 0 deletions python/lsst/ts/IntegrationTests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
from .image_taking_verification import *
from .load_camera_playlist import *
from .love_stress_test import *
from .lsstcam_calibrations import *
from .maintel_disabled_enabled import *
from .maintel_housekeeping import *
from .maintel_offline_standby import *
Expand Down
24 changes: 24 additions & 0 deletions python/lsst/ts/IntegrationTests/configs/image_taking_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,27 @@
explicit_start=True,
canonical=True,
)

# lsstcam_calibrations
registry["lsstcam_calibrations_flat"] = yaml.safe_dump(
{
"n_discard_bias": 0,
"n_discard_dark": 0,
"n_discard_flat": 0,
"n_bias": 10,
"n_dark": 10,
"n_flat": 10,
"exp_times_dark": 20,
"exp_times_flat": 5,
"detectors": [0, 1, 2, 3, 4, 5, 6, 7, 8],
"filter": "r_03",
"calib_collection": "LSSTCam/calib/u/integrationtester/daily.replace_me.calib_type",
"generate_calibrations": True,
"do_verify": True,
"script_mode": "BIAS_DARK_FLAT",
"do_defects": True,
"certify_calib_begin_date": "replace_me",
},
explicit_start=True,
canonical=True,
)
83 changes: 83 additions & 0 deletions python/lsst/ts/IntegrationTests/lsstcam_calibrations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This file is part of ts_IntegrationTests.
#
# Developed for the Vera C. Rubin Observatory Telescope & Site Software system.
# This product includes software developed by the Vera C. Rubin Observatory
# 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

__all__ = ["LsstCamCalibrations", "run_lsstcam_calibrations"]

import argparse
import asyncio

import yaml
from lsst.ts.IntegrationTests import BaseScript

from .configs.config_registry import registry


class LsstCamCalibrations(BaseScript):
"""Execute the given Standard or External script,
with the given Yaml configuration,
placed in the given ScriptQueue location.
Parameters
----------
calib_type : `str`
Defines which set of calibrations to run.
Choices are ["flat", "ptc"].
"""

index: int = 1
configs: tuple = ([],)
scripts: list = [
("maintel/make_lsstcam_calibrations.py", BaseScript.is_external),
]

def __init__(self, calib_type: str) -> None:
super().__init__()
self.calib_type = calib_type
self.calib_configs = yaml.safe_load(
registry[f"lsstcam_calibrations_{calib_type}"]
)
self.calib_configs["certify_calib_begin_date"] = super().get_current_date()
self.calib_configs["calib_collection"] = self.calib_configs[
"calib_collection"
].replace("replace_me", super().get_current_date("%Y%m%d"))
self.calib_configs["calib_collection"] = self.calib_configs[
"calib_collection"
].replace("calib_type", calib_type)
self.configs = (yaml.safe_dump(self.calib_configs),)


def run_lsstcam_calibrations() -> None:
parser = argparse.ArgumentParser()
parser.add_argument(
"calib_type",
type=str,
choices=["flat", "ptc"],
help="Specify which set of calibrations to run.",
)
args = parser.parse_args()
script_class = LsstCamCalibrations(calib_type=args.calib_type)
print(
f"\nLSSTCam Calibrations; running the "
f"master_{script_class.calib_type} calibrations"
f"\nwith configuration;\n{script_class.configs}"
)
asyncio.run(script_class.run())
78 changes: 78 additions & 0 deletions tests/test_lsstcam_calibrations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This file is part of ts_IntegrationTests.
#
# Developed for the Vera C. Rubin Observatory Telescope & Site Software system.
# This product includes software developed by the Vera C. Rubin Observatory
# 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
from datetime import date

from lsst.ts import salobj
from lsst.ts.IntegrationTests import LSSTCamCalibrations, ScriptQueueController


class LSSTCamCalibrationsTestCase(unittest.IsolatedAsyncioTestCase):
"""
Test the Make Latiss Configurations integration test scripts.
"""

async def asyncSetUp(self) -> None:
# Set the LSST_DDS_PARTITION_PREFIX ENV_VAR.
salobj.set_random_lsst_dds_partition_prefix()

# Create the ScriptQueue Controller.
self.controller = ScriptQueueController(index=1)

# Start the controller and wait for it be ready.
await self.controller.start_task

async def test_lsstcam_calibrations_flat(self) -> None:
"""Execute the LSSTCamCalibrations integration test script,
which runs the ts_standardscripts/maintel/make_lsstcam_calibratons.py
script.
Use the configuration stored in the image_taking_configs.py module.
"""
# Instantiate the LSSTCamCalibrations integration tests.
calib_type = "flat"
script_class = LSSTCamCalibrations(calib_type=calib_type)
# Assert configurations were updated with current date.
self.assertEqual(
script_class.calib_configs["certify_calib_begin_date"],
date.today().strftime("%Y-%m-%d"),
)
self.assertEqual(
script_class.calib_configs["calib_collection"],
f"LSSTCam/calib/u/integrationtester/daily."
f"{date.today().strftime('%Y%m%d')}.{calib_type}",
)
# Get number of scripts
num_scripts = len(script_class.scripts)
print(
f"AuxTel Make Latiss Configurations. "
f"Running the {script_class.scripts[0][0]} script "
f"for the master_{calib_type} calibrations,"
f"\nwith configuration;\n{script_class.configs}"
)
# Execute the scripts.
await script_class.run()
# Assert script was added to ScriptQueue.
self.assertEqual(len(self.controller.queue_list), num_scripts)
# Assert scripts passed.
self.assertEqual(script_class.script_states, [8])

0 comments on commit 8d0903f

Please sign in to comment.