Note

The following shows the code used to run this marx test. You can inspect it and adapt it to your needs, but you cannot copy and paste it directly because it depends on local $PATH and other environment variables. For example, we use a python function to manage the directory structure for all the images generated by all the tests instead of giving the file name directly to save images.

Image as source

Python : Make input image

In this example we use python to make a simple image as input. We setup a 3-d box and fill it with an emitting shell. We then integrate along one dimension to obtain a collapsed image. Physically, this represents the thin shell of a supernova explosion.

# Note that this code might not run if you directly copy and paste it:
# - Not all import statements are shown here
# - `self` is a reference to a test instance, which allows access to
#   parameters such as the directory where the test is run etc.

'''Make input image

In this example we use python to make a simple image as input.
We setup a 3-d box and fill it with an emitting shell. We then
integrate along one dimension to obtain a collapsed image.
Physically, this represents the thin shell of a supernova
explosion.
'''
import numpy as np
from astropy.wcs import WCS
from astropy.io import fits

# Actually to make this run faster, we'll do only one quadrant here
cube = np.zeros((201, 201, 201))
mg = np.mgrid[0: 201., 0:201, 0:201 ]
d = np.sqrt(mg[0, :, :, :]**2 + mg[1, :, :, :]**2 + mg[2, :, :, :]**2)
cube[(d > 160.) & (d < 170)] = 1
im = cube.sum(axis=0)
# Now rotate and put the four quarters together
image = np.zeros((401, 401))
image[:201, :201] = np.fliplr(np.flipud(im))
image[:201, 200:] = np.flipud(im)
image[200:, :201] = np.fliplr(im)
image[200:, 200:] = im

# Create a new WCS object.
w = WCS(naxis=2)
w.wcs.crpix = [100., 100.]
# Pixel size of our image shall be 1 arcsec
w.wcs.cdelt = [1. / 3600., 1. / 3600.]
w.wcs.ctype = ["RA---TAN", "DEC--TAN"]

# Now, write out the WCS object as a FITS header
header = w.to_header()

# header is an astropy.io.fits.Header object.  We can use it to create a new
# PrimaryHDU and write it to a file.
hdu = fits.PrimaryHDU(header=header, data=image)

# Save to FITS file
hdu.writeto(os.path.join(self.basepath, 'input_image.fits'), clobber=True)

marx : Run marx.

We run a monoenergetic simulation here for the Si XIII line at 6.65 Ang.

marx GratingType=NONE SourceType=IMAGE MinEnergy=1.9 MaxEnergy=1.9 S-ImageFile=input_image.fits OutputDir=image

marx2fits : step_2

marx2fits --pixadj=EDSER image image.fits

CIAO : ds9 images of the PSF

ds9 -width 800 -height 500 -log -cmap heat input_image.fits image.fits -pan to 4018 4141 physical -zoom 0.5 -sleep 1 -saveimage /melkor/d1/guenther/marx/doc/source/tests/figures/ImageSource_ds9.png -exit