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/1068/primary/pcadf051708271N003_asol1.fits outfile=obs.asp evtfile=download/1068/primary/acisf01068N003_evt2.fits.gz 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/1068/primary/acisf01068N003_evt2.fits.gz 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/1068/primary/acisf01068N003_evt2.fits.gz[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.53761100024)" 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

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/1068/primary/pcadf051708271N003_asol1.fits

marx : Set marx parameters appropriate for observation

marx RA_Nom=85.368613324065 Dec_Nom=-70.125850133808 Roll_Nom=116.86954725367 GratingType=NONE ExposureTime=2497.1563389971852 DitherModel=FILE DitherFile=download/1068/primary/pcadf051708271N003_asol1.fits TStart=51708271.701488 ACIS_Exposure_Time=3.2 SourceRA=84.914583 SourceDEC=-69.743611 DetectorType=ACIS-S DetOffsetX=-0.1814636513257093 DetOffsetZ=0.012571576507212967 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.368613324065
dec_pnt = -70.125850133808
roll_pnt = 116.86954725367

dither_asol_chandra{ file = "/melkor/d1/guenther/marx/test/testexp55/OffAxisPSF/download/1068/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.711488  limit=2497.1363389971852 limit_type=sec

marx : Run marx with SAOTrace ray file as input

marx RA_Nom=85.368613324065 Dec_Nom=-70.125850133808 Roll_Nom=116.86954725367 GratingType=NONE ExposureTime=2497.1563389971852 DitherModel=FILE DitherFile=download/1068/primary/pcadf051708271N003_asol1.fits TStart=51708271.701488 ACIS_Exposure_Time=3.2 SourceRA=84.914583 SourceDEC=-69.743611 DetectorType=ACIS-S DetOffsetX=-0.1814636513257093 DetOffsetZ=0.012571576507212967 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/1068/primary/acisf01068N003_evt2.fits.gz 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