Skip to content

Installation

J Tseng edited this page Aug 15, 2023 · 7 revisions

This page contains information on how to get started running (and later developing code for) snewpdag.

Environment

snewpdag had its initial development in python 3.8.2.

It's recommended to use a virtual environment. pyenv is pretty handy, and what I've used here. Look at the installation instructions (which can be installed in your local directory, and don't require superuser privileges). It's also helpful to add the pyenv-virtualenv plugin, as we use it in the instructions below.

(Here is an older primer on python virtual environments for information on virtual environments.)

Once you have pyenv set up, install the python version with pyenv install 3.8.2, or a later version of python. Then go to the parent directory for what you plan to be your development directory (here assumed to be snewpdag) and

git clone [email protected]:SNEWS2/snewpdag.git
pyenv virtualenv 3.8.2 snewpdag-venv
cd snewpdag
pyenv local snewpdag-venv

You can replace snewpdag-venv with snewpdag, since it's all right for the the virtual environment name (snewpdag-venv) to be the same as the working directory.

From here on, when you cd into the directory, it'll activate the virtual environment for you. And when you leave the directory, it'll deactivate it for you.

External packages

Required

External packages (which can usually be installed using pip) include numpy and healpy. These should pull in scipy and matplotlib as well.

pip install numpy
pip install healpy

In the case of healpy, I found that I needed to install one of its dependencies explicitly. This was the cfitsio library, which supposedly is included in healpy. The build process didn't seem to find the resulting local cfitsio library, so instead I installed the libcfitsio-dev package on my Ubuntu 16 system.

Optional

The repository lightcurve_match contains (among other things) code for generating lightcurves which can be used as input for snewpdag generator plugins.

lightcurve_match has been linked as a submodule. To clone lightcurve_match along with snewpdag,

  git clone --recurse-submodules

If you've already cloned, you'll see an empty externals/lightcurve_match subdirectory under snewpdag. The following commands will populate it:

  git submodule init
  git submodule update

This package also requires ROOT, so set it up now, and then

  make lightcurvesim

Run unit tests

Unit tests are useful to check that individual parts are doing what they should do. Ideally, one writes these at development time, but sometimes we have to backfill. But it's useful to run these on a new installation (and while you're writing new code) to see if anything's broken. From the main snewpdag directory (the one in which you installed it, and which contains Makefile), type

  make standalone_unittests

Run your first graphs

Let's try a stand-alone calculation. Again, from the main snewpdag directory, type

  make trial2

You should get a bunch of log messages, but in the end, you should have a few plots in the output subdirectory. The above uses the configuration file in snewpdag/data/test-liq-config.py.

If you want to start creating your own graphs, it may be easier to use CSV files. As an example,

python snewpdag/trials/Simple.py Control -n10 | python -m snewpdag --log INFO --jsonlines snewpdag/data/test-nth.csv

You can edit CSV files in a spreadsheet. Just make sure when you save that you double-quote all fields.

Plugin development

See the Plugin development wiki page.