Skip to content

Commit

Permalink
added raytracing/scattering test to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mlietzow committed Oct 15, 2024
1 parent 8efda40 commit ab87ebc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ fi
${POLARIS_BINARY} ${PROJECTS_PATH}/test/stellar_sed/POLARIS.cmd
${POLARIS_BINARY} ${PROJECTS_PATH}/test/reemission_sphere/POLARIS.cmd
${POLARIS_BINARY} ${PROJECTS_PATH}/test/stellar_scattering_sphere/POLARIS.cmd
# ${POLARIS_BINARY} ${PROJECTS_PATH}/test/raytracing_scattering/POLARIS.cmd
${POLARIS_BINARY} ${PROJECTS_PATH}/test/raytracing_scattering/POLARIS.cmd

# validate output
python3 ${PROJECTS_PATH}/test/stellar_sed/compare.py
python3 ${PROJECTS_PATH}/test/reemission_sphere/compare.py
python3 ${PROJECTS_PATH}/test/stellar_scattering_sphere/compare.py
# python3 ${PROJECTS_PATH}/test/raytracing_scattering/compare.py
python3 ${PROJECTS_PATH}/test/raytracing_scattering/compare.py
7 changes: 4 additions & 3 deletions projects/test/raytracing_scattering/POLARIS.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<cmd> CMD_DUST_EMISSION

<detector_dust_polar nr_pixel = "255*255"> 1e-6 1e-3 7 1 0.0 0.0 4.32e+18
<detector_dust_polar nr_pixel = "255*255"> 1e-5 1e-3 5 1 0.0 0.0 4.32e+18

<max_subpixel_lvl> 1

Expand All @@ -26,9 +26,10 @@

<cmd> CMD_DUST_EMISSION

<detector_dust_polar nr_pixel = "255*255"> 1e-6 1e-3 7 1 0.0 0.0 4.32e+18
<detector_dust_polar nr_pixel = "255*255"> 1e-5 1e-3 5 1 0.0 0.0 4.32e+18

<source_star nr_photons = "1e6"> 0 0 0 2 4500
<source_dust nr_photons = "2.1e6">

<max_subpixel_lvl> 1

Expand All @@ -43,7 +44,7 @@

<cmd> CMD_DUST_SCATTERING

<detector_dust_mc nr_pixel = "255*255"> 1e-6 1e-3 7 0.00 0.00 4.32e+18
<detector_dust_mc nr_pixel = "255*255"> 1e-5 1e-3 5 0.00 0.00 4.32e+18

<source_star nr_photons = "1e6"> 0 0 0 2 4500
<source_dust nr_photons = "2.1e6">
Expand Down
6 changes: 3 additions & 3 deletions projects/test/raytracing_scattering/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ def compare():
dust_mc_sed_data = read_data('projects/test/raytracing_scattering/dust_mc/data/polaris_detector_nr0001_sed.fits.gz')

max_rel_diff = np.max(np.abs( (dust_sed_data['I'] + dust_mc_sed_data['I']) / dust_rt_sed_data['I'] - 1.0 ))
if max_rel_diff > 1e-2:
if max_rel_diff > 1e-3:
raise Exception(f'Test failed: Stokes I does not match (max. relative difference = {max_rel_diff})')

mc_polarization = np.sqrt(dust_mc_sed_data['Q']**2 + dust_mc_sed_data['U']**2 + dust_mc_sed_data['V']**2) / (dust_mc_sed_data['I'] + dust_sed_data['I'])
rt_polarization = np.sqrt(dust_rt_sed_data['Q']**2 + dust_rt_sed_data['U']**2 + dust_rt_sed_data['V']**2) / dust_rt_sed_data['I']
max_abs_diff = np.max(np.abs( mc_polarization - rt_polarization ))
if max_abs_diff > 1e-2:
if max_abs_diff > 1e-3:
raise Exception(f'Test failed: Polarization does not match (max. absolute difference = {max_abs_diff})')

max_polarization = np.max(mc_polarization)
if max_polarization > 1e-2:
if max_polarization > 1e-3:
raise Exception(f'Test failed: Polarization is too large (max. value = {max_polarization})')

return True
Expand Down

0 comments on commit ab87ebc

Please sign in to comment.