Skip to content

Commit fb45be9

Browse files
committed
Adjust arrow scaling for pixel option
1 parent b5856e2 commit fb45be9

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

saenopy/gui/solver/modules/exporter/ExporterRender2D.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ def project_data(R, field, skip=1):
7979
length3 = np.linalg.norm(field[:, :3], axis=1)
8080
angle = np.arctan2(field[:, 1], field[:, 0])
8181
data = pd.DataFrame(np.hstack((R, length2[:, None], length3[:, None], angle[:, None])),
82-
columns=["x", "y", "length2", "length3", "angle"])
82+
columns=["x", "y", "length2", "length", "angle"])
8383
data = data.sort_values(by="length2", ascending=False)
8484
d2 = data.groupby(["x", "y"]).first()
8585
# optional slice
8686
if skip > 1:
8787
d2 = d2.loc[(slice(None, None, skip), slice(None, None, skip)), :]
88-
return np.array([i for i in d2.index]), d2[["length2", "angle", "length3"]]
88+
return np.array([i for i in d2.index]), d2[["length2", "angle", "length"]]
8989

9090
mesh, field, params_arrows, name = get_mesh_arrows(params, result)
9191

@@ -109,8 +109,7 @@ def project_data(R, field, skip=1):
109109
if field is not None:
110110
# rescale and offset
111111
scale = 1e6 / display_image[1][0]
112-
offset = np.array(display_image[0].shape[0:2]) / 2
113-
112+
offset = np.array(display_image[0].shape[0:2]) / 2
114113
R = mesh.nodes.copy()
115114
is3D = R.shape[1] == 3
116115
field = field.copy()
@@ -123,7 +122,8 @@ def project_data(R, field, skip=1):
123122
if getattr(mesh, "units", None) == "pixels":
124123
R = R[:, :2]
125124
R[:, 1] = display_image[0].shape[0] - R[:, 1]
126-
field = field[:, :2] * params_arrows["arrow_scale"]
125+
field = field[:, :2]
126+
field_to_pixel_factor = params_arrows["arrow_scale"]
127127
field[:, 1] = -field[:, 1]
128128
else: # "microns" + 3D
129129
R = R[:, :2][:, ::-1] * scale + offset[::-1]
@@ -169,13 +169,13 @@ def project_data(R, field, skip=1):
169169
# get the colormap
170170
cmap = plt.get_cmap(colormap)
171171
# calculate the colors of the arrows
172-
colors = cmap(field.length3 * scale_max_to_pixel_factor / scale_max)
172+
colors = cmap(field.length * scale_max_to_pixel_factor / scale_max)
173173
# set the transparency
174174
colors[:, 3] = alpha
175175
# make colors uint8
176176
colors = (colors * 255).astype(np.uint8)
177177

178-
pil_image = add_quiver(pil_image, R, field.length3 * field_to_pixel_factor, field.angle, colors,
178+
pil_image = add_quiver(pil_image, R, field.length * field_to_pixel_factor, field.angle, colors,
179179
scale=im_scale * aa_scale,
180180
width=params["2D_arrows"]["width"],
181181
headlength=params["2D_arrows"]["headlength"],

0 commit comments

Comments
 (0)