docs: def index_registry(args, reg, ts=None, idx=None):
      """
      Index into a :class:`~simkit.core.Registry` to return arguments
      from :class:`~simkit.core.data_sources.DataRegistry` and
      :class:`~simkit.core.outputs.OutputRegistry` based on the
      calculation parameter file.
  
      :param args: Arguments field from the calculation parameter file.
      :param reg: Registry in which to index to get the arguments.
      :type reg: :class:`~simkit.core.data_sources.DataRegistry`,
          :class:`~simkit.core.outputs.OutputRegistry`
      :param ts: Time step [units of time].
      :param idx: [None] Index of current time step for dynamic calculations.
  
      Required arguments for static and dynamic calculations are specified in the
      calculation parameter file by the "args" key. Arguments can be from
      either the data registry or the outputs registry, which is denoted by the
      "data" and "outputs" keys. Each argument is a dictionary whose key is the
      name of the argument in the formula specified and whose value can be one of
      the following:
  
      * The name of the argument in the registry ::
  
          {"args": {"outputs": {"T_bypass": "T_bypass_diode"}}}
  
        maps the formula argument "T_bypass" to the outputs registry item
        "T_bypass_diode".
  
      * A list with the name of the argument in the registry as the first element
        and a negative integer denoting the index relative to the current
        timestep as the second element ::
  
          {"args": {"data": {"T_cell": ["Tcell", -1]}}}
  
        indexes the previous timestep of "Tcell" from the data registry.
  
      * A list with the name of the argument in the registry as the first element
        and a list of positive integers denoting the index into the item from the
        registry as the second element ::
  
          {"args": {"data": {"cov": ["bypass_diode_covariance", [2]]}}}
  
        indexes the third element of "bypass_diode_covariance".
  
      * A list with the name of the argument in the registry as the first
        element, a negative real number denoting the time relative to the current
        timestep as the second element, and the units of the time as the third ::
  
          {"args": {"data": {"T_cell": ["Tcell", -1, 'day']}}}
  
        indexes the entire previous day of "Tcell".
      """
      # TODO: move this to new Registry method or __getitem__
      # TODO: replace idx with datetime object and use timeseries to interpolate
      #       into data, not necessary for outputs since that will conform to idx
      rargs = dict.fromkeys(args)  # make dictionary from arguments
      # iterate over arguments
      for k, v in args.iteritems():
          # var           ------------------ states ------------------
          # idx           ===== not None =====    ======= None =======
          # isconstant    True    False   None    True    False   None
          # is_dynamic    no      yes     yes     no      no      no
          is_dynamic = idx and not reg.isconstant.get(v)
          # switch based on string type instead of sequence
          if isinstance(v, basestring):
              # the default assumes the current index
              rargs[k] = reg[v][idx] if is_dynamic else reg[v]
          elif len(v) < 3:
              if reg.isconstant[v[0]]:
                  # only get indices specified by v[1]
                  # tuples interpreted as a list of indices, see
                  # NumPy basic indexing: Dealing with variable
                  # numbers of indices within programs
                  rargs[k] = reg[v[0]][tuple(v[1])]
              elif v[1] < 0:
                  # specified offset from current index
                  rargs[k] = reg[v[0]][idx + v[1]]
              else:
                  # get indices specified by v[1] at current index
                  rargs[k] = reg[v[0]][idx][tuple(v[1])]
          else:
              # specified timedelta from current index
              dt = 1 + (v[1] * UREG(str(v[2])) / ts).item()
              # TODO: deal with fractions of timestep
              rargs[k] = reg[v[0]][(idx + dt):(idx + 1)]
      return rargs