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:
- units
UnitSystem The unit system to use for dimensionful time quantities.
- dt
floator array_like, optional Timestep(s) for integration. Can be a scalar for fixed timesteps or an array of timesteps for variable spacing.
- n_steps
int, optional Number of integration steps to take.
- t1
float, optional Initial time for the integration.
- t2
float, optional Final time for the integration.
- tarray_like, optional
Explicit array of times at which to evaluate the orbit.
- units
- Returns:
- times
ndarray Array of times at which the orbit will be evaluated.
- times
- Raises:
ValueErrorIf the time specification is invalid or incomplete, or if the signs of
dtand(t2-t1)are inconsistent.
Notes
The following parameter combinations are supported:
dt, n_steps[, t1]: Fixed timestep and number of stepsdt, t1, t2: Fixed timestep with start and end timesdt, t1: Array of timesteps with initial time (dt must be array)n_steps, t1, t2: Number of steps between start and end timest: 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)