linref.experimental package

Submodules

linref.experimental.analysis module

linref.experimental.analysis.buffer_events(events, size, steps, scaler='linear', normalize=True, beg=None, end=None, fill='cut', closed='left_mod', rc=None, values=None)[source]

Digitize and buffer events over a defined range, extending them across uniform steps within the range and scaling their values relative to their digital distance from their intersecting step location.

Parameters

events1d or 2d array-like

The locations of the target events being analyzed. If points, must be flat array-like or of shape (x, 1). If ranges, must be array-like of shape (x, 2). All event locations should fall on the range [beg, end] (if provided) to be considered in the analysis.

sizepositive numeric

The size of each buffering step used to perform the analysis.

stepsint, default 10

The number of steps of buffering to perform.

scalerstr or callable, default ‘linear’

The scaling function to be called at each buffering step to scale buffered values. If a callable is provided, it must accept a single integer input for the zero-indexed buffering step, returning a single float scaling value. Predefined scaling functions can be called using the following labels:

linearlinearly scale down values from the center value to the

edge value

none : do not scale down buffered values

normalizebool, default True

Whether to normalize resulting buffered values so each event’s total buffers sum to 1.

beg, endnumeric, optional

The locations at which to begin and end the buffering analysis. If not provided, will default to the min and max values in the events data, respectively. If a predefined range collection is provided, that will supersede these input parameters.

closedstr {‘left’, ‘left_mod’, ‘right’, ‘right_mod’, ‘both’,

‘neither’}, default ‘left’

Whether window intervals are closed on the left-side, right-side, both, or neither. Values of ‘left’ and ‘right’ will avoid double- counting and under-counting events which occur on the edges of windows.

leftranges are always closed on the left and never closed on the

right.

left_modranges are always closed on the left and only closed on the

right when the next range is not consecutive.

rightranges are always closed on the right and never closed on the

right.

right_modranges are always closed on the right and only closed on

the left when the previous range is not consecutive.

both : ranges are always closed on both sides neither : ranges are never closed on either side

rcRangeCollection, optional

A predefined valid consecutive range collection instance which defines the analysis domain and which will be used to intersect with input events.

Created: 2022-01-06 Modified: 2022-01-06

linref.experimental.analysis.rasterize_events(events, values=None, size=1, blur=0, blur_style='linear', normalize=True, bounds=None, fill='cut', closed='left_mod', rc=None, **kwargs)[source]

Digitize and buffer events over a defined range, extending them across uniform steps within the range and scaling their values relative to their digital distance from their intersecting step location.

Parameters

events1d or 2d array-like

The locations of the target events being analyzed. If points, must be flat array-like or of shape (x, 1). If ranges, must be array-like of shape (x, 2). All event locations should fall on the range [beg, end] (if provided) to be considered in the analysis.

valuesnumeric or 1d array-like, optional

The value(s) associated with each event being analyzed. If not provided, all values will default to be 1.

sizepositive numeric, default 1

The length of each pixel used to perform the analysis.

blurint, default 0

The number of pixels to blur events across based on the blur style.

blur_stylestr or callable, default ‘linear’

The scaling function to be called at each blurring step to scale original values. If a callable is provided, it must accept a single integer input for the zero-indexed pixel number, returning a single float scaling value. Predefined blurring functions can be called using the following labels:

linearlinearly scale down values from the original value to zero

at the first index outside the blurred pixel range

none : do not scale down original values

normalizebool, default True

Whether to normalize resulting buffered values so each event’s total buffers sum to 1.

boundstwo-value numeric tuple, optional

The values at which to begin and end the pixelation analysis. If not provided, will default to the min and max location values in the events data, respectively. If a predefined range collection is provided, that will supersede these input parameters.

fill{‘none’,’cut’,’left’,’right’}, default ‘cut’

How to fill a gap at the end of an event’s range.

noneno window will be generated to fill the gap at the end of

the input range.

cuta truncated window will be created to fill the gap with a

length less than the full window length.

leftthe final window will be anchored on the end of the event

and will extend the full window length to the left.

rightthe final window will be anchored on the grid defined by

the step value, extending the full window length to the right, beyond the event’s end value.

