parse_time_specification#

gala.integrate.parse_time_specification(units, dt=None, n_steps=None, t1=None, t2=None, t=None)[source]#

Parse different ways of specifying integration times into an array of times.

This function accepts several different combinations of parameters to specify the times at which to evaluate the integrated orbit. The supported combinations allow for flexible time specification in orbit integration.

Parameters:
unitsUnitSystem

The unit system to use for dimensionful time quantities.

dtfloat or array_like, optional

Timestep(s) for integration. Can be a scalar for fixed timesteps or an array of timesteps for variable spacing.

n_stepsint, optional

Number of integration steps to take.

t1float, optional

Initial time for the integration.

t2float, optional

Final time for the integration.

tarray_like, optional

Explicit array of times at which to evaluate the orbit.

Returns:
timesndarray

Array of times at which the orbit will be evaluated.

Raises:
ValueError

If the time specification is invalid or incomplete, or if the signs of dt and (t2-t1) are inconsistent.

Notes

The following parameter combinations are supported:

  • dt, n_steps[, t1] : Fixed timestep and number of steps

  • dt, t1, t2 : Fixed timestep with start and end times

  • dt, t1 : Array of timesteps with initial time (dt must be array)

  • n_steps, t1, t2 : Number of steps between start and end times

  • t : Explicit array of times

Examples

Fixed timestep with number of steps:

>>> times = parse_time_specification(units, dt=0.1, n_steps=100)

Fixed timestep with start and end times:

>>> times = parse_time_specification(units, dt=0.1, t1=0, t2=10)

Explicit array of times:

>>> import numpy as np
>>> t_array = np.linspace(0, 10, 101)
>>> times = parse_time_specification(units, t=t_array)