Title: Time response data class by murrayrm · Pull Request #649 · python-control/python-control · GitHub
Open Graph Title: Time response data class by murrayrm · Pull Request #649 · python-control/python-control
X Title: Time response data class by murrayrm · Pull Request #649 · python-control/python-control
Description: 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 of TimeResponseData containing the results of simulations. The class implements an __iter__ method that allows backward compatibility with current call signatures. Old approach (still works): t, y = ct.step_response(siso_sys) plt.plot(t, y) t, y = ct.step_response(mimo_sys) plt.plot(t, y[0, 1], label="input 1 to output 0") plt.plot(t, y[1, 1], label="input 1 to output 1") New approach: response = ct.step_response(siso_sys) plt.plot(response.time, response.outputs) response = ct.step_response(mimo_sys) plt.plot(response.time, response.outputs[0, 1], label="input 1 to output 0") plt.plot(response.time, response.outputs[1, 1], label="input 1 to output 1") The attributes time, outputs, states and inputs 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 attributes t, y, x, and u, which are always in "MIMO" format (indexed by output, input (trace), and time: response = ct.step_response(siso_sys) plt.plot(response.t, response.y[0, 0]) Other notes: I adopted the terminology of a "trace" to handle the time response data returned by step_response and impulse_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 and inputs was chosen to be consistent with the OptimalControlResult 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 to FrequencyResponseData) 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: Plot methods that plot input/output simulations in a uniform way Methods to convert data into DataFrame format for use of pandas plotting capabilities I'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).
Open Graph Description: 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 no...
X Description: 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 no...
Opengraph URL: https://github.com/python-control/python-control/pull/649
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:1c8cb9ea-3c1e-41bb-e741-d59773050eff |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | C298:CFFCE:14C20A2:1DA2F31:697A3BEF |
| html-safe-nonce | 899214f43c411fd5aa6dd520f5cb37fa25c4bbb912afaaef48452518ded9e12e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMjk4OkNGRkNFOjE0QzIwQTI6MURBMkYzMTo2OTdBM0JFRiIsInZpc2l0b3JfaWQiOiI3NzU3MDMyMDIxNTEwNzMyNzgzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 9c389c8bf043efdcea0e0954fc06c2093934a477b7106a01cdd16664b7813919 |
| hovercard-subject-tag | pull_request:720197942 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python-control/python-control/pull/649/checks |
| twitter:image | https://avatars.githubusercontent.com/u/293362?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/293362?s=400&v=4 |
| og:image:alt | 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 no... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | af6de804ceb83ad30bb9b348cdeaccaa30cdcb566762d5e74e21e2bad88885d0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python-control/python-control git https://github.com/python-control/python-control.git |
| octolytics-dimension-user_id | 2285872 |
| octolytics-dimension-user_login | python-control |
| octolytics-dimension-repository_id | 22791752 |
| octolytics-dimension-repository_nwo | python-control/python-control |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 22791752 |
| octolytics-dimension-repository_network_root_nwo | python-control/python-control |
| turbo-body-classes | logged-out env-production page-responsive full-width full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2d980605f0959039ddebcbcf522b072508302977 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width