Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GL3 attenuation for C++ raytracer #521

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

christophwelling
Copy link
Collaborator

This fixes the GL3 attenuation model for the C++ raytracer. Instead of using the GSL integrator (which had problems dealing with the GL3 model), the raytracer uses get_path to get points on the ray path, and then uses those to calculate the attenuation factor.
This is not 100% the same, but I tested the difference by generating a transmitter at random depths from 0.5m and 150m, and a transmitter at random depths between 30 and 3000m and distances between 50 and 3000m. This plot shows the difference between the attenuation factor of the C++ and the python raytracer, so the difference is under 1%.
attenuation_test_random_points
To make it easier to compare, I also added the option to tell the raytracer to use python, even if the C++ implementation is available.

I also noticed another problem with the C++ raytracer: For frequencies above 1.4GHz or so, the interpolation can cause negative attenuation lenghts. Even though this is out of band, it can blow up the signal enough to overcome the filter. So I restricted the interpolation to 600MHz to prevent this.

Copy link
Collaborator

@cg-laser cg-laser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks Christoph! Looks good. The feature to specify to use the python ray tracer is great. Did you change it att all occurrences? Maybe it would be better to only use self._use_python_raytracer which is set in the init function as

self._use_python_raytracer = use_python_raytracer or not cpp_available

Could you also improve the log output so that it is logged that the python version is used?

In this block in the beginning, could you change it to use the logger

    from NuRadioMC.SignalProp.CPPAnalyticRayTracing import wrapper
    cpp_available = True
    print("using CPP version of ray tracer")
except:
    print("trying to compile the CPP extension on-the-fly")
    try:
        import subprocess
        import os
        subprocess.call(os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                 "install.sh"))
        from NuRadioMC.SignalProp.CPPAnalyticRayTracing import wrapper
        cpp_available = True
        print("compilation was successful, using CPP version of ray tracer")
    except:
        print("compilation was not successful, using python version of ray tracer")
        print("check NuRadioMC/NuRadioMC/SignalProp/CPPAnalyticRayTracing for manual compilation")
        cpp_available = False

Here I would change the log output to "CPP ray tracer available. It will be used if not specified otherwise".

@christophwelling
Copy link
Collaborator Author

Okay, I changed the output to use the logger and give clearer feedback.
I changed it in all places where there is a check if the C++ raytracer is available, so that should be all of them.

@christophwelling
Copy link
Collaborator Author

@cg-laser Can you approve this?

Copy link
Collaborator

@cg-laser cg-laser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the default logger setting is "warning" and we should use it to print all relevant output. Can you change the two logger statements to "warning" too?

Maybe the better fix would be to go add an additional "extended info" option, use it where we currently use "info", change the warning loggers to info (where appropriate) and change the default log level to info.

cg-laser
cg-laser previously approved these changes Jan 26, 2024
@colemanalan
Copy link
Collaborator

The GL3 attenuation model is not working correctly. After running some simulations using greenland_simple as the icemodel and GL3. I get the following results for the distances as which triggers occur. Most importantly, once reaching 10^17eV, the distributions "saturate".

image

Changing only GL3 --> GL2 in my configuration file produced results that looked more like I would expect (no saturation).

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants