From 71d065c815d30a112ac687c5882b7aa8495c2404 Mon Sep 17 00:00:00 2001 From: ggermain Date: Mon, 11 Mar 2024 13:10:15 -0400 Subject: [PATCH 01/11] First version of the 1DPAMYT model and setup.py mods --- acis_thermal_check/apps/dpamyt_check.py | 146 ++++++++++++++++++++++++ setup.py | 7 +- 2 files changed, 150 insertions(+), 3 deletions(-) create mode 100755 acis_thermal_check/apps/dpamyt_check.py diff --git a/acis_thermal_check/apps/dpamyt_check.py b/acis_thermal_check/apps/dpamyt_check.py new file mode 100755 index 0000000..0b5b241 --- /dev/null +++ b/acis_thermal_check/apps/dpamyt_check.py @@ -0,0 +1,146 @@ +#!/usr/bin/env python + +""" +======================== +1dpamyt_check +======================== + +This code generates backstop load review outputs for checking the ACIS +DPA temperature 1DPAMYT. It also generates 1DPAMYT model validation +plots comparing predicted values to telemetry for the previous three +weeks. +""" +import sys +import matplotlib + +from acis_thermal_check import ACISThermalCheck, get_options + +# Matplotlib setup +# Use Agg backend for command-line (non-interactive) operation +matplotlib.use("Agg") + + +class DPAMYTCheck(ACISThermalCheck): + def __init__(self): + valid_limits = { "1DPAMYT": [(1, 2.0), (50, 1.0), (99, 2.0)], + "PITCH": [(1, 3.0), (99, 3.0)], + "TSCPOS": [(1, 2.5), (99, 2.5)], } + # Specify the temperature where only those temps greater + # than this temperature will be displaye donthe histogram. + hist_limit = [20.0] + + # Specify the lower planning limit for the zero FEP case. + limits_map = {"planning.caution.low": "zero_feps"} + + # Call the superclass' __init__ with the arguments + super().__init__( + "1dpamyt", + "dpamyt", + valid_limits, + hist_limit, + limits_map=limits_map, + ) + + def custom_prediction_viols(self, times, temp, viols, load_start): + """ + Custom handling of limit violations. This is for checking the + +10 degC violation if all FEPs are off. + + Parameters + ---------- + times : NumPy array + The times for the predicted temperatures + temp : NumPy array + The predicted temperatures + viols : dict + Dictionary of violations information to add to + load_start : float + The start time of the load, used so that we only report + violations for times later than this time for the model + run. + """ + # Only check this violation when all FEPs are off + mask = self.predict_model.comp["fep_count"].dvals == 0 + zf_viols = self._make_prediction_viols( + times, + temp, + load_start, + self.limits["zero_feps"].value, + "zero-feps", + "min", + mask=mask, + ) + viols["zero_feps"] = { + "name": f"Zero FEPs ({self.limits['zero_feps'].value} C)", + "type": "Min", + "values": zf_viols, + } + + def custom_prediction_plots(self, plots): + """ + Customization of prediction plots. + + Parameters + ---------- + plots : dict of dicts + Contains the hooks to the plot figures, axes, and filenames + and can be used to customize plots before they are written, + e.g. add limit lines, etc. + """ + plots[self.name].add_limit_line(self.limits["zero_feps"], "Zero FEPs", ls="--") + + def custom_validation_plots(self, plots): + """ + Customization of validation plots. + + Parameters + ---------- + plots : dict of dicts + Contains the hooks to the plot figures, axes, and filenames + and can be used to customize plots before they are written, + e.g. add limit lines, etc. + """ + plots["1dpamyt"]["lines"]["ax"].axhline( + self.limits["zero_feps"].value, + linestyle="--", + zorder=-8, + color=self.limits["zero_feps"].color, + linewidth=2, + label="Zero FEPs", + ) + + def _calc_model_supp(self, model, state_times, states, ephem, state0): + """ + Update to initialize the dpa0 pseudo-node. If 1dpamyt + has an initial value (T_dpa) - which it does at + prediction time (gets it from state0), then T_dpa0 + is set to that. If we are running the validation, + T_dpa is set to None so we use the dvals in model.comp + + NOTE: If you change the name of the dpa0 pseudo node you + have to edit the new name into the if statement + below. + """ + if "dpa0" in model.comp: + if state0 is None: + T_dpa0 = model.comp["1dpamyt"].dvals + else: + T_dpa0 = state0["1dpamyt"] + model.comp["dpa0"].set_data(T_dpa0, model.times) + + +def main(): + args = get_options() + dpamyt_check = DPAMYTCheck() + try: + dpamyt_check.run(args) + except Exception as msg: + if args.traceback: + raise + else: + print("ERROR:", msg) + sys.exit(1) + + +if __name__ == "__main__": + main() diff --git a/setup.py b/setup.py index ceb993f..72a57d6 100644 --- a/setup.py +++ b/setup.py @@ -14,6 +14,7 @@ "console_scripts": [ "dea_check = acis_thermal_check.apps.dea_check:main", "dpa_check = acis_thermal_check.apps.dpa_check:main", + "dpamyt_check = acis_thermal_check.apps.dpamyt_check:main", "psmc_check = acis_thermal_check.apps.psmc_check:main", "acisfp_check = acis_thermal_check.apps.acisfp_check:main", "fep1_mong_check = acis_thermal_check.apps.fep1_mong_check:main", @@ -28,9 +29,9 @@ packages=["acis_thermal_check"], use_scm_version=True, setup_requires=["setuptools_scm", "setuptools_scm_git_archive"], - description="ACIS Thermal Model Library", - author="John ZuHone", - author_email="john.zuhone@cfa.harvard.edu", + description="ACIS Thermal Model Library Program for 1DPAMYT", + author="Gregg Germain", + author_email="ggermain@cfa.harvard.edu", url="https://github.com/acisops/acis_thermal_check", data_files=[("templates", templates), ("data", data)], include_package_data=True, From 01a2dbca318e37adf43d2ae29f8918ff3610480e Mon Sep 17 00:00:00 2001 From: ggermain Date: Tue, 19 Mar 2024 11:56:39 -0400 Subject: [PATCH 02/11] Changes author to acis ops --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 72a57d6..fe10f7e 100644 --- a/setup.py +++ b/setup.py @@ -29,9 +29,9 @@ packages=["acis_thermal_check"], use_scm_version=True, setup_requires=["setuptools_scm", "setuptools_scm_git_archive"], - description="ACIS Thermal Model Library Program for 1DPAMYT", - author="Gregg Germain", - author_email="ggermain@cfa.harvard.edu", + description="ACIS Thermal Model Library", + author="ACIS Ops", + author_email="acisdude@cfa.harvard.edu", url="https://github.com/acisops/acis_thermal_check", data_files=[("templates", templates), ("data", data)], include_package_data=True, From c077ae1b3c508f1ad0b824ce55d83d466fa508be Mon Sep 17 00:00:00 2001 From: ggermain Date: Wed, 20 Mar 2024 09:59:41 -0400 Subject: [PATCH 03/11] Added Release Notes to the Pull Request --- .../ReleaseNotes_1DPAMYT_V1.0.txt | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 acis_thermal_check/ReleaseNotes_1DPAMYT_V1.0.txt diff --git a/acis_thermal_check/ReleaseNotes_1DPAMYT_V1.0.txt b/acis_thermal_check/ReleaseNotes_1DPAMYT_V1.0.txt new file mode 100644 index 0000000..ab7d86d --- /dev/null +++ b/acis_thermal_check/ReleaseNotes_1DPAMYT_V1.0.txt @@ -0,0 +1,64 @@ + + +Change Description +================== + + The 1PIN1AT and 1CRBT transducer failures had minimal mission impact. + +1DPAMZT is used as a proxy for the internal BEP and FEP PC board temperatures. +As such, it is an important value in determining the health and performance +of the instrument. + +If the 1DPAMZT transducer fails, we could switch to using the 1DPAMYT +transducer values to substitute for the 1DPAMZT values. A new 1DPAMYT +thermal model was created and fitted. Limits have to be adjusted so that the 1DPAMYT +limits reflect the same FEP and BEP board temperatures as the 1DPAMZT limits. + + + + +Files Changed: +============== + +The changed and added files can be seen in this PR: + +https://github.com/acisops/acis_thermal_check/pull/72 + + + +Testing: +======== + +The change was tested, using the following loads: + +JAN2224 +FEB1124 +FEB1924 +FEB2624 +MAR0424 +MAR1124 +MAR1824 + +The predicted vs actual temperatures were compared and found to agree within acceptable limits. + +The ACIS load review software will be modified to execute this new model +in order to continue the test of the model and the fit. But it will not be used +to plan missions. + + +Interface impacts +================= + +None + + +Review +====== + +ACIS Ops + + +Deployment Plan +=============== + +Deploy as soon as FSDS approval given. From 0b2948374cb9b78ede6da8639fc60851a7bfd347 Mon Sep 17 00:00:00 2001 From: ggermain Date: Wed, 20 Mar 2024 10:01:45 -0400 Subject: [PATCH 04/11] Minor Release Notes update --- acis_thermal_check/ReleaseNotes_1DPAMYT_V1.0.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acis_thermal_check/ReleaseNotes_1DPAMYT_V1.0.txt b/acis_thermal_check/ReleaseNotes_1DPAMYT_V1.0.txt index ab7d86d..bbddac3 100644 --- a/acis_thermal_check/ReleaseNotes_1DPAMYT_V1.0.txt +++ b/acis_thermal_check/ReleaseNotes_1DPAMYT_V1.0.txt @@ -3,7 +3,7 @@ Change Description ================== - The 1PIN1AT and 1CRBT transducer failures had minimal mission impact. +The 1PIN1AT and 1CRBT transducer failures had minimal mission impact. 1DPAMZT is used as a proxy for the internal BEP and FEP PC board temperatures. As such, it is an important value in determining the health and performance From 50dd4d1edab01e274753af7426adea7c19b377b1 Mon Sep 17 00:00:00 2001 From: ggermain Date: Fri, 5 Apr 2024 12:54:03 -0400 Subject: [PATCH 05/11] Lower limit handler code removed --- acis_thermal_check/apps/dpamyt_check.py | 79 +------------------------ 1 file changed, 3 insertions(+), 76 deletions(-) diff --git a/acis_thermal_check/apps/dpamyt_check.py b/acis_thermal_check/apps/dpamyt_check.py index 0b5b241..cfecad9 100755 --- a/acis_thermal_check/apps/dpamyt_check.py +++ b/acis_thermal_check/apps/dpamyt_check.py @@ -26,88 +26,15 @@ def __init__(self): "PITCH": [(1, 3.0), (99, 3.0)], "TSCPOS": [(1, 2.5), (99, 2.5)], } # Specify the temperature where only those temps greater - # than this temperature will be displaye donthe histogram. + # than this temperature will be displayed on the histogram. hist_limit = [20.0] - - # Specify the lower planning limit for the zero FEP case. - limits_map = {"planning.caution.low": "zero_feps"} - + # Call the superclass' __init__ with the arguments super().__init__( "1dpamyt", "dpamyt", valid_limits, - hist_limit, - limits_map=limits_map, - ) - - def custom_prediction_viols(self, times, temp, viols, load_start): - """ - Custom handling of limit violations. This is for checking the - +10 degC violation if all FEPs are off. - - Parameters - ---------- - times : NumPy array - The times for the predicted temperatures - temp : NumPy array - The predicted temperatures - viols : dict - Dictionary of violations information to add to - load_start : float - The start time of the load, used so that we only report - violations for times later than this time for the model - run. - """ - # Only check this violation when all FEPs are off - mask = self.predict_model.comp["fep_count"].dvals == 0 - zf_viols = self._make_prediction_viols( - times, - temp, - load_start, - self.limits["zero_feps"].value, - "zero-feps", - "min", - mask=mask, - ) - viols["zero_feps"] = { - "name": f"Zero FEPs ({self.limits['zero_feps'].value} C)", - "type": "Min", - "values": zf_viols, - } - - def custom_prediction_plots(self, plots): - """ - Customization of prediction plots. - - Parameters - ---------- - plots : dict of dicts - Contains the hooks to the plot figures, axes, and filenames - and can be used to customize plots before they are written, - e.g. add limit lines, etc. - """ - plots[self.name].add_limit_line(self.limits["zero_feps"], "Zero FEPs", ls="--") - - def custom_validation_plots(self, plots): - """ - Customization of validation plots. - - Parameters - ---------- - plots : dict of dicts - Contains the hooks to the plot figures, axes, and filenames - and can be used to customize plots before they are written, - e.g. add limit lines, etc. - """ - plots["1dpamyt"]["lines"]["ax"].axhline( - self.limits["zero_feps"].value, - linestyle="--", - zorder=-8, - color=self.limits["zero_feps"].color, - linewidth=2, - label="Zero FEPs", - ) + hist_limit) def _calc_model_supp(self, model, state_times, states, ephem, state0): """ From f314d0f4134f32622bdb49bb17c13cbff89300a2 Mon Sep 17 00:00:00 2001 From: ggermain Date: Fri, 5 Apr 2024 12:56:32 -0400 Subject: [PATCH 06/11] Added APR0824 to the test suite --- acis_thermal_check/ReleaseNotes_1DPAMYT_V1.0.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/acis_thermal_check/ReleaseNotes_1DPAMYT_V1.0.txt b/acis_thermal_check/ReleaseNotes_1DPAMYT_V1.0.txt index bbddac3..a7f9578 100644 --- a/acis_thermal_check/ReleaseNotes_1DPAMYT_V1.0.txt +++ b/acis_thermal_check/ReleaseNotes_1DPAMYT_V1.0.txt @@ -38,6 +38,7 @@ FEB2624 MAR0424 MAR1124 MAR1824 +APR0824 The predicted vs actual temperatures were compared and found to agree within acceptable limits. From c1fecf8d3d7d262bb4b38137fd5f74c3d89396be Mon Sep 17 00:00:00 2001 From: John ZuHone Date: Wed, 17 Apr 2024 11:43:39 -0400 Subject: [PATCH 07/11] pre-commit fixes --- acis_thermal_check/apps/dpamyt_check.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/acis_thermal_check/apps/dpamyt_check.py b/acis_thermal_check/apps/dpamyt_check.py index cfecad9..6980078 100755 --- a/acis_thermal_check/apps/dpamyt_check.py +++ b/acis_thermal_check/apps/dpamyt_check.py @@ -11,6 +11,7 @@ weeks. """ import sys + import matplotlib from acis_thermal_check import ACISThermalCheck, get_options @@ -22,19 +23,17 @@ class DPAMYTCheck(ACISThermalCheck): def __init__(self): - valid_limits = { "1DPAMYT": [(1, 2.0), (50, 1.0), (99, 2.0)], - "PITCH": [(1, 3.0), (99, 3.0)], - "TSCPOS": [(1, 2.5), (99, 2.5)], } + valid_limits = { + "1DPAMYT": [(1, 2.0), (50, 1.0), (99, 2.0)], + "PITCH": [(1, 3.0), (99, 3.0)], + "TSCPOS": [(1, 2.5), (99, 2.5)], + } # Specify the temperature where only those temps greater # than this temperature will be displayed on the histogram. hist_limit = [20.0] - + # Call the superclass' __init__ with the arguments - super().__init__( - "1dpamyt", - "dpamyt", - valid_limits, - hist_limit) + super().__init__("1dpamyt", "dpamyt", valid_limits, hist_limit) def _calc_model_supp(self, model, state_times, states, ephem, state0): """ From d6b790ae31d7d8ae64227dc63a497dc1d870af34 Mon Sep 17 00:00:00 2001 From: ggermain Date: Wed, 17 Apr 2024 12:16:06 -0400 Subject: [PATCH 08/11] pre-commit-config fix, Chandra Limits update --- .pre-commit-config.yaml | 4 ++-- acis_thermal_check/apps/dpamyt_check.py | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 665e324..f65d051 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,11 +7,11 @@ repos: rev: 23.7.0 hooks: - id: black - language_version: python3.10 + language_version: python3.11 - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.0.282 hooks: - id: ruff args: ["--fix", "--format=github"] - language_version: python3.10 + language_version: python3.11 diff --git a/acis_thermal_check/apps/dpamyt_check.py b/acis_thermal_check/apps/dpamyt_check.py index 6980078..4e4efd7 100755 --- a/acis_thermal_check/apps/dpamyt_check.py +++ b/acis_thermal_check/apps/dpamyt_check.py @@ -23,11 +23,8 @@ class DPAMYTCheck(ACISThermalCheck): def __init__(self): - valid_limits = { - "1DPAMYT": [(1, 2.0), (50, 1.0), (99, 2.0)], - "PITCH": [(1, 3.0), (99, 3.0)], - "TSCPOS": [(1, 2.5), (99, 2.5)], - } + valid_limits = [(1, 2.0), (50, 1.0), (99, 2.0)] + # Specify the temperature where only those temps greater # than this temperature will be displayed on the histogram. hist_limit = [20.0] From 10bab71ee453f6d0e50758bd942e22523d4fc373 Mon Sep 17 00:00:00 2001 From: ggermain Date: Fri, 19 Apr 2024 16:13:52 -0400 Subject: [PATCH 09/11] Added lines to include Chandra_Limits capability --- acis_thermal_check/apps/dpamyt_check.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/acis_thermal_check/apps/dpamyt_check.py b/acis_thermal_check/apps/dpamyt_check.py index 4e4efd7..b289698 100755 --- a/acis_thermal_check/apps/dpamyt_check.py +++ b/acis_thermal_check/apps/dpamyt_check.py @@ -13,6 +13,7 @@ import sys import matplotlib +from chandra_limits import DPAMYTLimit from acis_thermal_check import ACISThermalCheck, get_options @@ -22,6 +23,8 @@ class DPAMYTCheck(ACISThermalCheck): + _limit_class = DPAMYTLimit + def __init__(self): valid_limits = [(1, 2.0), (50, 1.0), (99, 2.0)] From bb809fe6cf7c2a23ee0453a13deb88be453e35b0 Mon Sep 17 00:00:00 2001 From: ggermain Date: Mon, 22 Apr 2024 12:58:13 -0400 Subject: [PATCH 10/11] Additional test loads, chandra limtis and chandra model PR URLS added --- acis_thermal_check/ReleaseNotes_1DPAMYT_V1.0.txt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/acis_thermal_check/ReleaseNotes_1DPAMYT_V1.0.txt b/acis_thermal_check/ReleaseNotes_1DPAMYT_V1.0.txt index a7f9578..d718b53 100644 --- a/acis_thermal_check/ReleaseNotes_1DPAMYT_V1.0.txt +++ b/acis_thermal_check/ReleaseNotes_1DPAMYT_V1.0.txt @@ -14,7 +14,7 @@ transducer values to substitute for the 1DPAMZT values. A new 1DPAMYT thermal model was created and fitted. Limits have to be adjusted so that the 1DPAMYT limits reflect the same FEP and BEP board temperatures as the 1DPAMZT limits. - +The new model uses the new Chandra Limits. Files Changed: @@ -23,24 +23,32 @@ Files Changed: The changed and added files can be seen in this PR: https://github.com/acisops/acis_thermal_check/pull/72 +https://github.com/sot/chandra_models/pull/124 +https://github.com/sot/chandra_limits/pull/14 Testing: ======== -The change was tested, using the following loads: +The model and the updated Chandra Limits code was tested, using the +following loads: JAN2224 +JAN2324 FEB1124 FEB1924 FEB2624 MAR0424 MAR1124 MAR1824 +APR0124 APR0824 +APR1524 +APR2024 -The predicted vs actual temperatures were compared and found to agree within acceptable limits. +The predicted vs actual temperatures were compared and found to agree +within acceptable limits. The ACIS load review software will be modified to execute this new model in order to continue the test of the model and the fit. But it will not be used From 45c286acde8b9546fd0e66701999fd071e7872e9 Mon Sep 17 00:00:00 2001 From: ggermain Date: Wed, 24 Apr 2024 17:13:47 -0400 Subject: [PATCH 11/11] Small change to the wording in the Release Notes --- acis_thermal_check/ReleaseNotes_1DPAMYT_V1.0.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acis_thermal_check/ReleaseNotes_1DPAMYT_V1.0.txt b/acis_thermal_check/ReleaseNotes_1DPAMYT_V1.0.txt index d718b53..885006e 100644 --- a/acis_thermal_check/ReleaseNotes_1DPAMYT_V1.0.txt +++ b/acis_thermal_check/ReleaseNotes_1DPAMYT_V1.0.txt @@ -11,7 +11,7 @@ of the instrument. If the 1DPAMZT transducer fails, we could switch to using the 1DPAMYT transducer values to substitute for the 1DPAMZT values. A new 1DPAMYT -thermal model was created and fitted. Limits have to be adjusted so that the 1DPAMYT +thermal model was created and fitted. Limits were selected so that the 1DPAMYT limits reflect the same FEP and BEP board temperatures as the 1DPAMZT limits. The new model uses the new Chandra Limits.