[Debian-astro-commits] [gyoto] 159/221: Add Python example, revert spurious changes in Screen (some unconditional debug output)

Thibaut Jean-Claude Paumard thibaut at moszumanska.debian.org
Fri May 22 20:52:42 UTC 2015


This is an automated email from the git hooks/post-receive script.

thibaut pushed a commit to branch master
in repository gyoto.

commit 0f27551c51a02fffebc3a4dfa3d4030bde9941f6
Author: Thibaut Paumard <paumard at users.sourceforge.net>
Date:   Thu Dec 18 17:34:55 2014 +0100

    Add Python example, revert spurious changes in Screen (some unconditional debug output)
---
 lib/Screen.C      |  3 +-
 python/example.py | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 86 insertions(+), 2 deletions(-)

diff --git a/lib/Screen.C b/lib/Screen.C
index 4340973..5096ed4 100644
--- a/lib/Screen.C
+++ b/lib/Screen.C
@@ -90,7 +90,6 @@ Screen::Screen() :
     screen2_[ii]=0.;
     screen3_[ii]=0.;
   }
-  std::cerr << "Screen created" << std::endl;
 }
 
 Screen::Screen(const Screen& o) :
@@ -127,7 +126,7 @@ Screen::Screen(const Screen& o) :
 }
 Screen * Screen::clone() const { return new Screen(*this); }
 
-Screen::~Screen(){if (mask_) delete [] mask_; std::cerr << "Screen destroyed" << std::endl;}
+Screen::~Screen(){if (mask_) delete [] mask_;}
 
 std::ostream& Screen::print( std::ostream& o) const {
   o << "distance="    << distance_ << ", " ;
diff --git a/python/example.py b/python/example.py
new file mode 100644
index 0000000..53536f0
--- /dev/null
+++ b/python/example.py
@@ -0,0 +1,85 @@
+import numpy
+import matplotlib as ml
+import matplotlib.pyplot as plt
+import gyoto
+
+a=gyoto.Factory("../doc/examples/example-moving-star.xml")
+sc=a.getScenery()
+sc.nThreads(8)
+sc.astrobj().opticallyThin(False)
+
+# Trace and plot NULL geodesic:
+
+ph=gyoto.Photon()
+ph.setInitialCondition(sc.metric(), sc.astrobj(), sc.screen(), 0., 0.)
+ph.hit()
+n=ph.get_nelements()
+t=gyoto.array_double(n)
+r=gyoto.array_double(n)
+theta=gyoto.array_double(n)
+phi=gyoto.array_double(n)
+ph.getCoord(t, r, theta, phi)
+
+t2=numpy.zeros(n)
+r2=numpy.zeros(n)
+theta2=numpy.zeros(n)
+phi2=numpy.zeros(n)
+
+for i in range(0, n):
+    t2[i]=t[i]
+    r2[i]=r[i]
+    theta2[i]=theta[i]
+    phi2[i]=phi[i]
+
+plt.plot(t2, r2)
+plt.show()
+
+# Trace and plot timelike geodesic
+
+wl=gyoto.castToWorldline(sc.astrobj());
+wl.xFill(1000)
+
+n=wl.get_nelements()
+t=gyoto.array_double(n)
+r=gyoto.array_double(n)
+theta=gyoto.array_double(n)
+phi=gyoto.array_double(n)
+wl.getCoord(t, r, theta, phi)
+
+t2=numpy.zeros(n)
+r2=numpy.zeros(n)
+theta2=numpy.zeros(n)
+phi2=numpy.zeros(n)
+
+for i in range(0, n):
+    t2[i]=t[i]
+    r2[i]=r[i]
+    theta2[i]=theta[i]
+    phi2[i]=phi[i]
+
+plt.plot(r2*numpy.cos(phi2), r2*numpy.sin(phi2))
+plt.show()
+
+# Ray-trace scenery
+
+res=sc.screen().resolution()
+intensity=numpy.zeros((res, res), dtype=float)
+time=numpy.zeros((res, res), dtype=float)
+distance=numpy.zeros((res, res), dtype=float)
+aop=gyoto.Properties()
+aop.Intensity(intensity)
+aop.EmissionTime(time)
+aop.MinDistance(distance)
+
+ii=gyoto.Range(1, res, 1)
+jj=gyoto.Range(1, res, 1)
+grid=gyoto.Grid(ii, jj)
+
+sc.rayTrace(grid, aop)
+
+plt.imshow(intensity)
+plt.show()
+plt.imshow(time)
+plt.show()
+plt.imshow(distance)
+plt.show()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-astro/packages/gyoto.git



More information about the Debian-astro-commits mailing list