Coder Social home page Coder Social logo

python-simulation / black-hole-simulation-using-python Goto Github PK

View Code? Open in Web Editor NEW
102.0 5.0 19.0 57.21 MB

Non-spinning black hole simulation based on geodesics equation

Python 100.00%
simulation python geodesics-equation black-hole general-relativity interpolation schwarzschild

black-hole-simulation-using-python's Introduction

Black-hole-simulation-using-python

Non-spinning black hole simulation based on photon geodesic equation. This program takes an equirectangular image and returns the image distorded by the black hole. Results can be saved in form of matrices to call them later. An offset system can be used to simulate a moving background by saving a series of simulations with different offset.

An optional GUI can be used to control the BlackHole class.

Animation

An animation can be easily generated using the GUI.

Example

Black Hole spinning animation

black-hole-simulation-using-python's People

Contributors

marcelrsoub avatar python-simulation avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

black-hole-simulation-using-python's Issues

Not works anymore

Hi i have just tried to run your code using Pillow 5.1, without luck

┌<▸> ~/g/Black-hole-simulation-using-python
└➤
pip install -r requirements.txt
Requirement already satisfied: numpy>=1.14 in /usr/local/anaconda3/lib/python3.11/site-packages (from -r requirements.txt (line 1)) (1.24.3)
Requirement already satisfied: matplotlib>=3.1 in /usr/local/anaconda3/lib/python3.11/site-packages (from -r requirements.txt (line 2)) (3.7.1)
Requirement already satisfied: scipy>=1.1 in /usr/local/anaconda3/lib/python3.11/site-packages (from -r requirements.txt (line 3)) (1.11.1)
ERROR: Could not find a version that satisfies the requirement PIL>=5.1 (from versions: none)
ERROR: No matching distribution found for PIL>=5.1

I have Pillow 9.4.0, so do i have to downgrade?