closedstr {‘left’, ‘left_mod’, ‘right’, ‘right_mod’, ‘both’,

‘neither’}, default ‘left’

Whether window intervals are closed on the left-side, right-side, both, or neither. Values of ‘left’ and ‘right’ will avoid double- counting and under-counting events which occur on the edges of windows. If a predefined range collection is provided, that will supersede these input parameters.

leftranges are always closed on the left and never closed on the

right.

left_modranges are always closed on the left and only closed on the

right when the next range is not consecutive.

rightranges are always closed on the right and never closed on the

right.

right_modranges are always closed on the right and only closed on

the left when the previous range is not consecutive.

both : ranges are always closed on both sides neither : ranges are never closed on either side

rcRangeCollection, optional

A predefined valid consecutive range collection instance which defines the analysis domain and which will be used to intersect with input events.

Created: 2022-01-06 Modified: 2022-01-12

linref.experimental.curves module

class linref.experimental.curves.CurveDetector(line)[source]

Bases: object

Class for detecting curves along polylines based on geometric features of rays, arcs, and complex segments.

To-do

  • Deal with adjacent curves/reverse curves

  • Minimum points/length for curve definition

  • Add point/length buffer

  • Full curve radius estimate

property arc_length

The actual outer arc length of each arc defined by two adjacent rays. Size = n - 2

property bearing

Bearing of the ray defined by two adjacent points. Size = n - 1

property central_angle

The central angle of each arc defined by two adjacent rays. Size = n - 2

property curves

A list of shapely LineStrings for fitted curves.

property direction

The direction of the relative angle between two adjacent rays, indicating a left-hand angle (1) and a right-hand angle (0). Size = n - 2

property dx

X-dimension distance between adjacent points. Size = n - 1

property dy

Y-dimension distance between adjacent points. Size = n - 1

fit(max_radius=10000, max_radius_scale=0.65, span_ratio_sensitivity=0.35)[source]

A test of whether or not adjacent arcs have similar radii based on input detection parameters for the maximum radius scale and the maximum radius which can be detected within a curve. Size = n - 3

Parameters

max_radiusnumber, default 10000

The maximum radius to be considered within a detected curve.

max_radius_scalefloat [0, 1], default 0.65

The maximum span ratio-adjusted radius scale value to be considered within a detected curve. If span_ratio_sensitivity == 0, no adjustements to the radius scale are made.

span_ratio_sensitivitynumber [0, 1], default 0.35

A measure of the sensitivity of the detector to a given arc’s span ratio where 0 means no sensitivity and 1 means full sensitivity.

property line
property point_map

Array of values indicating which points are associated with which curves. Points with a value of 0 are not associated with any unique fitted curve.

property point_mask

A boolean array mask indicating which points have been detected to be part of a fitted curve

property radius

The radius of each arc defined by two adjacent rays. Size = n - 2

property radius_dif

The mathematical difference in radius between all pairs of adjacent arcs (i.e., 4-point segments). Size = n - 3

property radius_max

The maximum radius between all pairs of adjacent arcs (i.e., 4-point segments). Size = n - 3

property radius_scale

The mathematical difference in radius between all pairs of adjacent arcs (i.e., 4-point segments), normalized by the maximum radius between each pair. Size = n - 3

property ray_length

Length of the ray defined by two adjacent points. Size = n - 1

property relangle

Relative angle between two adjacent rays. Size = n - 2

property segment_mask

A boolean array mask indicating which 4-point segments have been detected to be part of a fitted curve.

property size
property span

Span length of each 3-point arc, measuring between the begin and end points of each arc defined by two adjacent rays. Size = n - 2

span_index(span_ratio_sensitivity=0.2)[source]

Abstract quantification of the influence of each arc’s span ratio on curve detection given an input sensitivity value between 0 and 1. Size = n - 2

Parameters

span_ratio_sensitivitynumber [0, 1], default 0.35

A measure of the sensitivity of the detector to a given arc’s span ratio where 0 means no sensitivity and 1 means full sensitivity.

property span_ratio

Ratio of the smaller ray to the larger ray of each arc defined by two adjacent rays. Size = n - 2

property xs
property ys

Module contents