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-BI chip

CIAO : Download data, extract point source

punlearn dmcopy
dmcopy "download/primary/acisf15713N002_evt2.fits[sky=circle(4096,4073,6)]" obs.fits clobber=yes

marx : Run in energy band, match observational setup

marx RA_Nom=182.259098914 Dec_Nom=-51.3416620121 Roll_Nom=33.9720282593 GratingType=NONE ExposureTime=10190.80681 DitherModel=FILE DitherFile=download/primary/pcadf508966864N002_asol1.fits TStart=508966864.848 ACIS_Exposure_Time=0.7 SourceRA=182.259167 SourceDEC=-51.344667 DetectorType=ACIS-S DetOffsetX=0.00144494226467 DetOffsetZ=-0.0075429459028 MinEnergy=0.3 MaxEnergy=2.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')

fig2 = plot22(obs, sim, 'fltgrade')