Skip to content

Commit

Permalink
Replace numpy nan syntax since NaN was removed
Browse files Browse the repository at this point in the history
as of numpy 2.0
  • Loading branch information
gschlafly committed Jun 26, 2024
1 parent 602d1ea commit 033bb08
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions src/VolumeRaytraceLFM/abstract_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,8 @@ def rays_through_vol(pixels_per_ml, naObj, nMedium, volume_ctr_um):

# Angles that reach the pixels
cam_pixels_azim = np.arctan2(jv - ml_ctr[1], iv - ml_ctr[0])
cam_pixels_azim[dist_from_ctr > ml_radius] = np.NaN
dist_from_ctr[dist_from_ctr > ml_radius] = np.NaN
cam_pixels_azim[dist_from_ctr > ml_radius] = np.nan
dist_from_ctr[dist_from_ctr > ml_radius] = np.nan
cam_pixels_tilt = np.arcsin(dist_from_ctr / ml_radius * naObj / nMedium)

# Plotting
Expand All @@ -490,7 +490,7 @@ def rays_through_vol(pixels_per_ml, naObj, nMedium, volume_ctr_um):
volume_ctr_um[0] * np.tan(cam_pixels_tilt) * np.cos(cam_pixels_azim)
+ volume_ctr_um[2]
)
ray_enter_x[np.isnan(ray_enter_y)] = np.NaN
ray_enter_x[np.isnan(ray_enter_y)] = np.nan
ray_enter = np.array([ray_enter_x, ray_enter_y, ray_enter_z])
vol_ctr_grid_tmp = np.array(
[
Expand Down Expand Up @@ -1114,17 +1114,17 @@ def plot_rays(self, colormap="inferno", use_matplotlib=False):
all_x = np.empty((3 * len(x_entry)))
all_x[::3] = x_entry
all_x[1::3] = x_exit
all_x[2::3] = np.NaN
all_x[2::3] = np.nan

all_y = np.empty((3 * len(y_entry)))
all_y[::3] = y_entry
all_y[1::3] = y_exit
all_y[2::3] = np.NaN
all_y[2::3] = np.nan

all_z = np.empty((3 * len(z_entry)))
all_z[::3] = z_entry
all_z[1::3] = z_exit
all_z[2::3] = np.NaN
all_z[2::3] = np.nan

# prepare colors for each line
rgba = [ray_ix / len(all_x) for ray_ix in range(len(all_x))]
Expand Down
18 changes: 9 additions & 9 deletions src/VolumeRaytraceLFM/birefringence_implementations.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,28 +344,28 @@ def plot_lines_plotly(

# Don't plot zero values
mask = delta_n == 0
x_base[mask] = np.NaN
y_base[mask] = np.NaN
z_base[mask] = np.NaN
x_tip[mask] = np.NaN
y_tip[mask] = np.NaN
z_tip[mask] = np.NaN
x_base[mask] = np.nan
y_base[mask] = np.nan
z_base[mask] = np.nan
x_tip[mask] = np.nan
y_tip[mask] = np.nan
z_tip[mask] = np.nan

# Gather all rays in single arrays, to plot them all at once, placing NAN in between them
array_size = 3 * len(x_base.flatten())
# Prepare colormap
all_x = np.empty((array_size))
all_x[::3] = x_base.flatten()
all_x[1::3] = x_tip.flatten()
all_x[2::3] = np.NaN
all_x[2::3] = np.nan
all_y = np.empty((array_size))
all_y[::3] = y_base.flatten()
all_y[1::3] = y_tip.flatten()
all_y[2::3] = np.NaN
all_y[2::3] = np.nan
all_z = np.empty((array_size))
all_z[::3] = z_base.flatten()
all_z[1::3] = z_tip.flatten()
all_z[2::3] = np.NaN
all_z[2::3] = np.nan
# Compute colors
all_color = np.empty((array_size))
all_color[::3] = (
Expand Down
6 changes: 3 additions & 3 deletions src/VolumeRaytraceLFM/visualization/plotting_rays.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,17 +355,17 @@ def plot_rays_at_sample(
all_x = np.empty((3 * len(x_entry)))
all_x[::3] = x_entry
all_x[1::3] = x_exit
all_x[2::3] = np.NaN
all_x[2::3] = np.nan

all_y = np.empty((3 * len(y_entry)))
all_y[::3] = y_entry
all_y[1::3] = y_exit
all_y[2::3] = np.NaN
all_y[2::3] = np.nan

all_z = np.empty((3 * len(z_entry)))
all_z[::3] = z_entry
all_z[1::3] = z_exit
all_z[2::3] = np.NaN
all_z[2::3] = np.nan

# prepare colors for each line
rgba = [ray_ix / len(all_x) for ray_ix in range(len(all_x))]
Expand Down

0 comments on commit 033bb08

Please sign in to comment.