Package: psplay
A tool to visualize and play with CMB maps.psplayis ajupyterextension to allow
interactive visualization of CMB maps throughLeafletlibrary.psplayalso
provides a set of tools based onpspyto compute and to show
CMB power spectra. You can have a better idea of whatpsplaycan do by watching this shortvideo.All the specific javascript library developed forpsplayis done bySigurd Naess.  The build process and javascript architecture is highly inspired byipyleafletproject.ExamplesFrom simulated CAR map to psplayFrom HEALPIX map file to psplayInstallationTo install, you will need to have or to installnumpy. Then, run$pipinstallpsplay[--user]psplayruns within a Jupyter notebook and we recommend to use JupyterLab to fully enjoypsplayTo enable the extension within Jupyter, you will need to install several JupyterLab extensions
especially the Pythonplotlylibraryand the Jupyterwidgets. You will also neednodejs libraryand its package managernpm. For JupyterLab > 2.0.0, you can do$jupyterlabextensioninstallplotlywidgetjupyterlab-plotly$jupyterlabextensioninstall@jupyter-widgets/jupyterlab-manager@jupyter-widgets/jupyterlab-sidecarFinally, you need to install thejupyter-leaflet-carextension$jupyterlabextensioninstalljupyter-leafletjupyter-leaflet-carUsingdockerGiven the number of requirements, you can use adockerimage already made with the needed
libraries and everything compiled and installed. You should first installdockerfor your operating system.Then, you can run thesimonsobs/psplayimage by doing$dockerrun--rm-p8888:8888simonsobs/psplayAfter pulling thedockerimage, a JupyterLab instance should start. If your web browser does not
automatically load the web page, you can copy-paste the JupyterLab URL.You can bind a local directory to make it available within thedockercontainer with the-vflag (seehttps://docs.docker.com/storage/bind-mountsfor more details).Using atNERSCOn NERSC machines, you can installpsplaywithin acondaenvironment but you can also use a
common installation for Simons Observatory people (i.e.people belonging tosobsgroup)
without need to redo the long installation process.First you need to log tocori.nersc.govmachines by enabling port forward to your local machine$ssh-L8888:localhost:8888user@cori.nersc.govEverything passingviaport 8888 inNERSCwill be forwarded to your local machine and you will
be able to grab the JupyterLab instance within your local web browser.Given a successful connection, you must load the latestpythonmodule$moduleloadpythonand then you can load thecondaenvironment with the whole software suite forpsplay$sourceactivate/global/cscratch1/sd/xgarrido/psplay/envFinally, you can copy the/global/cscratch1/sd/xgarrido/psplay/examples/minimaldirectory to
your home or scratch directory. For example purpose, this directory holds simulation files already
converted intoLeaflettiles. Then, fire a JupyterLab instance by typing$cd/your/owned/directory$cp-r/global/cscratch1/sd/xgarrido/psplay/examples/minimal.$jupyterlab--port8888--no-browserminimal_working_example.ipynbCopy-paste the URL into your local browser and run the Jupyter notebook.If port 8888 is already in use, JupyterLab will try another one and then breaks the port forward. In
this case you should restart the ssh session with another port.Installation from sourcesFor a development installation (requiresnpm)$gitclonehttps://github.com/xgarrido/psplay.git$cdpsplay$pipinstall-e.If you are using the classic Jupyter Notebook you need to install the nbextension:$jupyternbextensioninstall--py--symlink--sys-prefixpsplay$jupyternbextensionenable--py--sys-prefixpsplayIf you are using JupyterLab, you need to install the labextension:$jupyterlabextensioninstall@jupyter-widgets/jupyterlab-managerjsNote for developers:the-epip option allows one to modify the Python code in-place. Restart the kernel in order
to see the changes.the--symlinkargument on Linux or OS X allows one to modify the JavaScript code
in-place. This feature is not available with Windows.For automatically building the JavaScript code every time there is a change, run the following
command from thepsplay/js/directory:$npmrunwatchIf you are on JupyterLab you also need to run the following in a separate terminal:$jupyterlab--watchEvery time a JavaScript build has terminated you need to refresh the Notebook page in order to load
the JavaScript code again.AuthorsXavier GarridoThibaut LouisSigurd NaessThe code is part ofPSpipethe Simons Observatory power spectrum pipeline.