hypergas.plumeline module

Fitting the polynomial centerline for the CSF method.

hypergas.plumeline.calculate_perpendicular_extent(x_data, y_data, weights, w, rotation_angle, x_offset, y_offset, x_start, x_end, n_samples=100)[source]

Calculate the maximum perpendicular distance of plume points from the centerline.

Parameters:
  • x_data (array-like) – Coordinates of plume points in the original space.

  • y_data (array-like) – Coordinates of plume points in the original space.

  • weights (array-like) – Weights for each point.

  • w (array-like) – Polynomial coefficients defining the plume centerline in rotated space.

  • rotation_angle (float) – Rotation angle of the coordinate transformation.

  • x_offset (float) – Source location offsets.

  • y_offset (float) – Source location offsets.

  • x_start (float) – Range of x-coordinates (in rotated space) for evaluating the centerline.

  • x_end (float) – Range of x-coordinates (in rotated space) for evaluating the centerline.

  • n_samples (int, optional) – Number of sample points to generate along the centerline.

Returns:

max_perp_distance (float) – Maximum perpendicular distance from any sufficiently weighted point to the plume centerline.

hypergas.plumeline.compute_curve_arc_length_fine(w, x_start, x_end, n_samples=10000)[source]

Compute arc length of polynomial curve using fine numerical integration.

Parameters:
  • w (array) – Polynomial coefficients

  • x_start (float) – x-coordinate range in rotated space

  • x_end (float) – x-coordinate range in rotated space

  • n_samples (int) – Number of samples for numerical integration

Returns:

  • cumulative_arc (array) – Cumulative arc length at each x sample

  • x_samples (array) – x coordinates of samples

hypergas.plumeline.create_perpendicular_lines_equal_arc(w, rotation_angle, x_offset, y_offset, x_start, x_end, n_lines, line_width)[source]

Create perpendicular lines at equal arc-length intervals in original coordinate system.

Parameters:
  • w (array) – Polynomial coefficients

  • rotation_angle (float) – Rotation angle

  • x_offset (float) – Source location

  • y_offset (float) – Source location

  • x_start (float) – x-coordinate range in rotated space

  • x_end (float) – x-coordinate range in rotated space

  • n_lines (int) – Number of perpendicular lines

  • line_width (float) – Total width of perpendicular lines

Returns:

csf_lines (list of LineString) – Perpendicular lines in original coordinate system

hypergas.plumeline.evaluate_polynomial_curve(w, rotation_angle, x_offset, y_offset, x_rotated)[source]

Evaluate polynomial curve and transform back to original coordinates.

Parameters:
  • w (array) – Polynomial coefficients

  • rotation_angle (float) – Rotation angle

  • x_offset (float) – Translation offsets (source location)

  • y_offset (float) – Translation offsets (source location)

  • x_rotated (array) – x coordinates in rotated space

Returns:

x_original, y_original (arrays) – Coordinates in original space

hypergas.plumeline.feature(x, order=3)[source]

Generate polynomial feature matrix [1, x, x^2, …, x^order]

hypergas.plumeline.fit_polynomial_centerline(x, y, weights, x_source, y_source, order=3, alpha=0.01)[source]

Fit a polynomial curve through plume data using principal direction.

Parameters:
  • x (array-like) – Coordinates of points to fit

  • y (array-like) – Coordinates of points to fit

  • weights (array-like) – Weights for each point (e.g., gas concentrations)

  • x_source (float) – Source location

  • y_source (float) – Source location

  • order (int) – Polynomial order (3 = cubic)

  • alpha (float) – Regularization parameter

Returns:

  • w (array) – Polynomial coefficients

  • rotation_angle (float) – Rotation angle used

  • x_offset, y_offset (float) – Translation offsets

hypergas.plumeline.get_tangent_vector(w, x)[source]

Calculate unit tangent vector at point x for polynomial curve in rotated space.

Parameters:
  • w (array) – Polynomial coefficients [w0, w1, w2, …, wd]

  • x (float) – x-coordinate in rotated space

Returns:

tx, ty (float) – Unit tangent vector components in rotated space

hypergas.plumeline.get_x_at_arc_length(cumulative_arc, x_samples, target_arc_length)[source]

Find x coordinate corresponding to a specific arc length along the curve.

Parameters:
  • cumulative_arc (array) – Cumulative arc lengths

  • x_samples (array) – Corresponding x coordinates

  • target_arc_length (float) – Desired arc length from start

Returns:

x (float) – x coordinate at target arc length