redback.utils.get_optimal_time_array

redback.utils.get_optimal_time_array(t_min, t_max, resolution, user_times=None, time_units='seconds')[source]

Creates an adaptive time array optimized for the user’s requested evaluation times. This is a general utility for creating time grids that balance resolution across a wide dynamic range while concentrating points where the user will evaluate.

Results are cached for performance during inference (when models are called repeatedly with the same time array).

If user_times provided: Creates a hybrid array with extra resolution around user times If not provided: Uses multi-segment geomspace covering the full range

Parameters:
  • t_min – Minimum time in specified units (model range)

  • t_max – Maximum time in specified units (model range)

  • resolution – Total number of points desired

  • user_times – Array of times (in same units) where user wants to evaluate (optional)

  • time_units – Units of time (‘seconds’, ‘days’, or ‘generic’). Used only for informational purposes.

Returns:

Time array optimized for interpolation

Examples

>>> # For kilonova models (seconds)
>>> time_array = get_optimal_time_array(1e-2, 7e6, 500, user_times=user_eval_times)
>>>
>>> # For supernova models (days)
>>> time_array = get_optimal_time_array(0.1, 3000, 300, time_units='days')
>>>
>>> # Without user times, creates balanced multi-segment array
>>> time_array = get_optimal_time_array(1e-4, 1e8, 500)