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

Enhance StepFunctionPower component to allow multiple instances #90

Closed taldcroft closed 4 years ago

taldcroft commented 4 years ago

Description

This allows including multiple instances of the StepFunctionPower component on the same node by adding an id attribute. This identifier is put into the component name (via the str function). The default id is an empty string for back-compatibility.

Reminder: this needs to be ported to the shiny branch (by cherry-pick or rebase).

To make the model more self-documenting, I would recommend setting the id to be the date of the step, for instance _2020213 for the July 31 swap.

Approval

Reviewed and approved by TWG on July 21, 2020.

Testing

Functional

Made a new ACA model aca_spec_3_step which has a step function up at 2020:100 and same step function back down at 2020:120. This shows that the additional step functions are having the intended effect:

image

The new model spec as Python looks like:

model.add(xija.StepFunctionPower,
          node='aca0',
          time='2020:100:00:00:00',
          P=0.1,
          id='_2'
         )
model.add(xija.StepFunctionPower,
          node='aca0',
          time='2020:120:00:00:00',
          P=-0.1,
          id='_3'
         )

and as JSON:

        {
            "class_name": "StepFunctionPower",
            "init_args": [],
            "init_kwargs": {
                "P": 0.1,
                "id": "_2",
                "node": "aca0",
                "time": "2020:100:00:00:00"
            },
            "name": "step_power_2__aca0"
        },
        {
            "class_name": "StepFunctionPower",
            "init_args": [],
            "init_kwargs": {
                "P": -0.1,
                "id": "_3",
                "node": "aca0",
                "time": "2020:120:00:00:00"
            },
            "name": "step_power_3__aca0"
        }
jeanconn commented 4 years ago

This looks good to me. Could your functional test work as a unit test @taldcroft ?

matthewdahmer commented 4 years ago

Looks good to me as well!