Skip to content
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

trajectory results report now automatically generated by run_problem #918

Merged
merged 37 commits into from
Apr 17, 2023

Conversation

robfalck
Copy link
Contributor

@robfalck robfalck commented Mar 24, 2023

Summary

This is an update to the plot generation in dymos.

Now as single html file will be created for each trajectory.
It will contain:

  • The parameters for each phase, including their values and units
  • Plots of the timeseries outputs across all phases

These plots rely on bokeh and a dummy html file will be generated if it cannot be imported.

New options have been added:

dymos.options['use_timeseries_prefix'] = True will cause timeseries outputs of states, times, controls and parameters to be prefixed by the variable type (e.g. timeseries.states:x). This is the current default behavior of Dymos.

dymos.options['use_timeseries_prefix'] = False will remove the prefix (e.g. timeseries.x).

In a future version of dymos we will set the default value to False, but leave this option in place for users who want to recover the existing behavior.

Phases now have timeseries_options that control what is added to the timeseries by default. The currently available options are:

phase.timeseries_options['include_state_rates'] currently defaults to True and is necessary for grid refinement.

phase.timeseries_options['include_control_rates'] defaults to False (this is a change to current behavior). Timeseries control rates can be provided by requesting them explicitly or setting this option to True.

phase.timeseries_options['include_t_phase'] defaults to False (this is a change to current behavior). time_phase can be added to the timeseries by requesting it explicitly or by setting this option to True.

Related Issues

Backwards incompatibilities

The dymos options module is now _options. This was causing a namespace collision.
Users can now access the global dymos options as dm.options, for instance:

import dymos.options

dymos.options['use_timeseries_prefix'] = False

New Dependencies

bokeh is still optional but is required for the trajectory report to be generated.

robfalck added 17 commits March 6, 2023 17:09
…shows the timeseries plots and parameter values for that phase.
Added timeseries_options to Phase to allow the option of including control rates and state rates in the timeseries outputs (non-inclusion is the default).
Added use_prefix as an option in timeseries_options to remove the prefixed variable class from the timeseries outputs (e.g. 'states:x' is now just 'x', 'controls:u' is now just 'u').
…'use_timeseries_prefix']

Removed 'include_states' and 'include_controls' timeseries options for now.
@robfalck robfalck marked this pull request as draft March 25, 2023 12:33
Fixed a bug in ExplicitShooting when connecting the controls to the continuity comp.
Removed some commented lines from introspection.py.
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@robfalck robfalck requested a review from johnjasa April 1, 2023 01:45
@robfalck robfalck marked this pull request as ready for review April 7, 2023 16:39
Copy link
Member

@johnjasa johnjasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I really like this PR. Besides the trajectory results report, the "small" options changes are very helpful. I can't wait to not have timeseries in my models (no offense).

I've looked at the bokeh-produced html output for a few cases and I really dig it. I have small nitpicks/questions about the presentation:

  • is it possible increase the dpi of the text rendering for the axis labels and legends? I had to ctrl+ zoom in to see the names better on my screen, but they were pretty pixelated.
  • did you consider having 1- or 3-wide plots instead of 2-wide? I'm thinking about best monitor usage and I could where having different options might be beneficial, but I don't know how tough that would be to handle
  • some long names for plotted quantities sometimes fall off the edge of the y-axis label, like for control_rates:power_code_rate2 (unitless). If you say "hey that's just too long" that's fine, but maybe there's a quick way to scale the plot y-label or allow for different sized fonts? Not a huge deal

Overall great stuff! I really love when the majority of lines changed are for tests. That's a great sign. Thanks for continuing to improve Dymos, Rob!

desc='The plot library used to generate output plots for Dymos.')

options.declare('notebook_mode', default=False, types=bool,
desc='If True, provide notebook-enhanced plots and outputs.')

options.declare('use_timeseries_prefix', default=True, types=bool,
desc='If True, prefix timeseries outputs with the variable type for states, times, controls,'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to acknowledge here that the default behavior will change later on?

Copy link
Contributor Author

@robfalck robfalck Apr 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the 1st and 3rd bullets, I will look into the DPI. It's likely a font size issue but this will also impact your 3rd bullet point. That issue can be alleviated by turning off the prefixes.

Regarding the number of columns in the plots, I will see if that can be done via the UI so the user can change it on the fly. I will do that as a subsequent PR.

I'm planning on a relatively short time frame for the release of the next version, so I won't be making a note about the default behavior changing.


class PhaseTimeseriesOptionsDictionary(om.OptionsDictionary):
"""
An OptionsDictionary for phase options related to timeseries..
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get that second period out of here!

@@ -544,26 +545,31 @@ def _update_linkage_options_configure(self, linkage_options):
units[i] = phases[i].time_options['units']
shapes[i] = (1,)
elif classes[i] == 'state':
sources[i] = f'timeseries.states:{vars[i]}'
prefix = 'states:' if dymos_options['use_timeseries_prefix'] else ''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice slick way of handling this prefix name logic throughout

@johnjasa
Copy link
Member

Oh, and the two changes to default behavior you mention in the PR text. Is that a big deal? Will users have to change behavior or see different behavior than expected and be confused? I'm not sure how common those would come up, even.

@robfalck
Copy link
Contributor Author

Oh, and the two changes to default behavior you mention in the PR text. Is that a big deal? Will users have to change behavior or see different behavior than expected and be confused? I'm not sure how common those would come up, even.

The only users who may notice this are those who have built up some post processing machinery that relies on the current timeseries name format. I'll include big bold warnings in the next version about this change.

@robfalck robfalck merged commit a4255c2 into OpenMDAO:master Apr 17, 2023
@robfalck robfalck deleted the timeseries_reports_update branch August 14, 2024 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove parameters from timeseries by default.
2 participants