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/15713/primary/acisf15713N002_evt2.fits.gz[sky=circle(4096,4073,6)]" obs.fits clobber=yes

shell : Unzip fits file.

MARX cannot read zipped fits files, so we need to unzip the .fits.gz asol files that we downloaded from the archive. On the other hand, CIAO tools work on both zipped or unzipped files, so there is no need to unzip all of them, just the files that MARX reads as input.

gunzip -f download/15713/primary/pcadf508966864N002_asol1.fits

marx : Run in energy band, match observational setup

marx RA_Nom=182.25909891372 Dec_Nom=-51.341662012085 Roll_Nom=33.972028259258 GratingType=NONE ExposureTime=10190.806809961796 DitherModel=FILE DitherFile=download/15713/primary/pcadf508966864N002_asol1.fits TStart=508966864.84771 ACIS_Exposure_Time=0.7 SourceRA=182.259167 SourceDEC=-51.344667 DetectorType=ACIS-S DetOffsetX=0.0014449422646707344 DetOffsetZ=-0.007542945902798692 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 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')
fig1.savefig(self.figpath('grades'), bbox_inches='tight')

fig2 = plot22(obs, sim, 'fltgrade')
fig2.savefig(self.figpath('fltgrades'), bbox_inches='tight')