Utilities
data2rad(data, k=360)
Convert data measured on a circular scale to corresponding angular directions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
ndarray or float
|
Data measured on a circular scale. |
required |
k
|
float or int
|
Number of intervals in the full cycle. Default is 360. |
360
|
Returns:
Name | Type | Description |
---|---|---|
angle |
ndarray or float
|
Angular directions in radian. |
Source code in pycircstat2/utils.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
time2float(x, sep=':')
Convert an array of strings in time (hh:mm) to an array of floats.
Source code in pycircstat2/utils.py
40 41 42 43 44 45 46 47 48 49 |
|
angmod(rad, bounds=[0, 2 * np.pi])
Normalize angles to a specified range.
Parameters:
rad : Union[np.ndarray, float, int] An angle or array of angles in radians. bounds : list, optional A list or tuple of two values [min, max] defining the target range. Default is [0, 2π).
Returns:
Union[np.ndarray, float] The normalized angle(s), constrained to the specified range.
Source code in pycircstat2/utils.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
|
angular_distance(a, b)
Angular distance between two angles.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a
|
Union[ndarray, list, float]
|
angle(s). |
required |
b
|
float
|
target angle. |
required |
Returns:
Name | Type | Description |
---|---|---|
e |
ndarray
|
angular distance |
Reference
P642, Section 27.2, Zar, 2010
Source code in pycircstat2/utils.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
|
is_within_circular_range(value, lb, ub)
Check if a value lies within the circular range [lb, ub].
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The value to check. |
required |
lb
|
float
|
The lower bound of the range. |
required |
ub
|
float
|
The upper bound of the range. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the value is within the circular range, False otherwise. |
Source code in pycircstat2/utils.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
|
rotate_data(alpha, angle, unit='radian')
Rotate a circular dataset by a given angle, supporting degrees, radians, and hours.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
alpha
|
ndarray
|
Angles in the specified unit. |
required |
angle
|
float
|
Rotation angle in the specified unit. |
required |
unit
|
str
|
Unit of measurement ("degree", "radian", or "hour"). Default is "radian". |
'radian'
|
Returns:
Name | Type | Description |
---|---|---|
rotated_alpha |
ndarray
|
Rotated angles, normalized within the unit's full cycle. |
Source code in pycircstat2/utils.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|