┌<▸> ~/g/Black-hole-simulation-using-python
└➤
pip install Pillow==5.1
Collecting Pillow==5.1
Downloading Pillow-5.1.0.tar.gz (14.3 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 14.3/14.3 MB 4.4 MB/s eta 0:00:00
Preparing metadata (setup.py) ... done
Building wheels for collected packages: Pillow
Building wheel for Pillow (setup.py) ... done
Created wheel for Pillow: filename=Pillow-5.1.0-cp311-cp311-macosx_10_9_x86_64.whl size=462690 sha256=f2e4faf891e91b33565f6fad427b461b9beacabb822ad0e614d0ea450011b4c7
Stored in directory: /Users/aironman/Library/Caches/pip/wheels/90/8f/90/401a3b33bdfc4ffc28443b3ec2d54766c682523e95e2693658
Successfully built Pillow
Installing collected packages: Pillow
Attempting uninstall: Pillow
Found existing installation: Pillow 9.4.0
Uninstalling Pillow-9.4.0:
Successfully uninstalled Pillow-9.4.0
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
matplotlib 3.7.1 requires pillow>=6.2.0, but you have pillow 5.1.0 which is incompatible.
bokeh 3.2.1 requires pillow>=7.1.0, but you have pillow 5.1.0 which is incompatible.
scikit-image 0.20.0 requires pillow>=9.0.1, but you have pillow 5.1.0 which is incompatible.
imageio 2.31.1 requires pillow>=8.3.2, but you have pillow 5.1.0 which is incompatible.
Successfully installed Pillow-5.1.0

<▸> ~/g/Black-hole-simulation-using-python
└➤
pip install -r requirements.txt

Requirement already satisfied: numpy>=1.14 in /usr/local/anaconda3/lib/python3.11/site-packages (from -r requirements.txt (line 1)) (1.24.3)
Requirement already satisfied: matplotlib>=3.1 in /usr/local/anaconda3/lib/python3.11/site-packages (from -r requirements.txt (line 2)) (3.7.1)
Requirement already satisfied: scipy>=1.1 in /usr/local/anaconda3/lib/python3.11/site-packages (from -r requirements.txt (line 3)) (1.11.1)
ERROR: Could not find a version that satisfies the requirement PIL>=5.1 (from versions: none)
ERROR: No matching distribution found for PIL>=5.1

┌<▪> ~/g/Black-hole-simulation-using-python
└➤
pip list | grep Pillow
Pillow 5.1.0

┌<▸> ~/g/Black-hole-simulation-using-python
└➤
python black_hole.py
Openning /Users/aironman/git/Black-hole-simulation-using-python/images/milkyway.jpg
Traceback (most recent call last):
File "/Users/aironman/git/Black-hole-simulation-using-python/black_hole.py", line 1013, in
blackhole = BlackHole()
^^^^^^^^^^^
File "/Users/aironman/git/Black-hole-simulation-using-python/black_hole.py", line 49, in init
self.open(img_name, size=self.axe_X)
File "/Users/aironman/git/Black-hole-simulation-using-python/black_hole.py", line 143, in open
self.img_original = Image.open(img_name, mode='r')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/anaconda3/lib/python3.11/site-packages/PIL/Image.py", line 2559, in open
preinit()
File "/usr/local/anaconda3/lib/python3.11/site-packages/PIL/Image.py", line 376, in preinit
from . import JpegImagePlugin
File "/usr/local/anaconda3/lib/python3.11/site-packages/PIL/JpegImagePlugin.py", line 41, in
from . import Image, ImageFile, TiffImagePlugin
File "/usr/local/anaconda3/lib/python3.11/site-packages/PIL/TiffImagePlugin.py", line 400, in
class ImageFileDirectory_v2(collections.MutableMapping):
^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'collections' has no attribute 'MutableMapping'

┌<▸> ~/g/Black-hole-simulation-using-python
└➤
pip uninstall Pillow
Found existing installation: Pillow 5.1.0
Uninstalling Pillow-5.1.0:
Would remove:
/usr/local/anaconda3/lib/python3.11/site-packages/Pillow-5.1.0.dist-info/*
Proceed (Y/n)? Y
Successfully uninstalled Pillow-5.1.0

┌<▪> ~/g/Black-hole-simulation-using-python
└➤
pip install pillow
Collecting pillow
Obtaining dependency information for pillow from https://files.pythonhosted.org/packages/07/22/93d6b5aa5917d09ec7088a2c4d1821848f3f95fbdc2633ba9d9fc28444a1/Pillow-10.1.0-cp311-cp311-macosx_10_10_x86_64.whl.metadata
Using cached Pillow-10.1.0-cp311-cp311-macosx_10_10_x86_64.whl.metadata (9.5 kB)
Using cached Pillow-10.1.0-cp311-cp311-macosx_10_10_x86_64.whl (3.5 MB)
Installing collected packages: pillow
Successfully installed pillow-10.1.0

┌<▸> ~/g/Black-hole-simulation-using-python
└➤
python black_hole.py

Openning /Users/aironman/git/Black-hole-simulation-using-python/images/milkyway.jpg
Traceback (most recent call last):
File "/Users/aironman/git/Black-hole-simulation-using-python/black_hole.py", line 1013, in
blackhole = BlackHole()
^^^^^^^^^^^
File "/Users/aironman/git/Black-hole-simulation-using-python/black_hole.py", line 49, in init
self.open(img_name, size=self.axe_X)
File "/Users/aironman/git/Black-hole-simulation-using-python/black_hole.py", line 149, in open
self.img_debut = self.img_resize(size)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/aironman/git/Black-hole-simulation-using-python/black_hole.py", line 167, in img_resize
self.img_debut = self.img_debut.resize((axe_X, axe_Y), Image.ANTIALIAS)
^^^^^^^^^^^^^^^
AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'

So, i need Pillow >=5.1 but bellow 10.1.0...

Code of the old results

Hi, I saw your old results (images) and they turned to be the things that I was exactly looking for, can you please share the code you used to create these plots?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.