Skip to content

Using calin with Docker

Stephen Fegan edited this page Jan 9, 2017 · 16 revisions

Install calin using Docker

If you haven't already done so, install Docker on your machine and then install calin from DockerHub.

  1. Install Docker on your system, assuming you have the rights to do this.
  2. Get the calin image for Docker by running : docker pull llrcta/calin

Example 1 : run the event simulator in a Python notebook

I have tested this on MacOS 10.11.6 with Docker 1.12.0-a, and under Ubuntu. In principle it should work under Windows also but I haven't been able to connect to the notebook (any help would be appreciated!).

  1. Docker containers are basically light-weight virtual machines. To share data between the Docker container and your host system you need to share a directory with the container. If you wish to store the images produced by the simulation you should make a directory on your host system to store them, e.g.:

    mkdir ~/CTA

  2. Run the Jupyter (Python) notebook server in a Docker container:

    docker run --pid=host -t -i -p 127.0.0.1:8800:8888 -v ~/CTA:/CTA llrcta/calin:latest jupyter-notebook

    • The option -p 127.0.0.1:8800:8888 propagates connections to the TCP port 8800 on the host to the port 8888 within the container, thereby allowing access to the Jupyter notebook server running on the container.
    • The option -v ~/CTA:/CTA below shares the host directory ~/CTA with Docker, making it available as /CTA within the container. This can be omitted if not wanted.
    • the option --pid=host seems to be necessary to overcome a bug in the Jupyter notebook kernel.
  3. Connect to the container from a browser on the host system. The notebook for the event simulator is in the directory `/usr/share/calin/examples' within the container file system. Open this in the Notebook by connecting to the URL :

    http://localhost:8800/tree/usr/share/calin/examples/simulation

  4. Click on toy event simulation for mst nectarcam.ipynb to open the simulation notebook and (automatically) start a Python kernel to run the code.

  5. Run the notebook code by clicking on the Cells -> Run All menu option, as illustrated below.

  6. Use the simple interface at the bottom of the notebook to generate events by specifying the desired parameters of:

    • Particle type (gamma ray, proton, electron or muon)
    • Energy, specified as log10 of energy in GeV between 10GeV (=1) and 100TeV (=5) with resolution of 16 steps/decade
    • Impact point with respect to telescope : distance and polar angle
    • Direction of propagation of primary : off-axis angle and polar angle
    • NSB rate in mean PE per channel per event
    • Photon poisson and PMT amplifier noise enable/disable
    • Ad hoc clipping at 4000PE enable/disable

  7. Press "Run Simulation" to generate an event. This can be quite slow at high energies. The image will be written to /CTA/event.pdf if the directory /CTA was mounted in step 2, and will also be visible on the host filesystem in ~/CTA.