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.

Grades on an ACIS-FI chip

CIAO : Download data, extract point source

punlearn dmcopy
dmcopy "download/primary/acisf04496N003_evt2.fits[sky=circle(4072,4065,5)]" obs.fits clobber=yes

marx : Run in energy band, match observational setup

marx RA_Nom=167.965047745 Dec_Nom=-61.3085362934 Roll_Nom=222.900684193 GratingType=NONE ExposureTime=41183.73313 DitherModel=FILE DitherFile=download/primary/pcadf238342681N003_asol1.fits TStart=238342682.01 ACIS_Exposure_Time=3.2 SourceRA=167.974167 SourceDEC=-61.306944 DetectorType=ACIS-I DetOffsetX=0.0014398546217 DetOffsetZ=0.0050286306018 MinEnergy=2.0 MaxEnergy=4.0

marx2fits : use EDSER

marx2fits --pixadj=EDSER point marxsim.fits

Python : Plot grade distribution

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

def plotpie(ax, data, col, colors=['r', 'c', 'm', 'orange', 'g'],
    '''Bin up events data and display in pie chart'''
    counts = np.bincount(colname_case(data, col))
    labels = np.arange(len(counts))
    ind = counts > 0
    ax.pie(counts[ind], labels=labels[ind], colors=colors,
           autopct='%2i%%', **plotargs)

def plot22(obs, sim, colname, energies=[[300, 1000], [1000, 2000]]):
    '''Place 2*2 piecharts on a figure.
    obs : `astropy.table.Table`
        Observed events
    sim : `astropy.table.Table`
        Events simulated with MARX
    energies : list
        Two energy bands in eV defined as a list of lists.

    fig : `matplotlib.figure.Figure`
        Figure with plot
    fig = plt.figure(figsize=(7, 7))
    for i, data in enumerate([obs, sim]):
        for j, en in enumerate(energies):
            ax = fig.add_subplot(2, 2, i * 2 + j + 1, aspect='equal')
            obssimlab = 'Obs' if i == 0 else 'MARX'
            energylab = '{0} - {1} eV'.format(en[0], en[1])
            ax.set_title('{0}: {1}'.format(obssimlab, energylab))
            energy = colname_case(data, 'energy')
            plotpie(ax, data[(energy > en[0]) & (energy < en[1])], colname)
    return fig

'''Plot grade distribution'''
obs =, 'obs.fits'), hdu=1)
sim =, 'marxsim.fits'), hdu=1)

fig1 = plot22(obs, sim, 'grade', [[2000., 3000.], [3000., 4000.]])

fig2 = plot22(obs, sim, 'fltgrade', [[2000., 3000.], [3000., 4000.]])