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.

Grades on an ACIS-FI chip

CIAO : Download data, extract point source

punlearn dmcopy
dmcopy "download/4496/primary/acisf04496N003_evt2.fits.gz[sky=circle(4072,4065,5)]" 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/4496/primary/pcadf238342681N003_asol1.fits

marx : Run in energy band, match observational setup

marx RA_Nom=167.96504774467 Dec_Nom=-61.308536293407 Roll_Nom=222.90068419274 GratingType=NONE ExposureTime=41183.73312997818 DitherModel=FILE DitherFile=download/4496/primary/pcadf238342681N003_asol1.fits TStart=238342682.00964 ACIS_Exposure_Time=3.2 SourceRA=167.974167 SourceDEC=-61.306944 DetectorType=ACIS-I DetOffsetX=0.0014398546217030406 DetOffsetZ=0.0050286306017994775 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 plot22(obs, sim, colname, energies=[[300, 1000], [1000, 2000]]):
    '''Place 2*2 piecharts on a figure.
    Parameters
    ----------
    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.

    Returns
    -------
    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 = Table.read(os.path.join(self.basepath, 'obs.fits'), hdu=1)
sim = Table.read(os.path.join(self.basepath, 'marxsim.fits'), hdu=1)

fig1 = plot22(obs, sim, 'grade', [[2000., 3000.], [3000., 4000.]])
fig1.savefig(self.figpath('grades'), bbox_inches='tight')

fig2 = plot22(obs, sim, 'fltgrade', [[2000., 3000.], [3000., 4000.]])
fig2.savefig(self.figpath('fltgrades'), bbox_inches='tight')