-
Notifications
You must be signed in to change notification settings - Fork 67
Updates to phase.interpolate, renamed to phase.interp. #592
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
Conversation
…bset upon which the interpolation should be performed.
…eft in the upgrade guide and the test of the JOSS code.
p.set_val('traj.phase0.states:x', phase.interp('x', ys=[0, 10]), units='m') | ||
p.set_val('traj.phase0.states:y', phase.interp('y', ys=[10, 5]), units='m') | ||
p.set_val('traj.phase0.states:v', phase.interp('v', ys=[0, 9.9]), units='m/s') | ||
p.set_val('traj.phase0.controls:theta', phase.interp('theta', ys=[5, 100]), units='deg') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was the change in values intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not intentional but in the end only the state values matter here, since we're using fix_initial/fix_final. The control values will all change and the initial guess isn't that consequential.
p.set_val('traj.burn2.states:r', value=burn2.interp('r', [1, 3])) | ||
p.set_val('traj.burn2.states:theta', value=burn2.interp('theta', [0, 4.0])) | ||
p.set_val('traj.burn2.states:vr', value=burn2.interp('vr', [0, 0])) | ||
p.set_val('traj.burn2.states:vt', value=burn2.interp('vt', [1, np.sqrt(1 / 3)])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some value changes here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
p['traj0.phase0.states:v'] = phase.interpolate(ys=[0, 9.9], nodes='state_input') | ||
p.set_val('traj0.phase0.states:x', phase.interp('x', [0, 10]), units='m') | ||
p.set_val('traj0.phase0.states:y', phase.interp('y', [10, 5]), units='m') | ||
p.set_val('traj0.phase0.states:v', phase.interp('v', [0, 5]), units='m/s') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes here too. Wonder why you didn't need to change any asserts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, final velocity is unconstrained.
dymos/phase/phase.py
Outdated
@@ -1669,6 +1675,93 @@ def interpolate(self, xs=None, ys=None, nodes='all', kind='linear', axis=0): | |||
res = res.T | |||
return res | |||
|
|||
def interp(self, name=None, ys=None, xs=None, nodes=None, kind='linear', axis=0): | |||
""" | |||
Return an array of values on interpolated to the given node subset of the phase. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wording is funny here
Summary
Adds
phase.interp
to the API and deprecatesphase.interpolate
.phase.interp
is similar with a few exceptions:name
is first, followed byys
, this makes the most common use case of linear interpolation much more terse:phase.interpolate('x', [0, 10])
Related Issues
Status
Backwards incompatibilities
phase.interpolate is deprecated
New Dependencies
None