flopy.utils.recarray_utils module
- create_empty_recarray(length, dtype, default_value=0)[source]
Create a empty recarray with a defined default value for floats.
- Parameters:
- Returns:
r – Recarray of type dtype with shape length.
- Return type:
np.recarray
Examples
>>> import numpy as np >>> import flopy >>> dtype = np.dtype([('x', np.float32), ('y', np.float32)]) >>> ra = flopy.utils.create_empty_recarray(10, dtype)
- ra_slice(ra, cols)[source]
Create a slice of a recarray
- Parameters:
- Returns:
ra_slice – Slice of ra
- Return type:
np.recarray
Examples
>>> import flopy >>> raslice = flopy.utils.ra_slice(ra, ['x', 'y'])
- recarray(array, dtype)[source]
Convert a list of lists or tuples to a recarray.
- Parameters:
array (list of lists) – list of lists containing data to convert to a recarray. The number of entries in each list in the list must be the same.
dtype (np.dtype) – dtype of the array data
- Returns:
r – Recarray of type dtype with shape equal to the length of array.
- Return type:
np.recarray
Examples
>>> import numpy as np >>> import flopy >>> dtype = np.dtype([('x', np.float32), ('y', np.float32)]) >>> arr = [(1., 2.), (10., 20.), (100., 200.)] >>> ra = flopy.utils.recarray(arr, dtype)