Skip to content

Commit

Permalink
Subray rotation precomptuation is now cached
Browse files Browse the repository at this point in the history
  • Loading branch information
albertoesmp committed Oct 5, 2023
1 parent 4bec505 commit 3d0656d
Show file tree
Hide file tree
Showing 11 changed files with 229 additions and 222 deletions.
211 changes: 109 additions & 102 deletions scripts/debug/hda_pulse_records_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,19 @@ def read_records(path, sep=','):
'received_power': intensity_calc[:, 9],
# Subray simulation records
'subray_hit': subray_sim[:, 0].astype(bool),
'radius_step': subray_sim[:, 1],
'circle_steps': subray_sim[:, 2],
'circle_step': subray_sim[:, 3],
'divergence_angle_rad': subray_sim[:, 4],
'ray_dir_norm': subray_sim[:, 5],
'subray_dir_norm': subray_sim[:, 6],
'ray_subray_angle_rad': subray_sim[:, 7],
'ray_subray_sign_check': subray_sim[:, 8],
'subray_tmin': subray_sim[:, 9],
'subray_tmax': subray_sim[:, 10],
'subray_dir_x': subray_sim[:, 11],
'subray_dir_y': subray_sim[:, 12],
'subray_dir_z': subray_sim[:, 13],
'ray_dir_x': subray_sim[:, 14],
'ray_dir_y': subray_sim[:, 15],
'ray_dir_z': subray_sim[:, 16]
'divergence_angle_rad': subray_sim[:, 1],
'ray_dir_norm': subray_sim[:, 2],
'subray_dir_norm': subray_sim[:, 3],
'ray_subray_angle_rad': subray_sim[:, 4],
'ray_subray_sign_check': subray_sim[:, 5],
'subray_tmin': subray_sim[:, 6],
'subray_tmax': subray_sim[:, 7],
'subray_dir_x': subray_sim[:, 8],
'subray_dir_y': subray_sim[:, 9],
'subray_dir_z': subray_sim[:, 10],
'ray_dir_x': subray_sim[:, 11],
'ray_dir_y': subray_sim[:, 12],
'ray_dir_z': subray_sim[:, 13]
}


