GSEGUtils.validators
- GSEGUtils.validators.validate_spherical_angles(array)
Check spherical coordinates are valid.
- Acceptable ranges:
Radius: [0, +∞] Hz Angle: [-π, +π] V Angle: [0, +π]
Raises errors if not valid. No conversion is done.
- Parameters:
array (Array_Nx3_Float_T) – Nx3 array with rhv column order (Radius, Horizontal Angle, Vertical Angle)
- Return type:
- Raises:
TypeError – Non numpy array
- GSEGUtils.validators.validate_radius(array)
Check radii are non-negative.
- Parameters:
array (Array_Float_T) – Input array is independent of the distance unit
- Return type:
- Raises:
TypeError – Non numpy array
ValueError – Negative values
- GSEGUtils.validators.validate_azimuth_angles(array)
Check if azimuths in range of [0, 2π]
- Parameters:
array (Array_Float_T) – Array of angles in radians
- Return type:
- Raises:
TypeError – Non numpy array
ValueError – Values outside range [0, 2π]
- GSEGUtils.validators.validate_horizontal_angles(array)
Check if azimuths in range of [-π, +π]
- Parameters:
array (Array_Float_T) – Array of angles in radians
- Return type:
- Raises:
TypeError – Non numpy array
ValueError – Values outside range [-π, +π]
- GSEGUtils.validators.validate_zenith_angles(array)
Check if zenith angles in range of [0, +π]
- Parameters:
array (Array_Float_T) – Array of angles in radians
- Return type:
- Raises:
TypeError – Non numpy array
ValueError – Values outside range [0, +π]
- GSEGUtils.validators.validate_inclination_angles(array)
Check if inclination angles in range of [-π/2, +π/2]
- Parameters:
array (Array_Float_T) – Array of angles in radians
- Return type:
- Raises:
TypeError – Non numpy array
ValueError – Values outside range [-π/2, +π/2]
- GSEGUtils.validators.coerce_wrapped_azimuth_angles(array)
Coerces azimuth angles to be within the range [0, 2π).
- Parameters:
array (Array_Float_T) – Array of azimuth angles in radians
- Return type:
- GSEGUtils.validators.coerce_wrapped_horizontal_angles(array)
Coerce horizontal angles to range [-π, π)
- Parameters:
array (Array_Float_T) – Array of horizontal angles in radians
- Return type:
- GSEGUtils.validators.validate_transposed_2d_array(array, n)
Ensure an array is of MxN shape or NxM shape and transpose if necessary.
- Parameters:
- Return type:
- Raises:
ValueError – Unsupported shape
- GSEGUtils.validators.convert_slice_to_integer_range(selection, length)
Convert a slice object to an array of integer indices.
- Parameters:
- Return type:
- GSEGUtils.validators.validate_in_range(value, target_min, target_max)
Check if values are within the target range.
- Parameters:
- Raises:
ValueError – Values outside of range
- Return type:
None
- GSEGUtils.validators.normalize_min_max(array, lower, upper, target_dtype, v_min=None, v_max=None)
Normalize and scale the values in a numpy array to a specified range using min-max scaling.
The input array is initially normalized using v_min, v_max where array.min() and array.max() are the default if not set.
This is then scaled to the target range bounds of [lower, upper] and converted to the target data type.
- Parameters:
array (ArrayT) – Input array
lower (float or int or np.number) – Target lower bound after normalization
upper (float or int or np.number) – Target upper bound after normalization
target_dtype (npt.DtypeLike) – Output data type
v_min (float or int, optional) – Minima value used for normalization. Defaults to array.min() if not provided.
v_max (float or int, optional) – Maxima value used for normalization. Defaults to array.max() if not provided.
- Return type:
- GSEGUtils.validators.linear_map_dtype(array, target_dtype)
Linearly map the array values to the target dtype.
This function maps the input array values based on the current datatype’s minimum and maximum supported values to those of the target datatype.
Examples
np.int8 to np.uint16
>>> input = np.array([-50, 0, 127], dtype=np.int8) >>> linear_map_dtype(input, np.uint16) array([20046, 32896, 65535], dtype=uint16)
- Parameters:
array (ArrayT) – Input array
target_dtype (npt.DtypeLike) – Target dtype (64-bit types not supported)
- Return type:
- Raises:
ValueError – Dtype is 64-bit (e.g., np.float64, np.int64, np.uint64).
TypeError – Non-floating or integer object type passed
- GSEGUtils.validators.normalize_self(array)
Normalizes an input array to the limits expected by the array’s dtype.
For floating point values, this is [0, 1] and for integer values, it is the min and max defined by np.iinfo.
- GSEGUtils.validators.normalize_uint8(array)
Normalize to UInt8
- Parameters:
array (ArrayT)
- Return type:
- GSEGUtils.validators.normalize_uint16(array)
Normalize to UInt16
- Parameters:
array (ArrayT)
- Return type:
- GSEGUtils.validators.normalize_int8(array)
Normalize to Int8
- Parameters:
array (ArrayT)
- Return type:
- GSEGUtils.validators.normalize_int16(array)
Normalize to Int16
- Parameters:
array (ArrayT)
- Return type:
- GSEGUtils.validators.normalize_int32(array)
Normalize to Int32
- Parameters:
array (ArrayT)
- Return type: