示例#1
0
 def simulation(self):
     self.keeppos = simulator.KeepCol('pos')
     self.keepprob = simulator.KeepCol('probability')
     self.instrument.postprocess_steps = [self.keeppos, self.keepprob]
     source = self.source
     self.photons = source.generate_photons(self.n_photons)
     self.photons = self.pointing(self.photons)
     self.photons = self.instrument(self.photons)
def make_x3dplot(instrument):
    keeppos = simulator.KeepCol('pos')
    instrument.postprocess_steps = [keeppos]
    target = SkyCoord(30., 30., unit='deg')
    star = source.PointSource(coords=target, energy=.5, flux=1.)
    pointing = source.FixedPointing(coords=target)
    photons = star.generate_photons(5000)
    photons = pointing(photons)
    photons = instrument(photons)
    ind = (photons['probability'] >= 0) & (photons['facet'] >= 0)
    posdat = keeppos.format_positions()[ind, :, :]
    pp = photons[ind]
    fig = mlab.figure()
    plot_object(instrument, viewer=fig)
    plot_rays(posdat, scalar=pp['order'])
    return fig
示例#3
0
import copy
import numpy as np
gratingcolors = 'bgr'
for e in gas.elements:
    e.display = copy.deepcopy(e.display)
    e.ang = (np.arctan(e.pos4d[1, 3] / e.pos4d[2, 3]) + np.pi / 2) % (np.pi)
    e.colorid = int(e.ang / np.pi * 3)
    e.display['color'] = gratingcolors[e.colorid]

from mayavi import mlab
from astropy.coordinates import SkyCoord
from marxs import source, simulator
from marxs.visualization.mayavi import plot_object, plot_rays
# object to save intermediate photons positions after every step of the simulation
pos = simulator.KeepCol('pos')
instrum = simulator.Sequence(elements=[aper, mirr, gas, det, projectfp],
                             postprocess_steps=[pos])
star = source.PointSource(coords=SkyCoord(30., 30., unit='deg'),
                          energy=1.,
                          flux=1.)
pointing = source.FixedPointing(coords=SkyCoord(30., 30., unit='deg'))
photons = star.generate_photons(100)
photons = pointing(photons)
photons = instrum(photons)
ind = (photons['probability'] > 0) & (photons['facet'] >= 0)
posdat = pos.format_positions()[ind, :, :]

fig = mlab.figure(bgcolor=(1, 1, 1))
obj = plot_object(instrum, viewer=fig)
rays = plot_rays(posdat,
示例#4
0
 def post_process(self):
     self.KeepPos = simulator.KeepCol('pos')
     return [self.KeepPos]