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.

# Compiling a USER source¶

## Python : compile USER code¶

marx ships with a few examples of user sources. We pick one of them, copy them to the right directory and compile it with gcc.

# 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.

'''compile USER code

|marx| ships with a few examples of user sources. We pick one
of them, copy them to the right directory and compile it with gcc.
'''
marxpath = self.conf.get('marx', 'path')
src = os.path.join(marxpath,
'share', 'doc', 'marx', 'examples', 'user-source')
for f in ['point.c', 'user.h']:
shutil.copy(os.path.join(src, f),
os.path.join(self.basepath, f))

jdmath_h = os.path.join(marxpath, 'include')
jdmath_a = os.path.join(marxpath, 'lib', 'libjdmath.a')

subprocess.call(['gcc', '-I' + jdmath_h, jdmath_a,
'-shared', 'point.c', '-o', 'point.so'])


## marx : run USER source¶

marx SourceType=USER UserSourceFile=point.so


## marx2fits : turn into fits file¶

marx2fits --pixadj=EDSER point point.fits


## CIAO : ds9 images of the PSF¶

ds9 -width 800 -height 500 -log -cmap heat point.fits -pan to 4018 4141 physical -zoom 8 -saveimage /melkor/d1/guenther/marx/doc/source/tests/figures/UserSource_ds9.png -exit