Exemplo n.º 1
0
import numpy as np

from marxs.source import PointSource, FixedPointing
import astropy.units as u
from astropy.coordinates import SkyCoord
from ..constants import xyz2zxy
from .. import Arcus

import pytest

e = 0.5 * u.keV

mysource = PointSource(coords=SkyCoord(30. * u.deg, 30. * u.deg),
                       energy=e)
mypointing = FixedPointing(coords=SkyCoord(30 * u.deg, 30. * u.deg),
                           reference_transform=xyz2zxy)


@pytest.mark.parametrize("instrument", [Arcus(channels=['1']),
                                        Arcus(channels=['2m'])])
def test_orders_are_focussed(instrument):
    '''Check that the orders look reasonable.

    This test tries to be generic so that coordinate system etc. can be
    changed later, but still check that all light is focused to
    one point to detect error in setting up the mirrors.
    '''
    photons = mysource.generate_photons(2e4 * u.s)
    photons = mypointing(photons)
    photons = instrument(photons)
Exemplo n.º 2
0
import marxs.visualization.mayavi
from marxs.source import PointSource, FixedPointing


import sys
sys.path.append('../redsox')
import redsox
from mirror import Ageom

%matplotlib


my_source = PointSource(coords=SkyCoord(30., 30., unit='deg'), energy=0.25,
                        polarization=120.,
                        geomarea=Ageom)
my_pointing = FixedPointing(coords=SkyCoord(30., 30., unit='deg'),
                            reference_transform=redsox.xyz2zxy)

photons = my_source.generate_photons(1)
photons = my_pointing(photons)

photons = redsox.redsox(photons)


fig = mlab.figure(**kwargsfig)
redsox.mirror.display = copy.deepcopy(redsox.mirror.display)
redsox.mirror.display['color'] = (1., 0.6, 0.)
out = marxsavi.plot_object(redsox.redsox, viewer=fig)

pos_full = redsox.keeppos.format_positions()
ind = np.isfinite(photons['order']) & (photons['grating_id'] < 5000)
pos = np.empty((pos_full.shape[0], pos_full.shape[1] + 1, pos_full.shape[2]))
Exemplo n.º 3
0
detfp.display['opacity'] = 0.2

# Place an additional detector on the Rowland circle.
detcirc = marxs.optics.CircularDetector.from_rowland(rowland, width=20)
detcirc.loc_coos_name = ['detcirc_phi', 'detcirc_y']
detcirc.detpix_name = ['detcircpix_x', 'detcircpix_y']
detcirc.display['opacity'] = 0.2

uptomirror = Sequence(elements=[aper, mirror])

keeppos = marxs.simulator.KeepCol('pos')
mission = Sequence(elements=[aper, mirror, gas, catsupport, det, detfp],
                   postprocess_steps=[keeppos])

star = PointSource(coords=(23., 45.), flux=5.)
pointing = FixedPointing(coords=(23., 45.))
photons = star.generate_photons(exposuretime=2000)
photons = pointing(photons)

### Look at different energies for some orders in detail
p = uptomirror(photons.copy())

gratings = copy.deepcopy(gas)
p1 = p.copy()
p02 = p.copy()
p02['energy'] = 0.2

gratingeff = marxs.optics.constant_order_factory(0)
for elem in gratings.elements:
    elem.order_selector = gratingeff
Exemplo n.º 4
0
import numpy as np

from marxs.missions import chandra
from marxs.missions.chandra.hess import HETG
from marxs.source import ConstantPointSource, FixedPointing
from marxs.optics import MarxMirror
from marxs.analysis import find_best_detector_position, measure_FWHM

mysource = ConstantPointSource((30., 30.), energy=1., flux=50.)
mypointing = FixedPointing(coords=(30, 30.))
# mypointing = chandra.LissajousDither(coords=(30.,30.), roll=0.)
marxm = MarxMirror('./marxs/optics/hrma.par', position=np.array([0., 0, 0]))
hetg = HETG()
acis = chandra.ACIS(chips=[4, 5, 6, 7, 8, 9],
                    aimpoint=chandra.AIMPOINTS['ACIS-S'])
#mydet = FlatDetector(zoom=1e5, pixsize=23.985e-3)

# Chandra class is not finished yet.
Chandra = chandra.Chandra(sequence=[mypointing, marxm, hetg, acis])

photons = mysource.generate_photons(5000)
#photons = Chandra(photons)

