[Debian-astro-commits] [gyoto] 182/221: Add python/example-mpi.py showing how to use MPI

Thibaut Jean-Claude Paumard thibaut at moszumanska.debian.org
Fri May 22 20:52:45 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 aa91388eef6c4f7b0d6d77bb9f85232fec356ba8
Author: Thibaut Paumard <paumard at users.sourceforge.net>
Date:   Thu Jan 8 14:43:48 2015 +0100

    Add python/example-mpi.py showing how to use MPI
---
 python/example-mpi.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/python/example-mpi.py b/python/example-mpi.py
new file mode 100644
index 0000000..f69020f
--- /dev/null
+++ b/python/example-mpi.py
@@ -0,0 +1,56 @@
+#/bin/env python
+# -*- coding: utf-8 -*-
+# Example file for gyoto with MPI
+
+# Let mpi4py initilize the MPI environment:
+import mpi4py.MPI
+
+import numpy
+import matplotlib as ml
+import matplotlib.pyplot as plt
+import gyoto
+gyoto.loadPlugin("stdplug")
+import gyoto_std
+
+a=gyoto.Factory("../doc/examples/example-moving-star.xml")
+sc=a.getScenery()
+sc.nThreads(1)
+sc.astrobj().opticallyThin(False)
+
+# Ray-trace scenery
+
+# Prepare array for holding results
+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)
+
+# Store array pointers in AstrobjProperties
+aop=gyoto.AstrobjProperties()
+aop.Intensity(intensity)
+aop.EmissionTime(time)
+aop.MinDistance(distance)
+
+# Prepare Coord2dSet to select what Photons to launch
+ii=gyoto.Range(1, res, 1)
+jj=gyoto.Range(1, res, 1)
+grid=gyoto.Grid(ii, jj)
+
+# Spawn processes and clone scenery into them:
+sc.mpiSpawn(4)
+sc.mpiClone()
+
+# Ray-trace
+sc.rayTrace(grid, aop)
+
+# Terminate workers
+sc.mpiTerminate()
+
+#plt.imshow(intensity)
+#plt.show()
+#plt.imshow(time)
+#plt.show()
+#plt.imshow(distance)
+#plt.show()
+
+print("All done, exiting")

-- 
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