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 a Delay model component #106

Closed taldcroft closed 3 years ago

taldcroft commented 3 years ago

Description

Add a new model component class Delay to delay the compute model values from node by delay ksec.

For a positive delay, the computed model value (node.mval) will be constant at the initial value for the first delay ksec. Conversely for a negative delay the values at the end will be constant for delay ksec.

Testing

Functional testing

Made a new thermal model for 4HFSPAT using the Delay component (now included in the examples/delay directory).

taldcroft commented 3 years ago

@jzuhone - the instability was just related to this new Delay component if the code was

comp.node.mvals[:] = np.interp(x=self.times - comp.delay * 1000,
                                                xp=self.times, fp=comp.node.mvals)

instead of:

comp.node.mvals[1:] = np.interp(x=self.times - comp.delay * 1000,
                                                xp=self.times, fp=comp.node.mvals)[1:]

This is what I showed at the TWG when I moved the delay slider left and right and the beginning of the model calculation got wacky. This does not happen for the current code using [1:] to avoid copying the first element of the array.