str2d.Str2D.struct_array_from_bool_array
- classmethod Str2D.struct_array_from_bool_array(array: ndarray, char: str) Str2D [source]
Create a structured array from a boolean array. This is useful when you have a boolean array and you want to convert it to a structured array with fields ‘char’ and ‘alpha’.
The ‘char’ field will be filled with the specified character where the boolean array is True and ‘ ‘ where the boolean array is False. The ‘alpha’ field will be 1 where the boolean array is True and 0 where the boolean array is False.
- Parameters:
array (np.ndarray) – A 2D boolean array.
char (str) – The character to use when the boolean array is True.
- Returns:
A structured array with fields ‘char’ and ‘alpha’ created from the input boolean array.
- Return type:
np.ndarray