Esempio n. 1
0
File: test.py Progetto: gyoto/Gyoto
import gyoto
import sys
import os.path

# The name of the Gyoto plug-in that can be loaded in a given Python
# session is the same as the name of the Python executable
python_plugin = os.path.basename(sys.executable)
gyoto.requirePlugin(python_plugin)

sp = gyoto.Spectrum("Python")
sp.set("Module", "gyoto_sample_spectra")
sp.set("Class", "PowerLaw")
sp.set("Parameters", (1.0, 10.0))
print("value: {}".format(sp(3e8 / 2e-6)))
sp.set("Parameters", (2.0, 20.0))
print("value: {}".format(sp(3e8 / 2e-6)))

# BlackBody6000 does not accept any parameter:
sp = gyoto.Spectrum("Python")
sp.set("Module", "gyoto_sample_spectra")
sp.set("Class", "BlackBody6000")
print("value: {}".format(sp(3e8 / 2e-6)))

sp.set("Module", "gyoto_sample_spectra")
sp.set("Class", "PowerLaw")
sp.set("Parameters", (2.0, 0.0))
print("using Python integrate: {}".format(sp.integrate(1.0, 2.0)))

sp2 = gyoto.Spectrum("PowerLaw")
sp2.set("Exponent", 0.0)
sp2.set("Constant", 2.0)
Esempio n. 2
0
# heuristics. Respawning as gyoto instead of gyoto-mpi-worker.VERSION
# saves us from hard-coding VERSION, but is slightly unsafe. Make sure
# the right (ABI-compatible) version of gyoto is first in your PATH!
import os
if os.getenv('OMPI_COMM_WORLD_RANK', '0') != '0':
    os.execlp("gyoto", "")

# 2- Let mpi4py initialize the MPI environment:
import mpi4py.MPI

# 3- Prepare Gyoto::Scenery to ray-trace
import numpy
import matplotlib as ml
import matplotlib.pyplot as plt
import gyoto
gyoto.requirePlugin("stdplug")
import gyoto_std

a=gyoto.Factory("../doc/examples/example-moving-star.xml")
sc=a.getScenery()
sc.nThreads(1)
sc.astrobj().opticallyThin(False)

# 4- Prepare storage for ray-traced quantities

# 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)
Esempio n. 3
0
import numpy
import unittest
import gyoto
gyoto.requirePlugin('stdplug')
import gyoto_std

class TestStar(unittest.TestCase):

    def test_setInitCoord(self):
        st=gyoto_std.Star()
        gg=gyoto_std.KerrBL()
        st.metric(gg)
        pos_list=(600., 9., 1.5707999999999999741, 0)
        vel_list=(0., 0., 0.037037)
        st.setInitCoord(pos_list, vel_list)
        dst=numpy.zeros(8, float)
        dst2=numpy.zeros(8, float)
        st.getInitialCoord(dst)
        st.setPosition(pos_list)
        st.setVelocity(vel_list)
        st.getInitialCoord(dst2)
        self.assertTrue((dst == dst2).all())