def prepare_array(data, masked=True, nodata=<NUM_LIT:0>, dtype="<STR_LIT>"):
<EOL>if isinstance(data, (list, tuple)):<EOL><INDENT>return _prepare_iterable(data, masked, nodata, dtype)<EOL><DEDENT>elif isinstance(data, np.ndarray) and data.ndim == <NUM_LIT:2>:<EOL><INDENT>data = ma.expand_dims(data, axis=<NUM_LIT:0>)<EOL><DEDENT>if isinstance(data, ma.MaskedArray):<EOL><INDENT>return _prepare_masked(data, masked, nodata, dtype)<EOL><DEDENT>elif isinstance(data, np.ndarray):<EOL><INDENT>if masked:<EOL><INDENT>return ma.masked_values(data.astype(dtype, copy=False), nodata, copy=False)<EOL><DEDENT>else:<EOL><INDENT>return data.astype(dtype, copy=False)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>
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