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.

Off-axis PSF

CIAO : Get spectrum from flux correction

Use one of the asol files in only. Good enough for this example and simpler than stack syntax

asphist infile=download/primary/pcadf051708271N003_asol1.fits outfile=obs.asp evtfile=download/primary/acisf01068N003_evt2.fits clobber=yes
# It would be more accuarte to use mkwarf.
# However, that's slower and for our purposes an approximate solution is good enough.
mkarf detsubsys=ACIS-4 grating=NONE outfile=obs.arf obsfile=download/primary/acisf01068N003_evt2.fits asphistfile=obs.asp sourcepixelx=5246 sourcepixely=6890 engrid="0.3:8.0:0.1" maskfile=NONE pbkfile=NONE dafile=NONE verbose=1 mode=h clobber=yes

# We have to use the same energy binning in energy space here that we used for the arf!
# So, first convert the PI to energy (to a precision that's good enough).
dmtcalc "download/primary/acisf01068N003_evt2.fits[EVENTS][sky=circle(5246, 6890, 200)]" evt2_with_energy.fits  expr="energy=(float)pi*0.0149" clobber=yes
dmextract "evt2_with_energy.fits[bin energy=.3:7.999:0.1]" obs.spec clobber=yes opt=generic
dmcopy "obs.arf[cols energ_lo,energ_hi,specresp]" input_spec.fits clobber=yes
dmpaste input_spec.fits "obs.spec[cols counts]" input_spec_1.fits clobber=yes
dmtcalc input_spec_1.fits input_spec_2.fits  expr="flux=counts/((float)specresp * 1*3076.537611)" clobber=yes

# devide by binwidth to turn the flux into a flux DENSITY for marx
dmtcalc input_spec_2.fits input_spec_3.fits  expr="fluxdens=flux/0.1" clobber=yes
dmcopy "input_spec_3.fits[cols energ_hi,fluxdens]" "input_spec_marx.tbl[opt kernel=text/simple]" clobber=yes
dmcopy "input_spec_3.fits[cols energ_lo,energ_hi,flux]" "input_spec_saotrace.tbl[opt kernel=text/simple]" clobber=yes

# We now use a combination of some of the most obscure UNIX tools to
# bring the SAOTRACE input spectrum into the right format
# see http://cxc.harvard.edu/cal/Hrma/RDB/FileFormat.html

# Remove the leading "#" from the line with the column names
awk '{ sub(/\# ENERG_LO/,"ENERG_LO"); print }' < input_spec_saotrace.tbl > input_spec_saotrace.temp
# Then, replace spaces with tabs
tr ' ' \\t < input_spec_saotrace.temp > input_spec_saotrace.rdb

marx : Set marx parameters appropriate for observation

marx RA_Nom=85.3686133241 Dec_Nom=-70.1258501338 Roll_Nom=116.869547254 GratingType=NONE ExposureTime=2497.156339 DitherModel=FILE DitherFile=download/primary/pcadf051708271N003_asol1.fits TStart=51708271.7015 ACIS_Exposure_Time=3.2 SourceRA=84.914583 SourceDEC=-69.743611 DetectorType=ACIS-S DetOffsetX=-0.181463651326 DetOffsetZ=0.0125715765072 SpectrumType=FILE SpectrumFile=input_spec_marx.tbl OutputDir=marx_only SourceFlux=-1

marx2fits : No EDSER is available for HRC data

marx2fits --pixadj=NONE marx_only marx_only.fits

Lua input for SAOTrace : SAOTrace input matching observation

ra_pnt = 85.3686133241
dec_pnt = -70.1258501338
roll_pnt = 116.869547254

dither_asol_chandra{ file = "/melkor/d1/guenther/marx/test/testexp4/OffAxisPSF/download/primary/pcadf051708271N003_asol1.fits",
                     ra = ra_pnt, dec = dec_pnt, roll = roll_pnt }

point{ position = { ra = 84.914583,
          dec = -69.743611,
          ra_aimpt = ra_pnt,
          dec_aimpt = dec_pnt,
       },
       spectrum = { { file = "input_spec_saotrace.rdb",
                      units = "photons/s/cm2",
                      scale = 1,
                      format = "rdb",
                      emin = "ENERG_LO",
                      emax = "ENERG_HI",
                      flux = "FLUX"} }
    }

SAOTrace :

CXO time numbers are large and round-off error can appear which make SAOTrace fail. Therefore, shorten all times by about 0.01 sec to make sure.

trace-nest tag=saotrace srcpars=saotrace_source.lua tstart=51708271.7115  limit=2497.136339 limit_type=sec

marx : Run marx with SAOTrace ray file as input

marx RA_Nom=85.3686133241 Dec_Nom=-70.1258501338 Roll_Nom=116.869547254 GratingType=NONE ExposureTime=2497.156339 DitherModel=FILE DitherFile=download/primary/pcadf051708271N003_asol1.fits TStart=51708271.7015 ACIS_Exposure_Time=3.2 SourceRA=84.914583 SourceDEC=-69.743611 DetectorType=ACIS-S DetOffsetX=-0.181463651326 DetOffsetZ=0.0125715765072 SpectrumType=FILE SpectrumFile=input_spec_marx.tbl OutputDir=marx_saotrace SourceType=SAOSAC SAOSACFile=saotrace.fits SourceFlux=-1

marx2fits : Same settings as the marx2fits run above

marx2fits --pixadj=NONE marx_saotrace marx_saotrace.fits

CIAO : ds9 images of the PSF

ds9 -width 800 -height 500 -log -cmap heat download/primary/acisf01068N003_evt2.fits marx_only.fits marx_saotrace.fits -pan to 5256 6890 physical -bin about 5256 6890 -match frame wcs -match bin -frame 1 -regions command 'text 5:39:27.987 -69:43:52.31 # text=Observation font="helvetica 24"' -frame 2 -regions command 'text 5:39:27.987 -69:43:52.31 # text="only MARX" font="helvetica 24"' -frame 3 -regions command 'text 5:39:27.987 -69:43:52.31 # text=SAOTrace font="helvetica 24"' -regions command 'text 5:39:26.691 -69:44:09.93 # text="+ MARX" font="helvetica 24"' -saveimage /melkor/d1/guenther/marx/doc/source/tests/figures/OffAxisPSF_ds9.png -exit