photons = mypointing(photons)
photons = marxm(photons)
photons = photons[photons['probability'] > 0]

photons = hetg(photons)
photons['hetgy'] = photons['pos'].data[:, 1] / photons['pos'].data[:, 3]
photons['hetgz'] = photons['pos'].data[:, 2] / photons['pos'].data[:, 3]
Exemplo n.º 5
0
    ind = p['probability'] > 0
    plt.plot(p['det_x'][ind], p['det_y'][ind], c+'s', label='{0}'.format(x))
    plt.plot(p['det_x'][~ind], p['det_y'][~ind], c+'.')

plt.legend()


### for Ralf - step 1

import numpy as np
from marxs.source import ConstantPointSource, FixedPointing
from marxs.design import RowlandTorus, find_radius_of_photon_shell, GratingArrayStructure
from marxs.optics import MarxMirror, FlatGrating, uniform_efficiency_factory, FlatDetector

mysource = ConstantPointSource((30., 30.), 1., 1.)
mypointing = FixedPointing(coords=(30, 30.))
marxm = MarxMirror('./marxs/optics/hrma.par', position=np.array([0., 0,0]))

photons = mysource.generate_photons(10000)
photons = mypointing.process_photons(photons)
photons = marxm.process_photons(photons)

# design the gratings
radius0 = find_radius_of_photon_shell(photons, 0, 9e4)

mytorus = RowlandTorus(9e4/2, 9e4/2)
gratingeff = uniform_efficiency_factory()
mygas = GratingArrayStructure(mytorus, d_facet=60., x_range=[5e4,1e5], radius=[5380., 5500.], facetclass=FlatGrating, facetargs={'zoom': 30, 'd':0.002, 'order_selector': gratingeff})

pg = photons[photons['mirror_shell'] == 0]
pg = mygas.process_photons(pg)
Exemplo n.º 6
0
from astropy import table
from astropy.utils.metadata import enable_merge_strategies
from astropy.io import fits
import arcus

n_photons_list = [1e4, 1e5, 1e6, 1e7]

wave = np.arange(8., 50., 0.5) * u.Angstrom
energies = wave.to(u.keV, equivalencies=u.spectral()).value

for n_photons in n_photons_list:
    t0 = time.time()
    mysource = PointSource((0., 0.), energy=0.5, flux=1.)
    photons = mysource.generate_photons(n_photons / 2)

    mypointing = FixedPointing(coords=(0., 0.))
    photons = mypointing(photons)
    photons = arcus.arcus_joern(photons)

    photonsm = mysource.generate_photons(n_photons / 2)
    photonsm = mypointing(photonsm)
    photonsm = arcus.arcus_joernm(photonsm)
    photonsm['aperture'] += 2

    with enable_merge_strategies(utils.MergeIdentical):
        out = table.vstack([photons, photonsm])

        photons.write(tempfile.NamedTemporaryFile(), format='fits')
    runtime = time.time() - t0
    print 'n: {0:5.1e}, total time: {1:5.2f} s, time per photon: {2:5.1e} s'.format(
        n_photons, runtime, runtime / n_photons)
Exemplo n.º 7
0
import numpy as np

from marxs.missions import chandra
from marxs.missions.chandra.hess import HETG
from marxs.source import ConstantPointSource, FixedPointing
from marxs.optics import MarxMirror
from marxs.analysis import find_best_detector_position, measure_FWHM

mysource = ConstantPointSource((30., 30.), energy=1., flux=50.)
mypointing = FixedPointing(coords=(30, 30.))
# mypointing = chandra.LissajousDither(coords=(30.,30.), roll=0.)
marxm = MarxMirror('./marxs/optics/hrma.par', position=np.array([0., 0,0]))
hetg = HETG()
acis = chandra.ACIS(chips=[4,5,6,7,8,9], aimpoint=chandra.AIMPOINTS['ACIS-S'])
#mydet = FlatDetector(zoom=1e5, pixsize=23.985e-3)

# Chandra class is not finished yet.
Chandra = chandra.Chandra(sequence=[mypointing, marxm, hetg, acis])

photons = mysource.generate_photons(5000)
#photons = Chandra(photons)

photons = mypointing(photons)
photons = marxm(photons)
photons = photons[photons['probability'] > 0]

photons = hetg(photons)
photons['hetgy'] = photons['pos'].data[:,1]/photons['pos'].data[:,3]
photons['hetgz'] = photons['pos'].data[:,2]/photons['pos'].data[:,3]

photons = acis(photons)