{"id":15655135,"url":"https://github.com/zhampel/cr-geomag-prop","last_synced_at":"2025-05-01T14:53:31.381Z","repository":{"id":93474366,"uuid":"139786726","full_name":"zhampel/cr-geomag-prop","owner":"zhampel","description":"Visualization of cosmic rays propagating through the Earth's magnetic field","archived":false,"fork":false,"pushed_at":"2021-04-30T22:36:43.000Z","size":1496,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-01T14:53:26.230Z","etag":null,"topics":["astroparticle-physics","astrophysics","cosmic-rays","igrf","magnetic-fields","opencl-kernels","pyopencl","pyopengl","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zhampel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-05T02:46:56.000Z","updated_at":"2024-04-18T13:29:28.000Z","dependencies_parsed_at":"2023-04-12T08:32:50.643Z","dependency_job_id":null,"html_url":"https://github.com/zhampel/cr-geomag-prop","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhampel%2Fcr-geomag-prop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhampel%2Fcr-geomag-prop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhampel%2Fcr-geomag-prop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhampel%2Fcr-geomag-prop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhampel","download_url":"https://codeload.github.com/zhampel/cr-geomag-prop/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251895424,"owners_count":21661342,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["astroparticle-physics","astrophysics","cosmic-rays","igrf","magnetic-fields","opencl-kernels","pyopencl","pyopengl","python"],"created_at":"2024-10-03T12:56:29.302Z","updated_at":"2025-05-01T14:53:31.348Z","avatar_url":"https://github.com/zhampel.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Charged Particle in Geomagnetic Field Visualization\n\n[![Build Status](https://travis-ci.org/zhampel/cr-geomag-prop.svg?branch=master)](https://travis-ci.org/zhampel/cr-geomag-prop)\n![Python 2.7](https://img.shields.io/badge/python-2.7-blue.svg)\n[![GitHub license](https://img.shields.io/github/license/zhampel/cr-geomag-prop.svg)](https://github.com/zhampel/cr-geomag-prop/blob/master/LICENSE)\n\nThis project (cr-geomag-prop) demonstrates a tool to visualize charge particle\npropagation through the Earth's magnetic field using PyOpenCL and PyOpenGL.\nThe following [link](https://youtu.be/0FDwW1mo2Vk)\nshows a demonstration of this project's visualization of GeV proton particles\ninteracting with the geomagnetic field, while below is a screenshot from this simulation.\n\nTo check-out the repo:\n```\ngit clone https://github.com/zhampel/cr-geomag-prop.git\n```\n\n\n\u003cp float=\"left\"\u003e\n  \u003cimg src=\"docs/images/screenshot.png\" width=\"500\" /\u003e\n\u003c/p\u003e\n\nThe Earth texture was obtained freely at the\n[Planetary Pixel Emporium](http://planetpixelemporium.com/earth.html).\n\n\n\n## B-Field Models\nThere are two available models for estimating the geomagnetic field.\nThe first is the dipole approximation, where the axis of the field\nis tilted by 11.5 deg from the Earth's axis of rotation.\nThe second is the International Geomagnetic Reference Field\n([IGRF](https://www.ngdc.noaa.gov/IAGA/vmod/igrf.html)),\na best fit model to satellite borne and ground based sensor measurements\nusing a 13-order expansion of Legendre functions.\n\nThe two figures below show isoclinic diagrams of these two models,\nthe dipole being on the left, the IGRF on the right, where\ndeviation of IGRF from the symmetric dipole approximation is clearly visible.\nThese diagrams were generated using the following MATLAB\n[package](https://nl.mathworks.com/matlabcentral/fileexchange/34388-international-geomagnetic-reference-field--igrf--model).\n\n\u003cp float=\"left\"\u003e\n  \u003cimg src=\"docs/images/dipole_isoclinic_diagram.png\" width=\"400\" /\u003e\n  \u003cimg src=\"docs/images/igrf_isoclinic_diagram.png\" width=\"400\" /\u003e\n\u003c/p\u003e\n\nLinks showing short video demos of propagating protons in these fields are provided for the\n[IGRF](https://youtu.be/0FDwW1mo2Vk)\nmodel as well as the\n[dipole](https://youtu.be/YA2j0FwJTsI)\napproximation.\n\n# Usage\nUpon installation of required dependencies, one simply needs to run\n```\npython crprop/run.py -p proton -n 1000 -e 1e7 1e8 --lat_lon_alt 18.99 -97.308 3 -s boris\n```\nto start the simulation, where `-p` defines the species to run,\nthe number of particles to simulate is given by `-n`,\nand the minimum and maximum particle energy in electronvolts (eV) are provided as a list via `-e`.\nThe `--lat_lon_alt` flag allows the user to specify the particles's starting latitude and longitude in degrees,\nand the height above the Earth's surface in Earth radii.\nFinally, the `-s` option allows the user to choose the equation of motion integrator.\nThe values shown in the line above are the defaults, thus users can do a first run simply\nvia `python crprop/run.py`.\nUsers can also use a YAML config file to input all options and run via\n```\npython crprop/run.py -c config.yml\n```\nwith a default configuration file provided in the `crprops` directory.\n\n## Visualization\nOnce the window opens, one can also use various mouse operations to change the scene.\nHolding the left mouse button allows the user to move the viewing position, while\nholding down the right mouse button and moving up and down on the screen provides\na zooming operation.\nThe center mouse button provides translation of the origin about the screen.\n\nThe colors of the particles are representative of their energy, and are correlated\nper the respective wavelengths.\nRed corresponds to the lowest energies, while violet represents the highest values.\nThe color-to-energy scaling is log-linear, thus color wavelength is proportional\nto the logarithm of the particle energy.\n\nThere are several available user options when running the simulation:\n\n- `p` key or spacebar: start/pause the propagation\n- `r` key: start/stop the rotation of the perspective\n- `s` key: save the frames to png files\n- `t` key: toggle between a textured Earth and a simple sphere\n- `q` or `Esc` keys: quit the simulation\n\nA BASH script named `crprop/make_mp4.sh` is provided to generate\nan mp4 movie if saved frames are present in the `frames` directory.\nOne must have ffmpeg installed on the system to make the movie.\n\n\n## Installation of Required Software\nI've successfully run using Python2.7 and on Python3.7.5.\nThe installation of PyOpenCL and PyOpenGL potentially can be a bit tricky\ndepending on the platform, but on my Linux machines, I've had success via `make install` \nor `pip install -r requirements.txt`.\n\n### Mac\nOn my MacBook Pro, I've instead been able to get things running via the following steps:\n\n- Ensure Python3 accessible, e.g. in `/usr/local/bin/python3`\n- `brew install freeglut`\n- Start a new virtual-env: `virtualenv -p /usr/local/bin/python3 venv`\n- `pip install setuptools numpy pygame Pillow astropy pyyaml pybind11`\n- Download PyOpenGL and PyOpenGL-accelerate from [here](http://pyopengl.sourceforge.net/documentation/installation.html)\n- Untar each, then `python setup.py install` PyOpenGL, then PyOpenGL-accelerate\n- You can test the PyOpenGL installation with the PyOpenGL-Demo package, also found at the PyOpenGL site\n- Download PyOpenCL from [here](https://pypi.org/project/pyopencl/), for example\n- Build with specific Python paths and gl-interoperability (though I have found =paths unnecessary to specify explicitly...):\u003c/br\u003e\n`./configure.py --python-exe=PATH_TO_PYTHON_EXE --prefix=PATH_TO_PREFIX --enable-shared --cl-enable-gl`\n- `make \u0026\u0026 make install`\n\nTo test the installation, one can the PyOpenCL particle [example script](https://github.com/inducer/pyopencl/tree/master/examples/gl_particle_animation.py)\n\nOne can also go to Andreas Kloeckner's\n[site](https://documen.tician.de/pyopencl/) for even more details regarding PyOpenCL installation and documentation.\n\n\n### IGNORE BELOW\nThe installation of PyOpenCL and PyOpenGL potentially can be a bit tricky\ndepending on the platform, but may be done via `make install` or `pip install -r requirements.txt`.\nIf this doesn't work, the best resource for preparing the PyOpenCL installation can\nbe found at Andreas Klockner's [website](https://wiki.tiker.net/PyOpenCL/Installation/).\nI have had success with building PyOpenGL from source, but in principle\ncan be done via `pip` as shown [here](http://pyopengl.sourceforge.net/).\nOtherwise, NumPy, Pillow, and PyGame are the remaining requirements for cr-geomag-prop.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhampel%2Fcr-geomag-prop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhampel%2Fcr-geomag-prop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhampel%2Fcr-geomag-prop/lists"}