Expand Down Expand Up @@ -490,14 +487,8 @@ def do_subray_hit_subplot_hist(
def do_subray_hit_plots(arec, brec, outdir):
# Validate subray hit data
if(not validate_record('subray_hit', arec, 'a') or
not validate_record('radius_step', arec, 'a') or
not validate_record('circle_steps', arec, 'a') or
not validate_record('circle_step', arec, 'a') or
not validate_record('divergence_angle_rad', arec, 'a') or
not validate_record('subray_hit', brec, 'b') or
not validate_record('radius_step', brec, 'b') or
not validate_record('circle_steps', brec, 'b') or
not validate_record('circle_step', brec, 'b') or
not validate_record('divergence_angle_rad', brec, 'b')
):
print('Cannot do subray hit plots')
Expand All @@ -507,58 +498,66 @@ def do_subray_hit_plots(arec, brec, outdir):
fig = init_figure() # Initialize figure
# CASE A
ax = fig.add_subplot(4, 5, 1) # Initialize hit2Dhist on (radstep,circstep)
do_subray_hit_subplot_hist2d(
fig, ax,
arec['circle_step'][arec['subray_hit']],
arec['radius_step'][arec['subray_hit']],
title='Hit distribution (100%) (A)',
)
#do_subray_hit_subplot_hist2d(
# fig, ax,
# arec['circle_step'][arec['subray_hit']],
# arec['radius_step'][arec['subray_hit']],
# title='Hit distribution (100%) (A)',
#)
# Removed because radstep and circstep are no longer exported
ax = fig.add_subplot(4, 5, 2) # Initialize a hist on radius step by hit
do_subray_hit_subplot_hist(
fig, ax, arec['subray_hit'], arec['radius_step'],
ylabel='Absolute'
)
#do_subray_hit_subplot_hist(
# fig, ax, arec['subray_hit'], arec['radius_step'],
# ylabel='Absolute'
#)
# Removed because radstep is no longer exported
ax = fig.add_subplot(4, 5, 3) # Initialize a hist on circle steps by hit
do_subray_hit_subplot_hist(
fig, ax, arec['subray_hit'], arec['circle_steps'],
)
#do_subray_hit_subplot_hist(
# fig, ax, arec['subray_hit'], arec['circle_steps'],
#)
# Removed because circstep is no longer exported
ax = fig.add_subplot(4, 5, 4) # Initialize a hist on circle step by hit
do_subray_hit_subplot_hist(
fig, ax, arec['subray_hit'], arec['circle_step'],
)
#do_subray_hit_subplot_hist(
# fig, ax, arec['subray_hit'], arec['circle_step'],
#)
# Removed because circstep is no longer exported
ax = fig.add_subplot(4, 5, 5) # Initialize a hist on div. angle by hit
do_subray_hit_subplot_hist(
fig, ax, arec['subray_hit'],
1e03*arec['divergence_angle_rad']*180/np.pi,
)
ax = fig.add_subplot(4, 5, 6) # Initialize non-hit 2D hist on (rs, cs)
do_subray_hit_subplot_hist2d(
fig, ax,
arec['circle_step'][~arec['subray_hit']],
arec['radius_step'][~arec['subray_hit']],
title='No-hit distribution (100%)',
xlabel='Circle step',
ylabel='Radius step'
)
#do_subray_hit_subplot_hist2d(
# fig, ax,
# arec['circle_step'][~arec['subray_hit']],
# arec['radius_step'][~arec['subray_hit']],
# title='No-hit distribution (100%)',
# xlabel='Circle step',
# ylabel='Radius step'
#)
# Removed because radstep and circstep are no longer exported
ax = fig.add_subplot(4, 5, 7) # Initialize a hist on radius step by hit
do_subray_hit_subplot_hist(
fig, ax, arec['subray_hit'], arec['radius_step'],
ylabel='Relative ($100\\%$)',
relative=True,
xlabel='Radius step'
)
#do_subray_hit_subplot_hist(
# fig, ax, arec['subray_hit'], arec['radius_step'],
# ylabel='Relative ($100\\%$)',
# relative=True,
# xlabel='Radius step'
#)
# Removed because radstep is no longer exported
ax = fig.add_subplot(4, 5, 8) # Initialize a hist on circle steps by hit
do_subray_hit_subplot_hist(
fig, ax, arec['subray_hit'], arec['circle_steps'],
relative=True,
xlabel='Circle steps'
)
#do_subray_hit_subplot_hist(
# fig, ax, arec['subray_hit'], arec['circle_steps'],
# relative=True,
# xlabel='Circle steps'
#)
# Removed because circstep is no longer exported
ax = fig.add_subplot(4, 5, 9) # Initialize a hist on circle step by hit
do_subray_hit_subplot_hist(
fig, ax, arec['subray_hit'], arec['circle_step'],
relative=True,
xlabel='Circle step'
)
#do_subray_hit_subplot_hist(
# fig, ax, arec['subray_hit'], arec['circle_step'],
# relative=True,
# xlabel='Circle step'
#)
# Removed because circstep is no longer exported
ax = fig.add_subplot(4, 5, 10) # Initialize a hist on div. angle by hit
do_subray_hit_subplot_hist(
fig, ax, arec['subray_hit'],
Expand All @@ -568,58 +567,66 @@ def do_subray_hit_plots(arec, brec, outdir):
)
# CASE B
ax = fig.add_subplot(4, 5, 11) # Initialize hit2Dhist on (radstep,circstep)
do_subray_hit_subplot_hist2d(
fig, ax,
brec['circle_step'][brec['subray_hit']],
brec['radius_step'][brec['subray_hit']],
title='Hit distribution (100%) (B)',
)
#do_subray_hit_subplot_hist2d(
# fig, ax,
# brec['circle_step'][brec['subray_hit']],
# brec['radius_step'][brec['subray_hit']],
# title='Hit distribution (100%) (B)',
#)
# Removed because radstep and circstep are no longer exported
ax = fig.add_subplot(4, 5, 12) # Initialize a hist on radius step by hit
do_subray_hit_subplot_hist(
fig, ax, brec['subray_hit'], brec['radius_step'],
ylabel='Absolute'
)
#do_subray_hit_subplot_hist(
# fig, ax, brec['subray_hit'], brec['radius_step'],
# ylabel='Absolute'
#)
# Removed because radstep is no longer exported
ax = fig.add_subplot(4, 5, 13) # Initialize a hist on circle steps by hit
do_subray_hit_subplot_hist(
fig, ax, brec['subray_hit'], brec['circle_steps'],
)
#do_subray_hit_subplot_hist(
# fig, ax, brec['subray_hit'], brec['circle_steps'],
#)
# Removed because circstep is no longer exported
ax = fig.add_subplot(4, 5, 14) # Initialize a hist on circle step by hit
do_subray_hit_subplot_hist(
fig, ax, brec['subray_hit'], brec['circle_step'],
)
#do_subray_hit_subplot_hist(
# fig, ax, brec['subray_hit'], brec['circle_step'],
#)
# Removed because circstep is no longer exported
ax = fig.add_subplot(4, 5, 15) # Initialize a hist on div. angle by hit
do_subray_hit_subplot_hist(
fig, ax, brec['subray_hit'],
1e03*brec['divergence_angle_rad']*180/np.pi,
)
ax = fig.add_subplot(4, 5, 16) # Initialize non-hit 2D hist on (rs, cs)
do_subray_hit_subplot_hist2d(
fig, ax,
brec['circle_step'][~brec['subray_hit']],
brec['radius_step'][~brec['subray_hit']],
title='No-hit distribution (100%)',
xlabel='Circle step',
ylabel='Radius step'
)
#do_subray_hit_subplot_hist2d(
# fig, ax,
# brec['circle_step'][~brec['subray_hit']],
# brec['radius_step'][~brec['subray_hit']],
# title='No-hit distribution (100%)',
# xlabel='Circle step',
# ylabel='Radius step'
#)
# Removed because radstep and circstep are no longer exported
ax = fig.add_subplot(4, 5, 17) # Initialize a hist on radius step by hit
do_subray_hit_subplot_hist(
fig, ax, brec['subray_hit'], brec['radius_step'],
ylabel='Relative ($100\\%$)',
relative=True,
xlabel='Radius step'
)
#do_subray_hit_subplot_hist(
# fig, ax, brec['subray_hit'], brec['radius_step'],
# ylabel='Relative ($100\\%$)',
# relative=True,
# xlabel='Radius step'
#)
# Removed because radstep is no longer exported
ax = fig.add_subplot(4, 5, 18) # Initialize a hist on circle steps by hit
do_subray_hit_subplot_hist(
fig, ax, brec['subray_hit'], brec['circle_steps'],
relative=True,
xlabel='Circle steps'
)
#do_subray_hit_subplot_hist(
# fig, ax, brec['subray_hit'], brec['circle_steps'],
# relative=True,
# xlabel='Circle steps'
#)
# Removed because circstep is no longer exported
ax = fig.add_subplot(4, 5, 19) # Initialize a hist on circle step by hit
do_subray_hit_subplot_hist(
fig, ax, brec['subray_hit'], brec['circle_step'],
relative=True,
xlabel='Circle step'
)
#do_subray_hit_subplot_hist(
# fig, ax, brec['subray_hit'], brec['circle_step'],
# relative=True,
# xlabel='Circle step'
#)
# Removed because circstep is no longer exported
ax = fig.add_subplot(4, 5, 20) # Initialize a hist on div. angle by hit
do_subray_hit_subplot_hist(
fig, ax, brec['subray_hit'],
Expand Down
32 changes: 13 additions & 19 deletions src/dataanalytics/HDA_PulseRecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,37 +53,31 @@ class HDA_PulseRecorder : public HDA_Recorder{
*
* [0] -> Subray hit (0 does not hit, 1 hit)
*
* [1] -> Radius step
* [1] -> Divergence angle (in rad)
*
* [2] -> Circle steps
* [2] -> Ray direction norm
*
* [3] -> Circle step
* [3] -> Subray direction norm
*
* [4] -> Divergence angle (in rad)
* [4] -> Angle between ray and subray (in rad)
*
* [5] -> Ray direction norm
* [5] -> Ray-subray sign check (1 if sign match, 0 otherwise)
*
* [6] -> Subray direction norm
* [6] -> Min time for subray intersection
*
* [7] -> Angle between ray and subray (in rad)
* [7] -> Max time for subray intersection
*
* [8] -> Ray-subray sign check (1 if sign match, 0 otherwise)
* [8] -> Subray direction (x component)
*
* [9] -> Min time for subray intersection
* [9] -> Subray direction (y component)
*
* [10] -> Max time for subray intersection
* [10] -> Subray direction (z component)
*
* [11] -> Subray direction (x component)
* [11] -> Ray direction (x component)
*
* [12] -> Subray direction (y component)
* [12] -> Ray direction (y component)
*
* [13] -> Subray direction (z component)
*
* [14] -> Ray direction (x component)
*
* [15] -> Ray direction (y component)
*
* [16] -> Ray direction (z component)
* [13] -> Ray direction (z component)
*/
std::shared_ptr<HDA_RecordBuffer<std::vector<double>>> subraySim;

Expand Down
6 changes: 3 additions & 3 deletions src/scanner/MultiScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ void MultiScanner::prepareSimulation() {
sh->setDeflectorAnglePtr(&pmbd->state_currentBeamAngle_rad);
}
}
// Prepare scanning device
scanDevs[i].prepareSimulation();
}
}

Expand Down Expand Up @@ -158,9 +160,7 @@ Rotation MultiScanner::calcAbsoluteBeamAttitude(size_t const idx){
}
void MultiScanner::computeSubrays(
std::function<void(
int const circleStep,
double const circleStep_rad,
Rotation &r1,
Rotation &subrayRotation,
double const divergenceAngle,
NoiseSource<double> &intersectionHandlingNoiseSource,
std::map<double, double> &reflections,
Expand Down
4 changes: 1 addition & 3 deletions src/scanner/MultiScanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,7 @@ class MultiScanner : public Scanner{
*/
void computeSubrays(
std::function<void(
int const circleStep,
double const circleStep_rad,
Rotation &r1,
Rotation &subrayRotation,
double const divergenceAngle,
NoiseSource<double> &intersectionHandlingNoiseSource,
std::map<double, double> &reflections,
Expand Down
4 changes: 1 addition & 3 deletions src/scanner/Scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,7 @@ class Scanner : public Asset {
*/
virtual void computeSubrays(
std::function<void(
int const circleStep,
double const circleStep_rad,
Rotation &r1,
Rotation &subrayRotation,
double const divergenceAngle,
NoiseSource<double> &intersectionHandlingNoiseSource,
std::map<double, double> &reflections,
Expand Down
Loading

0 comments on commit 3d0656d

Please sign in to comment.