Tutorial: CinemasciΒΆ

This tutorial uses the Supercomputng Cinema tutorial.

The jupyter notebook workflow needs the following installed:

  • Python 3.7 or above
  • pandas, numpy
  • os, shutil
  • cinemasci v1.4
  • openCV 4.4 (opencv-python)
  • skimage (scikit-image)
  • notebook, jupyterLab

Start by cloning the full tutorial repository and navigating to the pngviewer subdirectory:

$ git clone https://github.com/cinemascience/cinema_tutorial_2020-SC
$ cd cinema_tutorial_2020-SC/cinema_jnc/pngviewer
$ jupyter notebook

In the jupyter notebook, open cinema_tutorial.ipynb. The first cell, Fig. 7 uses cinemasci to load a volume Cinema database from the Nyx cosmology simulation show the formation of dark matter halos in the universe over time. The sliders can be used to select the phi and theta view angles and to explore the database over time.

First cell in jupyter notebook showing volume database of Nyx simulation

Fig. 7 The first cell in the jupyter notebook workflow creates a Cinema viewer object and loads a Nyx volume database.

The second cell loads a Cinema database with two slices of the Nyx simulation (denoted 7 and 12) over 18 time steps, Fig. 8.

second cell in jupyter notebook showing slices in Nyx

Fig. 8 The second cell in the jupyter notebook workflow creates a Cinema viewer object and loads a Nyx database with two slices of the Nyx simulation.

The next cell, Fig. 9, runs an image-based analysis using the Python libraries, OpenCV and skimage. The Cinema database CSV file is loaded into a pandas dataframe for easy manipulation. The image statistics and output image names are saved into new lists.

simple analysis workflow calcuating image statistics and finding contours in Nyx slice database

Fig. 9 An example analysis cell that calculates image statistics and finds contours in the Nyx image database.

Finally, Fig. 10, the image statistics and output images names are added to the original dataframe and reordered per CinemaScience Specifications to create the new Cinema database. The workflow finishes by launching a HTML file in the browser to view the databases in the workflow.

writing out new Cinema database from the dataframe

Fig. 10 The new dataframe is written to a CSV file to create the updated Cinema database.

Note

To use browser based viewers, you need to allow local file access. See A Note on Browser Security for more information.

The CinemaScience GitHub page and the CinemaScience website are useful sources for more information and ideas.