Skip to content

Commit

Permalink
Merge pull request #862 from ToFuProject/Issue861_SolidAngle
Browse files Browse the repository at this point in the history
Issue861 solid angle
  • Loading branch information
Didou09 authored Oct 8, 2023
2 parents 106c627 + 52373b8 commit d7effcd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
14 changes: 7 additions & 7 deletions tofu/data/_class8_los_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def _compute_solid_angles_regular(

# reshape
if shape0_pts != ptsx.shape:
shape = tuple(np.r_[dout[k0]['solid_angle'].shape, shape0_pts])
shape = tuple(np.r_[dout[k0]['solid_angle'].shape[0], shape0_pts])
for k1, v1 in dout[k0].items():
dout[k0][k1] = v1.reshape(shape)

Expand Down Expand Up @@ -598,14 +598,14 @@ def _integrate_along_los_check(

# radius_max
if radius_max is None and mode == 'abs':

if key_bs_integrand is None and key_bs_coords is None:
pass

else:
wm = coll._which_mesh
wbs = coll._which_bsplines

rmax0, rmax1 = 0, 0
if key_bs_integrand is not None:
keym = coll.dobj[wbs][key_bs_integrand][wm]
Expand All @@ -614,15 +614,15 @@ def _integrate_along_los_check(
keym = submesh
knotsR = coll.dobj[wm][keym]['knots'][0]
rmax0 = np.max(coll.ddata[knotsR]['data'])

if key_bs_coords is not None:
keym = coll.dobj[wbs][key_bs_coords][wm]
submesh = coll.dobj[wm][keym]['submesh']
if submesh is not None:
keym = submesh
knotsR = coll.dobj[wm][keym]['knots'][0]
rmax1 = np.max(coll.ddata[knotsR]['data'])

radius_max = max(rmax0, rmax1)

# -----------------
Expand Down Expand Up @@ -752,4 +752,4 @@ def _interpolate_along_los_plot(
if vmax is not None:
ax.set_ylim(top=vmax)

return dout, dax
return dout, dax
27 changes: 14 additions & 13 deletions tofu/geom/_comp_solidangles.py
Original file line number Diff line number Diff line change
Expand Up @@ -1127,9 +1127,9 @@ def _visibility_unit_vectors(
)

# MC = point to centers
MCx = det_cent_x[iok] - pts_x[ii]
MCy = det_cent_y[iok] - pts_y[ii]
MCz = det_cent_z[iok] - pts_z[ii]
MCx = det_cents_x[iok] - pts_x[ii]
MCy = det_cents_y[iok] - pts_y[ii]
MCz = det_cents_z[iok] - pts_z[ii]

# MCn = MC.norm
MCn = (
Expand All @@ -1147,19 +1147,20 @@ def _visibility_unit_vectors(
Pz = pts_z[ii] + kk * unit_vector_z[iok, ii]

# Estimate visibility
vis = _GG.LOS_areVis_PtsFromPts_VesStruct(
np.array([pts_x[ii], pts_y[ii], pts_z[ii]]),
np.array([Px, Py, Pz]),
dist=kk[ii, iok],
vis = _GG.LOS_isVis_PtFromPts_VesStruct(
Px, Py, Pz,
np.array([[pts_x[ii]], [pts_y[ii]], [pts_z[ii]]]),
dist=kk,
**kwdargs,
)

# Set non-visible to 0 / nan
iout = vis == 0
solid_angle[ii, iout] = 0.
unit_vector_x[ii, iout] = np.nan
unit_vector_y[ii, iout] = np.nan
unit_vector_z[ii, iout] = np.nan
iokn = iok.nonzero()[0]
iout = iokn[vis == 0]
solid_angle[iout, ii] = 0.
unit_vector_x[iout, ii] = np.nan
unit_vector_y[iout, ii] = np.nan
unit_vector_z[iout, ii] = np.nan


###############################################################################
Expand Down Expand Up @@ -1566,4 +1567,4 @@ def calc_solidangle_apertures(
if timing:
return solid_angle, dt1, dt2, dt3
else:
return solid_angle
return solid_angle

0 comments on commit d7effcd

Please sign in to comment.