yt.frontends.boxlib.data_structures.BoxlibDataset.arr — The yt Project 3.2-dev documentation

# yt.frontends.boxlib.data_structures.BoxlibDataset.arr

`BoxlibDataset.` `arr`

  Converts an array into a `yt.units.yt_array.YTArray`

  The returned YTArray will be dimensionless by default, but can be cast to arbitray units using the `input_units` keyword argument.

  Parameters: | input_array : iterable A tuple, list, or array to attach units to input_units : String unit specification, unit symbol object, or astropy units object The units of the array. Powers must be specified using python syntax (cm**3, not cm^3). dtype : string or NumPy dtype object The dtype of the returned array data

  Examples

      >>> import yt
      >>> import numpy as np
      >>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
      >>> a = ds.arr([1, 2, 3], 'cm')
      >>> b = ds.arr([4, 5, 6], 'm')
      >>> a + b
      YTArray([ 401.,  502.,  603.]) cm
      >>> b + a
      YTArray([ 4.01,  5.02,  6.03]) m

  Arrays returned by this function know about the dataset’s unit system

      >>> a = ds.arr(np.ones(5), 'code_length')
      >>> a.in_units('Mpccm/h')
      YTArray([ 1.00010449,  1.00010449,  1.00010449,  1.00010449,
               1.00010449]) Mpc