work on curvature node
This commit is contained in:
@@ -3,7 +3,7 @@ from backend.nodes import (
|
||||
# IO
|
||||
colormap,
|
||||
crop_resize,
|
||||
fft_2d_invert,
|
||||
fft_2d_inverse,
|
||||
filter_fft_1d,
|
||||
filter_fft_2d,
|
||||
filter_gaussian,
|
||||
|
||||
@@ -159,6 +159,8 @@ def _compute_curvature_results(
|
||||
x0 = float(xc / q + 0.5 * xreal + field.xoff)
|
||||
y0 = float(yc / q + 0.5 * yreal + field.yoff)
|
||||
|
||||
print(f"debug: {x0}, {y0}, {r1}, {r2}")
|
||||
|
||||
return {
|
||||
"degree": float(degree),
|
||||
"x0": x0,
|
||||
@@ -290,8 +292,8 @@ class Curvature:
|
||||
OUTPUTS = (
|
||||
('ANNOTATION_SOURCE', 'output'),
|
||||
('RECORD_TABLE', 'measurements'),
|
||||
('LINE', 'profile_1'),
|
||||
('LINE', 'profile_2'),
|
||||
('LINE', 'profile_x'),
|
||||
('LINE', 'profile_y'),
|
||||
)
|
||||
FUNCTION = "process"
|
||||
|
||||
@@ -338,7 +340,7 @@ class Curvature:
|
||||
|
||||
profiles = []
|
||||
for pair in intersections[:2]:
|
||||
profiles.append(_profile_from_intersections(field, pair[0], pair[1]))
|
||||
profiles.append(_profile_from_intersections(field, pair[1], pair[0]))
|
||||
while len(profiles) < 2:
|
||||
profiles.append(_empty_profile(field.si_unit_xy, field.si_unit_z))
|
||||
|
||||
@@ -346,18 +348,36 @@ class Curvature:
|
||||
output = field.replace(overlays=[*field.overlays, markup_spec])
|
||||
|
||||
table = RecordTable([
|
||||
{"quantity": "Center x position", "value": float(results["x0"]), "unit": field.si_unit_xy},
|
||||
{"quantity": "Center y position", "value": float(results["y0"]), "unit": field.si_unit_xy},
|
||||
{"quantity": "Center value", "value": float(results["z0"]), "unit": field.si_unit_z},
|
||||
{"quantity": "Curvature radius 1", "value": float(results["r1"]), "unit": field.si_unit_xy},
|
||||
{"quantity": "Curvature radius 2", "value": float(results["r2"]), "unit": field.si_unit_xy},
|
||||
{"quantity": "Direction 1", "value": float(np.degrees(results["phi1"])), "unit": "deg"},
|
||||
{"quantity": "Direction 2", "value": float(np.degrees(results["phi2"])), "unit": "deg"},
|
||||
{"quantity": "Curvature radius 1", "value": results["r1"], "unit": field.si_unit_xy},
|
||||
{"quantity": "Curvature radius 2", "value": results["r2"], "unit": field.si_unit_xy},
|
||||
{"quantity": "Center x position", "value": results["x0"], "unit": field.si_unit_xy},
|
||||
{"quantity": "Center y position", "value": results["y0"], "unit": field.si_unit_xy},
|
||||
{"quantity": "Center value", "value": results["z0"], "unit": field.si_unit_z},
|
||||
{"quantity": "Direction 1", "value": results["phi1"], "unit": "deg"},
|
||||
{"quantity": "Direction 2", "value": results["phi2"], "unit": "deg"},
|
||||
])
|
||||
|
||||
preview_base = render_datafield_preview(field, field.colormap)
|
||||
emit_preview(encode_preview(_apply_markup_overlay(preview_base, field, markup_spec)))
|
||||
emit_table(table)
|
||||
panels = []
|
||||
|
||||
for p, title in zip(profiles, ["X Principal Axis", "Y Principal Axis"]):
|
||||
if len(p.data) > 0:
|
||||
panels.append({
|
||||
"title": title,
|
||||
"kind": "line_plot",
|
||||
"line": p.data.tolist(),
|
||||
"x_axis": p.x_axis.tolist(),
|
||||
"x_unit": field.si_unit_xy,
|
||||
})
|
||||
panels.append({
|
||||
"title": "Overview",
|
||||
"kind": "image",
|
||||
"image": encode_preview(_apply_markup_overlay(preview_base, field, markup_spec)),
|
||||
})
|
||||
|
||||
emit_preview({"kind": "panels", "panels": panels})
|
||||
# emit_table(table)
|
||||
|
||||
if warnings:
|
||||
emit_warning(warnings[0])
|
||||
|
||||
|
||||
@@ -90,8 +90,8 @@ class Histogram:
|
||||
})
|
||||
|
||||
table = RecordTable([
|
||||
{"quantity": "delta Y", "value": yb - ya, "unit": count_unit},
|
||||
{"quantity": "delta X", "value": xb - xa, "unit": field.si_unit_z},
|
||||
{"quantity": "delta Y", "value": yb - ya, "unit": count_unit},
|
||||
{"quantity": "A position", "value": xa, "unit": field.si_unit_z},
|
||||
{"quantity": "A count", "value": ya, "unit": count_unit},
|
||||
{"quantity": "B position", "value": xb, "unit": field.si_unit_z},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
from backend.node_registry import register_node
|
||||
from backend.execution_context import emit_value
|
||||
from backend.execution_context import emit_table, emit_value
|
||||
from backend.data_types import RecordTable
|
||||
from backend.nodes.helpers import _measurement_entry, _measurement_value, _scalar_payload
|
||||
|
||||
@@ -13,6 +13,7 @@ class ValueDisplay:
|
||||
"required": {
|
||||
"value": ("FLOAT", {
|
||||
"accepted_types": ["RECORD_TABLE"],
|
||||
"socket_only": True,
|
||||
}),
|
||||
"measurement": ("STRING", {
|
||||
"default": "",
|
||||
@@ -37,6 +38,7 @@ class ValueDisplay:
|
||||
def display_value(self, value, measurement: str = "") -> tuple:
|
||||
unit = ""
|
||||
if isinstance(value, RecordTable):
|
||||
emit_table(value)
|
||||
row = _measurement_entry(value, measurement)
|
||||
numeric = _measurement_value(value, measurement)
|
||||
unit = row.get("unit", "") if isinstance(row.get("unit"), str) else ""
|
||||
|
||||
Reference in New Issue
Block a user