-
Notifications
You must be signed in to change notification settings - Fork 438
Time response data class #649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Time response data class #649
Conversation
If you call me a skeptic about object-oriented software I'll answer "guilty as charged" but this seems pretty cool and would work well with #645. I also like the potential utility for future system identification routines, and for future plotting functionality. Presumably when the latter comes we can do things like add label text, which can come in handy. It would be nice, in the interest of minimizing friction for quick analyses of SISO systems, to have the shorter I'm not sure I understand the concept of a trace. is that different than the 3D array that encodes [output, input, time]? |
The latest push fixes an inconsistency in the way that squeeze processing was handled for states versus input/outputs. In the original code, squeeze processing was never applied to the state vector. The consequence was that if you used To avoid breaking code, I set things up so that if you access the state vector through the old interface (by assigning one of the time response systems to a tuple with As in the original PR, all legacy code continues to run unchanged and there are new unit tests to validate the updated behavior for the new interface. Alternatively, I would be OK making everything consistent across output, state, and input squeeze processing, but then we would break existing code. So my thought was to leave that in place and eventually deprecate it (perhaps after we have implemented all of the suggestions in #645). |
It's the same. I decided to use the term "trace" because in the case of step/impulse response it happens to be the case that each trace (simulation run) corresponds to choosing one of the inputs. But more generally, you could imagine having multiple input/output traces (eg, for the aforementioned system ID) and a given trace might just be come combination of inputs. Note also that |
I've added the ability to store labels in the latest commit and set things up so that the signals names for I/O systems, if present, are copied over as the default labels for |
@billtubbs Would this PR help with what you were working on for #645 ? ie., should we merge this PR? |
I've been using the branch with this PR as my default branch for a while and everything seems OK. Ready to be merged, I think. @billtubbs You mentioned in a separate note that you had made progress on #645. Does this conflict with that? If not, we can probably go ahead and merge. |
I don't think so. I haven't looked at this in detail but I was only planning to fix the specific axes and figure problems with some of the plot functions |
This PR adds a
TimeResponseData
class, following the discussion in #645, which provides a more object-oriented approach to the representation of time response data. All time responses functions now return an instance ofTimeResponseData
containing the results of simulations. The class implements an__iter__
method that allows backward compatibility with current call signatures.Old approach (still works):
New approach:
The attributes
time
,outputs
,states
andinputs
are actually class properties that carry out "squeeze processing" allowing use of 1D arrays for SISO systems. Time response data can also be accessed via the attributest
,y
,x
, andu
, which are always in "MIMO" format (indexed by output, input (trace), and time:Other notes:
I adopted the terminology of a "trace" to handle the time response data returned by
step_response
andimpulse_response
, where a MIMO system generates a full matrix of input/output responses. The output, state, and input responses for those functions are represented by a 3D array indexed by output/state/input, trace, and time.The terminology for
time
,outputs
,states
andinputs
was chosen to be consistent with theOptimalControlResult
class. This is implemented via a set of properties that perform the squeeze (and transpose) processing to provide compatibility with our existing functionality.The
InputOutputData
class is currently only used to store the output of simulations, but it is set up to serve as a pure data representation class (similar toFrequencyResponseData
) and could later be useful for things like input to system identification routines.No changes to existing unit tests were needed => should be fully backwards compatible.
At a future date, we may want to consider adding some additional functionality:
DataFrame
format for use of pandas plotting capabilitiesI'm still not completely sure if this is a useful PR, but I was motivated by the way a similar approach taken in JuliaControl and thought I would give it a try. Suggestions and comments welcome (will leave in draft form for a bit to allow for discussion).