sot / xija

Thermal modeling framework for Chandra X-ray Observatory
https://sot.github.io/xija
BSD 3-Clause "New" or "Revised" License
9 stars 5 forks source link

Add MSIDStatePower component #103

Closed matthewdahmer closed 4 years ago

matthewdahmer commented 4 years ago

This update adds the ability to apply a heat power shift when a state msid matches a specified value.

Description

In fitting a new fuel tank model, I found that there is a dependency on the SSR-B state, which can’t be accounted for in Xija without a new heat component. Since I anticipate using this type of state-based heat input for other models in other locations, I built a new flexible Xija heat component that can be defined to use a user-selected msid and state pair.

Here is an example that covers the key information one needs to use this update in the JSON model definition:

In the “comps” section:

      {
            "class_name": "MsidStatePower",
            "init_args": [],
            "init_kwargs": {
                "P": 0.5,
                "node": "pf0tank2t",
                "state_msid": "COSSRBX",
                "state_val": "ON "
            },
            "name": "cossrbx_on"
        }

In the “pars” section:

        {
            "comp_name": "cossrbx_on__pf0tank2t",
            "fmt": "{:.4g}",
            "frozen": false,
            "full_name": "cossrbx_on__pf0tank2t__P",
            "max": 2.0,
            "min": -2.0,
            "name": "P",
            "val": 0.004859426906919793
        }

Here is a link to a model that uses this new component: https://github.com/sot/chandra_models/blob/abaa609805431d72da9d4bc949ed5a5c7feb75d4/chandra_models/xija/pftank2t/pftank2t_spec.json

Doc string for this method copied here for convenience:

    A class that applies a constant heat power shift only when the state of an
     MSID, ``state_msid``, matches a specified value, ``state_val``.  The shift
     is ``P`` when the ``state_val`` for ``state_msid`` is matched, otherwise it
     is 0.0.

     :param model: parent model object
     :param node: node name or object for which to apply shift
     :param state_msid: state MSID name
     :param state_val: value of ``state_msid`` to be matched
     :param P: size of shift in heat power (default=0.0)

     The name of this component is constructed by concatenating the state msid name
     and the state msid value with an underscore. For example, if the ``MsidStatePower``
     component defines a power value for when the COSSRBX values match the string,
     "ON ", the name of this component is ``cossrbx_on``.

     The ``dvals`` data stored for this component are a boolean type. To initialize
     this component, one would use the following syntax:
         model.comp['cossrbx_on'].set_data(True)

Testing

matthewdahmer commented 4 years ago

@taldcroft I updated the plot_data__time() function in the MSIDStatePower component to show the boolean dvals data instead of the power values. I re-ran the unit tests on MacOS and re-ran a functional test using xija_gui_fit. Thank you for reviewing this PR!

taldcroft commented 4 years ago

Please see the note here: https://github.com/sot/skare3/wiki/Shiny-Ska3-testing#xija regarding promotion of this new functionality.