code: def prepare_array(data, masked=True, nodata=0, dtype="int16"):
      
      # input is iterable
      if isinstance(data, (list, tuple)):
          return _prepare_iterable(data, masked, nodata, dtype)
  
      # special case if a 2D single band is provided
      elif isinstance(data, np.ndarray) and data.ndim == 2:
          data = ma.expand_dims(data, axis=0)
  
      # input is a masked array
      if isinstance(data, ma.MaskedArray):
          return _prepare_masked(data, masked, nodata, dtype)
  
      # input is a NumPy array
      elif isinstance(data, np.ndarray):
          if masked:
              return ma.masked_values(data.astype(dtype, copy=False), nodata, copy=False)
          else:
              return data.astype(dtype, copy=False)
      else:
          raise ValueError(
              "data must be array, masked array or iterable containing arrays."
          )
docs: Turn input data into a proper array for further usage.
  
      Outut array is always 3-dimensional with the given data type. If the output
      is masked, the fill_value corresponds to the given nodata value and the
      nodata value will be burned into the data array.
  
      Parameters
      ----------
      data : array or iterable
          array (masked or normal) or iterable containing arrays
      nodata : integer or float
          nodata value (default: 0) used if input is not a masked array and
          for output array
      masked : bool
          return a NumPy Array or a NumPy MaskedArray (default: True)
      dtype : string
          data type of output array (default: "int16")
  
      Returns
      -------
      array : array